ipmi: kcs_bmc: Turn the driver data-structures inside-out
authorAndrew Jeffery <andrew@aj.id.au>
Tue, 8 Jun 2021 10:47:46 +0000 (20:17 +0930)
committerCorey Minyard <cminyard@mvista.com>
Tue, 22 Jun 2021 00:50:13 +0000 (19:50 -0500)
commitd7096970075ef47c9906fd241cc4939cc11ddd01
tree7a9481c20718d953e8c4a77a76a3ea401155ad9a
parent55ab48b4e356212fbe084ca110db73bb9a6e7058
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>
drivers/char/ipmi/kcs_bmc.c
drivers/char/ipmi/kcs_bmc.h
drivers/char/ipmi/kcs_bmc_aspeed.c
drivers/char/ipmi/kcs_bmc_cdev_ipmi.c
drivers/char/ipmi/kcs_bmc_npcm7xx.c