Re: [PATCH 1/5] regulator: irq_helpers: Allow omitting map_event for simple IRQs
From: Mark Brown
Date: Thu Nov 18 2021 - 08:35:09 EST
On Thu, Nov 18, 2021 at 01:48:26PM +0200, Matti Vaittinen wrote:
> +static bool single_bit_set(int val, int bits_to_check)
> +{
> + int bit;
> + const unsigned long bits = val;
> +
> + bit = find_first_bit(&bits, bits_to_check);
> + if (bit == bits_to_check)
> + return false;
> +
> + bit = find_next_bit(&bits, bits_to_check, bit + 1);
> +
> + return (bit == bits_to_check);
> +}
The namespacing here feels like it should be with the other _bit()
helpers rather than private to the regulator code, I can certainly see
other things wanting to use it.
> + if (!h->desc.map_event) {
> + if (rdev_amount != 1 ||
> + !single_bit_set(common_errs, sizeof(common_errs) * 8) ||
> + per_rdev_errs)
> + return ERR_PTR(-EINVAL);
> +
> + h->desc.map_event = map_event_simple;
> + }
This isn't the usual pattern, normally we would have the driver assign
the helper operation. We can always still do the check based on finding
the expected map_event set up.
Attachment:
signature.asc
Description: PGP signature