[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4FE8F90B.2010303@gmail.com>
Date: Mon, 25 Jun 2012 18:49:31 -0500
From: Rob Herring <robherring2@...il.com>
To: Alexandre Pereira da Silva <aletes.xgr@...il.com>
CC: Felipe Balbi <balbi@...com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Grant Likely <grant.likely@...retlab.ca>,
devicetree-discuss@...ts.ozlabs.org
Subject: Re: [RFC 2/2] usb: gadget: composite: parse dt overrides
On 06/25/2012 03:23 PM, Alexandre Pereira da Silva wrote:
> Grab the devicetree node properties to override VendorId, ProductId,
> bcdDevice, Manucacturer, Product and SerialNumber
>
> Signed-off-by: Alexandre Pereira da Silva <aletes.xgr@...il.com>
> ---
> drivers/usb/gadget/composite.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
Are these bindings documented? I think they should be less generic.
Perhaps prefixed with 'usb-'.
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 390749b..f3b480e 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -17,6 +17,7 @@
> #include <linux/module.h>
> #include <linux/device.h>
> #include <linux/utsname.h>
> +#include <linux/of.h>
>
> #include <linux/usb/composite.h>
> #include <asm/unaligned.h>
> @@ -1423,6 +1424,7 @@ static int composite_bind(struct usb_gadget *gadget)
> {
> struct usb_composite_dev *cdev;
> int status = -ENOMEM;
> + struct device_node *np = gadget->dev.of_node;
>
> cdev = kzalloc(sizeof *cdev, GFP_KERNEL);
> if (!cdev)
> @@ -1470,6 +1472,35 @@ static int composite_bind(struct usb_gadget *gadget)
>
> cdev->desc = *composite->dev;
>
> + /* grab overrides from devicetree */
Reading the code, it looks more like the DT entries are defaults rather
than overrides.
> + if (np) {
> + u32 reg;
> +
> + if (!idVendor &&
> + of_property_read_u32(np, "vendor_id", ®) == 0)
> + idVendor = reg;
if (!idVendor)
of_property_read_u32(np, "vendor_id", &idVendor);
Rob
> +
> + if (!idProduct &&
> + of_property_read_u32(np, "product_id", ®) == 0)
> + idProduct = reg;
> +
> + if (!bcdDevice &&
> + of_property_read_u32(np, "bcd_device", ®) == 0)
> + bcdDevice = reg;
> +
> + if (!iManufacturer)
> + of_property_read_string(np, "manufacturer",
> + &iManufacturer);
> +
> + if (!iProduct)
> + of_property_read_string(np, "product",
> + &iProduct);
> +
> + if (!iSerialNumber)
> + of_property_read_string(np, "serial_number",
> + &iSerialNumber);
> + }
> +
> /* standardized runtime overrides for device ID data */
> if (idVendor)
> cdev->desc.idVendor = cpu_to_le16(idVendor);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists