提交 71b3e0c1 编写于 作者: E Eric Miao 提交者: Greg Kroah-Hartman

platform: make better use of to_platform_{device,driver}() macros

This helps the code look more consistent and cleaner.
Signed-off-by: NEric Miao <eric.miao@marvell.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 49b420a1
...@@ -603,9 +603,8 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) ...@@ -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) 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); return (strcmp(pdev->name, drv->name) == 0);
} }
...@@ -623,26 +622,24 @@ static int platform_legacy_suspend(struct device *dev, pm_message_t mesg) ...@@ -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) static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg)
{ {
struct platform_driver *drv = to_platform_driver(dev->driver); struct platform_driver *pdrv = to_platform_driver(dev->driver);
struct platform_device *pdev; struct platform_device *pdev = to_platform_device(dev);
int ret = 0; int ret = 0;
pdev = container_of(dev, struct platform_device, dev); if (dev->driver && pdrv->suspend_late)
if (dev->driver && drv->suspend_late) ret = pdrv->suspend_late(pdev, mesg);
ret = drv->suspend_late(pdev, mesg);
return ret; return ret;
} }
static int platform_legacy_resume_early(struct device *dev) static int platform_legacy_resume_early(struct device *dev)
{ {
struct platform_driver *drv = to_platform_driver(dev->driver); struct platform_driver *pdrv = to_platform_driver(dev->driver);
struct platform_device *pdev; struct platform_device *pdev = to_platform_device(dev);
int ret = 0; int ret = 0;
pdev = container_of(dev, struct platform_device, dev); if (dev->driver && pdrv->resume_early)
if (dev->driver && drv->resume_early) ret = pdrv->resume_early(pdev);
ret = drv->resume_early(pdev);
return ret; return ret;
} }
......
...@@ -4135,10 +4135,9 @@ static int have_no_fdc = -ENODEV; ...@@ -4135,10 +4135,9 @@ static int have_no_fdc = -ENODEV;
static ssize_t floppy_cmos_show(struct device *dev, static ssize_t floppy_cmos_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct platform_device *p; struct platform_device *p = to_platform_device(dev);
int drive; int drive;
p = container_of(dev, struct platform_device,dev);
drive = p->id; drive = p->id;
return sprintf(buf, "%X\n", UDP->cmos); return sprintf(buf, "%X\n", UDP->cmos);
} }
......
...@@ -389,8 +389,7 @@ static void gigaset_freecshw(struct cardstate *cs) ...@@ -389,8 +389,7 @@ static void gigaset_freecshw(struct cardstate *cs)
static void gigaset_device_release(struct device *dev) static void gigaset_device_release(struct device *dev)
{ {
struct platform_device *pdev = struct platform_device *pdev = to_platform_device(dev);
container_of(dev, struct platform_device, dev);
/* adapted from platform_device_release() in drivers/base/platform.c */ /* adapted from platform_device_release() in drivers/base/platform.c */
//FIXME is this actually necessary? //FIXME is this actually necessary?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册