From patchwork Sat May 25 04:40:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Libo Chen X-Patchwork-Id: 2612961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id F3372DF2A2 for ; Sat, 25 May 2013 04:44:43 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ug6LP-00037y-8g; Sat, 25 May 2013 04:44:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ug6LM-0004S1-MQ; Sat, 25 May 2013 04:44:36 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ug6LH-0004R8-Nu for linux-arm-kernel@lists.infradead.org; Sat, 25 May 2013 04:44:33 +0000 Received: from 172.24.2.119 (EHLO szxeml206-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BCR30970; Sat, 25 May 2013 12:43:25 +0800 (CST) Received: from SZXEML415-HUB.china.huawei.com (10.82.67.154) by szxeml206-edg.china.huawei.com (172.24.2.59) with Microsoft SMTP Server (TLS) id 14.1.323.7; Sat, 25 May 2013 12:40:46 +0800 Received: from [127.0.0.1] (10.135.72.158) by szxeml415-hub.china.huawei.com (10.82.67.154) with Microsoft SMTP Server id 14.1.323.7; Sat, 25 May 2013 12:40:54 +0800 Message-ID: <51A040D2.20708@huawei.com> Date: Sat, 25 May 2013 12:40:50 +0800 From: Libo Chen User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Subject: [PATCH] module: use a macro instead of platform_driver_register X-Originating-IP: [10.135.72.158] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130525_004432_231871_D8BF6044 X-CRM114-Status: UNSURE ( 9.74 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -3.0 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.1 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: LKML , Li Zefan , stern@rowland.harvard.edu, Andrew Morton , David Miller , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org I found a lot of mistakes using struct platform_driver without owner so I make a macro instead of the function platform_driver_register. It can set owner in it, then guys don`t care about module owner again. Signed-off-by: Libo Chen --- drivers/base/platform.c | 8 +++++--- include/linux/platform_device.h | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 9eda842..ed75cf6 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -523,11 +523,13 @@ static void platform_drv_shutdown(struct device *_dev) } /** - * platform_driver_register - register a driver for platform-level devices + * __platform_driver_register - register a driver for platform-level devices * @drv: platform driver structure */ -int platform_driver_register(struct platform_driver *drv) +int __platform_driver_register(struct platform_driver *drv, + struct module *owner) { + drv->driver.owner = owner; drv->driver.bus = &platform_bus_type; if (drv->probe) drv->driver.probe = platform_drv_probe; @@ -538,7 +540,7 @@ int platform_driver_register(struct platform_driver *drv) return driver_register(&drv->driver); } -EXPORT_SYMBOL_GPL(platform_driver_register); +EXPORT_SYMBOL_GPL(__platform_driver_register); /** * platform_driver_unregister - unregister a driver for platform-level devices diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 9abf1db..cd46ee5 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -180,7 +180,13 @@ struct platform_driver { const struct platform_device_id *id_table; }; -extern int platform_driver_register(struct platform_driver *); +/* + * use a macro to avoid include chaining to get THIS_MODULE + */ +#define platform_driver_register(drv) \ + __platform_driver_register(drv, THIS_MODULE) +extern int __platform_driver_register(struct platform_driver *, + struct module *); extern void platform_driver_unregister(struct platform_driver *); /* non-hotpluggable platform devices may use this so that probe() and