Message ID | 5ae4b9dda3032acba8b8b0e39352e9e3953e3f88.1654727058.git.jahau@rocketmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Add support for magnetometer Yamaha YAS537 | expand |
On Thu, Jun 9, 2022 at 1:39 AM Jakob Hauser <jahau@rocketmail.com> wrote: > This is a preparation for adding YAS537 variant. > > In function yas5xx_probe(), there is a switch statement checking for device > IDs. If the ID is unknown, it exits with a device error. In later functions, > it's not neccessary to check the validity of the device IDs again. > > When adding YAS537 in a later patch, several of such switch statements will be > added. To make it more uniform, the redundant ones in YAS530/532 get herby > removed. This is done in a separate patch for better history control. > > Cc: Linus Walleij <linus.walleij@linaro.org> > Signed-off-by: Jakob Hauser <jahau@rocketmail.com> No big deal for me, this works fine. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij
On Thu, Jun 9, 2022 at 1:44 AM Jakob Hauser <jahau@rocketmail.com> wrote: > > This is a preparation for adding YAS537 variant. > > In function yas5xx_probe(), there is a switch statement checking for device > IDs. If the ID is unknown, it exits with a device error. In later functions, > it's not neccessary to check the validity of the device IDs again. > > When adding YAS537 in a later patch, several of such switch statements will be > added. To make it more uniform, the redundant ones in YAS530/532 get herby > removed. This is done in a separate patch for better history control. ... > - default: Please, leave it. Some static analyzers or weird compiler versions may complain on this. > - dev_err(yas5xx->dev, "unknown data format\n"); > - ret = -EINVAL; > - break; So leave this. > } Ditto for the rest.
diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c index 31637a890b7f..59844e1b794c 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -251,13 +251,9 @@ static int yas5xx_measure(struct yas5xx *yas5xx, u16 *t, u16 *x, u16 *y1, u16 *y *y1 = yas532_extract_axis(&data[4]); *y2 = yas532_extract_axis(&data[6]); break; - default: - dev_err(yas5xx->dev, "unknown data format\n"); - ret = -EINVAL; - break; } - return ret; + return 0; out_unlock: mutex_unlock(&yas5xx->lock); @@ -289,9 +285,6 @@ static s32 yas5xx_linearize(struct yas5xx *yas5xx, u16 val, int axis) /* Elaborate coefficients */ coef = yas532ac_coef[axis]; break; - default: - dev_err(yas5xx->dev, "unknown device type\n"); - return val; } /* * Linearization formula: @@ -798,9 +791,6 @@ static int yas5xx_meaure_offsets(struct yas5xx *yas5xx) case YAS532_DEVICE_ID: center = YAS532_DATA_CENTER; break; - default: - dev_err(yas5xx->dev, "unknown device type\n"); - return -EINVAL; } /*
This is a preparation for adding YAS537 variant. In function yas5xx_probe(), there is a switch statement checking for device IDs. If the ID is unknown, it exits with a device error. In later functions, it's not neccessary to check the validity of the device IDs again. When adding YAS537 in a later patch, several of such switch statements will be added. To make it more uniform, the redundant ones in YAS530/532 get herby removed. This is done in a separate patch for better history control. Cc: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jakob Hauser <jahau@rocketmail.com> --- drivers/iio/magnetometer/yamaha-yas530.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)