Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Vaishali Thakkar <vthakkar1994@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ide: Add helper macro for struct pci_driver bolierplate
Date: Sat, 11 Jul 2015 15:39:11 +0530	[thread overview]
Message-ID: <20150711100910.GA16981@vaishali-Ideapad-Z570> (raw)

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 <vthakkar1994@gmail.com>
---
 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


                 reply	other threads:[~2015-07-11 10:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150711100910.GA16981@vaishali-Ideapad-Z570 \
    --to=vthakkar1994@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox