Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2113495pxj; Wed, 19 May 2021 23:58:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc9JCETkjhJmZ6uTxM2FFtLDTVt/7tMEn9ceHNwteUllu0+1HYkFrbe86n6OV19txQhVP2 X-Received: by 2002:a17:906:4e0d:: with SMTP id z13mr3225126eju.343.1621493880923; Wed, 19 May 2021 23:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621493880; cv=none; d=google.com; s=arc-20160816; b=lJfahL4Y0SjHvKdfeHUGqYgj9iP0K460Yj5D5L7dU9Kq53Tb3PdSxvwQaUem2Uy9Gv YF+wg8gqGg0tTDPC9/edEcQVtG6hZWKqpBbkuPwM3Sf7HQDgSCY8HsPR0D4BOMBd3Ux1 nu4CttotsHBYYlLH6hAcroXz2zwN7LxCgCNtd1v3Z06NwmGRTD1rnMGupj3L1r7jS/fL hDEBpDyoqFo+1HuRXhSzl1N0YQGRbTpsz+LpMCAoA6SclELfWuymR0zd/WB46wNLWKDS IKkRi81X0mfEcq0QpHS4xkf8S78Ibbx8TI0WYHFBVqrUGb0u2GGTBqLxXBiug6ejqZOl /0iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:cc:references :to:subject:from; bh=j5l1J6V4nVB5rFUp6cMhSj79TFzb5fHyESPVSrEi7LA=; b=Iy6BB6LYUOroNecyNGEBrSb1d7OdQFaSg+84wRMGNdci8VR/Gg8vbgRSOIdoQfnrG1 VcXmHm2x0iUQe6LJ6xNTBlrL7EhKJ35lw7WtsqvdHcg6IKu3nTBdH/BVfjPIN/soSHX0 58mEdTL4hfYynr0jRMFpRAE7ISqY3SxB+/pgNcACrqliRwcgjEJfPU1mQTwlxLi4jquO kLJVwH9w0d/ebwPpgpx0a7sZW50sgvflluyByqXu+A5mSUHVybaL3nbGDFGKu2ZaSqh7 +bRBSqwJY4AUJCI8VHxIzwnrBF9VOxXoICUqyJf8Um4EEXPRlijRiXdZiCk4EotoiAfr mT1A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg40si1872039ejc.465.2021.05.19.23.57.36; Wed, 19 May 2021 23:58:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230343AbhETG6D (ORCPT + 99 others); Thu, 20 May 2021 02:58:03 -0400 Received: from router.aksignal.cz ([62.44.4.214]:60886 "EHLO router.aksignal.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbhETG6C (ORCPT ); Thu, 20 May 2021 02:58:02 -0400 Received: from localhost (localhost [127.0.0.1]) by router.aksignal.cz (Postfix) with ESMTP id E376247F79; Thu, 20 May 2021 08:56:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at router.aksignal.cz Received: from router.aksignal.cz ([127.0.0.1]) by localhost (router.aksignal.cz [127.0.0.1]) (amavisd-new, port 10026) with LMTP id qgsJZ187gLUn; Thu, 20 May 2021 08:56:39 +0200 (CEST) Received: from [172.25.162.36] (unknown [83.240.30.185]) (Authenticated sender: jiri.prchal@aksignal.cz) by router.aksignal.cz (Postfix) with ESMTPSA id 4ABF243DA9; Thu, 20 May 2021 08:56:39 +0200 (CEST) From: =?UTF-8?B?SmnFmcOtIFByY2hhbA==?= Subject: Re: [PATCH v4 4/4] nvmem: eeprom: at25: export FRAM serial num To: Greg Kroah-Hartman References: <20210520054714.8736-1-jiri.prchal@aksignal.cz> <20210520054714.8736-5-jiri.prchal@aksignal.cz> Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Christian Eggers , Arnd Bergmann Message-ID: Date: Thu, 20 May 2021 08:56:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: cs Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? >> +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? > > Also, please use sysfs_emit() in the future. Will do... > > > >> +} >> +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. Any example, please? > > thanks, > > greg k-h > thanks Jiri