Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753880AbbGKKJV (ORCPT ); Sat, 11 Jul 2015 06:09:21 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:32773 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753556AbbGKKJS (ORCPT ); Sat, 11 Jul 2015 06:09:18 -0400 Date: Sat, 11 Jul 2015 15:39:11 +0530 From: Vaishali Thakkar To: "David S. Miller" Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ide: Add helper macro for struct pci_driver bolierplate Message-ID: <20150711100910.GA16981@vaishali-Ideapad-Z570> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1620 Lines: 41 For simple IDE modules that contain a single pci_driver without any additional setup code then ends up being a block of duplicated boilerplate. This patch adds a new macro, module_ide_pci_driver(), which replaces the module_init()/module_exit() registrations with template functions. Signed-off-by: Vaishali Thakkar --- include/linux/ide.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/ide.h b/include/linux/ide.h index a633898..ac93cf5 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1189,6 +1189,17 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o #define ide_pci_register_driver(d) pci_register_driver(d) #endif +/** + * module_ide_pci_driver() - Helper macro for registering a IDE drivers + * @__pci_driver: pci_driver struct + * Helper macro for IDE drivers which do not 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_ide_pci_driver(__pci_driver) \ + module_driver(__pci_driver, ide_pci_register_driver, \ + pci_unregister_driver) + static inline int ide_pci_is_in_compatibility_mode(struct pci_dev *dev) { if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 5) != 5) -- 1.9.1 -- 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/