Update patch musb_sysfs_hostdevice.diff
authorPali Rohár <pali.rohar@gmail.com>
Sat, 8 Dec 2012 17:53:49 +0000 (18:53 +0100)
committerPali Rohár <pali.rohar@gmail.com>
Sat, 8 Dec 2012 17:53:49 +0000 (18:53 +0100)
* Add sysfs entry hostdevice2 which show host device speed detected by musb_virthub.c

kernel-power-2.6.28/debian/patches/musb_sysfs_hostdevice.diff

index fcc6b53..3f7dda1 100644 (file)
@@ -1,17 +1,18 @@
 --- kernel-power/drivers/usb/musb/musb_core.h  2012-05-22 23:46:25.063372234 +0200
 +++ kernel-power/drivers/usb/musb/musb_core.h  2012-05-22 23:58:04.727351773 +0200
-@@ -431,6 +431,8 @@ struct musb {
+@@ -431,6 +431,9 @@ struct musb {
  
        unsigned                power_draw;     /* current power draw, gadget only */
  
-+      const char              *hostdevice;    /* type of usb host device */
++      const char              *hostdevice;    /* type of usb host device (from musb_procfs.c) */
++      const char              *hostdevice2;   /* type of usb host device (from musb_virthub.c) */
 +
        bool                    is_host;
  
        int                     a_wait_bcon;    /* VBUS timeout in msecs */
 --- kernel-power/drivers/usb/musb/musb_core.c  2012-05-22 23:36:45.795389167 +0200
 +++ kernel-power/drivers/usb/musb/musb_core.c  2012-05-22 23:56:42.415354180 +0200
-@@ -1978,6 +1978,15 @@ musb_amp_show(struct device *dev, struct
+@@ -1978,6 +1978,24 @@ musb_amp_show(struct device *dev, struct
  static DEVICE_ATTR(mA, 0444, musb_amp_show, NULL);
  
  static ssize_t
 +static DEVICE_ATTR(hostdevice, 0444, musb_hostdevice_show, NULL);
 +
 +static ssize_t
++musb_hostdevice2_show(struct device *dev, struct device_attribute *attr, char *buf)
++{
++      struct musb *musb = dev_to_musb(dev);
++
++      return sprintf(buf, "%s\n", musb->hostdevice2);
++}
++static DEVICE_ATTR(hostdevice2, 0444, musb_hostdevice2_show, NULL);
++
++static ssize_t
  musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
  {
        struct musb *musb = dev_to_musb(dev);
-@@ -2060,6 +2069,8 @@ musb_mode_store(struct device *dev, stru
+@@ -2060,6 +2069,10 @@ musb_mode_store(struct device *dev, stru
                status = -EINVAL;
        mutex_unlock(&musb->mutex);
  
 +      musb->hostdevice = "none";
++      musb->hostdevice2 = "none";
 +      sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
++      sysfs_notify(&musb->controller->kobj, NULL, "hostdevice2");
        sysfs_notify(&musb->controller->kobj, NULL, "mode");
        schedule_work(&musb->irq_work);
  
-@@ -2154,6 +2165,8 @@ static void musb_irq_work(struct work_st
+@@ -2154,6 +2165,10 @@ static void musb_irq_work(struct work_st
  
        if (musb->xceiv->state != old_state) {
                old_state = musb->xceiv->state;
 +              musb->hostdevice = "none";
++              musb->hostdevice2 = "none";
 +              sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
++              sysfs_notify(&musb->controller->kobj, NULL, "hostdevice2");
                sysfs_notify(&musb->controller->kobj, NULL, "mode");
        }
        if (musb->power_draw != old_ma) {
-@@ -2240,6 +2240,7 @@ static void musb_free(struct musb *musb)
+@@ -2240,6 +2240,8 @@ static void musb_free(struct musb *musb)
        device_remove_file(musb->controller, &dev_attr_mA);
        device_remove_file(musb->controller, &dev_attr_connect);
        device_remove_file(musb->controller, &dev_attr_charger);
 +      device_remove_file(musb->controller, &dev_attr_hostdevice);
++      device_remove_file(musb->controller, &dev_attr_hostdevice2);
        device_remove_file(musb->controller, &dev_attr_mode);
        device_remove_file(musb->controller, &dev_attr_vbus);
  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
-@@ -2346,6 +2346,7 @@ bad_config:
+@@ -2346,6 +2346,8 @@ bad_config:
        musb->set_clock = plat->set_clock;
        musb->min_power = plat->min_power;
        musb->use_dma = use_dma;
 +      musb->hostdevice = "none";
++      musb->hostdevice2 = "none";
  
        /* Clock usage is chip-specific ... functional clock (DaVinci,
         * OMAP2430), or PHY ref (some TUSB6010 boards).  All this core
-@@ -2486,6 +2487,7 @@ bad_config:
+@@ -2486,6 +2487,8 @@ bad_config:
        status = device_create_file(dev, &dev_attr_mA);
        status = device_create_file(dev, &dev_attr_connect);
        status = device_create_file(dev, &dev_attr_charger);
 +      status = device_create_file(dev, &dev_attr_hostdevice);
++      status = device_create_file(dev, &dev_attr_hostdevice2);
        status = device_create_file(dev, &dev_attr_mode);
        status = device_create_file(dev, &dev_attr_vbus);
  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
-@@ -2510,6 +2512,7 @@ fail2:
+@@ -2510,6 +2512,8 @@ fail2:
        device_remove_file(dev, &dev_attr_mA);
        device_remove_file(dev, &dev_attr_connect);
        device_remove_file(dev, &dev_attr_charger);
 +      device_remove_file(dev, &dev_attr_hostdevice);
++      device_remove_file(dev, &dev_attr_hostdevice2);
        device_remove_file(musb->controller, &dev_attr_mode);
        device_remove_file(musb->controller, &dev_attr_vbus);
  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
                        musb->port1_status |= USB_PORT_STAT_HIGH_SPEED;
                        if (!(testmode & MUSB_TEST_FORCE_HS))
                                pr_err("Forced hostmode error: a high-speed device attached but not high-speed mode selected\n"); 
-+                      musb->hostdevice = "high";
++                      musb->hostdevice2 = "high";
                } else {
                        if (testmode & MUSB_TEST_FORCE_HS)
                                pr_err("Forced hostmode error: a full/low-speed device attached but high-speed mode selected\n"); 
-+                      musb->hostdevice = "full/low";
++                      musb->hostdevice2 = "full/low";
                }
-+              sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
++              sysfs_notify(&musb->controller->kobj, NULL, "hostdevice2");
  
                musb->port1_status &= ~USB_PORT_STAT_RESET;
                musb->port1_status |= USB_PORT_STAT_ENABLE