From: Kazuhiro Ondo Date: Thu, 3 Mar 2011 23:33:56 +0000 (-0600) Subject: ARM: tegra: stingray: usbnet: sysfs attribute to identify BLAN X-Git-Tag: firefly_0821_release~9834^2~61 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=14a13cbc5eada41e467c744aa274495f06a213d7;p=firefly-linux-kernel-4.4.55.git ARM: tegra: stingray: usbnet: sysfs attribute to identify BLAN This is to help user spece modules to identify Motorola BLAN networking device. Work around the issue of getting semi-random interface number depending on the boot-up configuration. Change-Id: Ib2b16699239a16da960c33ef98bbee84bde71dec Signed-off-by: Kazuhiro Ondo --- diff --git a/arch/arm/mach-tegra/board-stingray-usbnet.c b/arch/arm/mach-tegra/board-stingray-usbnet.c index b2c2199a3914..cb0d1e03689f 100644 --- a/arch/arm/mach-tegra/board-stingray-usbnet.c +++ b/arch/arm/mach-tegra/board-stingray-usbnet.c @@ -186,6 +186,17 @@ static struct usb_descriptor_header *hs_function[] = { if (context && context->gadget) \ dev_dbg(&(context->gadget->dev) , fmt , ## args) +static const char *usb_description = "Motorola BLAN Interface"; + +static ssize_t usbnet_desc_show(struct device *dev, + struct device_attribute *attr, char *buff) +{ + ssize_t status = 0; + status = sprintf(buff, "%s\n", usb_description); + return status; +} + +static DEVICE_ATTR(description, S_IRUGO, usbnet_desc_show, NULL); static inline struct usbnet_device *func_to_dev(struct usb_function *f) { @@ -402,6 +413,7 @@ static void usbnet_cleanup(struct usbnet_device *dev) { struct usbnet_context *context = dev->net_ctxt; if (context) { + device_remove_file(&(context->dev->dev), &dev_attr_description); unregister_netdev(context->dev); free_netdev(context->dev); dev->net_ctxt = NULL; @@ -752,7 +764,6 @@ static void usbnet_resume(struct usb_function *f) USBNETDBG(context, "%s\n", __func__); } - int usbnet_bind_config(struct usb_configuration *c) { struct usbnet_device *dev; @@ -779,6 +790,15 @@ int usbnet_bind_config(struct usb_configuration *c) free_netdev(net_dev); return -EINVAL; } + + ret = device_create_file(&net_dev->dev, &dev_attr_description); + if (ret < 0) { + pr_err("%s: sys file creation error\n", __func__); + unregister_netdev(net_dev); + free_netdev(net_dev); + return -EINVAL; + } + context = netdev_priv(net_dev); INIT_WORK(&context->usbnet_config_wq, usbnet_if_config); @@ -810,9 +830,9 @@ int usbnet_bind_config(struct usb_configuration *c) return 0; err1: - kfree(dev); pr_err("usbnet gadget driver failed to initialize\n"); usbnet_cleanup(dev); + kfree(dev); return ret; }