pt., 26 lip 2019 o 15:18 Jean Delvare <jdelvare@xxxxxxx> napisał(a): > > The integration of the at24 driver into the nvmem framework broke the > world-readability of spd EEPROMs. Fix it. > > Signed-off-by: Jean Delvare <jdelvare@xxxxxxx> > Fixes: 57d155506dd5 ("eeprom: at24: extend driver to plug into the NVMEM framework") > Cc: Andrew Lunn <andrew@xxxxxxx> > Cc: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx> > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > Cc: Bartosz Golaszewski <brgl@xxxxxxxx> > Cc: Arnd Bergmann <arnd@xxxxxxxx> > --- > drivers/misc/eeprom/at24.c | 2 +- > drivers/nvmem/core.c | 15 +++++++++++---- > 2 files changed, 12 insertions(+), 5 deletions(-) > > --- linux-5.1.orig/drivers/misc/eeprom/at24.c 2019-05-06 02:42:58.000000000 +0200 > +++ linux-5.1/drivers/misc/eeprom/at24.c 2019-07-26 13:56:37.612197390 +0200 > @@ -719,7 +719,7 @@ static int at24_probe(struct i2c_client > nvmem_config.name = dev_name(dev); > nvmem_config.dev = dev; > nvmem_config.read_only = !writable; > - nvmem_config.root_only = true; > + nvmem_config.root_only = !(flags & AT24_FLAG_IRUGO); Hi Jean, I have a preference for code as readable as possible. Please make it something like: root_only = flags & AT24_FLAG_IRUGO ? false : true;. Also: AFAICT these changes can easily be split into two separate patches, which would make pushing them upstream easier as at24 and nvmem go through different branches. Bart > nvmem_config.owner = THIS_MODULE; > nvmem_config.compat = true; > nvmem_config.base_dev = dev; > --- linux-5.1.orig/drivers/nvmem/core.c 2019-07-23 19:30:27.630099103 +0200 > +++ linux-5.1/drivers/nvmem/core.c 2019-07-26 14:21:31.002908472 +0200 > @@ -435,10 +435,17 @@ static int nvmem_setup_compat(struct nvm > if (!config->base_dev) > return -EINVAL; > > - if (nvmem->read_only) > - nvmem->eeprom = bin_attr_ro_root_nvmem; > - else > - nvmem->eeprom = bin_attr_rw_root_nvmem; > + if (nvmem->read_only) { > + if (config->root_only) > + nvmem->eeprom = bin_attr_ro_root_nvmem; > + else > + nvmem->eeprom = bin_attr_ro_nvmem; > + } else { > + if (config->root_only) > + nvmem->eeprom = bin_attr_rw_root_nvmem; > + else > + nvmem->eeprom = bin_attr_rw_nvmem; > + } > nvmem->eeprom.attr.name = "eeprom"; > nvmem->eeprom.size = nvmem->size; > #ifdef CONFIG_DEBUG_LOCK_ALLOC > > > -- > Jean Delvare > SUSE L3 Support