From patchwork Sun Dec 13 20:53:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Gortmaker X-Patchwork-Id: 7839731 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C7B36BEEE1 for ; Sun, 13 Dec 2015 20:54:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC98320374 for ; Sun, 13 Dec 2015 20:54:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD76320304 for ; Sun, 13 Dec 2015 20:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752362AbbLMUyP (ORCPT ); Sun, 13 Dec 2015 15:54:15 -0500 Received: from mail5.windriver.com ([192.103.53.11]:39508 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752317AbbLMUyO (ORCPT ); Sun, 13 Dec 2015 15:54:14 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id tBDKsA6O014774 (version=TLSv1 cipher=AES128-SHA bits=128 verify=OK); Sun, 13 Dec 2015 12:54:10 -0800 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:54:09 -0800 From: Paul Gortmaker To: CC: Paul Gortmaker , Mark Brown , Subject: [PATCH] spi: Add builtin_spi_driver() to avoid registration boilerplate Date: Sun, 13 Dec 2015 15:53:57 -0500 Message-ID: <1450040037-28334-1-git-send-email-paul.gortmaker@windriver.com> X-Mailer: git-send-email 2.6.1 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 SPI driver registration, so where a driver is clearly non-modular and builtin-only, we can register it in a similar fashion. Existing code that is clearly non-modular can be updated with the simple mapping of module_spi_driver(...) ---> builtin_spi_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: Mark Brown Cc: linux-spi@vger.kernel.org Signed-off-by: Paul Gortmaker --- [I've a drivers/video user of this in my personal testing queue, but obviously I can't submit that until builtin_spi_driver makes it to mainline. Since there are no drivers/spi users of it (yet), this change is sent to the spi list/maintainers on its own.] include/linux/spi/spi.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 075bede66521..1458f2f21dcc 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -272,6 +272,17 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) __spi_register_driver(THIS_MODULE, driver) /** + * builtin_spi_driver() - Helper macro for registering a SPI driver + * @__spi_driver: spi_driver struct + * + * Helper macro for SPI drivers which do not do anything special in + * init. This eliminates a lot of boilerplate. Each file may only + * use this macro once, and calling it replaces device_initcall() + */ +#define builtin_spi_driver(__spi_driver) \ + builtin_driver(__spi_driver, spi_register_driver) + +/** * module_spi_driver() - Helper macro for registering a SPI driver * @__spi_driver: spi_driver struct *