rtc: use class iteration api
authorDave Young <hidave.darkstar@gmail.com>
Tue, 22 Jan 2008 06:00:34 +0000 (14:00 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Jan 2008 04:40:44 +0000 (20:40 -0800)
Convert to use the class iteration api.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/rtc/interface.c

index f1e00ff54ce880fb94c69a38064abe6680c83933..7e3ad4f3b3432aa89c8a7d9a4d9902453f9adbbf 100644 (file)
@@ -251,20 +251,23 @@ void rtc_update_irq(struct rtc_device *rtc,
 }
 EXPORT_SYMBOL_GPL(rtc_update_irq);
 
+static int __rtc_match(struct device *dev, void *data)
+{
+       char *name = (char *)data;
+
+       if (strncmp(dev->bus_id, name, BUS_ID_SIZE) == 0)
+               return 1;
+       return 0;
+}
+
 struct rtc_device *rtc_class_open(char *name)
 {
        struct device *dev;
        struct rtc_device *rtc = NULL;
 
-       down(&rtc_class->sem);
-       list_for_each_entry(dev, &rtc_class->devices, node) {
-               if (strncmp(dev->bus_id, name, BUS_ID_SIZE) == 0) {
-                       dev = get_device(dev);
-                       if (dev)
-                               rtc = to_rtc_device(dev);
-                       break;
-               }
-       }
+       dev = class_find_device(rtc_class, name, __rtc_match);
+       if (dev)
+               rtc = to_rtc_device(dev);
 
        if (rtc) {
                if (!try_module_get(rtc->owner)) {
@@ -272,7 +275,6 @@ struct rtc_device *rtc_class_open(char *name)
                        rtc = NULL;
                }
        }
-       up(&rtc_class->sem);
 
        return rtc;
 }