[PATCH] staging: comedi: rework the comedi_auto_config 'context'

Ian Abbott abbotti at mev.co.uk
Tue Dec 4 11:04:19 UTC 2012

On 2012/12/03 09:17 PM, H Hartley Sweeten wrote:
> On Monday, December 03, 2012 3:23 AM, Ian Abbott wrote:
>> On 2012-11-30 22:19, H Hartley Sweeten wrote:
>>> The 'context' passed to comedi_auto_config() is currently an unsigned
>>> long value. This value is passed to the (*auto_attach)() function of a
>>> comedi driver. Currently none of the comedi drivers use the 'context'.
>>> The only callers of comedi_auto_config() are the two inline wrappers
>>> comedi_pci_auto_config() and comedi_usb_auto_config(). Both of these
>>> pass a 'context' of 0.
>>> Change the 'context' to a const void * and rework the auto_config code
>>> and the pci/usb drivers so that the 'context' passed is the struct
>>> {pci,usb}_device_id * that is passed to the {pci,usb}_driver (*probe)()
>>> function.
>>> Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
>>> Cc: Ian Abbott <abbotti at mev.co.uk>
>>> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
>> I'm not sure what you're planning to do with this, but maybe it would be 
>> better to pass the `driver_data` from the `struct pci_device_id` or the 
>> `driver_info` from the `struct usb_device_id` and change the type of the 
>> context to `kernel_ulong_t`?
> I'm trying to make the 'auto_attach' a continuation of the lower-level
> probe function regardless of the bus type. The 'driver_info' might be
> all that is required to do this but passing the *_device_id from the probe
> seemed cleaner.
> As I mentioned above, nothing in comedi uses the 'context' but it
> might as well contain something useful.

I'd prefer to keep the context as an integer type as we went over that
before and quoting Greg, "I think you got it right with an unsigned
 I'm not averse to changing it to a kernel_ulong_t though (although
since that's just a typedef of unsigned long in
<linux/mod_devicetable.h> there's probably not much point).

I think the driver_data or driver_info is about the only information in
a struct pci_device_id or struct usb_device_id that the code couldn't
determine easily by other means if it needed to.

-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti at mev.co.uk>             )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587              )=-

More information about the devel mailing list