On Tue, 2012-04-24 at 15:02 +1000, Peter Hutterer wrote:
> For bluetooth devices, the PRODUCT is set on the event device. For
> inputattached serial devices, the PRODUCT Is on the parent instead.
> 
> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
> ---
>  libwacom/libwacom.c |   19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
> index e05dbc0..7a52af4 100644
> --- a/libwacom/libwacom.c
> +++ b/libwacom/libwacom.c
> @@ -154,7 +154,8 @@ get_device_info (const char   *path,
>  
>               *vendor_id = strtol (vendor_str, NULL, 16);
>               *product_id = strtol (product_str, NULL, 16);
> -     } else if (*bus == WBUSTYPE_BLUETOOTH) {
> +     } else if (*bus == WBUSTYPE_BLUETOOTH || *bus == WBUSTYPE_SERIAL) {
> +             GUdevDevice *parent;
>               const char *product_str;
>               int garbage;
>  
> @@ -163,17 +164,23 @@ get_device_info (const char   *path,
>                * into:
>                * vendor 0x56a
>                * product 0x81 */
> +             parent = g_object_ref (device);
>               product_str = g_udev_device_get_property (device, "PRODUCT");
> +
> +             while (!product_str && parent) {
> +                     GUdevDevice *old_parent = parent;
> +                     parent = g_udev_device_get_parent (parent);
> +                     product_str = g_udev_device_get_property (parent, 
> "PRODUCT");
> +                     g_object_unref (old_parent);
> +             }
> +             if (parent)
> +                     g_object_unref (parent);

Really don't like the idea of an unbounded while() loop here. Especially
if you're not checking the retval of g_udev_device_get_parent()

>               g_assert (product_str);
>               if (sscanf(product_str, "%d/%x/%x/%d", &garbage, vendor_id, 
> product_id, &garbage) != 4) {
>                       libwacom_error_set(error, WERROR_UNKNOWN_MODEL, 
> "Unimplemented serial bus");
>                       goto bail;
>               }
> -     } else if (*bus == WBUSTYPE_SERIAL) {
> -             /* FIXME This matches the declaration in serial-wacf004.tablet
> -              * Might not be good enough though */
> -             *vendor_id = 0;
> -             *product_id = 0;
>       } else {
>               libwacom_error_set(error, WERROR_UNKNOWN_MODEL, "Unsupported 
> bus '%s'", bus_str);
>               goto bail;



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to