On Mon, Jul 20, 2015 at 04:52:30PM +0300, Teodora Baluta wrote:
> +static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo,
> +                               int index, int *val)
> +{
> +     switch (index) {
> +     case AXIS_X:
> +             *val = (raw[AXIS_X] - nfo) * 1000 / sens[AXIS_X];
> +             break;
> +     case AXIS_Y:
> +             *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y];
> +             break;
> +     case AXIS_Z:
> +             *val = (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z];
> +             break;
> +     default:
> +             return -EINVAL;
> +     }
> +
> +     return 0;
> +}

We never pass invalid indexes here so this could be replaced with:

static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo,
                                  int index, int *val)
{
        *val = (raw[index] - nfo) * 1000 / sens[index];
        return 0;
}

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to