On Wed, Oct 25, 2023 at 07:59:05AM +0000, Michel Alex wrote: > Calculate the maximum length of the buffer when writing > across the page boundary. If the buffer length (len) > exceeds the page boundary (pagesize), split it. Use this > length instead of comparing the length with the pagesize, > because if the write start address (offset) is not at the > beginning of a page and the page_offset + len is greater > than the page boundary (pagesize), the write operation > would overflow the current page and the behaviour can be > undefined (e.g. at24). > > Signed-off-by: Alex Michel <alex.mic...@wiedemann-group.com> [snip] > +static int i2c_eeprom_len(unsigned int offset, unsigned int len, unsigned > int pagesize) [snip] > static int i2c_eeprom_std_write(struct udevice *dev, int offset, > const uint8_t *buf, int size) > { > @@ -67,7 +78,7 @@ static int i2c_eeprom_std_write(struct udevice *dev, int > offset, > int ret; > > while (size > 0) { > - int write_size = min_t(int, size, priv->pagesize); > + int write_size = i2c_eeprom_len(offset, size, priv->pagesize); [snip]
We don't need to promote the types to unsigned here do we? -- Tom
signature.asc
Description: PGP signature