Messages in this thread | | | Subject | Re: [RFC Patch Resend 1/2] i2c debug counters as sysfs attributes | From | Joe Perches <> | Date | Tue, 09 Nov 2021 15:13:07 -0800 |
| |
On Tue, 2021-11-09 at 14:53 -0800, Sui Chen wrote: > This change adds a few example I2C debug counters as sysfs attributes: > - ber_cnt (bus error count) > - nack_cnt (NACK count) > - rec_fail_cnt, rec_succ_cnt (recovery failure/success count) > - timeout_cnt (timeout count) > - i2c_speed (bus frequency) > > The function i2c_adapter_create_stats_folder creates a stats directory > in the device's sysfs directory to hold the debug counters. The platform > drivers will instantiate the counters in the stats directory if > available. [] > diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c [] > +static ssize_t ber_cnt_show(struct device* pdev, > + struct device_attribute* attr, char* buf) { > + u64* ber_cnt = kobj_to_adapter(pdev)->stats->ber_cnt; > + if (ber_cnt == NULL) return 0; > + ssize_t ret = sprintf(buf, "%llu\n", *ber_cnt);
Please do not declare after code.
And this should instead use:
return sysfs_emit(buf, "%llu\n", *ber_cnt);
> + return ret; > +} > +DEVICE_ATTR_RO(ber_cnt); > + > +ssize_t nack_cnt_show(struct device* pdev, > + struct device_attribute* attr, char* buf) { > + u64* nack_cnt = kobj_to_adapter(pdev)->stats->nack_cnt; > + if (nack_cnt == NULL) return 0; > + ssize_t ret = sprintf(buf, "%llu\n", *nack_cnt);
etc...
| |