aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/w1.h
diff options
context:
space:
mode:
authorDavid Fries <David@Fries.net>2014-01-15 23:29:18 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 18:40:17 -0500
commit9fcbbac5ded489c3a4e121343db999dd51cd6c75 (patch)
tree1207602c8d7cc2da54784114a5d32d9ed6924b58 /drivers/w1/w1.h
parent70b34d2ed807b722413894975a8c60617defb887 (diff)
w1: process w1 netlink commands in w1_process thread
Netlink is a socket interface and is expected to be asynchronous. Clients can now make w1 requests without blocking by making use of the w1_master thread to process netlink commands which was previously only used for doing an automatic bus search. Signed-off-by: David Fries <David@Fries.net> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1/w1.h')
-rw-r--r--drivers/w1/w1.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 3376bfbb10f4..a096ef40119e 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -58,6 +58,7 @@ struct w1_reg_num
58#define W1_RESUME_CMD 0xA5 58#define W1_RESUME_CMD 0xA5
59 59
60#define W1_SLAVE_ACTIVE 0 60#define W1_SLAVE_ACTIVE 0
61#define W1_SLAVE_DETACH 1
61 62
62struct w1_slave 63struct w1_slave
63{ 64{
@@ -74,7 +75,6 @@ struct w1_slave
74 struct w1_family *family; 75 struct w1_family *family;
75 void *family_data; 76 void *family_data;
76 struct device dev; 77 struct device dev;
77 struct completion released;
78}; 78};
79 79
80typedef void (*w1_slave_found_callback)(struct w1_master *, u64); 80typedef void (*w1_slave_found_callback)(struct w1_master *, u64);
@@ -171,7 +171,14 @@ struct w1_master
171 struct list_head w1_master_entry; 171 struct list_head w1_master_entry;
172 struct module *owner; 172 struct module *owner;
173 unsigned char name[W1_MAXNAMELEN]; 173 unsigned char name[W1_MAXNAMELEN];
174 /* list_mutex protects just slist and async_list so slaves can be
175 * searched for and async commands added while the master has
176 * w1_master.mutex locked and is operating on the bus.
177 * lock order w1_mlock, w1_master.mutex, w1_master_list_mutex
178 */
179 struct mutex list_mutex;
174 struct list_head slist; 180 struct list_head slist;
181 struct list_head async_list;
175 int max_slave_count, slave_count; 182 int max_slave_count, slave_count;
176 unsigned long attempts; 183 unsigned long attempts;
177 int slave_ttl; 184 int slave_ttl;
@@ -205,11 +212,29 @@ struct w1_master
205 u32 seq; 212 u32 seq;
206}; 213};
207 214
215/**
216 * struct w1_async_cmd - execute callback from the w1_process kthread
217 * @async_entry: link entry
218 * @cb: callback function, must list_del and destroy this list before
219 * returning
220 *
221 * When inserted into the w1_master async_list, w1_process will execute
222 * the callback. Embed this into the structure with the command details.
223 */
224struct w1_async_cmd {
225 struct list_head async_entry;
226 void (*cb)(struct w1_master *dev, struct w1_async_cmd *async_cmd);
227};
228
208int w1_create_master_attributes(struct w1_master *); 229int w1_create_master_attributes(struct w1_master *);
209void w1_destroy_master_attributes(struct w1_master *master); 230void w1_destroy_master_attributes(struct w1_master *master);
210void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb); 231void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb);
211void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb); 232void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb);
233/* call w1_unref_slave to release the reference counts w1_search_slave added */
212struct w1_slave *w1_search_slave(struct w1_reg_num *id); 234struct w1_slave *w1_search_slave(struct w1_reg_num *id);
235/* decrements the reference on sl->master and sl, and cleans up if zero
236 * returns the reference count after it has been decremented */
237int w1_unref_slave(struct w1_slave *sl);
213void w1_slave_found(struct w1_master *dev, u64 rn); 238void w1_slave_found(struct w1_master *dev, u64 rn);
214void w1_search_process_cb(struct w1_master *dev, u8 search_type, 239void w1_search_process_cb(struct w1_master *dev, u8 search_type,
215 w1_slave_found_callback cb); 240 w1_slave_found_callback cb);
@@ -224,7 +249,8 @@ struct w1_master *w1_search_master_id(u32 id);
224 */ 249 */
225void w1_reconnect_slaves(struct w1_family *f, int attach); 250void w1_reconnect_slaves(struct w1_family *f, int attach);
226int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn); 251int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn);
227void w1_slave_detach(struct w1_slave *sl); 252/* 0 success, otherwise EBUSY */
253int w1_slave_detach(struct w1_slave *sl);
228 254
229u8 w1_triplet(struct w1_master *dev, int bdir); 255u8 w1_triplet(struct w1_master *dev, int bdir);
230void w1_write_8(struct w1_master *, u8); 256void w1_write_8(struct w1_master *, u8);
@@ -260,6 +286,8 @@ extern int w1_max_slave_ttl;
260extern struct list_head w1_masters; 286extern struct list_head w1_masters;
261extern struct mutex w1_mlock; 287extern struct mutex w1_mlock;
262 288
289/* returns 1 if there were commands to executed 0 otherwise */
290extern int w1_process_callbacks(struct w1_master *dev);
263extern int w1_process(void *); 291extern int w1_process(void *);
264 292
265#endif /* __KERNEL__ */ 293#endif /* __KERNEL__ */