lkml.org 
[lkml]   [2020]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v7 07/20] gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL
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@gmail.com> 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@gmail.com>
> > > ---
> > >
> >
> > [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.

\
 
 \ /
  Last update: 2020-09-09 11:36    [W:1.801 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site