Update patch musb_sysfs_hostdevice.diff
[kernel-power] / kernel-power-2.6.28 / debian / patches / musb_sysfs_hostdevice.diff
1 --- kernel-power/drivers/usb/musb/musb_core.h   2012-05-22 23:46:25.063372234 +0200
2 +++ kernel-power/drivers/usb/musb/musb_core.h   2012-05-22 23:58:04.727351773 +0200
3 @@ -431,6 +431,9 @@ struct musb {
4  
5         unsigned                power_draw;     /* current power draw, gadget only */
6  
7 +       const char              *hostdevice;    /* type of usb host device (from musb_procfs.c) */
8 +       const char              *hostdevice2;   /* type of usb host device (from musb_virthub.c) */
9 +
10         bool                    is_host;
11  
12         int                     a_wait_bcon;    /* VBUS timeout in msecs */
13 --- kernel-power/drivers/usb/musb/musb_core.c   2012-05-22 23:36:45.795389167 +0200
14 +++ kernel-power/drivers/usb/musb/musb_core.c   2012-05-22 23:56:42.415354180 +0200
15 @@ -1978,6 +1978,24 @@ musb_amp_show(struct device *dev, struct
16  static DEVICE_ATTR(mA, 0444, musb_amp_show, NULL);
17  
18  static ssize_t
19 +musb_hostdevice_show(struct device *dev, struct device_attribute *attr, char *buf)
20 +{
21 +       struct musb *musb = dev_to_musb(dev);
22 +
23 +       return sprintf(buf, "%s\n", musb->hostdevice);
24 +}
25 +static DEVICE_ATTR(hostdevice, 0444, musb_hostdevice_show, NULL);
26 +
27 +static ssize_t
28 +musb_hostdevice2_show(struct device *dev, struct device_attribute *attr, char *buf)
29 +{
30 +       struct musb *musb = dev_to_musb(dev);
31 +
32 +       return sprintf(buf, "%s\n", musb->hostdevice2);
33 +}
34 +static DEVICE_ATTR(hostdevice2, 0444, musb_hostdevice2_show, NULL);
35 +
36 +static ssize_t
37  musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
38  {
39         struct musb *musb = dev_to_musb(dev);
40 @@ -2060,6 +2069,10 @@ musb_mode_store(struct device *dev, stru
41                 status = -EINVAL;
42         mutex_unlock(&musb->mutex);
43  
44 +       musb->hostdevice = "none";
45 +       musb->hostdevice2 = "none";
46 +       sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
47 +       sysfs_notify(&musb->controller->kobj, NULL, "hostdevice2");
48         sysfs_notify(&musb->controller->kobj, NULL, "mode");
49         schedule_work(&musb->irq_work);
50  
51 @@ -2154,6 +2165,10 @@ static void musb_irq_work(struct work_st
52  
53         if (musb->xceiv->state != old_state) {
54                 old_state = musb->xceiv->state;
55 +               musb->hostdevice = "none";
56 +               musb->hostdevice2 = "none";
57 +               sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
58 +               sysfs_notify(&musb->controller->kobj, NULL, "hostdevice2");
59                 sysfs_notify(&musb->controller->kobj, NULL, "mode");
60         }
61         if (musb->power_draw != old_ma) {
62 @@ -2240,6 +2240,8 @@ static void musb_free(struct musb *musb)
63         device_remove_file(musb->controller, &dev_attr_mA);
64         device_remove_file(musb->controller, &dev_attr_connect);
65         device_remove_file(musb->controller, &dev_attr_charger);
66 +       device_remove_file(musb->controller, &dev_attr_hostdevice);
67 +       device_remove_file(musb->controller, &dev_attr_hostdevice2);
68         device_remove_file(musb->controller, &dev_attr_mode);
69         device_remove_file(musb->controller, &dev_attr_vbus);
70  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
71 @@ -2346,6 +2346,8 @@ bad_config:
72         musb->set_clock = plat->set_clock;
73         musb->min_power = plat->min_power;
74         musb->use_dma = use_dma;
75 +       musb->hostdevice = "none";
76 +       musb->hostdevice2 = "none";
77  
78         /* Clock usage is chip-specific ... functional clock (DaVinci,
79          * OMAP2430), or PHY ref (some TUSB6010 boards).  All this core
80 @@ -2486,6 +2487,8 @@ bad_config:
81         status = device_create_file(dev, &dev_attr_mA);
82         status = device_create_file(dev, &dev_attr_connect);
83         status = device_create_file(dev, &dev_attr_charger);
84 +       status = device_create_file(dev, &dev_attr_hostdevice);
85 +       status = device_create_file(dev, &dev_attr_hostdevice2);
86         status = device_create_file(dev, &dev_attr_mode);
87         status = device_create_file(dev, &dev_attr_vbus);
88  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
89 @@ -2510,6 +2512,8 @@ fail2:
90         device_remove_file(dev, &dev_attr_mA);
91         device_remove_file(dev, &dev_attr_connect);
92         device_remove_file(dev, &dev_attr_charger);
93 +       device_remove_file(dev, &dev_attr_hostdevice);
94 +       device_remove_file(dev, &dev_attr_hostdevice2);
95         device_remove_file(musb->controller, &dev_attr_mode);
96         device_remove_file(musb->controller, &dev_attr_vbus);
97  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
98 --- kernel-power/drivers/usb/musb/musb_procfs.c 2012-05-22 23:35:43.767390980 +0200
99 +++ kernel-power/drivers/usb/musb/musb_procfs.c 2012-05-22 23:57:28.355352837 +0200
100 @@ -692,13 +692,16 @@ static int musb_proc_write(struct file *
101                 case 1: /* pullup indicates a full/high-speed device */
102                         if (!(testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS)))
103                                 pr_err("Forced hostmode error: a full/high-speed device attached but low-speed mode selected\n"); 
104 +                       musb->hostdevice = "full/high";
105                         break;
106                 case 2: /* pullup indicates a low-speed device */
107                         if (testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS))
108                                 pr_err("Forced hostmode error: a low-speed device attached but full/high-speed mode selected\n"); 
109 +                       musb->hostdevice = "low";
110                         break;
111                 default:
112                         pr_err("Forced hostmode error: no device attached\n");
113 +                       musb->hostdevice = "none";
114                 }
115   
116                 if (!(testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS)))
117 @@ -721,6 +724,7 @@ static int musb_proc_write(struct file *
118                 DBG(1, "CONNECT (%s) devctl %02x\n",
119                                 otg_state_string(musb), devctl);
120                 }
121 +               sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
122                 sysfs_notify(&musb->controller->kobj, NULL, "mode");
123                 schedule_work(&musb->irq_work);
124                 break;
125 --- kernel-power/drivers/usb/musb/musb_virthub.c        2012-05-22 23:53:44.471359383 +0200
126 +++ kernel-power/drivers/usb/musb/musb_virthub.c        2012-05-22 23:57:34.791352649 +0200
127 @@ -169,10 +169,13 @@ static void musb_port_reset(struct musb
128                         musb->port1_status |= USB_PORT_STAT_HIGH_SPEED;
129                         if (!(testmode & MUSB_TEST_FORCE_HS))
130                                 pr_err("Forced hostmode error: a high-speed device attached but not high-speed mode selected\n"); 
131 +                       musb->hostdevice2 = "high";
132                 } else {
133                         if (testmode & MUSB_TEST_FORCE_HS)
134                                 pr_err("Forced hostmode error: a full/low-speed device attached but high-speed mode selected\n"); 
135 +                       musb->hostdevice2 = "full/low";
136                 }
137 +               sysfs_notify(&musb->controller->kobj, NULL, "hostdevice2");
138  
139                 musb->port1_status &= ~USB_PORT_STAT_RESET;
140                 musb->port1_status |= USB_PORT_STAT_ENABLE