[PATCH] drm/amdgpu: Fix unnecessary else after return in 'amdgpu_eeprom_xfer'

Chen, Guchun Guchun.Chen at amd.com
Wed Jul 26 07:52:18 UTC 2023


[Public]

Reviewed-by: Guchun Chen <guchun.chen at amd.com>

> -----Original Message-----
> From: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM at amd.com>
> Sent: Wednesday, July 26, 2023 3:18 PM
> To: Koenig, Christian <Christian.Koenig at amd.com>; Deucher, Alexander
> <Alexander.Deucher at amd.com>; Chen, Guchun <Guchun.Chen at amd.com>
> Cc: amd-gfx at lists.freedesktop.org; SHANMUGAM, SRINIVASAN
> <SRINIVASAN.SHANMUGAM at amd.com>
> Subject: [PATCH] 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 <guchun.chen at amd.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 39 +++++++++++---------
> --
>  1 file changed, 19 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> index 7d2a908438e9..e71768661ca8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> @@ -183,6 +183,8 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter
> *i2c_adap, u32 eeprom_addr,  {
>       const struct i2c_adapter_quirks *quirks = i2c_adap->quirks;
>       u16 limit;
> +     u16 ps; /* Partial size */
> +     int res = 0, r;
>
>       if (!quirks)
>               limit = 0;
> @@ -200,28 +202,25 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter
> *i2c_adap, u32 eeprom_addr,
>                                   eeprom_addr, buf_size,
>                                   read ? "read" : "write",
> EEPROM_OFFSET_SIZE);
>               return -EINVAL;
> -     } else {
> -             u16 ps; /* Partial size */
> -             int res = 0, r;
> -
> -             /* The "limit" includes all data bytes sent/received,
> -              * which would include the EEPROM_OFFSET_SIZE bytes.
> -              * Account for them here.
> -              */
> -             limit -= EEPROM_OFFSET_SIZE;
> -             for ( ; buf_size > 0;
> -                   buf_size -= ps, eeprom_addr += ps, eeprom_buf += ps) {
> -                     ps = min(limit, buf_size);
> -
> -                     r = __amdgpu_eeprom_xfer(i2c_adap, eeprom_addr,
> -                                              eeprom_buf, ps, read);
> -                     if (r < 0)
> -                             return r;
> -                     res += r;
> -             }
> +     }
>
> -             return res;
> +     /* The "limit" includes all data bytes sent/received,
> +      * which would include the EEPROM_OFFSET_SIZE bytes.
> +      * Account for them here.
> +      */
> +     limit -= EEPROM_OFFSET_SIZE;
> +     for ( ; buf_size > 0;
> +           buf_size -= ps, eeprom_addr += ps, eeprom_buf += ps) {
> +             ps = min(limit, buf_size);
> +
> +             r = __amdgpu_eeprom_xfer(i2c_adap, eeprom_addr,
> +                                      eeprom_buf, ps, read);
> +             if (r < 0)
> +                     return r;
> +             res += r;
>       }
> +
> +     return res;
>  }
>
>  int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap,
> --
> 2.25.1



More information about the amd-gfx mailing list