Message ID | 20210611094601.95131-5-jiri.prchal@aksignal.cz |
---|---|
State | New |
Headers | show |
Series | [v10,1/4] nvmem: prepare basics for FRAM support | expand |
Hi Jiri, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on robh/for-next] [also build test WARNING on linux/master linus/master v5.13-rc6] [cannot apply to char-misc/char-misc-testing next-20210616] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Jiri-Prchal/add-support-for-FRAM/20210616-203024 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next config: x86_64-randconfig-a015-20210615 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install x86_64 cross compiling tool for clang build # apt-get install binutils-x86-64-linux-gnu # https://github.com/0day-ci/linux/commit/a1e83140e4bcb84fc663fdb074e2cbb5a771bfc8 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Jiri-Prchal/add-support-for-FRAM/20210616-203024 git checkout a1e83140e4bcb84fc663fdb074e2cbb5a771bfc8 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/misc/eeprom/at25.c:181:28: warning: field width should have type 'int', but argument has type 'unsigned long' [-Wformat] return sysfs_emit(buf, "%*ph\n", sizeof(at25->sernum), at25->sernum); ~~^ ~~~~~~~~~~~~~~~~~~~~ drivers/misc/eeprom/at25.c:386:13: warning: cast to smaller integer type 'int' from 'const void *' [-Wvoid-pointer-to-int-cast] is_fram = (int)match->data; ^~~~~~~~~~~~~~~~ 2 warnings generated. vim +181 drivers/misc/eeprom/at25.c 175 176 static ssize_t sernum_show(struct device *dev, struct device_attribute *attr, char *buf) 177 { 178 struct at25_data *at25; 179 180 at25 = dev_get_drvdata(dev); > 181 return sysfs_emit(buf, "%*ph\n", sizeof(at25->sernum), at25->sernum); 182 } 183 static DEVICE_ATTR_RO(sernum); 184 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Jiri, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on robh/for-next] [also build test WARNING on linux/master linus/master v5.13-rc7] [cannot apply to char-misc/char-misc-testing next-20210621] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Jiri-Prchal/add-support-for-FRAM/20210616-203024 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next config: mips-randconfig-r035-20210622 (attached as .config) compiler: mips64-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/a1e83140e4bcb84fc663fdb074e2cbb5a771bfc8 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Jiri-Prchal/add-support-for-FRAM/20210616-203024 git checkout a1e83140e4bcb84fc663fdb074e2cbb5a771bfc8 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): drivers/misc/eeprom/at25.c: In function 'sernum_show': >> drivers/misc/eeprom/at25.c:181:27: warning: field width specifier '*' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=] 181 | return sysfs_emit(buf, "%*ph\n", sizeof(at25->sernum), at25->sernum); | ~^~ ~~~~~~~~~~~~~~~~~~~~ | | | | int long unsigned int drivers/misc/eeprom/at25.c: In function 'at25_probe': drivers/misc/eeprom/at25.c:386:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] 386 | is_fram = (int)match->data; | ^ vim +181 drivers/misc/eeprom/at25.c 175 176 static ssize_t sernum_show(struct device *dev, struct device_attribute *attr, char *buf) 177 { 178 struct at25_data *at25; 179 180 at25 = dev_get_drvdata(dev); > 181 return sysfs_emit(buf, "%*ph\n", sizeof(at25->sernum), at25->sernum); 182 } 183 static DEVICE_ATTR_RO(sernum); 184 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/Documentation/ABI/testing/sysfs-class-spi-eeprom b/Documentation/ABI/testing/sysfs-class-spi-eeprom index 7447e242d415..1ff757982079 100644 --- a/Documentation/ABI/testing/sysfs-class-spi-eeprom +++ b/Documentation/ABI/testing/sysfs-class-spi-eeprom @@ -6,3 +6,14 @@ Description: Contains the FRAM binary data. Same as EEPROM, just another file name to indicate that it employs ferroelectric process. It performs write operations at bus speed - no write delays. + +What: /sys/class/spi_master/spi<bus>/spi<bus>.<dev>/sernum +Date: May 2021 +KernelVersion: 5.14 +Contact: Jiri Prchal <jiri.prchal@aksignal.cz> +Description: + Contains the serial number of the Cypress FRAM (FM25VN) if it is + present. It will be displayed as a 8 byte hex string, as read + from the device. + + This is a read-only attribute. diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c index 6ac2ddfd6833..6e26de68a001 100644 --- a/drivers/misc/eeprom/at25.c +++ b/drivers/misc/eeprom/at25.c @@ -31,6 +31,7 @@ * AT25M02, AT25128B */ +#define FM25_SN_LEN 8 /* serial number length */ struct at25_data { struct spi_device *spi; struct mutex lock; @@ -38,6 +39,7 @@ struct at25_data { unsigned addrlen; struct nvmem_config nvmem_config; struct nvmem_device *nvmem; + u8 sernum[FM25_SN_LEN]; }; #define AT25_WREN 0x06 /* latch the write enable */ @@ -171,6 +173,21 @@ static int fm25_aux_read(struct at25_data *at25, u8 *buf, uint8_t command, return status; } +static ssize_t sernum_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct at25_data *at25; + + at25 = dev_get_drvdata(dev); + return sysfs_emit(buf, "%*ph\n", sizeof(at25->sernum), at25->sernum); +} +static DEVICE_ATTR_RO(sernum); + +static struct attribute *sernum_attrs[] = { + &dev_attr_sernum.attr, + NULL, +}; +ATTRIBUTE_GROUPS(sernum); + static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count) { struct at25_data *at25 = priv; @@ -359,6 +376,8 @@ static int at25_probe(struct spi_device *spi) int err; int sr; u8 id[FM25_ID_LEN]; + u8 sernum[FM25_SN_LEN]; + int i; const struct of_device_id *match; int is_fram = 0; @@ -415,6 +434,13 @@ static int at25_probe(struct spi_device *spi) else at25->chip.flags |= EE_ADDR2; + if (id[8]) { + fm25_aux_read(at25, sernum, FM25_RDSN, FM25_SN_LEN); + /* swap byte order */ + for (i = 0; i < FM25_SN_LEN; i++) + at25->sernum[i] = sernum[FM25_SN_LEN - 1 - i]; + } + at25->chip.page_size = PAGE_SIZE; strncpy(at25->chip.name, "fm25", sizeof(at25->chip.name)); } @@ -465,6 +491,7 @@ static struct spi_driver at25_driver = { .driver = { .name = "at25", .of_match_table = at25_of_match, + .dev_groups = sernum_groups, }, .probe = at25_probe, };
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 ef cd ab 89 67 45 23 01 Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz> --- v2: no change here v3: resend and added more recipients v4: resend v5: reworked up on Greg comments: no spaces in string, sysfs done correctly v6: no change here v7: moved FM25_SN_LEN, static array, used sysfs_emit, DEVICE_ATTR_RO v8: clarify sysfs_emit format v9: sizeof parentheses, export with spaces MSB first v10: moved documentation to here --- .../ABI/testing/sysfs-class-spi-eeprom | 11 ++++++++ drivers/misc/eeprom/at25.c | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+)