Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752569AbYL3HDV (ORCPT ); Tue, 30 Dec 2008 02:03:21 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751330AbYL3HDM (ORCPT ); Tue, 30 Dec 2008 02:03:12 -0500 Received: from rv-out-0506.google.com ([209.85.198.230]:65088 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751310AbYL3HDL (ORCPT ); Tue, 30 Dec 2008 02:03:11 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=k4V/HFPiwbprlsqEgSA8lmsyBgODT7kKuPCyq82CQn9gtvP7hOLypW8ZdqA8djGhGS Oid4kWR1VmMycd0oxOowXTaEfrQHWRu+KZIZJKMJQ/LGhAuGAlaUUWDqCQY1alHDvv1/ MQdI54acy7yXifgiogIiyq+KZA6MWUQvg5Nwc= Message-ID: Date: Tue, 30 Dec 2008 15:03:08 +0800 From: "Eric Miao" To: LKML Subject: [PATCH 1/2] platform: make better use of to_platform_{device,driver}() macros MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_126033_4435606.1230620588935" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8495 Lines: 174 ------=_Part_126033_4435606.1230620588935 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline This helps the code look more consistent and cleaner. Signed-off-by: Eric Miao --- drivers/base/platform.c | 21 +++++++++------------ drivers/block/floppy.c | 3 +-- 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 dfcbfe5..d0591f0 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -606,9 +606,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 (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); } @@ -626,26 +625,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; } diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index cf29cc4..9c3c5c7 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4133,10 +4133,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); } diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c index ac245e7..3071a52 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) 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? -- 1.6.0.4 ------=_Part_126033_4435606.1230620588935 Content-Type: text/x-diff; name=0001-platform-make-better-use-of-to_platform_-device-dri.patch Content-Transfer-Encoding: base64 X-Attachment-Id: f_fpc7pc2s0 Content-Disposition: attachment; filename=0001-platform-make-better-use-of-to_platform_-device-dri.patch RnJvbSAwM2IzMWNlN2NjMjA0MzUzZTczYjM5YTJjMGYzYWJhNjhhYjA3ODgzIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBFcmljIE1pYW8gPGVyaWMubWlhb0BtYXJ2ZWxsLmNvbT4KRGF0 ZTogVHVlLCAzMCBEZWMgMjAwOCAxMzo0OToxNyArMDgwMApTdWJqZWN0OiBwbGF0Zm9ybTogbWFr ZSBiZXR0ZXIgdXNlIG9mIHRvX3BsYXRmb3JtX3tkZXZpY2UsZHJpdmVyfSgpIG1hY3JvcwoKVGhp cyBoZWxwcyB0aGUgY29kZSBsb29rIG1vcmUgY29uc2lzdGVudCBhbmQgY2xlYW5lci4KClNpZ25l ZC1vZmYtYnk6IEVyaWMgTWlhbyA8ZXJpYy5taWFvQG1hcnZlbGwuY29tPgotLS0KIGRyaXZlcnMv YmFzZS9wbGF0Zm9ybS5jICAgICAgICAgICAgfCAgIDIxICsrKysrKysrKy0tLS0tLS0tLS0tLQog ZHJpdmVycy9ibG9jay9mbG9wcHkuYyAgICAgICAgICAgICB8ICAgIDMgKy0tCiBkcml2ZXJzL2lz ZG4vZ2lnYXNldC9zZXItZ2lnYXNldC5jIHwgICAgMyArLS0KIDMgZmlsZXMgY2hhbmdlZCwgMTEg aW5zZXJ0aW9ucygrKSwgMTYgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEvZHJpdmVycy9iYXNl L3BsYXRmb3JtLmMgYi9kcml2ZXJzL2Jhc2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2lnYXNldC9zZXItZ2lnYXNldC5jCkBAIC0zODksOCArMzg5LDcgQEAgc3Rh dGljIHZvaWQgZ2lnYXNldF9mcmVlY3NodyhzdHJ1Y3QgY2FyZHN0YXRlICpjcykKIAogc3RhdGlj IHZvaWQgZ2lnYXNldF9kZXZpY2VfcmVsZWFzZShzdHJ1Y3QgZGV2aWNlICpkZXYpCiB7Ci0Jc3Ry dWN0IHBsYXRmb3JtX2RldmljZSAqcGRldiA9Ci0JCWNvbnRhaW5lcl9vZihkZXYsIHN0cnVjdCBw bGF0Zm9ybV9kZXZpY2UsIGRldik7CisJc3RydWN0IHBsYXRmb3JtX2RldmljZSAqcGRldiA9IHRv X3BsYXRmb3JtX2RldmljZShkZXYpOwogCiAJLyogYWRhcHRlZCBmcm9tIHBsYXRmb3JtX2Rldmlj ZV9yZWxlYXNlKCkgaW4gZHJpdmVycy9iYXNlL3BsYXRmb3JtLmMgKi8KIAkvL0ZJWE1FIGlzIHRo aXMgYWN0dWFsbHkgbmVjZXNzYXJ5PwotLSAKMS42LjAuNAoK ------=_Part_126033_4435606.1230620588935-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/