summaryrefslogtreecommitdiff
path: root/drivers/char/ipmi/kcs_bmc.c
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2021-06-08 13:47:46 +0300
committerCorey Minyard <cminyard@mvista.com>2021-06-22 03:50:13 +0300
commitd7096970075ef47c9906fd241cc4939cc11ddd01 (patch)
tree7a9481c20718d953e8c4a77a76a3ea401155ad9a /drivers/char/ipmi/kcs_bmc.c
parent55ab48b4e356212fbe084ca110db73bb9a6e7058 (diff)
downloadlinux-d7096970075ef47c9906fd241cc4939cc11ddd01.tar.xz
ipmi: kcs_bmc: Turn the driver data-structures inside-out
Make the KCS device drivers responsible for allocating their own memory. Until now the private data for the device driver was allocated internal to the private data for the chardev interface. This coupling required the slightly awkward API of passing through the struct size for the driver private data to the chardev constructor, and then retrieving a pointer to the driver private data from the allocated chardev memory. In addition to being awkward, the arrangement prevents the implementation of alternative userspace interfaces as the device driver private data is not independent. Peel a layer off the onion and turn the data-structures inside out by exploiting container_of() and embedding `struct kcs_device` in the driver private data. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Reviewed-by: Zev Weiss <zweiss@equinix.com> Message-Id: <20210608104757.582199-6-andrew@aj.id.au> Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char/ipmi/kcs_bmc.c')
-rw-r--r--drivers/char/ipmi/kcs_bmc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c
index ef5c48ffe74a..07bb6747f29a 100644
--- a/drivers/char/ipmi/kcs_bmc.c
+++ b/drivers/char/ipmi/kcs_bmc.c
@@ -44,12 +44,21 @@ int kcs_bmc_handle_event(struct kcs_bmc *kcs_bmc)
}
EXPORT_SYMBOL(kcs_bmc_handle_event);
-struct kcs_bmc *kcs_bmc_ipmi_alloc(struct device *dev, int sizeof_priv, u32 channel);
-struct kcs_bmc *kcs_bmc_alloc(struct device *dev, int sizeof_priv, u32 channel)
+int kcs_bmc_ipmi_add_device(struct kcs_bmc *kcs_bmc);
+int kcs_bmc_add_device(struct kcs_bmc *kcs_bmc)
{
- return kcs_bmc_ipmi_alloc(dev, sizeof_priv, channel);
+ return kcs_bmc_ipmi_add_device(kcs_bmc);
}
-EXPORT_SYMBOL(kcs_bmc_alloc);
+EXPORT_SYMBOL(kcs_bmc_add_device);
+
+int kcs_bmc_ipmi_remove_device(struct kcs_bmc *kcs_bmc);
+void kcs_bmc_remove_device(struct kcs_bmc *kcs_bmc)
+{
+ if (kcs_bmc_ipmi_remove_device(kcs_bmc))
+ pr_warn("Failed to remove device for KCS channel %d\n",
+ kcs_bmc->channel);
+}
+EXPORT_SYMBOL(kcs_bmc_remove_device);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Haiyue Wang <haiyue.wang@linux.intel.com>");