Re: [PATCH 1/9] usb-serial: new API for driver registration

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

 



On Fri, Feb 24, 2012 at 05:29:51PM -0500, Alan Stern wrote:
> On Fri, 24 Feb 2012, Greg KH wrote:
> 
> > On Thu, Feb 23, 2012 at 02:55:59PM -0500, Alan Stern wrote:
> > > + * Registers @udriver and all the drivers in the @serial_drivers array.
> > > + * Automatically fills in the .no_dynamic_id field in @udriver and
> > > + * the .usb_driver field in each serial driver.
> > > + */
> > > +int usb_serial_register_drivers(struct usb_driver *udriver,
> > > +		struct usb_serial_driver * const serial_drivers[])
> > 
> > If we want the usb_driver to be in "const" memory, then modifying the
> > no_dynamic_id field seems like a bad idea, right?  Not that it is at the
> > moment, but I guess it could be in the future.
> 
> No, you misinterpreted it.  The "const" refers to the array of 
> usb_serial_driver pointers.  It doesn't mean that the individual 
> usb_serial_driver structures won't get modified; it only means that the 
> array of pointers won't get modified.
> 
> I know the C syntax is hard to decode; it took me several tries to get
> it right.  The way to read it is like this: For any value of i,
> serial_drivers[i] is a const pointer to (non-const) struct
> usb_serial_driver.
> 
> Nothing about the usb_driver is declared const, just the array of 
> pointers.

No, I understand the existing code (well, I too had to look at it a
bunch to verify what you point out above, c syntax in this area is hard
to understand at times.)

My point was that it might be nice to make the usb_driver structure in
the modules const, which would make them read-only on some systems,
providing a bit more protection.

Oh crap, they are really kobjects down in the end, nevermind, that would
never work out, they are really supposed to be dynamic, so this can't
work without some driver core rework anyway.

nevermind...

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux