mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
d709697007
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>
66 lines
1.7 KiB
C
66 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2015-2018, Intel Corporation.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include "kcs_bmc.h"
|
|
|
|
u8 kcs_bmc_read_data(struct kcs_bmc *kcs_bmc)
|
|
{
|
|
return kcs_bmc->io_inputb(kcs_bmc, kcs_bmc->ioreg.idr);
|
|
}
|
|
EXPORT_SYMBOL(kcs_bmc_read_data);
|
|
|
|
void kcs_bmc_write_data(struct kcs_bmc *kcs_bmc, u8 data)
|
|
{
|
|
kcs_bmc->io_outputb(kcs_bmc, kcs_bmc->ioreg.odr, data);
|
|
}
|
|
EXPORT_SYMBOL(kcs_bmc_write_data);
|
|
|
|
u8 kcs_bmc_read_status(struct kcs_bmc *kcs_bmc)
|
|
{
|
|
return kcs_bmc->io_inputb(kcs_bmc, kcs_bmc->ioreg.str);
|
|
}
|
|
EXPORT_SYMBOL(kcs_bmc_read_status);
|
|
|
|
void kcs_bmc_write_status(struct kcs_bmc *kcs_bmc, u8 data)
|
|
{
|
|
kcs_bmc->io_outputb(kcs_bmc, kcs_bmc->ioreg.str, data);
|
|
}
|
|
EXPORT_SYMBOL(kcs_bmc_write_status);
|
|
|
|
void kcs_bmc_update_status(struct kcs_bmc *kcs_bmc, u8 mask, u8 val)
|
|
{
|
|
kcs_bmc->io_updateb(kcs_bmc, kcs_bmc->ioreg.str, mask, val);
|
|
}
|
|
EXPORT_SYMBOL(kcs_bmc_update_status);
|
|
|
|
int kcs_bmc_ipmi_event(struct kcs_bmc *kcs_bmc);
|
|
int kcs_bmc_handle_event(struct kcs_bmc *kcs_bmc)
|
|
{
|
|
return kcs_bmc_ipmi_event(kcs_bmc);
|
|
}
|
|
EXPORT_SYMBOL(kcs_bmc_handle_event);
|
|
|
|
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_add_device(kcs_bmc);
|
|
}
|
|
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>");
|
|
MODULE_DESCRIPTION("KCS BMC to handle the IPMI request from system software");
|