Blob Blame History Raw
From 7960f18a56475bf2177c5ff56c72eb4c12c56440 Mon Sep 17 00:00:00 2001
From: Corey Minyard <cminyard@mvista.com>
Date: Thu, 5 Apr 2018 22:03:35 -0500
Subject: [PATCH] ipmi_si: Convert over to a shutdown handler
Git-commit: 7960f18a56475bf2177c5ff56c72eb4c12c56440
Patch-mainline: v4.18-rc1
References: FATE#326156

Move the shutdown handling to a shutdown function called from
the IPMI core code.  That makes for a cleaner shutdown.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/char/ipmi/ipmi_si_intf.c |   31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1206,9 +1206,11 @@ static void set_maintenance_mode(void *s
 		atomic_set(&smi_info->req_events, 0);
 }
 
+static void shutdown_smi(void *send_info);
 static const struct ipmi_smi_handlers handlers = {
 	.owner                  = THIS_MODULE,
 	.start_processing       = smi_start_processing,
+	.shutdown               = shutdown_smi,
 	.get_smi_info		= get_smi_info,
 	.sender			= sender,
 	.request_events		= request_events,
@@ -2200,20 +2202,9 @@ skip_fallback_noirq:
 }
 module_init(init_ipmi_si);
 
-static void shutdown_one_si(struct smi_info *smi_info)
+static void shutdown_smi(void *send_info)
 {
-	int           rv = 0;
-
-	if (smi_info->intf) {
-		ipmi_smi_t intf = smi_info->intf;
-
-		smi_info->intf = NULL;
-		rv = ipmi_unregister_smi(intf);
-		if (rv) {
-			pr_err(PFX "Unable to unregister device: errno=%d\n",
-			       rv);
-		}
-	}
+	struct smi_info *smi_info = send_info;
 
 	if (smi_info->io.dev)
 		dev_set_drvdata(smi_info->io.dev, NULL);
@@ -2267,6 +2258,20 @@ static void shutdown_one_si(struct smi_i
 	smi_info->si_sm = NULL;
 }
 
+static void shutdown_one_si(struct smi_info *smi_info)
+{
+	int rv;
+	ipmi_smi_t intf = smi_info->intf;
+
+	if (!intf)
+		return;
+
+	smi_info->intf = NULL;
+	rv = ipmi_unregister_smi(intf);
+	if (rv)
+		pr_err(PFX "Unable to unregister device: errno=%d\n", rv);
+}
+
 static void cleanup_one_si(struct smi_info *smi_info)
 {
 	if (!smi_info)