Skip to content

Commit 6cf2021

Browse files
srishanmalexdeucher
authored andcommitted
drm/amdgpu: Fix unnecessary else after return in 'amdgpu_eeprom_xfer'
Fixes the following: WARNING: else is not generally useful after a break or return + return -EINVAL; + } else { Cc: Guchun Chen <[email protected]> Cc: Christian König <[email protected]> Cc: Alex Deucher <[email protected]> Signed-off-by: Srinivasan Shanmugam <[email protected]> Reviewed-by: Guchun Chen <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 82f3350 commit 6cf2021

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,
183183
{
184184
const struct i2c_adapter_quirks *quirks = i2c_adap->quirks;
185185
u16 limit;
186+
u16 ps; /* Partial size */
187+
int res = 0, r;
186188

187189
if (!quirks)
188190
limit = 0;
@@ -200,28 +202,25 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,
200202
eeprom_addr, buf_size,
201203
read ? "read" : "write", EEPROM_OFFSET_SIZE);
202204
return -EINVAL;
203-
} else {
204-
u16 ps; /* Partial size */
205-
int res = 0, r;
206-
207-
/* The "limit" includes all data bytes sent/received,
208-
* which would include the EEPROM_OFFSET_SIZE bytes.
209-
* Account for them here.
210-
*/
211-
limit -= EEPROM_OFFSET_SIZE;
212-
for ( ; buf_size > 0;
213-
buf_size -= ps, eeprom_addr += ps, eeprom_buf += ps) {
214-
ps = min(limit, buf_size);
215-
216-
r = __amdgpu_eeprom_xfer(i2c_adap, eeprom_addr,
217-
eeprom_buf, ps, read);
218-
if (r < 0)
219-
return r;
220-
res += r;
221-
}
205+
}
222206

223-
return res;
207+
/* The "limit" includes all data bytes sent/received,
208+
* which would include the EEPROM_OFFSET_SIZE bytes.
209+
* Account for them here.
210+
*/
211+
limit -= EEPROM_OFFSET_SIZE;
212+
for ( ; buf_size > 0;
213+
buf_size -= ps, eeprom_addr += ps, eeprom_buf += ps) {
214+
ps = min(limit, buf_size);
215+
216+
r = __amdgpu_eeprom_xfer(i2c_adap, eeprom_addr,
217+
eeprom_buf, ps, read);
218+
if (r < 0)
219+
return r;
220+
res += r;
224221
}
222+
223+
return res;
225224
}
226225

227226
int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap,

0 commit comments

Comments
 (0)