On Mon, Aug 15, 2011 at 04:58:44PM +0200, Bart Van Assche wrote:
> On Mon, Aug 15, 2011 at 4:45 PM, Greg KH <gre...@suse.de> wrote:
> > On Mon, Aug 15, 2011 at 04:33:14PM +0200, Bart Van Assche wrote:
> >> On Sun, Jul 24, 2011 at 9:43 PM,  <rpear...@systemfabricworks.com> wrote:
> >> > +   for (i = 0; i < ARRAY_SIZE(rxe_dev_attributes); ++i) {
> >> > +           err = device_create_file(&dev->dev, rxe_dev_attributes[i]);
> >> > +           if (err) {
> >> > +                   pr_warn("device_create_file failed, "
> >> > +                           "i = %d, err = %d\n", i, err);
> >> > +                   goto err2;
> >> > +           }
> >> > +   }
> >
> > How about using the api functions that are already present in the kernel
> > to do the exact thing you are asking for here?
> >
> > And no one should EVER be doing a loop like the above mentioned one, so
> > yes, it is their fault :)
> 
> Hello Greg,
> 
> Thanks for replying, but It seems like I have missed something. I have
> found a function called device_add_attributes() in drivers/base/core.c
> but it's declared static. Does your reply mean that there exists an
> exported function that allows to add multiple device attributes at
> once without defining a new device class ?

Yes.

For a device, you HAVE to be creating these attributes before the
hotplug event is sent out, and to do that, you need to set the correct
pointer before registering the device.  See the documentation for the
driver model for how to do this properly.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to