On Wed, Apr 13, 2005 at 11:11:54AM -0700, Pete Zaitcev wrote:
> The suspect code is also easy to spot: a) uses list_for_each_safe,
> b) uses container_of instead of list_entry. That's whole two "newbie
> points".

OK to bring the newbie score of drivers/base/bus.c down by another two
points, here's a cosmetic patch on top of that one.

Roman.


Replace container_of by list_entry for list entries; replace
list_for_each with list_for_each_entry.

Signed-off-by: Roman Kagan <[EMAIL PROTECTED]>

 drivers/base/bus.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

--- linux-2.6.12-rc2/drivers/base/bus.c.list_entry      2005-04-13 
08:45:48.000000000 +0400
+++ linux-2.6.12-rc2/drivers/base/bus.c 2005-04-14 14:07:58.000000000 +0400
@@ -353,14 +353,13 @@ int device_attach(struct device * dev)
 void driver_attach(struct device_driver * drv)
 {
        struct bus_type * bus = drv->bus;
-       struct list_head * entry;
+       struct device * dev;
        int error;
 
        if (!bus->match)
                return;
 
-       list_for_each(entry, &bus->devices.list) {
-               struct device * dev = container_of(entry, struct device, 
bus_list);
+       list_for_each_entry(dev, &bus->devices.list, bus_list)
                if (!dev->driver) {
                        error = driver_probe_device(drv, dev);
                        if (error && (error != -ENODEV))
@@ -369,7 +368,6 @@ void driver_attach(struct device_driver 
                                    "%s: probe of %s failed with error %d\n",
                                    drv->name, dev->bus_id, error);
                }
-       }
 }
 
 
@@ -406,7 +404,7 @@ void device_release_driver(struct device
 static void driver_detach(struct device_driver * drv)
 {
        while (!list_empty(&drv->devices)) {
-               struct device * dev = container_of(drv->devices.next, struct 
device, driver_list);
+               struct device * dev = list_entry(drv->devices.next, struct 
device, driver_list);
                device_release_driver(dev);
        }
 }


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to