Skip to contentSkip to conversation

drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c:145:8-12: opportunity for str_read_write(read)

DISCUSSION kernel test robot 1 participant 1 message Oct 16, 2024

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Luben Tuikov <[email protected]>
CC: Alex Deucher <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2f87d0916ce0d2925cedbc9e8f5d6291ba2ac7b2
commit: 93ade343bbadd73999324dcc66c933e398e39818 drm/amdgpu: EEPROM respects I2C quirks
date:   3 years, 4 months ago

:::::: branch date: 16 hours ago
:::::: commit date: 3 years, 4 months ago
config: i386-randconfig-054-20241016 (https://download.01.org/0day-ci/archive/20241016/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c:145:8-12: opportunity for str_read_write(read)

vim +145 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c

93ade343bbadd7 Luben Tuikov 2021-01-28  112  
93ade343bbadd7 Luben Tuikov 2021-01-28  113  /**
93ade343bbadd7 Luben Tuikov 2021-01-28  114   * amdgpu_eeprom_xfer -- Read/write from/to an I2C EEPROM device
93ade343bbadd7 Luben Tuikov 2021-01-28  115   * @i2c_adap: pointer to the I2C adapter to use
93ade343bbadd7 Luben Tuikov 2021-01-28  116   * @slave_addr: I2C address of the slave device
93ade343bbadd7 Luben Tuikov 2021-01-28  117   * @eeprom_addr: EEPROM address from which to read/write
93ade343bbadd7 Luben Tuikov 2021-01-28  118   * @eeprom_buf: pointer to data buffer to read into/write from
93ade343bbadd7 Luben Tuikov 2021-01-28  119   * @buf_size: the size of @eeprom_buf
93ade343bbadd7 Luben Tuikov 2021-01-28  120   * @read: True if reading from the EEPROM, false if writing
93ade343bbadd7 Luben Tuikov 2021-01-28  121   *
93ade343bbadd7 Luben Tuikov 2021-01-28  122   * Returns the number of bytes read/written; -errno on error.
93ade343bbadd7 Luben Tuikov 2021-01-28  123   */
93ade343bbadd7 Luben Tuikov 2021-01-28  124  int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap,
93ade343bbadd7 Luben Tuikov 2021-01-28  125  		       u16 slave_addr, u16 eeprom_addr,
93ade343bbadd7 Luben Tuikov 2021-01-28  126  		       u8 *eeprom_buf, u16 buf_size, bool read)
93ade343bbadd7 Luben Tuikov 2021-01-28  127  {
93ade343bbadd7 Luben Tuikov 2021-01-28  128  	const struct i2c_adapter_quirks *quirks = i2c_adap->quirks;
93ade343bbadd7 Luben Tuikov 2021-01-28  129  	u16 limit;
93ade343bbadd7 Luben Tuikov 2021-01-28  130  
93ade343bbadd7 Luben Tuikov 2021-01-28  131  	if (!quirks)
93ade343bbadd7 Luben Tuikov 2021-01-28  132  		limit = 0;
93ade343bbadd7 Luben Tuikov 2021-01-28  133  	else if (read)
93ade343bbadd7 Luben Tuikov 2021-01-28  134  		limit = quirks->max_read_len;
93ade343bbadd7 Luben Tuikov 2021-01-28  135  	else
93ade343bbadd7 Luben Tuikov 2021-01-28  136  		limit = quirks->max_write_len;
93ade343bbadd7 Luben Tuikov 2021-01-28  137  
93ade343bbadd7 Luben Tuikov 2021-01-28  138  	if (limit == 0) {
93ade343bbadd7 Luben Tuikov 2021-01-28  139  		return __amdgpu_eeprom_xfer(i2c_adap, slave_addr, eeprom_addr,
93ade343bbadd7 Luben Tuikov 2021-01-28  140  					    eeprom_buf, buf_size, read);
93ade343bbadd7 Luben Tuikov 2021-01-28  141  	} else if (limit <= EEPROM_OFFSET_SIZE) {
93ade343bbadd7 Luben Tuikov 2021-01-28  142  		dev_err_ratelimited(&i2c_adap->dev,
93ade343bbadd7 Luben Tuikov 2021-01-28  143  				    "maddr:0x%04X size:0x%02X:quirk max_%s_len must be > %d",
93ade343bbadd7 Luben Tuikov 2021-01-28  144  				    eeprom_addr, buf_size,

93ade343bbadd7 Luben Tuikov 2021-01-28 @145 read ? "read" : "write", EEPROM_OFFSET_SIZE);

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki