PERFORCE change 170842 for review
Andrew Thompson
thompsa at FreeBSD.org
Sun Nov 22 22:41:44 UTC 2009
2009/11/21 Nathan Whitehorn <nwhitehorn at freebsd.org>:
> Hans Petter Selasky wrote:
>>
>> On Thursday 19 November 2009 23:47:59 Nathan Whitehorn wrote:
>>>>
>>>> @@ -1530,7 +1574,7 @@
>>>> return (ENXIO);
>>>>
>>>> if (usbd_lookup_id_by_uaa(atp_devs, sizeof(atp_devs), uaa) == 0)
>>>> - return BUS_PROBE_SPECIFIC;
>>>> + return 0;
>>>> else
>>>> return ENXIO;
>>>> }
>>>>
>>>
>>> Why are you replacing symbolic constants with less informative numeric
>>> ones? -Nathan
>>>
>>
>> Because returning zero in probe has special meaning and is hardcoded in
>> the subr_bus.c code aswell. The other return values will not be changed.
>>
>
> It's the same thing as far as the code is concerned, of course, my complaint
> was merely a style issue. Using the constant makes the meaning of the return
> value clearer, especially since this driver uses this return value to
> override the BUS_PROBE_GENERIC priority of ums(4). Changing it from the
> constant that was already there seemed like a step backward in readability.
I think we should really bring back the probe returns for usb, to
allow drivers to be overridden.
ie, UMATCH_VENDOR_PRODUCT vs UMATCH_IFACECLASS
http://fxr.watson.org/fxr/source/dev/usb/usbdi.h?v=FREEBSD72#L236
Something like...
Index: usb_lookup.c
===================================================================
--- usb_lookup.c (revision 199667)
+++ usb_lookup.c (working copy)
@@ -133,6 +133,33 @@ done:
return (NULL);
}
+int
+usbd_probe_priority(const struct usb_device_id *id)
+{
+ int pri;
+
+ pri = UMATCH_GENERIC;
+
+ /* Probe priority, lowest to highest */
+ if (id->match_flag_int_class)
+ pri = UMATCH_IFACECLASS;
+ if (id->match_flag_int_subclass)
+ pri = UMATCH_IFACECLASS_IFACESUBCLASS;
+ if (id->match_flag_int_protocol)
+ pri = UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;
+ if (id->match_flag_dev_protocol)
+ pri = UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO;
+ if (id->match_flag_dev_class && id->match_flag_dev_subclass)
+ pri = UMATCH_DEVCLASS_DEVSUBCLASS;
+ if (id->match_flag_vendor && id->match_flag_product)
+ pri = UMATCH_VENDOR_PRODUCT;
+ if (id->match_flag_vendor && id->match_flag_product &&
+ (id->match_flag_dev_lo || id->match_flag_dev_hi))
+ pri = UMATCH_VENDOR_PRODUCT_REV;
+
+ return (pri);
+}
+
/*------------------------------------------------------------------------*
* usbd_lookup_id_by_uaa - factored out code
*
@@ -148,7 +175,7 @@ usbd_lookup_id_by_uaa(const struct usb_device_id *
if (id) {
/* copy driver info */
uaa->driver_info = id->driver_info;
- return (0);
+ return (usbd_probe_priority(id));
}
return (ENXIO);
}
More information about the p4-projects
mailing list