From patchwork Wed Jan 9 11:15:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Porcedda X-Patchwork-Id: 1952071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 63C57DF25A for ; Wed, 9 Jan 2013 11:18:57 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TstdS-0005Dt-MV; Wed, 09 Jan 2013 11:15:54 +0000 Received: from mail-bk0-f41.google.com ([209.85.214.41]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tstd9-00059J-Up for linux-arm-kernel@lists.infradead.org; Wed, 09 Jan 2013 11:15:36 +0000 Received: by mail-bk0-f41.google.com with SMTP id jg9so818317bkc.14 for ; Wed, 09 Jan 2013 03:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=PUKQ2qd+pItX+OhhNtrwZoE23dMBlbSsiIboSAjevfg=; b=AU5cdJ/tX0bs1K0Z4At88+SLx73JrfPovQtD0LXA6gJyhK52183ulm1Df/NHPfkPbP 1cXs9tyV9sc6UgcJAC6ajjUqfmnL5FsLYHbWBcqjo0eKkR7aTmb44Ud4K+5LfU5uKN/U HIVWN+c41j2hOBF499WhyGrzl2CDmRGx6pL+uhSUnt3bZbhex96sB14ODaW0qxFkhWGL eP2hokCZ9TKbI4psClPJJ7v7//21dLfGeb8HTQ8Xgox5+ptmhCOpqy3hJTExqFvLIR16 p49h9Tbq8YzsdcsJIPBFY7j8a5zG7+pwTOWsq6oU7uMV5x+4aDki8DNAdbpS6MfVtNhI QVfg== X-Received: by 10.204.149.85 with SMTP id s21mr32689280bkv.37.1357730134633; Wed, 09 Jan 2013 03:15:34 -0800 (PST) Received: from ld2036.tmt.telital.com ([213.205.6.118]) by mx.google.com with ESMTPS id hm8sm48220416bkc.10.2013.01.09.03.15.32 (version=SSLv3 cipher=OTHER); Wed, 09 Jan 2013 03:15:33 -0800 (PST) From: Fabio Porcedda To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate Date: Wed, 9 Jan 2013 12:15:26 +0100 Message-Id: <1357730128-23018-2-git-send-email-fabio.porcedda@gmail.com> X-Mailer: git-send-email 1.8.0.3 In-Reply-To: <1357730128-23018-1-git-send-email-fabio.porcedda@gmail.com> References: <1357730128-23018-1-git-send-email-fabio.porcedda@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130109_061536_234673_1922C7FA X-CRM114-Status: GOOD ( 12.64 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.41 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (fabio.porcedda[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Greg Kroah-Hartman X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For simple modules that contain a single platform_driver without any additional setup code then ends up being a block of duplicated boilerplate. This patch adds a new macro, module_platform_driver_probe(), which replaces the module_init()/module_exit() registrations with template functions. This macro use the same idea of module_platform_driver(). This macro is useful to stop the misuse of module_platform_driver() for removing the platform_driver_probe() boilerplate. Signed-off-by: Fabio Porcedda Cc: Greg Kroah-Hartman --- include/linux/platform_device.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index a9ded9a..c082c71 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -204,6 +204,24 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data module_driver(__platform_driver, platform_driver_register, \ platform_driver_unregister) +/* module_platform_driver_probe() - Helper macro for drivers that don't do + * anything special in module init/exit. This eliminates a lot of + * boilerplate. Each module may only use this macro once, and + * calling it replaces module_init() and module_exit() + */ +#define module_platform_driver_probe(__platform_driver, __platform_probe) \ +static int __init __platform_driver##_init(void) \ +{ \ + return platform_driver_probe(&(__platform_driver), \ + __platform_probe); \ +} \ +module_init(__platform_driver##_init); \ +static void __exit __platform_driver##_exit(void) \ +{ \ + platform_driver_unregister(&(__platform_driver)); \ +} \ +module_exit(__platform_driver##_exit); + extern struct platform_device *platform_create_bundle(struct platform_driver *driver, int (*probe)(struct platform_device *), struct resource *res, unsigned int n_res,