On Sun, Aug 09, 2020 at 09:25:16PM +0800, Kent Gibson wrote: > Add support for requesting lines using the GPIO_V2_GET_LINE_IOCTL, and > returning their current values using GPIO_V2_LINE_GET_VALUES_IOCTL. > > Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx> > --- > [snip] > +static long line_get_values(struct line *line, void __user *ip) > +{ > + struct gpio_v2_line_values lv; > + DECLARE_BITMAP(vals, GPIO_V2_LINES_MAX); > + DECLARE_BITMAP(mask, GPIO_V2_LINES_MAX); > + struct gpio_desc **descs; > + int ret, i, didx, num_get = 0; > + > + /* NOTE: It's ok to read values of output lines. */ > + if (copy_from_user(&lv, ip, sizeof(lv))) > + return -EFAULT; > + > + if (lv.mask == 0) > + return -EINVAL; > + > + bitmap_from_u64(mask, lv.mask); > + num_get = bitmap_weight(mask, line->num_descs); Nuts, that doesn't do what I intend, and is part of a failed experiment that I thought I had reverted. Assume that in the next version the mask handling will be similar to line_set_values_locked in patch 09. i.e. for (i = 0; i < line->num_descs; i++) if (lv.mask & BIT_ULL(i)) num_get++; and the subsequent mask tests will be against lv.mask instead of the mask bitmap declared above (which will be gone). I won't do a v4 just yet though - there is sure to be other things to go in there. Cheers, Kent.