Hi Alexandre, Thanks for the feedback. > Subject: Re: [PATCH v3 2/4] rtc: pcf85363: Add support for NXP pcf85263 rtc > > On 06/12/2018 15:49:57+0000, Biju Das wrote: > > Hi Geert, > > > > Thanks for the feedback. > > > > > Subject: Re: [PATCH v3 2/4] rtc: pcf85363: Add support for NXP > > > pcf85263 rtc > > > > > > Hi Biju, > > > > > > On Thu, Dec 6, 2018 at 4:24 PM Biju Das <biju.das@xxxxxxxxxxxxxx> > wrote: > > > > > Subject: Re: [PATCH v3 2/4] rtc: pcf85363: Add support for NXP > > > > > pcf85263 rtc CC nvmem maintainer > > > > > > > > > > On Thu, Dec 6, 2018 at 10:04 AM Biju Das > > > > > <biju.das@xxxxxxxxxxxxxx> > > > wrote: > > > > > > Add support for NXP pcf85263 real-time clock. pcf85263 rtc is > > > > > > compatible with pcf85363,except that pcf85363 has additional > > > > > > 64 bytes of > > > > > RAM. > > > > > > > > > --- a/drivers/rtc/rtc-pcf85363.c > > > > > > +++ b/drivers/rtc/rtc-pcf85363.c > > > > > > @@ -120,6 +120,11 @@ struct pcf85363 { > > > > > > struct regmap *regmap; > > > > > > }; > > > > > > > > > > > > +struct pcf85x63_config { > > > > > > + struct regmap_config regmap; > > > > > > + unsigned int num_nvram; }; > > > > > > + > > > > > > static int pcf85363_rtc_read_time(struct device *dev, struct > > > > > > rtc_time > > > > > > *tm) { > > > > > > struct pcf85363 *pcf85363 = dev_get_drvdata(dev); @@ > > > > > > -311,25 > > > > > > +316,68 @@ static int pcf85363_nvram_write(void *priv, > > > > > > +unsigned int > > > > > offset, void *val, > > > > > > val, bytes); } > > > > > > > > > > > > -static const struct regmap_config regmap_config = { > > > > > > - .reg_bits = 8, > > > > > > - .val_bits = 8, > > > > > > - .max_register = 0x7f, > > > > > > +static int pcf85x63_nvram_read(void *priv, unsigned int > > > > > > +offset, void > > > *val, > > > > > > + size_t bytes) > > > > > > > > > > Given bytes should be 1, val should be a pointer to a single byte... > > > > > What if bytes == 0? > > > > > > > > I doubt we get "bytes==0" because of the checks in " > > > drivers/nvmem/core.c" > > > > Function " bin_attr_nvmem_read/ bin_attr_nvmem_write". > > > > > > Depends. There are other functions calling nvmem_reg_{read,write}(), > e.g. > > > nvmem_device_{read,write}(). > > > > OK. In that case, I will return (-EINVAL) for "bytes !=1" > > > > I think it is probably better to ensure the nvmem core never passes an invalid > number of bytes. All the ther RTC drivers make that assumption. In that case, I will do following checks in nvmem_device_{read,write}() before calling nvmem_reg_{read,write}(), nvmem_device_read /* Stop the user from reading */ if (offset >= nvmem->size) return 0; if (bytes == 0) return -EINVAL; if (offset + bytes > nvmem->size) bytes = nvmem->size - offset; nvmem_device_write /* Stop the user from writing */ if (offset >= nvmem->size) return -EFBIG; if (bytes == 0) return -EINVAL; if (offset + bytes > nvmem->size) bytes = nvmem->size - offset; regards, Biju [https://www2.renesas.eu/media/email/unicef.jpg] This Christmas, instead of sending out cards, Renesas Electronics Europe have decided to support Unicef with a donation. For further details click here<https://www.unicef.org/> to find out about the valuable work they do, helping children all over the world. We would like to take this opportunity to wish you a Merry Christmas and a prosperous New Year. Renesas Electronics Europe Ltd, Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, UK. Registered in England & Wales under Registered No. 04586709.