drm/amdgpu: use u32 for buf size in __amdgpu_eeprom_xfer
Subsystems (2)
PATCH 1/1 drm/amdgpu: use u32 for buf size in __amdgpu_eeprom_xfer
And also make sure the the value of msg[1].len should be in the range of u16.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +5 -5
@@ -90,7 +90,7 @@#define MAKE_I2C_ADDR (_aa) ((0xA << 3) | (((_aa) >> 16) & 0xF))static int __amdgpu_eeprom_xfer (struct i2c_adapter *i2c_adap,u32 eeprom_addr, -u8 *eeprom_buf,u16 buf_size,bool read) +u8 *eeprom_buf,u32 buf_size,bool read) {u8 eeprom_offset_buf[EEPROM_OFFSET_SIZE ];struct i2c_msg msgs[] = {
@@ -133,15 +133,15 @@ static int __amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,* cycle begins. This is implied for the * "i2c_transfer()" abstraction. */ - len =min (EEPROM_PAGE_SIZE - (eeprom_addr & -EEPROM_PAGE_MASK ), - (u32 )buf_size); + len =min (EEPROM_PAGE_SIZE - (eeprom_addr &EEPROM_PAGE_MASK ), + buf_size); }else {/* Reading from the EEPROM has no limitation * on the number of bytes read from the EEPROM * device--they are simply sequenced out. +* Keep in mind that i2c_msg.len is u16 type. */ - len = buf_size; + len =min (U16_MAX , buf_size); } msgs[1 ].len = len; msgs[1 ].buf = eeprom_buf;
Signature · 1 line
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Tuesday, May 21, 2024 11:17 AM
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH] drm/amdgpu: use u32 for buf size in __amdgpu_eeprom_xfer
And also make sure the the value of msg[1].len should be in the range of u16.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +5 -5
@@ -90,7 +90,7 @@#define MAKE_I2C_ADDR (_aa) ((0xA << 3) | (((_aa) >> 16) & 0xF))static int __amdgpu_eeprom_xfer (struct i2c_adapter *i2c_adap,u32 eeprom_addr, -u8 *eeprom_buf,u16 buf_size,bool read) +u8 *eeprom_buf,u32 buf_size,bool read) {u8 eeprom_offset_buf[EEPROM_OFFSET_SIZE ];struct i2c_msg msgs[] = {
@@ -133,15 +133,15 @@ static int __amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,* cycle begins. This is implied for the * "i2c_transfer()" abstraction. */ - len =min (EEPROM_PAGE_SIZE - (eeprom_addr & -EEPROM_PAGE_MASK ), - (u32 )buf_size); + len =min (EEPROM_PAGE_SIZE - (eeprom_addr &EEPROM_PAGE_MASK ), + buf_size); }else {/* Reading from the EEPROM has no limitation * on the number of bytes read from the EEPROM * device--they are simply sequenced out. +* Keep in mind that i2c_msg.len is u16 type. */ - len = buf_size; + len =min (U16_MAX , buf_size); } msgs[1 ].len = len; msgs[1 ].buf = eeprom_buf;
--
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Tuesday, May 21, 2024 11:17
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH] drm/amdgpu: use u32 for buf size in __amdgpu_eeprom_xfer
And also make sure the the value of msg[1].len should be in the range of u16.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +5 -5
@@ -90,7 +90,7 @@#define MAKE_I2C_ADDR (_aa) ((0xA << 3) | (((_aa) >> 16) & 0xF))static int __amdgpu_eeprom_xfer (struct i2c_adapter *i2c_adap,u32 eeprom_addr, -u8 *eeprom_buf,u16 buf_size,bool read) +u8 *eeprom_buf,u32 buf_size,bool read) {u8 eeprom_offset_buf[EEPROM_OFFSET_SIZE ];struct i2c_msg msgs[] = {
@@ -133,15 +133,15 @@ static int __amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,* cycle begins. This is implied for the * "i2c_transfer()" abstraction. */ - len =min (EEPROM_PAGE_SIZE - (eeprom_addr & -EEPROM_PAGE_MASK ), - (u32 )buf_size); + len =min (EEPROM_PAGE_SIZE - (eeprom_addr &EEPROM_PAGE_MASK ), + buf_size); }else {/* Reading from the EEPROM has no limitation * on the number of bytes read from the EEPROM * device--they are simply sequenced out. +* Keep in mind that i2c_msg.len is u16 type. */ - len = buf_size; + len =min (U16_MAX , buf_size); } msgs[1 ].len = len; msgs[1 ].buf = eeprom_buf;
--
2.34.1