Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2078831pxj; Wed, 19 May 2021 22:54:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/UgiN1eGtuIDuaUvViRNGvfHfLpRBpi7PiHSQK1rHfQbIzZzW0Y3FmC6f/rO55OoWDC+Y X-Received: by 2002:a92:ce90:: with SMTP id r16mr3437517ilo.220.1621490081083; Wed, 19 May 2021 22:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621490081; cv=none; d=google.com; s=arc-20160816; b=AthlVyxtlMRbW2LgdQu0JFf32WOSAaG6dvMOi3gmMkdUX17Qz/qILVp7AM6UjwLpXL lavvj076jC5EqtxKkSCaiuTIpXQooiJ9ZxVoq6sEyf9NZgY8BFusOCcyV15ksW2CYxCz Ez2xjpEHcTe4PpV2QwTkXF4v4uruiomExdnOxKAkOWmWAfAnNZ9AkNerPHGE8R/zDdUy znDyGSxjP5P/m+ED5wYJNV4BXzEGicRtOYEEnQ+i1HBXs1OQ7n8TNZklQ3PPtei/vM9+ MNgw0f9oJATbMPgqc7ExqExP15+iox0dEMeUXnV/O/nMzWkbbyJxFm9mkGlWU01fZPuF I9Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VGgaobclSXF0+xnct8eeqowzearjWTQ9ELbgu72NqZc=; b=d+g4fDXgX9G/kSaSatWqt0O5SjneE1+atStv88Om+aAkUSrhiptVF8Ps9gxxIErmzZ jdPY2oviMAH3azkYn01DFi4ERds/6JMpDIxhUdeadE+3cwuDAeAB/Y6pbAdzMXCxugy1 prfGiOAoEffP4YPD1dc9RBRlyQS05TJAjJ5CZ7rriYIoSZ4ApWzJopD3VSDLZ9XYmssn Jk8Vbk5ZH1XnBfO2F4ha4D7qpr28ado0oQFAZ+DPq6TDnGEzjWkpomI3AJ8qjhTgaUzo bsN+WX45iCkq748HOUohiYlr1vccHtcvL0hTfoliwyB/UfqUP7lyXIHLTOyZufym/1RP lxng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IbwTYbQu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si1604997jap.46.2021.05.19.22.54.27; Wed, 19 May 2021 22:54:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IbwTYbQu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230310AbhETFyB (ORCPT + 99 others); Thu, 20 May 2021 01:54:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:50392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbhETFyA (ORCPT ); Thu, 20 May 2021 01:54:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 179B3600CD; Thu, 20 May 2021 05:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621489959; bh=mmvYidpxJwJA6FRO4I+/38QOPSQq4ArdS9cwWG/bWFg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IbwTYbQubAcOmFoz9TeQpdhC9GH/78A6G6iQKzsNXrQoK0JGp82HA3xbJMCRQ4npb Bt9+Itqj4vXO1p7I7NBs/J30ES5vSbdNEvrfLcGl1cvERekgbgpHGv9HRUw1OZBQHD xxz8BfT42GgsegWioNuGtF1byogSi5xf6EkwbCKQ= Date: Thu, 20 May 2021 07:52:34 +0200 From: Greg Kroah-Hartman To: Jiri Prchal Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Christian Eggers , Arnd Bergmann Subject: Re: [PATCH v4 4/4] nvmem: eeprom: at25: export FRAM serial num Message-ID: References: <20210520054714.8736-1-jiri.prchal@aksignal.cz> <20210520054714.8736-5-jiri.prchal@aksignal.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210520054714.8736-5-jiri.prchal@aksignal.cz> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > a4 36 44 f2 ae 6c 00 00 > > Signed-off-by: Jiri Prchal > --- > v2: no change here > v3: resend and added more recipients > v4: resend > --- > drivers/misc/eeprom/at25.c | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c > index 4f6e983c278b..b2cffeb3af2c 100644 > --- a/drivers/misc/eeprom/at25.c > +++ b/drivers/misc/eeprom/at25.c > @@ -38,6 +38,7 @@ struct at25_data { > struct nvmem_config nvmem_config; > struct nvmem_device *nvmem; > int has_sernum; > + char *sernum; > }; > > #define AT25_WREN 0x06 /* latch the write enable */ > @@ -172,6 +173,19 @@ static int fm25_aux_read(struct at25_data *at25, char *buf, uint8_t command, > return status; > } > > +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"? Also, please use sysfs_emit() in the future. > +} > +static DEVICE_ATTR_RO(sernum); > + > static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count) > { > struct at25_data *at25 = priv; > @@ -427,8 +441,13 @@ static int at25_probe(struct spi_device *spi) > else > at25->chip.flags |= EE_ADDR2; > > - if (id[8]) > + if (id[8]) { > at25->has_sernum = 1; > + at25->sernum = kzalloc(FM25_SN_LEN, GFP_KERNEL); > + if (!at25->sernum) > + return -ENOMEM; > + fm25_aux_read(at25, at25->sernum, FM25_RDSN, FM25_SN_LEN); > + } > else > at25->has_sernum = 0; > > @@ -467,6 +486,13 @@ static int at25_probe(struct spi_device *spi) > if (IS_ERR(at25->nvmem)) > return PTR_ERR(at25->nvmem); > > + /* 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. thanks, greg k-h