[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231103061522.1268637-10-andrew@codeconstruct.com.au>
Date: Fri, 3 Nov 2023 16:45:21 +1030
From: Andrew Jeffery <andrew@...econstruct.com.au>
To: minyard@....org, openipmi-developer@...ts.sourceforge.net
Cc: Andrew Jeffery <andrew@...econstruct.com.au>,
linux-kernel@...r.kernel.org, Jonathan.Cameron@...wei.com,
aladyshev22@...il.com, jk@...econstruct.com.au
Subject: [PATCH 09/10] ipmi: kcs_bmc: Add module_kcs_bmc_driver()
Remove some cruft in the client modules by adding the usual module macro
for the KCS subsystem.
Signed-off-by: Andrew Jeffery <andrew@...econstruct.com.au>
---
drivers/char/ipmi/kcs_bmc.c | 4 +++-
drivers/char/ipmi/kcs_bmc.h | 1 +
drivers/char/ipmi/kcs_bmc_cdev_ipmi.c | 15 +--------------
drivers/char/ipmi/kcs_bmc_client.h | 7 ++++++-
drivers/char/ipmi/kcs_bmc_serio.c | 15 +--------------
5 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c
index 203cb73faa91..c69eb671d9d0 100644
--- a/drivers/char/ipmi/kcs_bmc.c
+++ b/drivers/char/ipmi/kcs_bmc.c
@@ -174,7 +174,7 @@ void kcs_bmc_remove_device(struct kcs_bmc_device *dev)
}
EXPORT_SYMBOL(kcs_bmc_remove_device);
-void kcs_bmc_register_driver(struct kcs_bmc_driver *drv)
+int kcs_bmc_register_driver(struct kcs_bmc_driver *drv)
{
struct kcs_bmc_client *client;
struct kcs_bmc_device *dev;
@@ -191,6 +191,8 @@ void kcs_bmc_register_driver(struct kcs_bmc_driver *drv)
list_add(&client->entry, &kcs_bmc_clients);
}
mutex_unlock(&kcs_bmc_lock);
+
+ return 0;
}
EXPORT_SYMBOL(kcs_bmc_register_driver);
diff --git a/drivers/char/ipmi/kcs_bmc.h b/drivers/char/ipmi/kcs_bmc.h
index 880d835fb90c..979d673f8f56 100644
--- a/drivers/char/ipmi/kcs_bmc.h
+++ b/drivers/char/ipmi/kcs_bmc.h
@@ -7,6 +7,7 @@
#define __KCS_BMC_H__
#include <linux/list.h>
+#include <linux/module.h>
#include <linux/spinlock.h>
#define KCS_BMC_EVENT_TYPE_OBE BIT(0)
diff --git a/drivers/char/ipmi/kcs_bmc_cdev_ipmi.c b/drivers/char/ipmi/kcs_bmc_cdev_ipmi.c
index 9fca31f8c7c2..21d4c4c11e07 100644
--- a/drivers/char/ipmi/kcs_bmc_cdev_ipmi.c
+++ b/drivers/char/ipmi/kcs_bmc_cdev_ipmi.c
@@ -523,20 +523,7 @@ static struct kcs_bmc_driver kcs_bmc_ipmi_driver = {
.ops = &kcs_bmc_ipmi_driver_ops,
};
-static int __init kcs_bmc_ipmi_init(void)
-{
- kcs_bmc_register_driver(&kcs_bmc_ipmi_driver);
-
- return 0;
-}
-module_init(kcs_bmc_ipmi_init);
-
-static void __exit kcs_bmc_ipmi_exit(void)
-{
- kcs_bmc_unregister_driver(&kcs_bmc_ipmi_driver);
-}
-module_exit(kcs_bmc_ipmi_exit);
-
+module_kcs_bmc_driver(kcs_bmc_ipmi_driver);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Haiyue Wang <haiyue.wang@...ux.intel.com>");
MODULE_AUTHOR("Andrew Jeffery <andrew@...id.au>");
diff --git a/drivers/char/ipmi/kcs_bmc_client.h b/drivers/char/ipmi/kcs_bmc_client.h
index 1c6c812d6edc..afc9e71c9fc0 100644
--- a/drivers/char/ipmi/kcs_bmc_client.h
+++ b/drivers/char/ipmi/kcs_bmc_client.h
@@ -5,6 +5,7 @@
#define __KCS_BMC_CONSUMER_H__
#include <linux/irqreturn.h>
+#include <linux/module.h>
#include "kcs_bmc.h"
@@ -44,9 +45,13 @@ struct kcs_bmc_driver {
const struct kcs_bmc_driver_ops *ops;
};
-void kcs_bmc_register_driver(struct kcs_bmc_driver *drv);
+int kcs_bmc_register_driver(struct kcs_bmc_driver *drv);
void kcs_bmc_unregister_driver(struct kcs_bmc_driver *drv);
+#define module_kcs_bmc_driver(__kcs_bmc_driver) \
+ module_driver(__kcs_bmc_driver, kcs_bmc_register_driver, \
+ kcs_bmc_unregister_driver)
+
int kcs_bmc_enable_device(struct kcs_bmc_client *client);
void kcs_bmc_disable_device(struct kcs_bmc_client *client);
u8 kcs_bmc_read_data(struct kcs_bmc_client *client);
diff --git a/drivers/char/ipmi/kcs_bmc_serio.c b/drivers/char/ipmi/kcs_bmc_serio.c
index 3cfda39506f6..8bb598c2aa38 100644
--- a/drivers/char/ipmi/kcs_bmc_serio.c
+++ b/drivers/char/ipmi/kcs_bmc_serio.c
@@ -123,20 +123,7 @@ static struct kcs_bmc_driver kcs_bmc_serio_driver = {
.ops = &kcs_bmc_serio_driver_ops,
};
-static int __init kcs_bmc_serio_init(void)
-{
- kcs_bmc_register_driver(&kcs_bmc_serio_driver);
-
- return 0;
-}
-module_init(kcs_bmc_serio_init);
-
-static void __exit kcs_bmc_serio_exit(void)
-{
- kcs_bmc_unregister_driver(&kcs_bmc_serio_driver);
-}
-module_exit(kcs_bmc_serio_exit);
-
+module_kcs_bmc_driver(kcs_bmc_serio_driver);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Andrew Jeffery <andrew@...id.au>");
MODULE_DESCRIPTION("Adapter driver for serio access to BMC KCS devices");
--
2.39.2
Powered by blists - more mailing lists