[PATCH linux dev-4.7 8/8] ipmi: add a sysfs file for configure maximum response time
Cédric Le Goater
clg at kaod.org
Wed Oct 26 17:57:47 AEDT 2016
We could also use an ioctl for that purpose. sysfs seems a better
approach.
Signed-off-by: Cédric Le Goater <clg at kaod.org>
---
drivers/char/ipmi/bt-bmc.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c
index 228ecdb689de..1ebb0171c724 100644
--- a/drivers/char/ipmi/bt-bmc.c
+++ b/drivers/char/ipmi/bt-bmc.c
@@ -84,6 +84,33 @@ struct bt_bmc {
static atomic_t open_count = ATOMIC_INIT(0);
+static ssize_t bt_bmc_show_response_time(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct bt_bmc *bt_bmc = dev_get_drvdata(dev);
+
+ return snprintf(buf, PAGE_SIZE - 1, "%d\n", bt_bmc->response_time);
+}
+
+static ssize_t bt_bmc_set_response_time(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct bt_bmc *bt_bmc = dev_get_drvdata(dev);
+ unsigned long val;
+ int err;
+
+ err = kstrtoul(buf, 0, &val);
+ if (err)
+ return err;
+ bt_bmc->response_time = val;
+ return count;
+}
+
+static DEVICE_ATTR(response_time, S_IWUSR | S_IRUGO,
+ bt_bmc_show_response_time, bt_bmc_set_response_time);
+
static u8 bt_inb(struct bt_bmc *bt_bmc, int reg)
{
return ioread8(bt_bmc->base + reg);
@@ -572,6 +599,10 @@ static int bt_bmc_probe(struct platform_device *pdev)
bt_bmc_config_irq(bt_bmc, pdev);
bt_bmc->response_time = BT_BMC_RESPONSE_TIME;
+ rc = device_create_file(&pdev->dev, &dev_attr_response_time);
+ if (rc)
+ dev_warn(&pdev->dev, "can't create response_time file\n");
+
if (bt_bmc->irq) {
dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
--
2.7.4
More information about the openbmc
mailing list