aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-05-22 17:21:08 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-22 00:54:47 -0400
commit695794ae0c5bdd9bd06e35b118801e2e9be04f9e (patch)
tree71011d17230e67798c6e474ffac10cb93d72919e /drivers
parent93562b537659fc0f63920fd4d9d24f54e434f4c4 (diff)
Driver Core: add ability for class_find_device to start in middle of list
This mirrors the functionality that driver_find_device has as well. We add a start variable, and all callers of the function are fixed up at the same time. The block layer will be using this new functionality in a follow-on patch. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/class.c22
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/ieee1394/nodemgr.c9
-rw-r--r--drivers/rtc/interface.c2
-rw-r--r--drivers/scsi/hosts.c3
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c4
-rw-r--r--drivers/spi/spi.c2
7 files changed, 26 insertions, 18 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 2eb7048003a8..3918d0e432d4 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -302,6 +302,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
302/** 302/**
303 * class_find_device - device iterator for locating a particular device 303 * class_find_device - device iterator for locating a particular device
304 * @class: the class we're iterating 304 * @class: the class we're iterating
305 * @start: Device to begin with
305 * @data: data for the match function 306 * @data: data for the match function
306 * @match: function to check device 307 * @match: function to check device
307 * 308 *
@@ -319,8 +320,9 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
319 * re-acquired in @match, otherwise it will self-deadlocking. For 320 * re-acquired in @match, otherwise it will self-deadlocking. For
320 * example, calls to add or remove class members would be verboten. 321 * example, calls to add or remove class members would be verboten.
321 */ 322 */
322struct device *class_find_device(struct class *class, void *data, 323struct device *class_find_device(struct class *class, struct device *start,
323 int (*match)(struct device *, void *)) 324 void *data,
325 int (*match)(struct device *, void *))
324{ 326{
325 struct device *dev; 327 struct device *dev;
326 int found = 0; 328 int found = 0;
@@ -330,15 +332,17 @@ struct device *class_find_device(struct class *class, void *data,
330 332
331 down(&class->sem); 333 down(&class->sem);
332 list_for_each_entry(dev, &class->devices, node) { 334 list_for_each_entry(dev, &class->devices, node) {
335 if (start) {
336 if (start == dev)
337 start = NULL;
338 continue;
339 }
333 dev = get_device(dev); 340 dev = get_device(dev);
334 if (dev) { 341 if (match(dev, data)) {
335 if (match(dev, data)) { 342 found = 1;
336 found = 1;
337 break;
338 } else
339 put_device(dev);
340 } else
341 break; 343 break;
344 } else
345 put_device(dev);
342 } 346 }
343 up(&class->sem); 347 up(&class->sem);
344 348
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 9ae28aa709d5..9f05de6f80b5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1289,7 +1289,7 @@ void device_destroy(struct class *class, dev_t devt)
1289{ 1289{
1290 struct device *dev; 1290 struct device *dev;
1291 1291
1292 dev = class_find_device(class, &devt, __match_devt); 1292 dev = class_find_device(class, NULL, &devt, __match_devt);
1293 if (dev) { 1293 if (dev) {
1294 put_device(dev); 1294 put_device(dev);
1295 device_unregister(dev); 1295 device_unregister(dev);
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 47c0d85e0f32..994a21e5a0aa 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -754,7 +754,8 @@ static void nodemgr_remove_uds(struct node_entry *ne)
754 */ 754 */
755 mutex_lock(&nodemgr_serialize_remove_uds); 755 mutex_lock(&nodemgr_serialize_remove_uds);
756 for (;;) { 756 for (;;) {
757 dev = class_find_device(&nodemgr_ud_class, ne, __match_ne); 757 dev = class_find_device(&nodemgr_ud_class, NULL, ne,
758 __match_ne);
758 if (!dev) 759 if (!dev)
759 break; 760 break;
760 ud = container_of(dev, struct unit_directory, unit_dev); 761 ud = container_of(dev, struct unit_directory, unit_dev);
@@ -901,7 +902,8 @@ static struct node_entry *find_entry_by_guid(u64 guid)
901 struct device *dev; 902 struct device *dev;
902 struct node_entry *ne; 903 struct node_entry *ne;
903 904
904 dev = class_find_device(&nodemgr_ne_class, &guid, __match_ne_guid); 905 dev = class_find_device(&nodemgr_ne_class, NULL, &guid,
906 __match_ne_guid);
905 if (!dev) 907 if (!dev)
906 return NULL; 908 return NULL;
907 ne = container_of(dev, struct node_entry, node_dev); 909 ne = container_of(dev, struct node_entry, node_dev);
@@ -940,7 +942,8 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
940 param.host = host; 942 param.host = host;
941 param.nodeid = nodeid; 943 param.nodeid = nodeid;
942 944
943 dev = class_find_device(&nodemgr_ne_class, &param, __match_ne_nodeid); 945 dev = class_find_device(&nodemgr_ne_class, NULL, &param,
946 __match_ne_nodeid);
944 if (!dev) 947 if (!dev)
945 return NULL; 948 return NULL;
946 ne = container_of(dev, struct node_entry, node_dev); 949 ne = container_of(dev, struct node_entry, node_dev);
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 58b7336640ff..d397fa5f3a91 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -345,7 +345,7 @@ struct rtc_device *rtc_class_open(char *name)
345 struct device *dev; 345 struct device *dev;
346 struct rtc_device *rtc = NULL; 346 struct rtc_device *rtc = NULL;
347 347
348 dev = class_find_device(rtc_class, name, __rtc_match); 348 dev = class_find_device(rtc_class, NULL, name, __rtc_match);
349 if (dev) 349 if (dev)
350 rtc = to_rtc_device(dev); 350 rtc = to_rtc_device(dev);
351 351
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 35cd892dce04..78dad28b70d5 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -466,7 +466,8 @@ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
466 struct device *cdev; 466 struct device *cdev;
467 struct Scsi_Host *shost = ERR_PTR(-ENXIO); 467 struct Scsi_Host *shost = ERR_PTR(-ENXIO);
468 468
469 cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match); 469 cdev = class_find_device(&shost_class, NULL, &hostnum,
470 __scsi_host_match);
470 if (cdev) { 471 if (cdev) {
471 shost = scsi_host_get(class_to_shost(cdev)); 472 shost = scsi_host_get(class_to_shost(cdev));
472 put_device(cdev); 473 put_device(cdev);
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 3af7cbcc5c5d..06748f318cd5 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -170,7 +170,7 @@ iscsi_create_endpoint(int dd_size)
170 int err; 170 int err;
171 171
172 for (id = 1; id < ISCSI_MAX_EPID; id++) { 172 for (id = 1; id < ISCSI_MAX_EPID; id++) {
173 dev = class_find_device(&iscsi_endpoint_class, &id, 173 dev = class_find_device(&iscsi_endpoint_class, NULL, &id,
174 iscsi_match_epid); 174 iscsi_match_epid);
175 if (!dev) 175 if (!dev)
176 break; 176 break;
@@ -222,7 +222,7 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
222 struct iscsi_endpoint *ep; 222 struct iscsi_endpoint *ep;
223 struct device *dev; 223 struct device *dev;
224 224
225 dev = class_find_device(&iscsi_endpoint_class, &handle, 225 dev = class_find_device(&iscsi_endpoint_class, NULL, &handle,
226 iscsi_match_epid); 226 iscsi_match_epid);
227 if (!dev) 227 if (!dev)
228 return NULL; 228 return NULL;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 1ad12afc6ba0..1771b2456bfa 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -502,7 +502,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num)
502 struct device *dev; 502 struct device *dev;
503 struct spi_master *master = NULL; 503 struct spi_master *master = NULL;
504 504
505 dev = class_find_device(&spi_master_class, &bus_num, 505 dev = class_find_device(&spi_master_class, NULL, &bus_num,
506 __spi_master_match); 506 __spi_master_match);
507 if (dev) 507 if (dev)
508 master = container_of(dev, struct spi_master, dev); 508 master = container_of(dev, struct spi_master, dev);