From patchwork Sun Dec 13 20:33:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Gortmaker X-Patchwork-Id: 556228 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3C9831402B4 for ; Mon, 14 Dec 2015 07:35:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752163AbbLMUfm (ORCPT ); Sun, 13 Dec 2015 15:35:42 -0500 Received: from mail1.windriver.com ([147.11.146.13]:40107 "EHLO mail1.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752020AbbLMUfl (ORCPT ); Sun, 13 Dec 2015 15:35:41 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id tBDKXY9Y006339 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Sun, 13 Dec 2015 12:33:34 -0800 (PST) Received: from yow-lpgnfs-02.corp.ad.wrs.com (128.224.149.8) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.248.2; Sun, 13 Dec 2015 12:33:33 -0800 From: Paul Gortmaker To: CC: Paul Gortmaker , Wolfram Sang , Lee Jones , Linus Walleij , Alexandre Courbot , , Subject: [PATCH] i2c: create builtin_i2c_driver to avoid registration boilerplate Date: Sun, 13 Dec 2015 15:33:19 -0500 Message-ID: <1450038799-27995-1-git-send-email-paul.gortmaker@windriver.com> X-Mailer: git-send-email 2.6.1 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org In commit f309d4443130bf814e991f836e919dca22df37ae ("platform_device: better support builtin boilerplate avoidance") we introduced the builtin_driver macro. Here we use that support and extend it to I2C driver registration, so where a driver is clearly non-modular and builtin-only, we can register it in a similar fashion. And existing code that is clearly non-modular can be updated with the simple mapping of module_i2c_driver(...) ---> builtin_i2c_driver(...) We've essentially cloned the former to make the latter, and taken out the remove/module_exit parts since those never get used in a non-modular build of the code. A similar thing was done in commit b4eb6cdbbd13698704863f680c643c569909e1c2 ("PCI: Add builtin_pci_driver() to avoid registration boilerplate"). Cc: Wolfram Sang Cc: Lee Jones Cc: Linus Walleij Cc: Alexandre Courbot Cc: linux-gpio@vger.kernel.org Cc: linux-i2c@vger.kernel.org Signed-off-by: Paul Gortmaker --- [I've about 10 drivers/mfd and one drivers/gpio users of this in my personal testing queue, but obviously I can't submit those until builtin_i2c_driver makes it to mainline. Since there are no drivers/i2c users yet this change is sent to i2c on its own.] include/linux/i2c.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 768063baafbf..d3ca750bfcdf 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -622,7 +622,7 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap) } /** - * module_i2c_driver() - Helper macro for registering a I2C driver + * module_i2c_driver() - Helper macro for registering a modular I2C driver * @__i2c_driver: i2c_driver struct * * Helper macro for I2C drivers which do not do anything special in module @@ -633,6 +633,17 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap) module_driver(__i2c_driver, i2c_add_driver, \ i2c_del_driver) +/** + * builtin_i2c_driver() - Helper macro for registering a builtin I2C driver + * @__i2c_driver: i2c_driver struct + * + * Helper macro for I2C drivers which do not do anything special in their + * init. This eliminates a lot of boilerplate. Each driver may only + * use this macro once, and calling it replaces device_initcall(). + */ +#define builtin_i2c_driver(__i2c_driver) \ + builtin_driver(__i2c_driver, i2c_add_driver) + #endif /* I2C */ #if IS_ENABLED(CONFIG_OF)