nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Introduce module_nd_driver
@ 2018-03-14 18:25 Johannes Thumshirn
  2018-03-14 18:25 ` [PATCH 1/3] libnvdimm: provide module_nd_driver wrapper Johannes Thumshirn
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2018-03-14 18:25 UTC (permalink / raw)
  To: Dan Williams, Ross Zwisler
  Cc: Linux Kernel Mailinglist, Linux NV-DIMM Mailing List

Provide a module_nd_driver() wrapper and move over the appliccable
drivers nd_pmem.ko and dax_pmem.ko.

Johannes Thumshirn (3):
  libnvdimm: provide module_nd_driver wrapper
  libnvdimm, pmem: use module_nd_driver
  device-dax: use module_nd_driver

 drivers/dax/pmem.c    | 12 +-----------
 drivers/nvdimm/pmem.c | 12 +-----------
 include/linux/nd.h    |  6 ++++++
 3 files changed, 8 insertions(+), 22 deletions(-)

-- 
2.13.6

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] libnvdimm: provide module_nd_driver wrapper
  2018-03-14 18:25 [PATCH 0/3] Introduce module_nd_driver Johannes Thumshirn
@ 2018-03-14 18:25 ` Johannes Thumshirn
  2018-03-14 18:25 ` [PATCH 2/3] libnvdimm, pmem: use module_nd_driver Johannes Thumshirn
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2018-03-14 18:25 UTC (permalink / raw)
  To: Dan Williams, Ross Zwisler
  Cc: Linux Kernel Mailinglist, Linux NV-DIMM Mailing List

Provide a module_nd_driver() wrapper over simple nd_driver_register()
nd_driver_unregister() combinations in module_init() and module_exit()
respectively.

Note an explicit nd_driver_unregister() had to be implemented as nd
bus drivers did call device_unregister() direcly in the module_exit()
function.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 include/linux/nd.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/nd.h b/include/linux/nd.h
index 5dc6b695437d..43c181a6add5 100644
--- a/include/linux/nd.h
+++ b/include/linux/nd.h
@@ -180,6 +180,12 @@ struct nd_region;
 void nvdimm_region_notify(struct nd_region *nd_region, enum nvdimm_event event);
 int __must_check __nd_driver_register(struct nd_device_driver *nd_drv,
 		struct module *module, const char *mod_name);
+static inline void nd_driver_unregister(struct nd_device_driver *drv)
+{
+	driver_unregister(&drv->drv);
+}
 #define nd_driver_register(driver) \
 	__nd_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
+#define module_nd_driver(driver) \
+	module_driver(driver, nd_driver_register, nd_driver_unregister)
 #endif /* __LINUX_ND_H__ */
-- 
2.13.6

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] libnvdimm, pmem: use module_nd_driver
  2018-03-14 18:25 [PATCH 0/3] Introduce module_nd_driver Johannes Thumshirn
  2018-03-14 18:25 ` [PATCH 1/3] libnvdimm: provide module_nd_driver wrapper Johannes Thumshirn
