From: Joe Perches <joe@perches.com>
To: Sui Chen <suichen@google.com>, linux-kernel@vger.kernel.org
Subject: Re: [RFC Patch Resend 1/2] i2c debug counters as sysfs attributes
Date: Tue, 09 Nov 2021 15:13:07 -0800 [thread overview]
Message-ID: <3c5e49d49a1cb5c2a54fe75ba315fe563e6575d9.camel@perches.com> (raw)
In-Reply-To: <20211109225321.618688-2-suichen@google.com>
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...
next prev parent reply other threads:[~2021-11-09 23:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 22:53 [RFC Patch Resend 0/2] I2C statistics as sysfs attributes Sui Chen
2021-11-09 22:53 ` [RFC Patch Resend 1/2] i2c debug counters " Sui Chen
2021-11-09 23:13 ` Joe Perches [this message]
2021-11-09 22:53 ` [RFC Patch Resend 2/2] add npcm7xx " Sui Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3c5e49d49a1cb5c2a54fe75ba315fe563e6575d9.camel@perches.com \
--to=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=suichen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).