lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Venj0SEYKBwHcXD+sPgmX85P+Adw=T1wmGwERK0AzQ=Bw@mail.gmail.com>
Date: Wed, 13 Aug 2025 18:53:48 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Ben Collins <bcollins@...ter.com>
Cc: Jonathan Cameron <jic23@...nel.org>, David Lechner <dlechner@...libre.com>, 
	Nuno Sá <nuno.sa@...log.com>, 
	Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 5/5] iio: mcp9600: Add support for IIR filter

On Wed, Aug 13, 2025 at 5:17 PM Ben Collins <bcollins@...ter.com> wrote:
>
> MCP9600 supports an IIR filter with 7 levels. Add IIR attribute
> to allow get/set of this value.
>

...

>         case IIO_CHAN_INFO_THERMOCOUPLE_TYPE:
>                 *val = mcp9600_tc_types[data->thermocouple_type];
>                 return IIO_VAL_CHAR;

Again, either here + blank line, or as already mentioned, remove a
stray one below.

> +       case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> +               *val = data->filter_level;
> +               return IIO_VAL_INT;
>
>         default:
>                 return -EINVAL;

...

>         cfg  = FIELD_PREP(MCP9600_SENSOR_TYPE_MASK,
>                           mcp9600_type_map[data->thermocouple_type]);
> +       cfg |= FIELD_PREP(MCP9600_FILTER_MASK, data->filter_level);

FIELD_MODIFY() ?

...

> +static int mcp9600_write_raw(struct iio_dev *indio_dev,
> +                            struct iio_chan_spec const *chan,
> +                            int val, int val2, long mask)
> +{
> +       struct mcp9600_data *data = iio_priv(indio_dev);
> +
> +       switch (mask) {
> +       case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:

> +               if (val < 0 || val > 7)

in_range() ?
Where 8 will be an ARRAY_SIZE() ?

> +                       return -EINVAL;
> +
> +               data->filter_level = val;
> +               return mcp9600_config(data);

> +

So, make sure these blank lines in the switch-cases are all consistent
all over the code.

> +       default:
> +               return -EINVAL;
> +       }
> +}

...

> +       /* Default filter level of the chip is 0 (off) */
> +       data->filter_level = 0;

Why do we need an explicit assignment? If you want to have a comment
(which seems somehow valuable), find a better place for it without
likely unneeded assignment.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