2 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
20 #include <linux/completion.h>
21 #include <linux/mutex.h>
23 #define W1_SLAVE_ACTIVE 0
24 #define W1_SLAVE_DETACH 1
27 * struct w1_async_cmd - execute callback from the w1_process kthread
28 * @async_entry: link entry
29 * @cb: callback function, must list_del and destroy this list before
32 * When inserted into the w1_master async_list, w1_process will execute
33 * the callback. Embed this into the structure with the command details.
36 struct list_head async_entry
;
37 void (*cb
)(struct w1_master
*dev
, struct w1_async_cmd
*async_cmd
);
40 int w1_create_master_attributes(struct w1_master
*master
);
41 void w1_destroy_master_attributes(struct w1_master
*master
);
42 void w1_search(struct w1_master
*dev
, u8 search_type
,
43 w1_slave_found_callback cb
);
44 void w1_search_devices(struct w1_master
*dev
, u8 search_type
,
45 w1_slave_found_callback cb
);
46 /* call w1_unref_slave to release the reference counts w1_search_slave added */
47 struct w1_slave
*w1_search_slave(struct w1_reg_num
*id
);
49 * decrements the reference on sl->master and sl, and cleans up if zero
50 * returns the reference count after it has been decremented
52 int w1_unref_slave(struct w1_slave
*sl
);
53 void w1_slave_found(struct w1_master
*dev
, u64 rn
);
54 void w1_search_process_cb(struct w1_master
*dev
, u8 search_type
,
55 w1_slave_found_callback cb
);
56 struct w1_slave
*w1_slave_search_device(struct w1_master
*dev
,
57 struct w1_reg_num
*rn
);
58 struct w1_master
*w1_search_master_id(u32 id
);
60 /* Disconnect and reconnect devices in the given family. Used for finding
61 * unclaimed devices after a family has been registered or releasing devices
62 * after a family has been unregistered. Set attach to 1 when a new family
63 * has just been registered, to 0 when it has been unregistered.
65 void w1_reconnect_slaves(struct w1_family
*f
, int attach
);
66 int w1_attach_slave_device(struct w1_master
*dev
, struct w1_reg_num
*rn
);
67 /* 0 success, otherwise EBUSY */
68 int w1_slave_detach(struct w1_slave
*sl
);
70 void __w1_remove_master_device(struct w1_master
*dev
);
72 void w1_family_put(struct w1_family
*f
);
73 void __w1_family_get(struct w1_family
*f
);
74 struct w1_family
*w1_family_registered(u8 fid
);
76 extern struct device_driver w1_master_driver
;
77 extern struct device w1_master_device
;
78 extern int w1_max_slave_count
;
79 extern int w1_max_slave_ttl
;
80 extern struct list_head w1_masters
;
81 extern struct mutex w1_mlock
;
82 extern spinlock_t w1_flock
;
84 int w1_process_callbacks(struct w1_master
*dev
);
85 int w1_process(void *data
);