diff options
author | Eric Miao <eric.miao@marvell.com> | 2009-01-31 09:47:44 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 19:38:24 -0400 |
commit | 71b3e0c1ad90f28e34c105069175cbd4edb43dfa (patch) | |
tree | af7f1dd890d10acc33e36a923d2604ff26dfb071 | |
parent | 49b420a13ff95b449947181190b08367348e3e1b (diff) |
platform: make better use of to_platform_{device,driver}() macros
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>
-rw-r--r-- | drivers/base/platform.c | 21 | ||||
-rw-r--r-- | drivers/block/floppy.c | 3 | ||||
-rw-r--r-- | drivers/isdn/gigaset/ser-gigaset.c | 3 |
3 files changed, 11 insertions, 16 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 349a1013603f..62a8768d96b3 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -603,9 +603,8 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
603 | */ | 603 | */ |
604 | static int platform_match(struct device *dev, struct device_driver *drv) | 604 | static int platform_match(struct device *dev, struct device_driver *drv) |
605 | { | 605 | { |
606 | struct platform_device *pdev; | 606 | struct platform_device *pdev = to_platform_device(dev); |
607 | 607 | ||
608 | pdev = container_of(dev, struct platform_device, dev); | ||
609 | return (strcmp(pdev->name, drv->name) == 0); | 608 | return (strcmp(pdev->name, drv->name) == 0); |
610 | } | 609 | } |
611 | 610 | ||
@@ -623,26 +622,24 @@ static int platform_legacy_suspend(struct device *dev, pm_message_t mesg) | |||
623 | 622 | ||
624 | static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg) | 623 | static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg) |
625 | { | 624 | { |
626 | struct platform_driver *drv = to_platform_driver(dev->driver); | 625 | struct platform_driver *pdrv = to_platform_driver(dev->driver); |
627 | struct platform_device *pdev; | 626 | struct platform_device *pdev = to_platform_device(dev); |
628 | int ret = 0; | 627 | int ret = 0; |
629 | 628 | ||
630 | pdev = container_of(dev, struct platform_device, dev); | 629 | if (dev->driver && pdrv->suspend_late) |
631 | if (dev->driver && drv->suspend_late) | 630 | ret = pdrv->suspend_late(pdev, mesg); |
632 | ret = drv->suspend_late(pdev, mesg); | ||
633 | 631 | ||
634 | return ret; | 632 | return ret; |
635 | } | 633 | } |
636 | 634 | ||
637 | static int platform_legacy_resume_early(struct device *dev) | 635 | static int platform_legacy_resume_early(struct device *dev) |
638 | { | 636 | { |
639 | struct platform_driver *drv = to_platform_driver(dev->driver); | 637 | struct platform_driver *pdrv = to_platform_driver(dev->driver); |
640 | struct platform_device *pdev; | 638 | struct platform_device *pdev = to_platform_device(dev); |
641 | int ret = 0; | 639 | int ret = 0; |
642 | 640 | ||
643 | pdev = container_of(dev, struct platform_device, dev); | 641 | if (dev->driver && pdrv->resume_early) |
644 | if (dev->driver && drv->resume_early) | 642 | ret = pdrv->resume_early(pdev); |
645 | ret = drv->resume_early(pdev); | ||
646 | 643 | ||
647 | return ret; | 644 | return ret; |
648 | } | 645 | } |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 83d8ed39433d..c2c95e614506 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -4135,10 +4135,9 @@ static int have_no_fdc = -ENODEV; | |||
4135 | static ssize_t floppy_cmos_show(struct device *dev, | 4135 | static ssize_t floppy_cmos_show(struct device *dev, |
4136 | struct device_attribute *attr, char *buf) | 4136 | struct device_attribute *attr, char *buf) |
4137 | { | 4137 | { |
4138 | struct platform_device *p; | 4138 | struct platform_device *p = to_platform_device(dev); |
4139 | int drive; | 4139 | int drive; |
4140 | 4140 | ||
4141 | p = container_of(dev, struct platform_device,dev); | ||
4142 | drive = p->id; | 4141 | drive = p->id; |
4143 | return sprintf(buf, "%X\n", UDP->cmos); | 4142 | return sprintf(buf, "%X\n", UDP->cmos); |
4144 | } | 4143 | } |
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c index ac245e7e96a5..3071a52467ed 100644 --- a/drivers/isdn/gigaset/ser-gigaset.c +++ b/drivers/isdn/gigaset/ser-gigaset.c | |||
@@ -389,8 +389,7 @@ static void gigaset_freecshw(struct cardstate *cs) | |||
389 | 389 | ||
390 | static void gigaset_device_release(struct device *dev) | 390 | static void gigaset_device_release(struct device *dev) |
391 | { | 391 | { |
392 | struct platform_device *pdev = | 392 | struct platform_device *pdev = to_platform_device(dev); |
393 | container_of(dev, struct platform_device, dev); | ||
394 | 393 | ||
395 | /* adapted from platform_device_release() in drivers/base/platform.c */ | 394 | /* adapted from platform_device_release() in drivers/base/platform.c */ |
396 | //FIXME is this actually necessary? | 395 | //FIXME is this actually necessary? |