aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/w1.h
diff options
context:
space:
mode:
authorDavid Fries <david@fries.net>2008-10-16 01:04:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:49 -0400
commitc30c9b15187e977ab5928f7276e9dfcd8d6f9460 (patch)
treed36d7513c5acf1d39f581625ffa5c1915ae5627f /drivers/w1/w1.h
parentdd78c9439fc1e031835bccb934d27b978c72c536 (diff)
W1: fix deadlocks and remove w1_control_thread
w1_control_thread was removed which would wake up every second and process newly registered family codes and complete some final cleanup for a removed master. Those routines were moved to the threads that were previously requesting those operations. A new function w1_reconnect_slaves takes care of reconnecting existing slave devices when a new family code is registered or removed. The removal case was missing and would cause a deadlock waiting for the family code reference count to decrease, which will now happen. A problem with registering a family code was fixed. A slave device would be unattached if it wasn't yet claimed, then attached at the end of the list, two unclaimed slaves would cause an infinite loop. The struct w1_bus_master.search now takes a pointer to the struct w1_master device to avoid searching for it, which would have caused a lock ordering deadlock with the removal of w1_control_thread. Signed-off-by: David Fries <david@fries.net> Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/w1/w1.h')
-rw-r--r--drivers/w1/w1.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index f1df5343f4ad..13e0ea880bf8 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -77,7 +77,7 @@ struct w1_slave
77 struct completion released; 77 struct completion released;
78}; 78};
79 79
80typedef void (* w1_slave_found_callback)(void *, u64); 80typedef void (*w1_slave_found_callback)(struct w1_master *, u64);
81 81
82 82
83/** 83/**
@@ -142,12 +142,14 @@ struct w1_bus_master
142 */ 142 */
143 u8 (*reset_bus)(void *); 143 u8 (*reset_bus)(void *);
144 144
145 /** Really nice hardware can handles the different types of ROM search */ 145 /** Really nice hardware can handles the different types of ROM search
146 void (*search)(void *, u8, w1_slave_found_callback); 146 * w1_master* is passed to the slave found callback.
147 */
148 void (*search)(void *, struct w1_master *,
149 u8, w1_slave_found_callback);
147}; 150};
148 151
149#define W1_MASTER_NEED_EXIT 0 152#define W1_MASTER_NEED_EXIT 0
150#define W1_MASTER_NEED_RECONNECT 1
151 153
152struct w1_master 154struct w1_master
153{ 155{
@@ -181,12 +183,21 @@ struct w1_master
181}; 183};
182 184
183int w1_create_master_attributes(struct w1_master *); 185int w1_create_master_attributes(struct w1_master *);
186void w1_destroy_master_attributes(struct w1_master *master);
184void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb); 187void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb);
185void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb); 188void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb);
186struct w1_slave *w1_search_slave(struct w1_reg_num *id); 189struct w1_slave *w1_search_slave(struct w1_reg_num *id);
187void w1_search_process(struct w1_master *dev, u8 search_type); 190void w1_search_process(struct w1_master *dev, u8 search_type);
188struct w1_master *w1_search_master_id(u32 id); 191struct w1_master *w1_search_master_id(u32 id);
189 192
193/* Disconnect and reconnect devices in the given family. Used for finding
194 * unclaimed devices after a family has been registered or releasing devices
195 * after a family has been unregistered. Set attach to 1 when a new family
196 * has just been registered, to 0 when it has been unregistered.
197 */
198void w1_reconnect_slaves(struct w1_family *f, int attach);
199void w1_slave_detach(struct w1_slave *sl);
200
190u8 w1_triplet(struct w1_master *dev, int bdir); 201u8 w1_triplet(struct w1_master *dev, int bdir);
191void w1_write_8(struct w1_master *, u8); 202void w1_write_8(struct w1_master *, u8);
192int w1_reset_bus(struct w1_master *); 203int w1_reset_bus(struct w1_master *);