@ 2018-03-14 18:25 ` Johannes Thumshirn
  2018-03-14 18:25 ` [PATCH 3/3] device-dax: " Johannes Thumshirn
  2018-03-15  7:22 ` [PATCH 0/3] Introduce module_nd_driver Christoph Hellwig
  3 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2018-03-14 18:25 UTC (permalink / raw)
  To: Dan Williams, Ross Zwisler
  Cc: Linux Kernel Mailinglist, Linux NV-DIMM Mailing List

Use module_nd_driver() instead of having module_init() and
module_exit() callbacks which just call nd_driver_register() and
nd_driver_unregister().

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvdimm/pmem.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 06f8dcc52ca6..d8ab882be790 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -547,17 +547,7 @@ static struct nd_device_driver nd_pmem_driver = {
 	.type = ND_DRIVER_NAMESPACE_IO | ND_DRIVER_NAMESPACE_PMEM,
 };
 
-static int __init pmem_init(void)
-{
-	return nd_driver_register(&nd_pmem_driver);
-}
-module_init(pmem_init);
-
-static void pmem_exit(void)
-{
-	driver_unregister(&nd_pmem_driver.drv);
-}
-module_exit(pmem_exit);
+module_nd_driver(nd_pmem_driver);
 
 MODULE_AUTHOR("Ross Zwisler <ross.zwisler@linux.intel.com>");
 MODULE_LICENSE("GPL v2");
-- 
2.13.6

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] device-dax: use module_nd_driver
  2018-03-14 18:25 [PATCH 0/3] Introduce module_nd_driver Johannes Thumshirn
  2018-03-14 18:25 ` [PATCH 1/3] libnvdimm: provide module_nd_driver wrapper Johannes Thumshirn
  2018-03-14 18:25 ` [PATCH 2/3] libnvdimm, pmem: use module_nd_driver Johannes Thumshirn
@ 2018-03-14 18:25 ` Johannes Thumshirn
  2018-03-15  7:22 ` [PATCH 0/3] Introduce module_nd_driver Christoph Hellwig
  3 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2018-03-14 18:25 UTC (permalink / raw)
  To: Dan Williams, Ross Zwisler
  Cc: Linux Kernel Mailinglist, Linux NV-DIMM Mailing List

Use module_nd_driver() instead of having module_init() and
module_exit() callbacks which just call nd_driver_register() and
nd_driver_unregister().

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/dax/pmem.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
index 31b6ecce4c64..d927ae82ba0d 100644
--- a/drivers/dax/pmem.c
+++ b/drivers/dax/pmem.c
@@ -150,17 +150,7 @@ static struct nd_device_driver dax_pmem_driver = {
 	.type = ND_DRIVER_DAX_PMEM,
 };
 
-static int __init dax_pmem_init(void)
-{
-	return nd_driver_register(&dax_pmem_driver);
-}
-module_init(dax_pmem_init);
-
-static void __exit dax_pmem_exit(void)
-{
-	driver_unregister(&dax_pmem_driver.drv);
-}
-module_exit(dax_pmem_exit);
+module_nd_driver(dax_pmem_driver);
 
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Intel Corporation");
-- 
2.13.6

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] Introduce module_nd_driver
  2018-03-14 18:25 [PATCH 0/3] Introduce module_nd_driver Johannes Thumshirn
                   ` (2 preceding siblings ...)
  2018-03-14 18:25 ` [PATCH 3/3] device-dax: " Johannes Thumshirn
@ 2018-03-15  7:22 ` Christoph Hellwig
  2018-03-15  8:11   ` Johannes Thumshirn
  3 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2018-03-15  7:22 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: Linux NV-DIMM Mailing List, Linux Kernel Mailinglist

On Wed, Mar 14, 2018 at 07:25:05PM +0100, Johannes Thumshirn wrote:
> Provide a module_nd_driver() wrapper and move over the appliccable
> drivers nd_pmem.ko and dax_pmem.ko.

What is the point?  It saves a hand fulk of lines, while making
the code both harder to read and harder to extend.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] Introduce module_nd_driver
  2018-03-15  7:22 ` [PATCH 0/3] Introduce module_nd_driver Christoph Hellwig
@ 2018-03-15  8:11   ` Johannes Thumshirn
  2018-03-15 14:24     ` Dan Williams
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Thumshirn @ 2018-03-15  8:11 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Linux NV-DIMM Mailing List, Linux Kernel Mailinglist

On Thu, Mar 15, 2018 at 12:22:57AM -0700, Christoph Hellwig wrote:
> What is the point?  It saves a hand fulk of lines, while making
> the code both harder to read and harder to extend.

In the end it's just style alignment with most of the other "busses"
in the kernel, like pci, of, acpi, platform and so on...

But yes I admit it's not a huge win. For the harder to read part, I
doubt it. A quick:
git grep -E module_.*._driver drivers/ | wc -l
has 3896 hit's, so it's not that uncommon ;-)

But anyways, it's just code churn I came up with while being
frustrated hunting down a bug in this subsystem.

Byte,
	   Johannes
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] Introduce module_nd_driver
  2018-03-15  8:11   ` Johannes Thumshirn
@ 2018-03-15 14:24     ` Dan Williams
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2018-03-15 14:24 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, Linux Kernel Mailinglist, Linux NV-DIMM Mailing List

On Thu, Mar 15, 2018 at 1:11 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> On Thu, Mar 15, 2018 at 12:22:57AM -0700, Christoph Hellwig wrote:
>> What is the point?  It saves a hand fulk of lines, while making
>> the code both harder to read and harder to extend.
>
> In the end it's just style alignment with most of the other "busses"
> in the kernel, like pci, of, acpi, platform and so on...
>
> But yes I admit it's not a huge win. For the harder to read part, I
> doubt it. A quick:
> git grep -E module_.*._driver drivers/ | wc -l
> has 3896 hit's, so it's not that uncommon ;-)
>
> But anyways, it's just code churn I came up with while being
> frustrated hunting down a bug in this subsystem.
>

Works for me. Removing more lines than you add is always welcome.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-15 14:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-14 18:25 [PATCH 0/3] Introduce module_nd_driver Johannes Thumshirn
2018-03-14 18:25 ` [PATCH 1/3] libnvdimm: provide module_nd_driver wrapper Johannes Thumshirn
2018-03-14 18:25 ` [PATCH 2/3] libnvdimm, pmem: use module_nd_driver Johannes Thumshirn
2018-03-14 18:25 ` [PATCH 3/3] device-dax: " Johannes Thumshirn
2018-03-15  7:22 ` [PATCH 0/3] Introduce module_nd_driver Christoph Hellwig
2018-03-15  8:11   ` Johannes Thumshirn
2018-03-15 14:24     ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).