Commit 71b3e0c1ad90f28e34c105069175cbd4edb43dfa
Committed by
Greg Kroah-Hartman
1 parent
49b420a13f
Exists in
master
and in
39 other branches
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>
Showing 3 changed files with 11 additions and 16 deletions Side-by-side Diff
drivers/base/platform.c
... | ... | @@ -603,9 +603,8 @@ |
603 | 603 | */ |
604 | 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 | 608 | return (strcmp(pdev->name, drv->name) == 0); |
610 | 609 | } |
611 | 610 | |
612 | 611 | |
613 | 612 | |
614 | 613 | |
... | ... | @@ -623,26 +622,24 @@ |
623 | 622 | |
624 | 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); | |
627 | - struct platform_device *pdev; | |
625 | + struct platform_driver *pdrv = to_platform_driver(dev->driver); | |
626 | + struct platform_device *pdev = to_platform_device(dev); | |
628 | 627 | int ret = 0; |
629 | 628 | |
630 | - pdev = container_of(dev, struct platform_device, dev); | |
631 | - if (dev->driver && drv->suspend_late) | |
632 | - ret = drv->suspend_late(pdev, mesg); | |
629 | + if (dev->driver && pdrv->suspend_late) | |
630 | + ret = pdrv->suspend_late(pdev, mesg); | |
633 | 631 | |
634 | 632 | return ret; |
635 | 633 | } |
636 | 634 | |
637 | 635 | static int platform_legacy_resume_early(struct device *dev) |
638 | 636 | { |
639 | - struct platform_driver *drv = to_platform_driver(dev->driver); | |
640 | - struct platform_device *pdev; | |
637 | + struct platform_driver *pdrv = to_platform_driver(dev->driver); | |
638 | + struct platform_device *pdev = to_platform_device(dev); | |
641 | 639 | int ret = 0; |
642 | 640 | |
643 | - pdev = container_of(dev, struct platform_device, dev); | |
644 | - if (dev->driver && drv->resume_early) | |
645 | - ret = drv->resume_early(pdev); | |
641 | + if (dev->driver && pdrv->resume_early) | |
642 | + ret = pdrv->resume_early(pdev); | |
646 | 643 | |
647 | 644 | return ret; |
648 | 645 | } |
drivers/block/floppy.c
... | ... | @@ -4135,10 +4135,9 @@ |
4135 | 4135 | static ssize_t floppy_cmos_show(struct device *dev, |
4136 | 4136 | struct device_attribute *attr, char *buf) |
4137 | 4137 | { |
4138 | - struct platform_device *p; | |
4138 | + struct platform_device *p = to_platform_device(dev); | |
4139 | 4139 | int drive; |
4140 | 4140 | |
4141 | - p = container_of(dev, struct platform_device,dev); | |
4142 | 4141 | drive = p->id; |
4143 | 4142 | return sprintf(buf, "%X\n", UDP->cmos); |
4144 | 4143 | } |
drivers/isdn/gigaset/ser-gigaset.c
... | ... | @@ -389,8 +389,7 @@ |
389 | 389 | |
390 | 390 | static void gigaset_device_release(struct device *dev) |
391 | 391 | { |
392 | - struct platform_device *pdev = | |
393 | - container_of(dev, struct platform_device, dev); | |
392 | + struct platform_device *pdev = to_platform_device(dev); | |
394 | 393 | |
395 | 394 | /* adapted from platform_device_release() in drivers/base/platform.c */ |
396 | 395 | //FIXME is this actually necessary? |