lkml.org 
[lkml]   [2018]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 3/8] gpio: pci-idio-16: Implement get_multiple callback
On Mon, Mar 12, 2018 at 10:49 PM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:

> +static int idio_16_gpio_get_multiple(struct gpio_chip *chip,
> + unsigned long *mask, unsigned long *bits)
> +{


> + /* clear bits array to a clean slate */
> + for (i = 0; i < chip->ngpio; i += BITS_PER_LONG)
> + bits[i / BITS_PER_LONG] = 0;

bitmap_clear() or bitmap_zero()

> + /* get bits are evaluated a gpio register size at a time */
> + for (i = 0; i < chip->ngpio; i += gpio_reg_size) {
> + bit_word_offset = i % BITS_PER_LONG;
> + bits_mask = mask[BIT_WORD(i)] & (reg_mask << bit_word_offset);
> + if (!bits_mask) {
> + /* no get bits in this register so skip to next one */
> + continue;
> + }

for_each_set_bit() ?

> + /* store acquired bits */
> + bits[BIT_WORD(i)] |= port_state << bit_word_offset;

__set_bit()
__clear_bit()

We have bitmap API for *ages*. Is it too hard to check?

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2018-03-13 17:04    [W:0.082 / U:1.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site