Re: [PATCH v3] dma-buf: Add a capabilities directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 31, 2022 at 07:53:50AM -0500, Jason Ekstrand wrote:
> On Mon, 2022-05-30 at 10:26 +0200, Greg KH wrote:
> > On Mon, May 30, 2022 at 08:15:04AM +0000, Simon Ser wrote:
> > > On Monday, May 30th, 2022 at 09:20, Greg KH
> > > <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> > > 
> > > > > > +static struct attribute *dma_buf_caps_attrs[] = {
> > > > > > +       &dma_buf_sync_file_import_export_attr.attr,
> > > > > > +       NULL,
> > > > > > +};
> > > > > > +
> > > > > > +static const struct attribute_group dma_buf_caps_attr_group
> > > > > > = {
> > > > > > +       .attrs = dma_buf_caps_attrs,
> > > > > > +};
> > > > > 
> > > > > Didn't we had macros for those? I think I have seen something
> > > > > for that.
> > > > 
> > > > Yes, please use ATTRIBUTE_GROUPS()
> > > 
> > > This doesn't allow the user to set a group name, and creates an
> > > unused
> > > "_groups" variable, causing warnings.
> > 
> > Then set a group name.
> > 
> > But you really want to almost always be using lists of groups, which
> > is
> > why that macro works that way.
> 
> I think I see the confusion here.  The ATTRIBUTE_GROUPS() macro is
> intended for device drivers and to be used with add_device().  However,
> this is dma-buf so there is no device and no add_device() call to hook.
> Unless there are other magic macros to use in this case, I think we're
> stuck doing it manually.

Have a list of attribute groups and add it to the kobject when you
create it so they all get created at the same time.

Don't do piece-meal "add one, and then another, and then another" as
that just gets messy and complex and impossible to unwind the error
conditions from.

sysfs_create_groups() is what you need to use here.  I need to drop
sysfs_create_group() one day...

thanks,

greg k-h



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux