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.