public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Jiří Prchal" <jiri.prchal@aksignal.cz>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Rob Herring <robh+dt@kernel.org>,
	Christian Eggers <ceggers@arri.de>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v4 4/4] nvmem: eeprom: at25: export FRAM serial num
Date: Thu, 20 May 2021 09:08:24 +0200	[thread overview]
Message-ID: <YKYK6HlQYHBPPCKq@kroah.com> (raw)
In-Reply-To: <f0951762-8067-e353-f585-2cb17f7be134@aksignal.cz>

On Thu, May 20, 2021 at 08:56:39AM +0200, Jiří Prchal wrote:
> Here I'm completlly lost:
> 
> On 20. 05. 21 7:52, Greg Kroah-Hartman wrote:
> > On Thu, May 20, 2021 at 07:47:14AM +0200, Jiri Prchal wrote:
> > > This exports serial number of FRAM in sysfs file named "sernum".
> > > Formatted in hex, each byte separated by space.
> > > Example:
> > > $ cat /sys/class/spi_master/spi0/spi0.0/sernum
> > 
> > No new Documentation/ABI/ entry for this?
> No, should I do and how / where?

All sysfs files need a Documentation/ABI/ entry.

> > > +static ssize_t sernum_show(struct device *dev, struct device_attribute *attr, char *buf)
> > > +{
> > > +	struct at25_data *at25;
> > > +	int i;
> > > +
> > > +	at25 = dev_get_drvdata(dev);
> > > +	for (i = 0; i < FM25_SN_LEN; i++)
> > > +		buf += sprintf(buf, "%02x ", at25->sernum[i]);
> > > +	sprintf(--buf, "\n");
> > > +	return (3 * i);
> > 
> > No, that is not how sysfs files work, sorry.  They are "one value per
> > file".  This looks like multiple values in the same file, why not just
> > one file per "sernum"?
> It's formatted by spaces. It's one long number like MAC addr, so is better
> to expose it as hex string without spaces? Or like MAC separated by colon?

Why format it at all?  Just dump out the whole thing as a string.

But who is going to care about this?  What tool will be reading it and
what will it be for?  The Documentation/ABI/ entry would help explain
all of this.

> > > +	/* Export the FM25 serial number */
> > > +	if (at25->has_sernum) {
> > > +		err = device_create_file(&spi->dev, &dev_attr_sernum);
> > 
> > You just raced with userspace and lost :(
> ?
> > 
> > Please do this correctly, by setting the driver group if you need a file
> > like this.
> Any example, please?

Loads, see any platform driver that sets the dev_groups pointer.

thanks,

greg k-h

      reply	other threads:[~2021-05-20  7:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20  5:47 [PATCH v4 0/4] add support for FRAM Jiri Prchal
2021-05-20  5:47 ` [PATCH v4 1/4] nvmem: eeprom: at25: " Jiri Prchal
2021-05-20  5:53   ` Greg Kroah-Hartman
2021-05-20  6:54     ` Jiří Prchal
2021-05-20  7:08       ` Greg Kroah-Hartman
2021-05-20  5:47 ` [PATCH v4 2/4] " Jiri Prchal
2021-05-20  5:53   ` Greg Kroah-Hartman
2021-05-20  5:47 ` [PATCH v4 3/4] nvmem: eeprom: add documentation " Jiri Prchal
2021-05-20  5:47 ` [PATCH v4 4/4] nvmem: eeprom: at25: export FRAM serial num Jiri Prchal
2021-05-20  5:52   ` Greg Kroah-Hartman
2021-05-20  6:56     ` Jiří Prchal
2021-05-20  7:08       ` Greg Kroah-Hartman [this message]

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=YKYK6HlQYHBPPCKq@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=ceggers@arri.de \
    --cc=devicetree@vger.kernel.org \
    --cc=jiri.prchal@aksignal.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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