Re: [PATCH v3 6/8] iio: sx9324: Add Setting for internal compensation resistor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 26, 2022 at 12:34 AM Gwendal Grignou <gwendal@xxxxxxxxxxxx> wrote:
>
> Based on device tree setting, set the internal compensation resistor.

...

> +               if (!strcmp(res, "lowest"))
> +                       reg_def->def |= SX9324_REG_AFE_CTRL0_RINT_LOWEST;
> +               else if (!strcmp(res, "low"))
> +                       reg_def->def |= SX9324_REG_AFE_CTRL0_RINT_LOW;
> +               else if (!strcmp(res, "high"))
> +                       reg_def->def |= SX9324_REG_AFE_CTRL0_RINT_HIGH;
> +               else if (!strcmp(res, "highest"))
> +                       reg_def->def |= SX9324_REG_AFE_CTRL0_RINT_HIGHEST;

As far as I can see the values, you can simply put the string literals
into the array:

static const char * const sx9324_rints = { "lowest", "low", "high", "highest" };

Then

  ret = match_string(sx9324_rints, ARRAY_SIZE(sx9324_rints), res);
  if (ret < 0)
    return ret;
  reg_def->def |= ret << SX9324_REG_AFE_CTRL0_RINT_SHIFT;

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux