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, 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.

Alan Stern

--
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