]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
platform: make better use of to_platform_{device,driver}() macros
authorEric Miao <eric.miao@marvell.com>
Sat, 31 Jan 2009 14:47:44 +0000 (22:47 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 24 Mar 2009 23:38:24 +0000 (16:38 -0700)
This helps the code look more consistent and cleaner.

Signed-off-by: Eric Miao <eric.miao@marvell.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/platform.c
drivers/block/floppy.c
drivers/isdn/gigaset/ser-gigaset.c

index 349a1013603fdb2485b3d82b2454ad1c3b2b3002..62a8768d96b3cc31593d19481b9db1102e87bc71 100644 (file)
@@ -603,9 +603,8 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
  */
 static int platform_match(struct device *dev, struct device_driver *drv)
 {
-       struct platform_device *pdev;
+       struct platform_device *pdev = to_platform_device(dev);
 
-       pdev = container_of(dev, struct platform_device, dev);
        return (strcmp(pdev->name, drv->name) == 0);
 }
 
@@ -623,26 +622,24 @@ static int platform_legacy_suspend(struct device *dev, pm_message_t mesg)
 
 static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg)
 {
-       struct platform_driver *drv = to_platform_driver(dev->driver);
-       struct platform_device *pdev;
+       struct platform_driver *pdrv = to_platform_driver(dev->driver);
+       struct platform_device *pdev = to_platform_device(dev);
        int ret = 0;
 
-       pdev = container_of(dev, struct platform_device, dev);
-       if (dev->driver && drv->suspend_late)
-               ret = drv->suspend_late(pdev, mesg);
+       if (dev->driver && pdrv->suspend_late)
+               ret = pdrv->suspend_late(pdev, mesg);
 
        return ret;
 }
 
 static int platform_legacy_resume_early(struct device *dev)
 {
-       struct platform_driver *drv = to_platform_driver(dev->driver);
-       struct platform_device *pdev;
+       struct platform_driver *pdrv = to_platform_driver(dev->driver);
+       struct platform_device *pdev = to_platform_device(dev);
        int ret = 0;
 
-       pdev = container_of(dev, struct platform_device, dev);
-       if (dev->driver && drv->resume_early)
-               ret = drv->resume_early(pdev);
+       if (dev->driver && pdrv->resume_early)
+               ret = pdrv->resume_early(pdev);
 
        return ret;
 }
index 83d8ed39433d058f70896057e52fc4d1e4dc99f3..c2c95e614506761a98ace446e02219203e5530dd 100644 (file)
@@ -4135,10 +4135,9 @@ static int have_no_fdc = -ENODEV;
 static ssize_t floppy_cmos_show(struct device *dev,
                                struct device_attribute *attr, char *buf)
 {
-       struct platform_device *p;
+       struct platform_device *p = to_platform_device(dev);
        int drive;
 
-       p = container_of(dev, struct platform_device,dev);
        drive = p->id;
        return sprintf(buf, "%X\n", UDP->cmos);
 }
index ac245e7e96a557445212e50b0987c39c46efd960..3071a52467edc0a2e1afe66f1488cc4e77bc9d37 100644 (file)
@@ -389,8 +389,7 @@ static void gigaset_freecshw(struct cardstate *cs)
 
 static void gigaset_device_release(struct device *dev)
 {
-       struct platform_device *pdev =
-               container_of(dev, struct platform_device, dev);
+       struct platform_device *pdev = to_platform_device(dev);
 
        /* adapted from platform_device_release() in drivers/base/platform.c */
        //FIXME is this actually necessary?