Skip to content

Commit 02a1743

Browse files
author
Russ Weight
committed
mfd: intel-m10-bmc: Sysfs for time_sync_frequency
Add a sysfs node, time_sync_frequency to, to allow the frequency of timestamp synchronization with the BMC to be modified from the default of 60 seconds. Signed-off-by: Russ Weight <russell.h.weight@intel.com>
1 parent 0ba1318 commit 02a1743

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
What: /sys/bus/platform/devices/intel-m10-bmc-log.*.auto/time_sync_frequency
2+
Date: Mar 2021
3+
KernelVersion: 5.12
4+
Contact: Russ Weight <russell.h.weight@intel.com>
5+
Description: Read/write. This sysfs node controls the frequency (in
6+
seconds) that the host writes to the MAX10 BMC registers
7+
to synchronize the timestamp registers used for the BMC
8+
error log. Write zero to stop the timestamp synchronization.
9+
Write a non-zero integer value to restart or modify the
10+
update frequency. Reading from this file will return the
11+
same integer value.
12+
Format: "%u".

drivers/mfd/intel-m10-bmc-log.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,42 @@ static void m10bmc_log_time_sync(struct work_struct *work)
4747
schedule_delayed_work(&log->dwork, log->freq_s * HZ);
4848
}
4949

50+
static ssize_t
51+
time_sync_frequency_store(struct device *dev, struct device_attribute *attr,
52+
const char *buf, size_t count)
53+
{
54+
struct m10bmc_log *ddata = dev_get_drvdata(dev);
55+
unsigned int ret, old_freq = ddata->freq_s;
56+
57+
ret = kstrtouint(buf, 0, &ddata->freq_s);
58+
if (ret)
59+
return ret;
60+
61+
if (old_freq)
62+
cancel_delayed_work_sync(&ddata->dwork);
63+
64+
if (ddata->freq_s)
65+
m10bmc_log_time_sync(&ddata->dwork.work);
66+
67+
return count;
68+
}
69+
70+
static ssize_t
71+
time_sync_frequency_show(struct device *dev, struct device_attribute *attr,
72+
char *buf)
73+
{
74+
struct m10bmc_log *ddata = dev_get_drvdata(dev);
75+
76+
return sysfs_emit(buf, "%u\n", ddata->freq_s);
77+
}
78+
static DEVICE_ATTR_RW(time_sync_frequency);
79+
80+
static struct attribute *m10bmc_log_attrs[] = {
81+
&dev_attr_time_sync_frequency.attr,
82+
NULL,
83+
};
84+
ATTRIBUTE_GROUPS(m10bmc_log);
85+
5086
static int m10bmc_log_probe(struct platform_device *pdev)
5187
{
5288
struct m10bmc_log *ddata;
@@ -77,6 +113,9 @@ int m10bmc_log_remove(struct platform_device *pdev)
77113
static struct platform_driver intel_m10bmc_log_driver = {
78114
.probe = m10bmc_log_probe,
79115
.remove = m10bmc_log_remove,
116+
.driver = {
117+
.dev_groups = m10bmc_log_groups,
118+
},
80119
};
81120
module_platform_driver(intel_m10bmc_log_driver);
82121

0 commit comments

Comments
 (0)