On Wed, Sep 09, 2020 at 11:26:00AM +0200, Bartosz Golaszewski wrote: > On Wed, Sep 9, 2020 at 11:24 AM Kent Gibson <warthog618@xxxxxxxxx> wrote: > > > > On Sat, Sep 05, 2020 at 09:35:36PM +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. > > > > > > The struct linereq implementation is based on the v1 struct linehandle > > > implementation. > > > > > > Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx> > > > --- > > > > > > > [snip] > > > > > if (copy_from_user(&offset, ip, sizeof(offset))) > > > return -EFAULT; > > > @@ -1104,6 +1505,25 @@ int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt) > > > MAJOR(devt), gdev->id); > > > > > > return 0; > > > + /* > > > + * array sizes must ensure 64-bit alignment and not create holes in > > > + * the struct packing. > > > + */ > > > + BUILD_BUG_ON(IS_ALIGNED(GPIO_V2_LINES_MAX, 2)); > > > + BUILD_BUG_ON(IS_ALIGNED(GPIO_MAX_NAME_SIZE, 8)); > > > + > > > + /* > > > + * check that uAPI structs are 64-bit aligned for 32/64-bit > > > + * compatibility > > > + */ > > > + BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_attribute), 8)); > > > + BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_config_attribute), 8)); > > > + BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_config), 8)); > > > + BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_request), 8)); > > > + BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_info), 8)); > > > + BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_info_changed), 8)); > > > + BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_event), 8)); > > > + BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_values), 8)); > > > } > > > > > > > A couple of things here - these should all be !IS_ALIGNED. > > And the BUILD_BUG_ON gets compiled out, and so doesn't fail, if they are > > after the return. > > > > How would you like that fixed - v8 or a patch once v7 is in? > > > > Cheers, > > Kent. > > v8 please. Why is it compiled out though? Does it need some config option? > Not sure - haven't looked into it. I only noticed the condition was inverted in passing, and when I flipped it it still compiled. Moving the return to the end of the function made them all fail, as they should if IS_ALIGNED is true. Having BUILD_BUG_ON being able to compile out quietly is a problem in itself. Nothing special in my setup that I am aware of. Cheers, Kent.