lkml.org 
[lkml]   [2021]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/5] regulator: irq_helpers: Allow omitting map_event for simple IRQs
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.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2021-11-18 14:35    [W:0.093 / U:0.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site