lkml.org 
[lkml]   [2012]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCHv3 1/1] [RFC] uartclk from serial_core exposed to sysfs
Date
Dear Greg KH,

> On Fri, Aug 17, 2012 at 06:30:36PM +0200, Tomas Hlavacek wrote:
> > Hello Greg!
> >
> > On Fri, Aug 17, 2012 at 5:06 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> > >> @@ -2355,6 +2373,14 @@ int uart_add_one_port(struct uart_driver *drv,
> > >> struct uart_port *uport)
> > >>
> > >> }
> > >>
> > >> /*
> > >>
> > >> + * Expose uartclk in sysfs. Use driverdata of the tty device for
> > >> + * referencing the UART port.
> > >> + */
> > >> + dev_set_drvdata(tty_dev, port);
> > >> + if (device_create_file(tty_dev, &dev_attr_uartclk) < 0)
> > >> + dev_err(tty_dev, "Failed to add uartclk attr\n");
> > >
> > > I think you just raced with userspace in creating the file after the
> > > device was announced to userspace. Are you sure it's ok?
> > >
> > > If not (hint, I don't think so), please make it a default attribute of
> > > the device, which will then cause the file to be created before it is
> > > announced to userspace. It will also be less code as you don't have to
> > > clean it up by hand :)
> >
> > Do you mean I should modify the tty_register_device() function not to
> > use device_create() but it should rather do the device initialization
> > on it's own.
>
> No, not at all.
>
> > And I should add add the attribute (via struct attribute_group) to
> > struct device in between device_initialize() and device_add() calls.
> > Did I get it right?
>
> No, make this a driver attribute, that way when the device is
> registered, it adds the attribute automagically to the device that is
> bound to it.

(hint, DEVICE_ATTR), right ?

> Does that make sense?
>
> greg k-h

Best regards,
Marek Vasut


\
 
 \ /
  Last update: 2012-08-17 21:21    [W:0.398 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site