w1: add helper macro module_w1_family
authorAndrew F. Davis <afd@ti.com>
Tue, 2 Aug 2016 21:07:09 +0000 (14:07 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 2 Aug 2016 23:35:39 +0000 (19:35 -0400)
The helper macro module_w1_family can be used in module drivers that
only register a w1 driver in their module init functions.  Add this
macro and use it in all applicable drivers.

Link: http://lkml.kernel.org/r/20160531204313.20979-2-afd@ti.com
Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/w1/slaves/w1_ds2406.c
drivers/w1/slaves/w1_ds2408.c
drivers/w1/slaves/w1_ds2413.c
drivers/w1/slaves/w1_ds2423.c
drivers/w1/slaves/w1_ds2431.c
drivers/w1/slaves/w1_ds2433.c
drivers/w1/slaves/w1_ds2760.c
drivers/w1/slaves/w1_ds2780.c
drivers/w1/slaves/w1_ds2781.c
drivers/w1/slaves/w1_ds28e04.c
drivers/w1/w1_family.h

index d488961a8c903c3600a65460fc7a5bd9a7f1f4b6..51f2f66d655516b999ca7aadab0a1e5dcc0f7ac8 100644 (file)
@@ -153,16 +153,4 @@ static struct w1_family w1_family_12 = {
        .fid = W1_FAMILY_DS2406,
        .fops = &w1_f12_fops,
 };
-
-static int __init w1_f12_init(void)
-{
-       return w1_register_family(&w1_family_12);
-}
-
-static void __exit w1_f12_exit(void)
-{
-       w1_unregister_family(&w1_family_12);
-}
-
-module_init(w1_f12_init);
-module_exit(w1_f12_exit);
+module_w1_family(w1_family_12);
index 7dfa0e11688a1c93b4e466522ec4ccd1e2b59250..aec5958e66e9c585304a3c52f164533fbbf329f3 100644 (file)
@@ -351,16 +351,4 @@ static struct w1_family w1_family_29 = {
        .fid = W1_FAMILY_DS2408,
        .fops = &w1_f29_fops,
 };
-
-static int __init w1_f29_init(void)
-{
-       return w1_register_family(&w1_family_29);
-}
-
-static void __exit w1_f29_exit(void)
-{
-       w1_unregister_family(&w1_family_29);
-}
-
-module_init(w1_f29_init);
-module_exit(w1_f29_exit);
+module_w1_family(w1_family_29);
index ee28fc1ff3901fcc3533db529bdc50e59da21f20..f2e1c51533b957f480ee8eb78f1d01a39df81c16 100644 (file)
@@ -135,16 +135,4 @@ static struct w1_family w1_family_3a = {
        .fid = W1_FAMILY_DS2413,
        .fops = &w1_f3a_fops,
 };
-
-static int __init w1_f3a_init(void)
-{
-       return w1_register_family(&w1_family_3a);
-}
-
-static void __exit w1_f3a_exit(void)
-{
-       w1_unregister_family(&w1_family_3a);
-}
-
-module_init(w1_f3a_init);
-module_exit(w1_f3a_exit);
+module_w1_family(w1_family_3a);
index 7e41b7d91fb54fca9e4fbb8ae1a536c16cc1508d..4ab54fd9dde26f4d5335c61fe78040f2d2daa17d 100644 (file)
@@ -138,19 +138,7 @@ static struct w1_family w1_family_1d = {
        .fid = W1_COUNTER_DS2423,
        .fops = &w1_f1d_fops,
 };
-
-static int __init w1_f1d_init(void)
-{
-       return w1_register_family(&w1_family_1d);
-}
-
-static void __exit w1_f1d_exit(void)
-{
-       w1_unregister_family(&w1_family_1d);
-}
-
-module_init(w1_f1d_init);
-module_exit(w1_f1d_exit);
+module_w1_family(w1_family_1d);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Mika Laitio <lamikr@pilppa.org>");
index 9c4ff9d28adc94d0061d977a26843500fc4211b3..80572cb63ba8506e9b4c04d22515ab00526aa520 100644 (file)
@@ -288,19 +288,7 @@ static struct w1_family w1_family_2d = {
        .fid = W1_EEPROM_DS2431,
        .fops = &w1_f2d_fops,
 };
-
-static int __init w1_f2d_init(void)
-{
-       return w1_register_family(&w1_family_2d);
-}
-
-static void __exit w1_f2d_fini(void)
-{
-       w1_unregister_family(&w1_family_2d);
-}
-
-module_init(w1_f2d_init);
-module_exit(w1_f2d_fini);
+module_w1_family(w1_family_2d);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Bernhard Weirich <bernhard.weirich@riedel.net>");
index 72319a968a9e25902940568d798fd83ee6c83d55..6cf378c89ecbdec9b3b7aeb81c152399f2b5f63e 100644 (file)
@@ -305,16 +305,4 @@ static struct w1_family w1_family_23 = {
        .fid = W1_EEPROM_DS2433,
        .fops = &w1_f23_fops,
 };
-
-static int __init w1_f23_init(void)
-{
-       return w1_register_family(&w1_family_23);
-}
-
-static void __exit w1_f23_fini(void)
-{
-       w1_unregister_family(&w1_family_23);
-}
-
-module_init(w1_f23_init);
-module_exit(w1_f23_fini);
+module_w1_family(w1_family_23);
index 59a81cfe64d5e4b18c0ea18bf4ac28f2f1f2d417..ffa37f773b3bf362a28a7d0b2c62e8be0f5b0ef1 100644 (file)
@@ -162,26 +162,13 @@ static struct w1_family w1_ds2760_family = {
        .fid = W1_FAMILY_DS2760,
        .fops = &w1_ds2760_fops,
 };
-
-static int __init w1_ds2760_init(void)
-{
-       pr_info("1-Wire driver for the DS2760 battery monitor chip - (c) 2004-2005, Szabolcs Gyurko\n");
-       return w1_register_family(&w1_ds2760_family);
-}
-
-static void __exit w1_ds2760_exit(void)
-{
-       w1_unregister_family(&w1_ds2760_family);
-}
+module_w1_family(w1_ds2760_family);
 
 EXPORT_SYMBOL(w1_ds2760_read);
 EXPORT_SYMBOL(w1_ds2760_write);
 EXPORT_SYMBOL(w1_ds2760_store_eeprom);
 EXPORT_SYMBOL(w1_ds2760_recall_eeprom);
 
-module_init(w1_ds2760_init);
-module_exit(w1_ds2760_exit);
-
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Szabolcs Gyurko <szabolcs.gyurko@tlt.hu>");
 MODULE_DESCRIPTION("1-wire Driver Dallas 2760 battery monitor chip");
index e63eb86d66f174a52d5a06a1f6d9ee54a10aa574..f5c2aa429a9262de25d0bfa701713764767cc96e 100644 (file)
@@ -154,19 +154,7 @@ static struct w1_family w1_ds2780_family = {
        .fid = W1_FAMILY_DS2780,
        .fops = &w1_ds2780_fops,
 };
-
-static int __init w1_ds2780_init(void)
-{
-       return w1_register_family(&w1_ds2780_family);
-}
-
-static void __exit w1_ds2780_exit(void)
-{
-       w1_unregister_family(&w1_ds2780_family);
-}
-
-module_init(w1_ds2780_init);
-module_exit(w1_ds2780_exit);
+module_w1_family(w1_ds2780_family);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Clifton Barnes <cabarnes@indesign-llc.com>");
index 99b0f4dc0e31080f66d75574580a30ca4954757c..9c03e014cf9eb6159f5087dc1065bd8f283fddaf 100644 (file)
@@ -151,19 +151,7 @@ static struct w1_family w1_ds2781_family = {
        .fid = W1_FAMILY_DS2781,
        .fops = &w1_ds2781_fops,
 };
-
-static int __init w1_ds2781_init(void)
-{
-       return w1_register_family(&w1_ds2781_family);
-}
-
-static void __exit w1_ds2781_exit(void)
-{
-       w1_unregister_family(&w1_ds2781_family);
-}
-
-module_init(w1_ds2781_init);
-module_exit(w1_ds2781_exit);
+module_w1_family(w1_ds2781_family);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Renata Sayakhova <renata@oktetlabs.ru>");
index 365d6dff21de2e1a6222da448ce86ea1126d7dec..5e348d38ec5c944f2bb9e38d0aad16279b42ccb7 100644 (file)
@@ -427,16 +427,4 @@ static struct w1_family w1_family_1C = {
        .fid = W1_FAMILY_DS28E04,
        .fops = &w1_f1C_fops,
 };
-
-static int __init w1_f1C_init(void)
-{
-       return w1_register_family(&w1_family_1C);
-}
-
-static void __exit w1_f1C_fini(void)
-{
-       w1_unregister_family(&w1_family_1C);
-}
-
-module_init(w1_f1C_init);
-module_exit(w1_f1C_fini);
+module_w1_family(w1_family_1C);
index ed5dcb80a1f7a4f789a3676c518490389e2c95d0..10a7a0767187c52d67a41c3fcffa7ecd38c80e63 100644 (file)
@@ -88,4 +88,16 @@ struct w1_family * w1_family_registered(u8);
 void w1_unregister_family(struct w1_family *);
 int w1_register_family(struct w1_family *);
 
+/**
+ * module_w1_driver() - Helper macro for registering a 1-Wire families
+ * @__w1_family: w1_family struct
+ *
+ * Helper macro for 1-Wire families 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_w1_family(__w1_family) \
+       module_driver(__w1_family, w1_register_family, \
+                       w1_unregister_family)
+
 #endif /* __W1_FAMILY_H */