Re: [PATCH 3/5] fs: remove ki_nbytes

2015-02-05 Thread Al Viro
On Thu, Feb 05, 2015 at 10:29:42AM -0500, Alan Stern wrote:
> On Wed, 4 Feb 2015, Al Viro wrote:
> 
> > > > Um...  readv() is also going through ->aio_read().
> > > 
> > > Why does readv() do this but not read()?  Wouldn't it make more sense 
> > > to have all the read* calls use the same internal interface?
> > 
> > Because there are two partially overlapping classes wrt vector IO semantics:
> ...
> 
> Thanks for the detailed explanation.  It appears to boil down to a 
> series of historical accidents.
> 
> In any case, feel free to copy the non-isochronous behavior of the
> synchronous routines in the async routines.  It certainly won't hurt 
> anything.

Hmm...  What happens if f_fs.c successfully queues struct usb_request, returns
-EIOCBQUEUED and then gets hit by io_cancel(2)?  AFAICS, you get
ffs_aio_cancel() called, which dequeues usb_request and buggers off.
The thing is, freeing io_data and stuff hanging off it would be done by
ffs_user_copy_worker(), which would be scheduled via schedule_work() by
ffs_epfile_async_io_complete(), i.e. usb_request ->complete() callback.
And usb_ep_dequeue() (aka. ep->ops->dequeue()) has tons of instances, but
AFAICS some of them might not trigger usb_gadget_giveback_request(), which
would normally call ->complete()...

Example:
net2272_dequeue(struct usb_ep *_ep, struct usb_request *_req)
{
struct net2272_ep *ep;
struct net2272_request *req;
unsigned long flags;
int stopped;

ep = container_of(_ep, struct net2272_ep, ep);
if (!_ep || (!ep->desc && ep->num != 0) || !_req)
return -EINVAL;

spin_lock_irqsave(&ep->dev->lock, flags);
stopped = ep->stopped;
ep->stopped = 1;

/* make sure it's still queued on this endpoint */
list_for_each_entry(req, &ep->queue, queue) {
if (&req->req == _req)
break;
}
if (&req->req != _req) {
spin_unlock_irqrestore(&ep->dev->lock, flags);
return -EINVAL;
}

/* queue head may be partially complete */
if (ep->queue.next == &req->queue) {
dev_dbg(ep->dev->dev, "unlink (%s) pio\n", _ep->name);
net2272_done(ep, req, -ECONNRESET);
}
req = NULL;
ep->stopped = stopped;

spin_unlock_irqrestore(&ep->dev->lock, flags);
return 0;
}

Note that net2272_done(), which would call usb_gadget_giveback_request(),
is only called if the victim happens to be queue head.  Is that just a
net2272.c bug, or am I missing something subtle here?  Looks like
at least on that hardware io_cancel() could leak io_data and everything
that hangs off it...

FWIW, net2272.c was the first one I looked at (happened to be on the last
line of screen during git grep for \.dequeue in drivers/usb/gadget ;-)
and after checking several more it seems that it's a Sod's Law in action -
I'd checked about 5 of them and they seem to call usb_gadget_giveback_request()
as long as they find the sucker in queue, head or no head.  OTOH, there's
a lot more of those guys, so that observation is not worth much...

IOW, is that a net2272.c bug, or a f_fs.c one? 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] Documentation: dt-bindings: add dt binding info for hi6220

2015-02-05 Thread Zhangfei Gao
On 6 February 2015 at 02:24, Sergei Shtylyov
 wrote:
>> diff --git a/Documentation/devicetree/bindings/usb/hi6220-usb.txt
>> b/Documentation/devicetree/bindings/usb/hi6220-usb.txt
>> new file mode 100644
>> index 000..e926364
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/hi6220-usb.txt
>> @@ -0,0 +1,50 @@
>> +Hisilicon hi6220  SoC USB controlle
>
>
>Controller.
Yes, my mistake.
To prevent spelling error next time, will paste to google doc first
for the auto spelling check.

>
>> +-
>> +
>> +usb controller is inherited from dwc2, refer dwc2.txt
>> +-
>> +
>> +Required properties:
>> +- compatible: "hisilicon,hi6220-usb-phy"
>
>
>PHY? I thought you were describing the USB controller.
my bad
should be compatible: "hisilicon,hi6220-usb"

>
>> +Refer to dwc2.txt for dwc2 usb properties
>> +
>> +
>> +phy:
change to PHY:
>> +-
>> +
>> +Required properties:
>> +- compatible: "hisilicon,hi6220-usb-phy"
>> +- vcc-supply: phandle to the regulator that provides power to the PHY.
>> +- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
>
>
>Actually, it's phandle and clock specifier.
Change to
 - clocks: phandle and clock specifier of the PHY clock.

>
>> +  /bindings/clock/clock-bindings.txt
>> +- hisilicon,peripheral-syscon: phandle of syscon used to control
>> peripheral.
>> +- hisilicon,gpio_vbus_det: gpio of detecting vbus.
>> +- hisilicon,gpio_id_det: gpio of detecting id.
>
>
>Hyphens are preferred over underscores in the prop names.
Change to
- hisilicon,gpio-vbus-det: gpio of detecting vbus.
- hisilicon,gpio-id-det: gpio of detecting id.

Thanks Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 0/7] r8152: adjust the code

2015-02-05 Thread Hayes Wang
V2:
Correct the subject of patch #5. Replace "link feed" with "line feed".

v1:
Code adjustment.

Hayes Wang (7):
  r8152: adjust rx_bottom
  r8152: adjust lpm timer
  r8152: check linking status with netif_carrier_ok
  r8152: check RTL8152_UNPLUG for rtl8152_close
  r8152: adjust the line feed for hw_features
  r8152: replace get_protocol with vlan_get_protocol
  r8152: use BIT macro

 drivers/net/usb/r8152.c | 99 +++--
 1 file changed, 46 insertions(+), 53 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 1/7] r8152: adjust rx_bottom

2015-02-05 Thread Hayes Wang
If a error occurs when submitting rx, skip the remaining submissions
and try to submit them again next time.

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index b74a272..41a1cbc 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1643,7 +1643,7 @@ static int rx_bottom(struct r8152 *tp, int budget)
 {
unsigned long flags;
struct list_head *cursor, *next, rx_queue;
-   int work_done = 0;
+   int ret = 0, work_done = 0;
 
if (!skb_queue_empty(&tp->rx_queue)) {
while (work_done < budget) {
@@ -1734,7 +1734,18 @@ find_next_rx:
}
 
 submit:
-   r8152_submit_rx(tp, agg, GFP_ATOMIC);
+   if (!ret) {
+   ret = r8152_submit_rx(tp, agg, GFP_ATOMIC);
+   } else {
+   urb->actual_length = 0;
+   list_add_tail(&agg->list, next);
+   }
+   }
+
+   if (!list_empty(&rx_queue)) {
+   spin_lock_irqsave(&tp->rx_lock, flags);
+   list_splice_tail(&rx_queue, &tp->rx_done);
+   spin_unlock_irqrestore(&tp->rx_lock, flags);
}
 
 out1:
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 2/7] r8152: adjust lpm timer

2015-02-05 Thread Hayes Wang
Set LPM timer to 500us, except for RTL_VER_04 which doesn't link at
USB 3.0.

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 41a1cbc..ff122fa 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3256,10 +3256,10 @@ static void r8153_init(struct r8152 *tp)
 
ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_LPM_CTRL);
ocp_data &= ~LPM_TIMER_MASK;
-   if (tp->udev->speed == USB_SPEED_SUPER)
-   ocp_data |= LPM_TIMER_500US;
-   else
+   if (tp->version == RTL_VER_04 && tp->udev->speed != USB_SPEED_SUPER)
ocp_data |= LPM_TIMER_500MS;
+   else
+   ocp_data |= LPM_TIMER_500US;
ocp_write_byte(tp, MCU_TYPE_USB, USB_LPM_CTRL, ocp_data);
 
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_AFE_CTRL2);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 4/7] r8152: check RTL8152_UNPLUG for rtl8152_close

2015-02-05 Thread Hayes Wang
It is unnecessary to accress the hw register if the device is unplugged.

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 6667809..aade7b5 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3046,7 +3046,7 @@ static int rtl8152_close(struct net_device *netdev)
netif_stop_queue(netdev);
 
res = usb_autopm_get_interface(tp->intf);
-   if (res < 0) {
+   if (res < 0 || test_bit(RTL8152_UNPLUG, &tp->flags)) {
rtl_drop_queued_tx(tp);
rtl_stop_rx(tp);
} else {
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 5/7] r8152: adjust the line feed for hw_features

2015-02-05 Thread Hayes Wang
Keep NETIF_F_HW_VLAN_CTAG_RX and NETIF_F_HW_VLAN_CTAG_TX at the
same line.

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index aade7b5..8bdd477 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3908,8 +3908,7 @@ static int rtl8152_probe(struct usb_interface *intf,
netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG |
  NETIF_F_TSO | NETIF_F_FRAGLIST |
  NETIF_F_IPV6_CSUM | NETIF_F_TSO6 |
- NETIF_F_HW_VLAN_CTAG_RX |
- NETIF_F_HW_VLAN_CTAG_TX;
+ NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX;
netdev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
NETIF_F_HIGHDMA | NETIF_F_FRAGLIST |
NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 6/7] r8152: replace get_protocol with vlan_get_protocol

2015-02-05 Thread Hayes Wang
vlan_get_protocol() has been defined and use it to replace
get_protocol().

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 8bdd477..24e6aef9 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1330,18 +1330,6 @@ static struct tx_agg *r8152_get_tx_agg(struct r8152 *tp)
return agg;
 }
 
-static inline __be16 get_protocol(struct sk_buff *skb)
-{
-   __be16 protocol;
-
-   if (skb->protocol == htons(ETH_P_8021Q))
-   protocol = vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
-   else
-   protocol = skb->protocol;
-
-   return protocol;
-}
-
 /* r8152_csum_workaround()
  * The hw limites the value the transport offset. When the offset is out of the
  * range, calculate the checksum by sw.
@@ -1447,7 +1435,7 @@ static int r8152_tx_csum(struct r8152 *tp, struct tx_desc 
*desc,
goto unavailable;
}
 
-   switch (get_protocol(skb)) {
+   switch (vlan_get_protocol(skb)) {
case htons(ETH_P_IP):
opts1 |= GTSENDV4;
break;
@@ -1478,7 +1466,7 @@ static int r8152_tx_csum(struct r8152 *tp, struct tx_desc 
*desc,
goto unavailable;
}
 
-   switch (get_protocol(skb)) {
+   switch (vlan_get_protocol(skb)) {
case htons(ETH_P_IP):
opts2 |= IPV4_CS;
ip_protocol = ip_hdr(skb)->protocol;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 3/7] r8152: check linking status with netif_carrier_ok

2015-02-05 Thread Hayes Wang
Replace (tp->speed & LINK_STATUS) with netif_carrier_ok().

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index ff122fa..6667809 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -581,7 +581,6 @@ struct r8152 {
u16 ocp_base;
u8 *intr_buff;
u8 version;
-   u8 speed;
 };
 
 enum rtl_version {
@@ -1157,12 +1156,12 @@ static void intr_callback(struct urb *urb)
 
d = urb->transfer_buffer;
if (INTR_LINK & __le16_to_cpu(d[0])) {
-   if (!(tp->speed & LINK_STATUS)) {
+   if (!netif_carrier_ok(tp->netdev)) {
set_bit(RTL8152_LINK_CHG, &tp->flags);
schedule_delayed_work(&tp->schedule, 0);
}
} else {
-   if (tp->speed & LINK_STATUS) {
+   if (netif_carrier_ok(tp->netdev)) {
set_bit(RTL8152_LINK_CHG, &tp->flags);
schedule_delayed_work(&tp->schedule, 0);
}
@@ -1894,7 +1893,7 @@ static void rtl8152_set_rx_mode(struct net_device *netdev)
 {
struct r8152 *tp = netdev_priv(netdev);
 
-   if (tp->speed & LINK_STATUS) {
+   if (netif_carrier_ok(netdev)) {
set_bit(RTL8152_SET_RX_MODE, &tp->flags);
schedule_delayed_work(&tp->schedule, 0);
}
@@ -2918,21 +2917,20 @@ static void set_carrier(struct r8152 *tp)
speed = rtl8152_get_speed(tp);
 
if (speed & LINK_STATUS) {
-   if (!(tp->speed & LINK_STATUS)) {
+   if (!netif_carrier_ok(netdev)) {
tp->rtl_ops.enable(tp);
set_bit(RTL8152_SET_RX_MODE, &tp->flags);
netif_carrier_on(netdev);
rtl_start_rx(tp);
}
} else {
-   if (tp->speed & LINK_STATUS) {
+   if (netif_carrier_ok(netdev)) {
netif_carrier_off(netdev);
napi_disable(&tp->napi);
tp->rtl_ops.disable(tp);
napi_enable(&tp->napi);
}
}
-   tp->speed = speed;
 }
 
 static void rtl_work_func_t(struct work_struct *work)
@@ -2964,7 +2962,7 @@ static void rtl_work_func_t(struct work_struct *work)
 
/* don't schedule napi before linking */
if (test_bit(SCHEDULE_NAPI, &tp->flags) &&
-   (tp->speed & LINK_STATUS)) {
+   netif_carrier_ok(tp->netdev)) {
clear_bit(SCHEDULE_NAPI, &tp->flags);
napi_schedule(&tp->napi);
}
@@ -2987,8 +2985,7 @@ static int rtl8152_open(struct net_device *netdev)
if (res)
goto out;
 
-   /* set speed to 0 to avoid autoresume try to submit rx */
-   tp->speed = 0;
+   netif_carrier_off(netdev);
 
res = usb_autopm_get_interface(tp->intf);
if (res < 0) {
@@ -3005,7 +3002,7 @@ static int rtl8152_open(struct net_device *netdev)
cancel_delayed_work_sync(&tp->schedule);
 
/* disable the tx/rx, if the workqueue has enabled them. */
-   if (tp->speed & LINK_STATUS)
+   if (netif_carrier_ok(netdev))
tp->rtl_ops.disable(tp);
}
 
@@ -3014,7 +3011,6 @@ static int rtl8152_open(struct net_device *netdev)
rtl8152_set_speed(tp, AUTONEG_ENABLE,
  tp->mii.supports_gmii ? SPEED_1000 : SPEED_100,
  DUPLEX_FULL);
-   tp->speed = 0;
netif_carrier_off(netdev);
netif_start_queue(netdev);
set_bit(WORK_ENABLE, &tp->flags);
@@ -3340,7 +3336,7 @@ static int rtl8152_resume(struct usb_interface *intf)
rtl_runtime_suspend_enable(tp, false);
clear_bit(SELECTIVE_SUSPEND, &tp->flags);
set_bit(WORK_ENABLE, &tp->flags);
-   if (tp->speed & LINK_STATUS)
+   if (netif_carrier_ok(tp->netdev))
rtl_start_rx(tp);
} else {
tp->rtl_ops.up(tp);
@@ -3348,7 +3344,6 @@ static int rtl8152_resume(struct usb_interface *intf)
  tp->mii.supports_gmii ?
  SPEED_1000 : SPEED_100,
  DUPLEX_FULL);
-   tp->speed = 0;
netif_carrier_off(tp->netdev);
set_bit(WORK_ENABLE, &tp->flags);
}
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 7/7] r8152: use BIT macro

2015-02-05 Thread Hayes Wang
Use BIT macro to replace (1 << bits).

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 24e6aef9..5980ac6 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -489,16 +489,16 @@ struct rx_desc {
 #define RX_LEN_MASK0x7fff
 
__le32 opts2;
-#define RD_UDP_CS  (1 << 23)
-#define RD_TCP_CS  (1 << 22)
-#define RD_IPV6_CS (1 << 20)
-#define RD_IPV4_CS (1 << 19)
+#define RD_UDP_CS  BIT(23)
+#define RD_TCP_CS  BIT(22)
+#define RD_IPV6_CS BIT(20)
+#define RD_IPV4_CS BIT(19)
 
__le32 opts3;
-#define IPF(1 << 23) /* IP checksum fail */
-#define UDPF   (1 << 22) /* UDP checksum fail */
-#define TCPF   (1 << 21) /* TCP checksum fail */
-#define RX_VLAN_TAG(1 << 16)
+#define IPFBIT(23) /* IP checksum fail */
+#define UDPF   BIT(22) /* UDP checksum fail */
+#define TCPF   BIT(21) /* TCP checksum fail */
+#define RX_VLAN_TAGBIT(16)
 
__le32 opts4;
__le32 opts5;
@@ -507,24 +507,24 @@ struct rx_desc {
 
 struct tx_desc {
__le32 opts1;
-#define TX_FS  (1 << 31) /* First segment of a packet */
-#define TX_LS  (1 << 30) /* Final segment of a packet */
-#define GTSENDV4   (1 << 28)
-#define GTSENDV6   (1 << 27)
+#define TX_FS  BIT(31) /* First segment of a packet */
+#define TX_LS  BIT(30) /* Final segment of a packet */
+#define GTSENDV4   BIT(28)
+#define GTSENDV6   BIT(27)
 #define GTTCPHO_SHIFT  18
 #define GTTCPHO_MAX0x7fU
 #define TX_LEN_MAX 0x3U
 
__le32 opts2;
-#define UDP_CS (1 << 31) /* Calculate UDP/IP checksum */
-#define TCP_CS (1 << 30) /* Calculate TCP/IP checksum */
-#define IPV4_CS(1 << 29) /* Calculate IPv4 checksum */
-#define IPV6_CS(1 << 28) /* Calculate IPv6 checksum */
+#define UDP_CS BIT(31) /* Calculate UDP/IP checksum */
+#define TCP_CS BIT(30) /* Calculate TCP/IP checksum */
+#define IPV4_CSBIT(29) /* Calculate IPv4 checksum */
+#define IPV6_CSBIT(28) /* Calculate IPv6 checksum */
 #define MSS_SHIFT  17
 #define MSS_MAX0x7ffU
 #define TCPHO_SHIFT17
 #define TCPHO_MAX  0x7ffU
-#define TX_VLAN_TAG(1 << 16)
+#define TX_VLAN_TAGBIT(16)
 };
 
 struct r8152;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] usb: phy: load usb phy earlier

2015-02-05 Thread Peter Chen
On Thu, Feb 05, 2015 at 09:24:02PM +0800, Zhangfei Gao wrote:
> Since phy is definitely used in usb controller, load the phy
> earlier to make boot time shorter.
> 
> Signed-off-by: Zhangfei Gao 
> ---
>  drivers/usb/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
> index 2f1e2aa..d8926c6 100644
> --- a/drivers/usb/Makefile
> +++ b/drivers/usb/Makefile
> @@ -5,6 +5,7 @@
>  # Object files in subdirectories
>  
>  obj-$(CONFIG_USB)+= core/
> +obj-$(CONFIG_USB_SUPPORT)+= phy/
>  
>  obj-$(CONFIG_USB_DWC3)   += dwc3/
>  obj-$(CONFIG_USB_DWC2)   += dwc2/
> @@ -48,7 +49,6 @@ obj-$(CONFIG_USB_MICROTEK)  += image/
>  obj-$(CONFIG_USB_SERIAL) += serial/
>  
>  obj-$(CONFIG_USB)+= misc/
> -obj-$(CONFIG_USB_SUPPORT)+= phy/
>  obj-$(CONFIG_EARLY_PRINTK_DBGP)  += early/
>  
>  obj-$(CONFIG_USB_ATM)+= atm/
> -- 
> 1.9.1
> 

After thinking more, I think it is a good patch, USB PHY works proper
is the base for coming USB controller operation, with this patch,
it can avoid the controller drivers which are linked earlier than USB PHY
always being probed deferral, look at drivers/Makefile, it links drivers
follow the similar method.

Acked-by: Peter Chen 

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v4] ehci-pci: disable for Intel MID platforms (update)

2015-02-05 Thread Peter Chen
 
> 
> In this series no, but 'chipidea: pci: register nop PHY' from the other patch 
> if not
> queued yet. Thanks!
> 
> >

It is already at my next tree, will send Greg it soon.

Peter



Re: [PATCH v2] hso: Use static attribute groups for sysfs entry

2015-02-05 Thread David Miller
From: Takashi Iwai 
Date: Thu,  5 Feb 2015 11:15:24 +0100

> Pass the static attribute groups and the driver data via
> tty_port_register_device_attr() instead of manual device_create_file()
> and device_remove_file() calls.
> 
> Signed-off-by: Takashi Iwai 
> ---
> v1->v2: rebased to linux-next

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: dummy-hcd: Remove utf8 from format string

2015-02-05 Thread Rasmus Villemoes
Not everybody uses a utf8 locale (unfortunately), so let's avoid
non-ascii characters in the kernel log. Replace the 3-byte utf8
sequence with a 3-byte ascii equivalent.

Signed-off-by: Rasmus Villemoes 
---
 drivers/usb/gadget/udc/dummy_hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c 
b/drivers/usb/gadget/udc/dummy_hcd.c
index 9c598801404c..3a30b6583613 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -2626,7 +2626,7 @@ static int __init init(void)
return -EINVAL;
 
if (mod_data.num < 1 || mod_data.num > MAX_NUM_UDC) {
-   pr_err("Number of emulated UDC must be in range of 1…%d\n",
+   pr_err("Number of emulated UDC must be in range of 1...%d\n",
MAX_NUM_UDC);
return -EINVAL;
}
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Fwd: USB error -110, block shutdown

2015-02-05 Thread lesto fante
on multiple machine, from a multiple pc, when reading data from USB
port CDC driver (actually using arduino uno, arduino due,
stm32f3-discovery) i often get a

hub 1-3:1.0: hub_port_status failed (err = -110) [19953.337829] hub
1-3:1.0: hub_port_status failed (err = -110) [19958.344533] hub
1-3:1.0: hub_port_status failed (err = -110) [19963.351241] hub
1-3:1.0: hub_port_status failed (err = -110) [19968.357932] hub
1-3:1.0: hub_port_status failed (err = -110)and now also
[19947.028872] INFO: task CSteamControlle:967 blocked for more than
120 seconds. [19947.028876] Not tainted 3.18.2-2-ARCH #1
[19947.028878] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
disables this message. [19947.028880] CSteamControlle D
0002 0 967 850 0x2002 [19947.028883] 88009ab33d88
0086 8800b0f6c670 00013640 [19947.028886]
88009ab33fd8 00013640 8802341b8000 8800b0f6c670
[19947.02] 88009ab33cb8 88009ab33e38 88009ab33d58
811dd90a [19947.028890] Call Trace: [19947.028896]
[] ? do_last.isra.35+0x1ba/0xea0 [19947.028900]
[] ? mntput_no_expire+0x2c/0x160 [19947.028903]
[] schedule+0x29/0x70 [19947.028905]
[] schedule_preempt_disabled+0x16/0x20
[19947.028907] [] __mutex_lock_slowpath+0xd5/0x140
[19947.028909] [] mutex_lock+0x1b/0x30
[19947.028926] [] read_descriptors+0x40/0x110
[usbcore] [19947.028929] []
sysfs_kf_bin_read+0x47/0x70 [19947.028931] []
kernfs_fop_read+0x9d/0x160 [19947.028934] []
vfs_read+0x94/0x180 [19947.028936] []
SyS_read+0x59/0xd0 [19947.028938] []
cstar_dispatch+0x7/0x25 now if i try to run lsusb and usb-devices
freeze, and also if i shutdown the PC it will hung ouputting on loop
"hub 1-3:1.0: hub_port_status failed (err = -110)", a hard
reset/shutdown is required. now i bought a FTDI serial to usb chip and
this has not happen. i may do some debug/wireshark sniff if needed BTW
found some log from kernel some version older, was giving the same
problem but i always has some weird warining (follow) and even some
failed enumeration

[ 9810.374551] usb 2-1: new full-speed USB device number 32 using xhci_hcd

[ 9810.487773] usb 2-1: device descriptor read/64, error -71

[ 9810.590916] xhci_hcd :03:00.0: Setup ERROR: setup context
command for slot 1.

[ 9810.590930] usb 2-1: hub failed to enable device, error -22

[ 9810.697435] usb 2-1: new full-speed USB device number 33 using xhci_hcd

[ 9810.810657] usb 2-1: device descriptor read/64, error -71

[ 9810.913783] xhci_hcd :03:00.0: Setup ERROR: setup context
command for slot 1.

[ 9810.913796] usb 2-1: hub failed to enable device, error -22

[ 9811.020320] usb 2-1: new full-speed USB device number 34 using xhci_hcd

[ 9811.021453] usb 2-1: Device not responding to setup address.

[ 9811.225147] usb 2-1: Device not responding to setup address.

[ 9811.426369] usb 2-1: device not accepting address 34, error -71

[ 9811.532933] usb 2-1: new full-speed USB device number 35 using xhci_hcd

[ 9811.534723] usb 2-1: Device not responding to setup address.

[ 9811.773474] usb 2-1: ep 0x82 - rounding interval to 1024
microframes, ep desc says 2040 microframes

[ 9811.775403] cdc_acm 2-1:1.0: This device cannot do calls on its
own. It is not a modem.

[ 9811.775417] cdc_acm 2-1:1.0: ttyACM1: USB ACM device



"clean" lsusb -v

Bus 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass9 Hub
  bDeviceSubClass 0
  bDeviceProtocol 0 Full speed (or root) hub
  bMaxPacketSize064
  idVendor   0x1d6b Linux Foundation
  idProduct  0x0002 2.0 root hub
  bcdDevice3.18
  iManufacturer   3
  iProduct2
  iSerial 1
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   25
bNumInterfaces  1
bConfigurationValue 1
iConfiguration  0
bmAttributes 0xe0
  Self Powered
  Remote Wakeup
MaxPower0mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   1
  bInterfaceClass 9 Hub
  bInterfaceSubClass  0
  bInterfaceProtocol  0 Full speed (or root) hub
  iInterface  0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81  EP 1 IN
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0004  1x 4 bytes
bInterval  12

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Couldn't

[PATCH] uwb/whci: Delete an unnecessary check before the function call "umc_device_unregister"

2015-02-05 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 5 Feb 2015 21:40:29 +0100

The umc_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/uwb/whci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/uwb/whci.c b/drivers/uwb/whci.c
index 46b7cfc..c3ee39a 100644
--- a/drivers/uwb/whci.c
+++ b/drivers/uwb/whci.c
@@ -133,8 +133,7 @@ static void whci_del_cap(struct whci_card *card, int n)
 {
struct umc_dev *umc = card->devs[n];
 
-   if (umc != NULL)
-   umc_device_unregister(umc);
+   umc_device_unregister(umc);
 }
 
 static int whci_n_caps(struct pci_dev *pci)
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Payment

2015-02-05 Thread Finance Department
Dear Recipient,

You have been awarded the sum of  8,000,000.00 (Eight Million Pounds sterling) 
with reference number 77100146 by office of the ministry of finance UK.Send us 
your personal details to deliver your funds.

Gloria Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] usb: musb: Fix use for of_property_read_bool for disabled multipoint

2015-02-05 Thread Tony Lindgren
* Felipe Balbi  [150205 10:12]:
> On Thu, Feb 05, 2015 at 08:35:12AM -0800, Tony Lindgren wrote:
> > The value for the multipoint dts property is ignored when parsing with
> > of_property_read_bool, so we currently have multipoint always set as 1
> > even if value 0 is specified in the dts file.
> > 
> > Let's fix this to read the value too instead of just the property like
> > the binding documentation says as otherwise MUSB will fail to work
> > on devices with Mentor configuration that does not support multipoint.
> > 
> > Cc: Brian Hutchinson 
> > Signed-off-by: Tony Lindgren 
> 
> do you mind waiting a little bit to see if my boolean properties with
> value patch is accepted ?

This can wait for v3.20-rc1 for sure but cc stable would be nice to
avoid more pointless debugging by somebody else.
 
> http://marc.info/?l=linux-omap&m=142315930232743&w=2
> 
> At least let's see where the discussion moves.

Cool yeah at least a warning should be printed, sounds like it may
not be usable for fixing $subject though.

I also noticed that a last minute change I did from read_u32 to
read_u8 in $subject patch broke things and introduced new build
warnings. Here's a fixed version back to using read_u32 instead
of read_u8 so we don't need to specify the storage size with
/bits/ 8 values in the dts files.

Regards,

Tony

8< 
From: Tony Lindgren 
Date: Wed, 4 Feb 2015 06:28:49 -0800
Subject: [PATCH] usb: musb: Fix use for of_property_read_bool for disabled 
multipoint

The value for the multipoint dts property is ignored when parsing with
of_property_read_bool, so we currently have multipoint always set as 1
even if value 0 is specified in the dts file.

Let's fix this to read the value too instead of just the property like
the binding documentation says as otherwise MUSB will fail to work
on devices with Mentor configuration that does not support multipoint.

Cc: Brian Hutchinson 
Signed-off-by: Tony Lindgren 

--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -687,7 +687,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
struct musb_hdrc_config *config;
struct platform_device *musb;
struct device_node *dn = parent->dev.of_node;
-   int ret;
+   int ret, val;
 
memset(resources, 0, sizeof(resources));
res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc");
@@ -739,7 +739,10 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
pdata.mode = get_musb_port_mode(dev);
/* DT keeps this entry in mA, musb expects it as per USB spec */
pdata.power = get_int_prop(dn, "mentor,power") / 2;
-   config->multipoint = of_property_read_bool(dn, "mentor,multipoint");
+
+   ret = of_property_read_u32(dn, "mentor,multipoint", &val);
+   if (!ret && val)
+   config->multipoint = true;
 
ret = platform_device_add_data(musb, &pdata, sizeof(pdata));
if (ret) {
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -516,7 +516,7 @@ static int omap2430_probe(struct platform_device *pdev)
struct omap2430_glue*glue;
struct device_node  *np = pdev->dev.of_node;
struct musb_hdrc_config *config;
-   int ret = -ENOMEM;
+   int ret = -ENOMEM, val;
 
glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
if (!glue)
@@ -559,7 +559,10 @@ static int omap2430_probe(struct platform_device *pdev)
of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
of_property_read_u32(np, "power", (u32 *)&pdata->power);
-   config->multipoint = of_property_read_bool(np, "multipoint");
+
+   ret = of_property_read_u32(np, "multipoint", &val);
+   if (!ret && val)
+   config->multipoint = true;
 
pdata->board_data   = data;
pdata->config   = config;
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] Documentation: dt-bindings: add dt binding info for hi6220

2015-02-05 Thread Sergei Shtylyov

Hello.

On 02/05/2015 05:46 PM, Zhangfei Gao wrote:


Signed-off-by: Zhangfei Gao 
---
  .../devicetree/bindings/usb/hi6220-usb.txt | 50 ++
  1 file changed, 50 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/usb/hi6220-usb.txt



diff --git a/Documentation/devicetree/bindings/usb/hi6220-usb.txt 
b/Documentation/devicetree/bindings/usb/hi6220-usb.txt
new file mode 100644
index 000..e926364
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/hi6220-usb.txt
@@ -0,0 +1,50 @@
+Hisilicon hi6220  SoC USB controlle


   Controller.


+-
+
+usb controller is inherited from dwc2, refer dwc2.txt
+-
+
+Required properties:
+- compatible: "hisilicon,hi6220-usb-phy"


   PHY? I thought you were describing the USB controller.


+Refer to dwc2.txt for dwc2 usb properties
+
+
+phy:
+-
+
+Required properties:
+- compatible: "hisilicon,hi6220-usb-phy"
+- vcc-supply: phandle to the regulator that provides power to the PHY.
+- clocks: phandle to the PHY clock. Use as per Documentation/devicetree


   Actually, it's phandle and clock specifier.


+  /bindings/clock/clock-bindings.txt
+- hisilicon,peripheral-syscon: phandle of syscon used to control peripheral.
+- hisilicon,gpio_vbus_det: gpio of detecting vbus.
+- hisilicon,gpio_id_det: gpio of detecting id.


   Hyphens are preferred over underscores in the prop names.

[...]

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] usb: musb: Fix getting a generic phy for musb_dsps

2015-02-05 Thread Tony Lindgren
We still have a combination of legacy phys and generic phys in
use so we need to support both types of phy for musb_dsps.c.

Cc: Brian Hutchinson 
Signed-off-by: Tony Lindgren 
---
 drivers/usb/musb/musb_dsps.c | 17 +
 1 file changed, 17 insertions(+)

--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -457,12 +457,25 @@ static int dsps_musb_init(struct musb *musb)
if (IS_ERR(musb->xceiv))
return PTR_ERR(musb->xceiv);
 
+   musb->phy = devm_phy_get(dev->parent, "usb2-phy");
+
/* Returns zero if e.g. not clocked */
rev = dsps_readl(reg_base, wrp->revision);
if (!rev)
return -ENODEV;
 
usb_phy_init(musb->xceiv);
+   if (IS_ERR(musb->phy))  {
+   musb->phy = NULL;
+   } else {
+   ret = phy_init(musb->phy);
+   if (ret < 0)
+   return ret;
+   ret = phy_power_on(musb->phy);
+   if (ret)
+   return ret;
+   }
+
setup_timer(&glue->timer, otg_timer, (unsigned long) musb);
 
/* Reset the musb */
@@ -502,6 +515,10 @@ static int dsps_musb_exit(struct musb *musb)
 
del_timer_sync(&glue->timer);
usb_phy_shutdown(musb->xceiv);
+   if (musb->phy) {
+   phy_power_off(musb->phy);
+   phy_exit(musb->phy);
+   }
debugfs_remove_recursive(glue->dbgfs_root);
 
return 0;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] usb: musb: Fix use for of_property_read_bool for disabled multipoint

2015-02-05 Thread Felipe Balbi
On Thu, Feb 05, 2015 at 08:35:12AM -0800, Tony Lindgren wrote:
> The value for the multipoint dts property is ignored when parsing with
> of_property_read_bool, so we currently have multipoint always set as 1
> even if value 0 is specified in the dts file.
> 
> Let's fix this to read the value too instead of just the property like
> the binding documentation says as otherwise MUSB will fail to work
> on devices with Mentor configuration that does not support multipoint.
> 
> Cc: Brian Hutchinson 
> Signed-off-by: Tony Lindgren 

do you mind waiting a little bit to see if my boolean properties with
value patch is accepted ?

http://marc.info/?l=linux-omap&m=142315930232743&w=2

At least let's see where the discussion moves.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: fix sparse warnings

2015-02-05 Thread Felipe Balbi
On Thu, Feb 05, 2015 at 05:02:46PM +0200, Laurent Pinchart wrote:
> Hi Prabhakar,
> 
> Thank you for the patch.
> 
> On Thursday 05 February 2015 13:02:18 Lad Prabhakar wrote:
> > From: "Lad, Prabhakar" 
> > 
> > this patch fixes following sparse warnings:
> > 
> > uvc_video.c:283:5: warning: symbol 'uvcg_video_pump' was not declared.
> > Should it be static? uvc_video.c:342:5: warning: symbol 'uvcg_video_enable'
> > was not declared. Should it be static? uvc_video.c:381:5: warning: symbol
> > 'uvcg_video_init' was not declared. Should it be static?
> > 
> > Signed-off-by: Lad, Prabhakar 
> 
> Acked-by: Laurent Pinchart 
> 
> Felipe, could you please take this in your tree ?

my tree is closed for v3.20. I'll pick it up once -rc1 is out

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: dwc2: Register interrupt handler only once gadget is correctly initialized

2015-02-05 Thread Sergei Shtylyov

Hello.

On 02/05/2015 08:47 PM, Romain Perier wrote:


Don't register interrupt handler becore usb gadget is correctly initialized.


   s/becore/before/?


For some embedded platforms which don't have a usb-phy it crashes the driver
because an interrupt is emitted with non-initiliazed hardware.


   s/non-initiliazed/non-initialized/.


According to devm_request_irq documentation, an interrupt can be emitted
at any time once the interrupt is registered, so we have to care about driver
and hardware initialization.



Signed-off-by: Romain Perier 


[...]

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: dwc2: Register interrupt handler only once gadget is correctly initialized

2015-02-05 Thread Romain Perier
Don't register interrupt handler becore usb gadget is correctly initialized.
For some embedded platforms which don't have a usb-phy it crashes the driver
because an interrupt is emitted with non-initiliazed hardware.
According to devm_request_irq documentation, an interrupt can be emitted
at any time once the interrupt is registered, so we have to care about driver
and hardware initialization.

Signed-off-by: Romain Perier 
---
 drivers/usb/dwc2/platform.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index ae095f0..b26cf8c 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -196,14 +196,6 @@ static int dwc2_driver_probe(struct platform_device *dev)
return irq;
}
 
-   dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
-   irq);
-   retval = devm_request_irq(hsotg->dev, irq,
- dwc2_handle_common_intr, IRQF_SHARED,
- dev_name(hsotg->dev), hsotg);
-   if (retval)
-   return retval;
-
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
hsotg->regs = devm_ioremap_resource(&dev->dev, res);
if (IS_ERR(hsotg->regs))
@@ -237,6 +229,15 @@ static int dwc2_driver_probe(struct platform_device *dev)
retval = dwc2_gadget_init(hsotg, irq);
if (retval)
return retval;
+
+dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
+irq);
+retval = devm_request_irq(hsotg->dev, irq,
+dwc2_handle_common_intr, IRQF_SHARED,
+dev_name(hsotg->dev), hsotg);
+if (retval)
+return retval;
+
retval = dwc2_hcd_init(hsotg, irq, params);
if (retval)
return retval;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6 5/5] USB: gadget: atmel_usba_udc: Add suspend/resume with wakeup support

2015-02-05 Thread Nicolas Ferre
Le 22/01/2015 17:56, Sylvain Rochet a écrit :
> This patch add suspend/resume with wakeup support for Atmel USBA.
> 
> On suspend: We stay continuously clocked if Vbus signal is not
> available. If Vbus signal is available we set the Vbus signal as a wake
> up source then we stop the USBA itself and all clocks used by USBA.
> 
> On resume: We recover clocks and USBA if we stopped them. If a device is
> currently connected at resume time we enable the controller.
> 
> Signed-off-by: Sylvain Rochet 
> Acked-by: Boris Brezillon 
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 68 
> +
>  1 file changed, 68 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 361f740..7942c2f 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -2178,6 +2178,7 @@ static int usba_udc_probe(struct platform_device *pdev)
>   ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
>   if (ret)
>   return ret;
> + device_init_wakeup(&pdev->dev, 1);
>  
>   usba_init_debugfs(udc);
>   for (i = 1; i < udc->num_ep; i++)
> @@ -2193,6 +2194,7 @@ static int __exit usba_udc_remove(struct 
> platform_device *pdev)
>  
>   udc = platform_get_drvdata(pdev);
>  
> + device_init_wakeup(&pdev->dev, 0);
>   usb_del_gadget_udc(&udc->gadget);
>  
>   for (i = 1; i < udc->num_ep; i++)
> @@ -2202,10 +2204,76 @@ static int __exit usba_udc_remove(struct 
> platform_device *pdev)
>   return 0;
>  }
>  
> +#ifdef CONFIG_PM
> +static int usba_udc_suspend(struct device *dev)
> +{
> + struct usba_udc *udc = dev_get_drvdata(dev);
> +
> + /* Not started */
> + if (!udc->driver)
> + return 0;
> +
> + mutex_lock(&udc->vbus_mutex);
> +
> + if (!device_may_wakeup(dev)) {
> + usba_stop(udc);
> + goto out;
> + }
> +
> + /*
> +  * Device may wake up. We stay clocked if we failed
> +  * to request vbus irq, assuming always on.
> +  */
> + if (gpio_is_valid(udc->vbus_pin)) {
> + usba_stop(udc);
> + /* Only wake up on device connection */
> + if (udc->caps && udc->caps->irq_single_edge_support)
> + irq_set_irq_type(gpio_to_irq(udc->vbus_pin),
> + udc->vbus_pin_inverted ?
> + IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING);

As said earlier, let's try another approach for this.

Bye,

> +
> + enable_irq_wake(gpio_to_irq(udc->vbus_pin));
> + }
> +
> +out:
> + mutex_unlock(&udc->vbus_mutex);
> + return 0;
> +}
> +
> +static int usba_udc_resume(struct device *dev)
> +{
> + struct usba_udc *udc = dev_get_drvdata(dev);
> +
> + /* Not started */
> + if (!udc->driver)
> + return 0;
> +
> + if (device_may_wakeup(dev) && gpio_is_valid(udc->vbus_pin)) {
> + disable_irq_wake(gpio_to_irq(udc->vbus_pin));
> +
> + if (udc->caps && udc->caps->irq_single_edge_support)
> + irq_set_irq_type(gpio_to_irq(udc->vbus_pin),
> + IRQ_TYPE_EDGE_BOTH);
> + }
> +
> + /* If Vbus is present, enable the controller and wait for reset */
> + mutex_lock(&udc->vbus_mutex);
> + udc->vbus_prev = vbus_is_present(udc);
> + if (udc->vbus_prev)
> + usba_start(udc);
> + mutex_unlock(&udc->vbus_mutex);
> +
> + return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(usba_udc_pm_ops, usba_udc_suspend, usba_udc_resume);
> +
>  static struct platform_driver udc_driver = {
>   .remove = __exit_p(usba_udc_remove),
>   .driver = {
>   .name   = "atmel_usba_udc",
> + .pm = &usba_udc_pm_ops,
>   .of_match_table = of_match_ptr(atmel_udc_dt_ids),
>   },
>  };
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6 4/5] USB: gadget: atmel_usba_udc: Prepare for IRQ single edge support

2015-02-05 Thread Nicolas Ferre
Le 22/01/2015 18:14, Boris Brezillon a écrit :
> On Thu, 22 Jan 2015 17:56:44 +0100
> Sylvain Rochet  wrote:
> 
>> Renamed struct usba_udc_errata to struct usba_udc_caps, we are adding a
>> new property which is not about errata, this way the struct is not
>> misnamed.
>>
>> New struct usba_udc_caps property: irq_single_edge_support, boolean,
>> set to true if the board supports IRQ_TYPE_EDGE_FALLING and
>> IRQ_TYPE_EDGE_RISING, otherwise set to false.
>>
>> Signed-off-by: Sylvain Rochet 
> 
> Acked-by: Boris Brezillon 

Some comments:

>> ---
>>  drivers/usb/gadget/udc/atmel_usba_udc.c | 25 +++--
>>  drivers/usb/gadget/udc/atmel_usba_udc.h |  5 +++--
>>  2 files changed, 18 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
>> b/drivers/usb/gadget/udc/atmel_usba_udc.c
>> index d554106..361f740 100644
>> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
>> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
>> @@ -338,8 +338,8 @@ static int vbus_is_present(struct usba_udc *udc)
>>  
>>  static void toggle_bias(struct usba_udc *udc, int is_on)
>>  {
>> -if (udc->errata && udc->errata->toggle_bias)
>> -udc->errata->toggle_bias(udc, is_on);
>> +if (udc->caps && udc->caps->toggle_bias)
>> +udc->caps->toggle_bias(udc, is_on);
>>  }
>>  
>>  static void generate_bias_pulse(struct usba_udc *udc)
>> @@ -347,8 +347,8 @@ static void generate_bias_pulse(struct usba_udc *udc)
>>  if (!udc->bias_pulse_needed)
>>  return;
>>  
>> -if (udc->errata && udc->errata->pulse_bias)
>> -udc->errata->pulse_bias(udc);
>> +if (udc->caps && udc->caps->pulse_bias)
>> +udc->caps->pulse_bias(udc);
>>  
>>  udc->bias_pulse_needed = false;
>>  }
>> @@ -1901,18 +1901,23 @@ static void at91sam9g45_pulse_bias(struct usba_udc 
>> *udc)
>>  at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
>>  }
>>  
>> -static const struct usba_udc_errata at91sam9rl_errata = {
>> +static const struct usba_udc_caps at91sam9rl_caps = {
>>  .toggle_bias = at91sam9rl_toggle_bias,
>>  };
>>  
>> -static const struct usba_udc_errata at91sam9g45_errata = {
>> +static const struct usba_udc_caps at91sam9g45_caps = {
>>  .pulse_bias = at91sam9g45_pulse_bias,
>> +.irq_single_edge_support = true,

Nope! at91sam9g45 doesn't have this property. You'll have to create
another compatible string and capabilities structure
("atmel,at91sam9x5-udc")

But still, I don't know if it's the proper approach. The possibility tro
trigger an IRQ on both edges or a single edge is a capacity of the gpio
controller, not the USBA IP. So, it's a little bit strange to have this
capability here.

I don't know if it's actually feasible but trying to configure the IRQ
on a single edge, testing if it's accepted by the GPIO irq controller
and if not, falling back to a "both edge" pattern. Doesn't it look like
a way to workaround this issue nicely? Can you give it a try?

Bye,

>> +};
>> +
>> +static const struct usba_udc_caps sama5d3_caps = {
>> +.irq_single_edge_support = true,
>>  };
>>  
>>  static const struct of_device_id atmel_udc_dt_ids[] = {
>> -{ .compatible = "atmel,at91sam9rl-udc", .data = &at91sam9rl_errata },
>> -{ .compatible = "atmel,at91sam9g45-udc", .data = &at91sam9g45_errata },
>> -{ .compatible = "atmel,sama5d3-udc" },
>> +{ .compatible = "atmel,at91sam9rl-udc", .data = &at91sam9rl_caps },
>> +{ .compatible = "atmel,at91sam9g45-udc", .data = &at91sam9g45_caps },
>> +{ .compatible = "atmel,sama5d3-udc", .data = &sama5d3_caps },
>>  { /* sentinel */ }
>>  };
>>  
>> @@ -1934,7 +1939,7 @@ static struct usba_ep * atmel_udc_of_init(struct 
>> platform_device *pdev,
>>  if (!match)
>>  return ERR_PTR(-EINVAL);
>>  
>> -udc->errata = match->data;
>> +udc->caps = match->data;
>>  
>>  udc->num_ep = 0;
>>  
>> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
>> b/drivers/usb/gadget/udc/atmel_usba_udc.h
>> index 085749a..4fe4c87 100644
>> --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
>> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
>> @@ -304,9 +304,10 @@ struct usba_request {
>>  unsigned intmapped:1;
>>  };
>>  
>> -struct usba_udc_errata {
>> +struct usba_udc_caps {
>>  void (*toggle_bias)(struct usba_udc *udc, int is_on);
>>  void (*pulse_bias)(struct usba_udc *udc);
>> +bool irq_single_edge_support;
>>  };
>>  
>>  struct usba_udc {
>> @@ -322,7 +323,7 @@ struct usba_udc {
>>  struct usb_gadget gadget;
>>  struct usb_gadget_driver *driver;
>>  struct platform_device *pdev;
>> -const struct usba_udc_errata *errata;
>> +const struct usba_udc_caps *caps;
>>  int irq;
>>  int vbus_pin;
>>  int vbus_pin_inverted;
> 
> 
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://v

[PATCH 1/2] usb: musb: Fix use for of_property_read_bool for disabled multipoint

2015-02-05 Thread Tony Lindgren
The value for the multipoint dts property is ignored when parsing with
of_property_read_bool, so we currently have multipoint always set as 1
even if value 0 is specified in the dts file.

Let's fix this to read the value too instead of just the property like
the binding documentation says as otherwise MUSB will fail to work
on devices with Mentor configuration that does not support multipoint.

Cc: Brian Hutchinson 
Signed-off-by: Tony Lindgren 
---
 drivers/usb/musb/musb_dsps.c | 7 +--
 drivers/usb/musb/omap2430.c  | 7 +--
 2 files changed, 10 insertions(+), 4 deletions(-)

--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -687,7 +687,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
struct musb_hdrc_config *config;
struct platform_device *musb;
struct device_node *dn = parent->dev.of_node;
-   int ret;
+   int ret, val;
 
memset(resources, 0, sizeof(resources));
res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc");
@@ -739,7 +739,10 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
pdata.mode = get_musb_port_mode(dev);
/* DT keeps this entry in mA, musb expects it as per USB spec */
pdata.power = get_int_prop(dn, "mentor,power") / 2;
-   config->multipoint = of_property_read_bool(dn, "mentor,multipoint");
+
+   ret = of_property_read_u8(dn, "mentor,multipoint", &val);
+   if (!ret && val)
+   config->multipoint = true;
 
ret = platform_device_add_data(musb, &pdata, sizeof(pdata));
if (ret) {
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -516,7 +516,7 @@ static int omap2430_probe(struct platform_device *pdev)
struct omap2430_glue*glue;
struct device_node  *np = pdev->dev.of_node;
struct musb_hdrc_config *config;
-   int ret = -ENOMEM;
+   int ret = -ENOMEM, val;
 
glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
if (!glue)
@@ -559,7 +559,10 @@ static int omap2430_probe(struct platform_device *pdev)
of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
of_property_read_u32(np, "power", (u32 *)&pdata->power);
-   config->multipoint = of_property_read_bool(np, "multipoint");
+
+   ret = of_property_read_u8(np, "multipoint", &val);
+   if (!ret && val)
+   config->multipoint = true;
 
pdata->board_data   = data;
pdata->config   = config;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] MUSB fix for disabled multipoint and generic phy

2015-02-05 Thread Tony Lindgren
Hi,

Here are two fixes, the first one probably should be Cc stable.

Regards,

Tony


Tony Lindgren (2):
  usb: musb: Fix use for of_property_read_bool for disabled multipoint
  usb: musb: Fix getting a generic phy for musb_dsps

 drivers/usb/musb/musb_dsps.c | 24 ++--
 drivers/usb/musb/omap2430.c  |  7 +--
 2 files changed, 27 insertions(+), 4 deletions(-)

-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: OOPS: musb_am335x: __device_attach

2015-02-05 Thread Matwey V. Kornilov

The issue is still there for 3.19.0-rc7

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: whci-hcd: Delete an unnecessary check before the function call "usb_put_hcd"

2015-02-05 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 5 Feb 2015 16:54:12 +0100

The usb_put_hcd() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/usb/host/whci/hcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c
index d7b363a..43626c4 100644
--- a/drivers/usb/host/whci/hcd.c
+++ b/drivers/usb/host/whci/hcd.c
@@ -313,8 +313,7 @@ error_wusbhc_create:
uwb_rc_put(wusbhc->uwb_rc);
 error:
whc_clean_up(whc);
-   if (usb_hcd)
-   usb_put_hcd(usb_hcd);
+   usb_put_hcd(usb_hcd);
return ret;
 }
 
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: difference in option.ko and sierra.ko Linux drivers

2015-02-05 Thread Dan Williams
On Thu, 2015-02-05 at 07:33 -0800, Greg KH wrote:
> On Thu, Feb 05, 2015 at 07:36:40PM +0530, temp sha wrote:
> > You mean to say only Sierra has its own proprietary commands and no one 
> > else ?
> > What is so special about Sierra that requires a dedicated driver in
> > Linux while rest of
> > all vendors share the same option driver ? Does Sierra do something unique 
> > and
> > different from rest of all vendors?
> 
> Sierra does unique things for their chips, the driver source itself
> should explain this.

Yes, it has some specific commands for power control and a few other
functions.  While it is not extremely different than option, the Sierra
driver is currently meant to drive Sierra devices.

temp sha, what is the problem with using the Huawei device with the
option driver?  Is there a bug that prevents the device from working
there?  Every other non-Gobi/non-MBIM Huawei device is currently driven
by 'option' and I think yours should also be the same.

Dan

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ueagle-atm: Delete unnecessary checks before the function call "release_firmware"

2015-02-05 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 5 Feb 2015 16:33:09 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/usb/atm/ueagle-atm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 5a45937..888998a 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -952,7 +952,7 @@ static void uea_load_page_e1(struct work_struct *work)
int i;
 
/* reload firmware when reboot start and it's loaded already */
-   if (ovl == 0 && pageno == 0 && sc->dsp_firm) {
+   if (ovl == 0 && pageno == 0) {
release_firmware(sc->dsp_firm);
sc->dsp_firm = NULL;
}
@@ -1074,7 +1074,7 @@ static void uea_load_page_e4(struct work_struct *work)
uea_dbg(INS_TO_USBDEV(sc), "sending DSP page %u\n", pageno);
 
/* reload firmware when reboot start and it's loaded already */
-   if (pageno == 0 && sc->dsp_firm) {
+   if (pageno == 0) {
release_firmware(sc->dsp_firm);
sc->dsp_firm = NULL;
}
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: difference in option.ko and sierra.ko Linux drivers

2015-02-05 Thread Greg KH
On Thu, Feb 05, 2015 at 07:36:40PM +0530, temp sha wrote:
> You mean to say only Sierra has its own proprietary commands and no one else ?
> What is so special about Sierra that requires a dedicated driver in
> Linux while rest of
> all vendors share the same option driver ? Does Sierra do something unique and
> different from rest of all vendors?

Sierra does unique things for their chips, the driver source itself
should explain this.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] fs: remove ki_nbytes

2015-02-05 Thread Alan Stern
On Wed, 4 Feb 2015, Al Viro wrote:

> > > Um...  readv() is also going through ->aio_read().
> > 
> > Why does readv() do this but not read()?  Wouldn't it make more sense 
> > to have all the read* calls use the same internal interface?
> 
> Because there are two partially overlapping classes wrt vector IO semantics:
...

Thanks for the detailed explanation.  It appears to boil down to a 
series of historical accidents.

In any case, feel free to copy the non-isochronous behavior of the
synchronous routines in the async routines.  It certainly won't hurt 
anything.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: appledisplay: Deletion of a check before backlight_device_unregister()

2015-02-05 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 5 Feb 2015 16:07:43 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/usb/misc/appledisplay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index b3d245e..a0a3827 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -329,7 +329,7 @@ error:
pdata->urbdata, 
pdata->urb->transfer_dma);
usb_free_urb(pdata->urb);
}
-   if (pdata->bd && !IS_ERR(pdata->bd))
+   if (!IS_ERR(pdata->bd))
backlight_device_unregister(pdata->bd);
kfree(pdata->msgdata);
}
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: function/uvc_v4l2.c: fix sparse warnings

2015-02-05 Thread Laurent Pinchart
Hi Prabhakar,

Thank you for the patch.

On Thursday 05 February 2015 13:16:26 Lad Prabhakar wrote:
> From: "Lad, Prabhakar" 
> 
> this patch fixes following sparse warnings:
> 
> uvc_v4l2.c:264:29: warning: symbol 'uvc_v4l2_ioctl_ops' was not declared.
> Should it be static? uvc_v4l2.c:355:29: warning: symbol 'uvc_v4l2_fops' was
> not declared. Should it be static?
> 
> Signed-off-by: Lad, Prabhakar 

Acked-by: Laurent Pinchart 

Felipe, could you please take this in your tree ?

> ---
>  drivers/usb/gadget/function/uvc_v4l2.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/gadget/function/uvc_v4l2.c
> b/drivers/usb/gadget/function/uvc_v4l2.c index 5aad7fe..8b818fd 100644
> --- a/drivers/usb/gadget/function/uvc_v4l2.c
> +++ b/drivers/usb/gadget/function/uvc_v4l2.c
> @@ -27,6 +27,7 @@
>  #include "uvc.h"
>  #include "uvc_queue.h"
>  #include "uvc_video.h"
> +#include "uvc_v4l2.h"
> 
> /* -
>  * Requests handling

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: fix sparse warnings

2015-02-05 Thread Laurent Pinchart
Hi Prabhakar,

Thank you for the patch.

On Thursday 05 February 2015 13:02:18 Lad Prabhakar wrote:
> From: "Lad, Prabhakar" 
> 
> this patch fixes following sparse warnings:
> 
> uvc_video.c:283:5: warning: symbol 'uvcg_video_pump' was not declared.
> Should it be static? uvc_video.c:342:5: warning: symbol 'uvcg_video_enable'
> was not declared. Should it be static? uvc_video.c:381:5: warning: symbol
> 'uvcg_video_init' was not declared. Should it be static?
> 
> Signed-off-by: Lad, Prabhakar 

Acked-by: Laurent Pinchart 

Felipe, could you please take this in your tree ?

> ---
>  drivers/usb/gadget/function/uvc_video.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/gadget/function/uvc_video.c
> b/drivers/usb/gadget/function/uvc_video.c index 9cb86bc..50a5e63 100644
> --- a/drivers/usb/gadget/function/uvc_video.c
> +++ b/drivers/usb/gadget/function/uvc_video.c
> @@ -21,6 +21,7 @@
> 
>  #include "uvc.h"
>  #include "uvc_queue.h"
> +#include "uvc_video.h"
> 
>  /*
> --
> * Video codecs

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] usb: phy: add phy-hi6220

2015-02-05 Thread Zhangfei Gao
Add usb phy controller for hi6220 platform

Signed-off-by: Zhangfei Gao 
---
 drivers/usb/phy/Kconfig  |   9 ++
 drivers/usb/phy/Makefile |   1 +
 drivers/usb/phy/phy-hi6220.c | 290 +++
 3 files changed, 300 insertions(+)
 create mode 100644 drivers/usb/phy/phy-hi6220.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index c6d0c8e..405a3d0 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -173,6 +173,15 @@ config USB_MXS_PHY
 
  MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x.
 
+config USB_HI6220_PHY
+   tristate "hi6220 USB PHY support"
+   select USB_PHY
+   select MFD_SYSCON
+   help
+ Enable this to support the HISILICON HI6220 USB PHY.
+
+ To compile this driver as a module, choose M here.
+
 config USB_RCAR_PHY
tristate "Renesas R-Car USB PHY support"
depends on USB || USB_GADGET
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 75f2bba..819283c 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_SAMSUNG_USBPHY)  += phy-samsung-usb.o
 obj-$(CONFIG_TWL6030_USB)  += phy-twl6030-usb.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += phy-tegra-usb.o
 obj-$(CONFIG_USB_GPIO_VBUS)+= phy-gpio-vbus-usb.o
+obj-$(CONFIG_USB_HI6220_PHY)   += phy-hi6220.o
 obj-$(CONFIG_USB_ISP1301)  += phy-isp1301.o
 obj-$(CONFIG_USB_MSM_OTG)  += phy-msm-usb.o
 obj-$(CONFIG_USB_MV_OTG)   += phy-mv-usb.o
diff --git a/drivers/usb/phy/phy-hi6220.c b/drivers/usb/phy/phy-hi6220.c
new file mode 100644
index 000..87b1f0e
--- /dev/null
+++ b/drivers/usb/phy/phy-hi6220.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2015 Linaro Ltd.
+ * Copyright (c) 2015 Hisilicon Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SC_PERIPH_CTRL40x00c
+
+#define PERIPH_CTRL4_PICO_SIDDQBIT(6)
+#define PERIPH_CTRL4_PICO_OGDISABLEBIT(8)
+#define PERIPH_CTRL4_PICO_VBUSVLDEXT   BIT(10)
+#define PERIPH_CTRL4_PICO_VBUSVLDEXTSELBIT(11)
+#define PERIPH_CTRL4_OTG_PHY_SEL   BIT(21)
+
+#define SC_PERIPH_CTRL50x010
+
+#define PERIPH_CTRL5_USBOTG_RES_SELBIT(3)
+#define PERIPH_CTRL5_PICOPHY_ACAENBBIT(4)
+#define PERIPH_CTRL5_PICOPHY_BC_MODE   BIT(5)
+#define PERIPH_CTRL5_PICOPHY_CHRGSEL   BIT(6)
+#define PERIPH_CTRL5_PICOPHY_VDATSRCENDBIT(7)
+#define PERIPH_CTRL5_PICOPHY_VDATDETENBBIT(8)
+#define PERIPH_CTRL5_PICOPHY_DCDENBBIT(9)
+#define PERIPH_CTRL5_PICOPHY_IDDIG BIT(10)
+
+#define SC_PERIPH_CTRL80x018
+
+#define EYE_PATTERN_PARA   0x7053348c
+
+#define SC_PERIPH_RSTDIS0  0x304
+
+#define PERIPH_RSTDIS0_USBOTG_BUS  BIT(4)
+#define PERIPH_RSTDIS0_POR_PICOPHY BIT(5)
+#define PERIPH_RSTDIS0_USBOTG  BIT(6)
+#define PERIPH_RSTDIS0_USBOTG_32K  BIT(7)
+
+enum usb_mode {
+   USB_EMPTY,
+   GADGET_DEVICE,
+   OTG_HOST,
+};
+
+struct hi6220_priv {
+   struct usb_phy phy;
+   struct delayed_work work;
+   struct regmap *reg;
+   struct clk *clk;
+   struct regulator *vcc;
+   int gpio_vbus_det;
+   int gpio_id_det;
+   enum usb_mode mode;
+};
+
+static void hi6220_start_periphrals(struct hi6220_priv *priv, bool on)
+{
+   struct usb_otg *otg = priv->phy.otg;
+
+   if (!otg->gadget)
+   return;
+
+   if (on)
+   usb_gadget_connect(otg->gadget);
+   else
+   usb_gadget_disconnect(otg->gadget);
+}
+
+static void hi6220_detect_work(struct work_struct *work)
+{
+   struct hi6220_priv *priv =
+   container_of(work, struct hi6220_priv, work.work);
+   int id_det, vbus_det;
+   enum usb_mode mode;
+
+   if (!gpio_is_valid(priv->gpio_id_det) ||
+   !gpio_is_valid(priv->gpio_vbus_det))
+   return;
+
+   id_det = gpio_get_value_cansleep(priv->gpio_id_det);
+   vbus_det = gpio_get_value_cansleep(priv->gpio_vbus_det);
+
+   if (vbus_det == 0) {
+   if (id_det == 1)
+   mode = GADGET_DEVICE;
+   else
+   mode = OTG_HOST;
+   } else {
+   mode = USB_EMPTY;
+   }
+
+   if (mode == GADGET_DEVICE && priv->mode == USB_EMPTY)
+   hi6220_start_periphrals(priv, true);
+   if (mode == USB_EMPTY && priv->mode == GADGET_DEVICE)
+   hi6220_start_periphrals(priv, false);
+
+   priv->mode = mode;
+}
+
+static irqreturn_t hiusb_gpio_intr(int irq, void

[PATCH 3/4] usb: dwc2: platform: add hi6220 support

2015-02-05 Thread Zhangfei Gao
Signed-off-by: Zhangfei Gao 
---
 drivers/usb/dwc2/platform.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index ae095f0..ceee385 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -50,6 +50,34 @@
 
 static const char dwc2_driver_name[] = "dwc2";
 
+static const struct dwc2_core_params params_hi6220 = {
+   .otg_cap= 2,/* No HNP/SRP capable */
+   .otg_ver= 0,/* 1.3 */
+   .dma_enable = 1,
+   .dma_desc_enable= 0,
+   .speed  = 0,/* High Speed */
+   .enable_dynamic_fifo= 1,
+   .en_multiple_tx_fifo= 1,
+   .host_rx_fifo_size  = 512,
+   .host_nperio_tx_fifo_size   = 512,
+   .host_perio_tx_fifo_size= 512,
+   .max_transfer_size  = 65535,
+   .max_packet_count   = 511,
+   .host_channels  = 16,
+   .phy_type   = 1,/* UTMI */
+   .phy_utmi_width = 8,
+   .phy_ulpi_ddr   = 0,/* Single */
+   .phy_ulpi_ext_vbus  = 0,
+   .i2c_enable = 0,
+   .ulpi_fs_ls = 0,
+   .host_support_fs_ls_low_power   = 0,
+   .host_ls_low_power_phy_clk  = 0,/* 48 MHz */
+   .ts_dline   = 0,
+   .reload_ctl = 0,
+   .ahbcfg = 0x7 << GAHBCFG_HBSTLEN_SHIFT, /* 
INCR16 */
+   .uframe_sched   = 0,
+};
+
 static const struct dwc2_core_params params_bcm2835 = {
.otg_cap= 0,/* HNP/SRP capable */
.otg_ver= 0,/* 1.3 */
@@ -129,6 +157,7 @@ static int dwc2_driver_remove(struct platform_device *dev)
 
 static const struct of_device_id dwc2_of_match_table[] = {
{ .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 },
+   { .compatible = "hisilicon,hi6220-usb", .data = ¶ms_hi6220 },
{ .compatible = "rockchip,rk3066-usb", .data = ¶ms_rk3066 },
{ .compatible = "snps,dwc2", .data = NULL },
{ .compatible = "samsung,s3c6400-hsotg", .data = NULL},
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] Documentation: dt-bindings: add dt binding info for hi6220 dwc2

2015-02-05 Thread Zhangfei Gao
Add necessary dwc2 binding documentation for Hisilicon soc: hi6220

Signed-off-by: Zhangfei Gao 
---
 Documentation/devicetree/bindings/usb/dwc2.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
b/Documentation/devicetree/bindings/usb/dwc2.txt
index fd132cb..2213682 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -4,6 +4,7 @@ Platform DesignWare HS OTG USB 2.0 controller
 Required properties:
 - compatible : One of:
   - brcm,bcm2835-usb: The DWC2 USB controller instance in the BCM2835 SoC.
+  - hisilicon,hi6220-usb: The DWC2 USB controller instance in the hi6220 SoC.
   - rockchip,rk3066-usb: The DWC2 USB controller instance in the rk3066 Soc;
   - "rockchip,rk3188-usb", "rockchip,rk3066-usb", "snps,dwc2": for rk3188 Soc;
   - "rockchip,rk3288-usb", "rockchip,rk3066-usb", "snps,dwc2": for rk3288 Soc;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] Documentation: dt-bindings: add dt binding info for hi6220

2015-02-05 Thread Zhangfei Gao
Signed-off-by: Zhangfei Gao 
---
 .../devicetree/bindings/usb/hi6220-usb.txt | 50 ++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/hi6220-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/hi6220-usb.txt 
b/Documentation/devicetree/bindings/usb/hi6220-usb.txt
new file mode 100644
index 000..e926364
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/hi6220-usb.txt
@@ -0,0 +1,50 @@
+Hisilicon hi6220  SoC USB controlle
+-
+
+usb controller is inherited from dwc2, refer dwc2.txt
+-
+
+Required properties:
+- compatible: "hisilicon,hi6220-usb-phy"
+Refer to dwc2.txt for dwc2 usb properties
+
+
+phy:
+-
+
+Required properties:
+- compatible: "hisilicon,hi6220-usb-phy"
+- vcc-supply: phandle to the regulator that provides power to the PHY.
+- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
+  /bindings/clock/clock-bindings.txt
+- hisilicon,peripheral-syscon: phandle of syscon used to control peripheral.
+- hisilicon,gpio_vbus_det: gpio of detecting vbus.
+- hisilicon,gpio_id_det: gpio of detecting id.
+
+Example:
+
+   peripheral_ctrl: syscon@f703 {
+   compatible = "syscon";
+   reg = <0x0 0xf703 0x0 0x1000>;
+   };
+
+   usb2_phy: usbphy {
+   compatible = "hisilicon,hi6220-usb-phy";
+   vcc-supply = <&fixed_5v_hub>;
+   hisilicon,gpio_vbus_det = <&gpio2 6 0>;
+   hisilicon,gpio_id_det = <&gpio2 5 0>;
+   hisilicon,peripheral-syscon = <&peripheral_ctrl>;
+   clocks = <&clock_sys HI6220_USBOTG_HCLK>;
+   };
+
+   usb: usb@f72c {
+   compatible = "hisilicon,hi6220-usb";
+   reg = <0x0 0xf72c 0x0 0x4>;
+   phys = <&usb2_phy>;
+   dr_mode = "otg";
+   g-use-dma;
+   g-rx-fifo-size = <512>;
+   g-np-tx-fifo-size = <128>;
+   g-tx-fifo-size = <128>;
+   interrupts = <0 77 0x4>;
+   };
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] add usb support for hi6220

2015-02-05 Thread Zhangfei Gao
hi6220 usb controller is inherited from dwc2
add phy accordingly
support otg gadget/host

Zhangfei Gao (4):
  Documentation: dt-bindings: add dt binding info for hi6220 dwc2
  Documentation: dt-bindings: add dt binding info for hi6220
  usb: dwc2: platform: add hi6220 support
  usb: phy: add phy-hi6220

 Documentation/devicetree/bindings/usb/dwc2.txt |   1 +
 .../devicetree/bindings/usb/hi6220-usb.txt |  50 
 drivers/usb/dwc2/platform.c|  29 +++
 drivers/usb/phy/Kconfig|   8 +
 drivers/usb/phy/Makefile   |   1 +
 drivers/usb/phy/phy-hi6220.c   | 290 +
 6 files changed, 379 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/hi6220-usb.txt
 create mode 100644 drivers/usb/phy/phy-hi6220.c

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: difference in option.ko and sierra.ko Linux drivers

2015-02-05 Thread temp sha
You mean to say only Sierra has its own proprietary commands and no one else ?
What is so special about Sierra that requires a dedicated driver in
Linux while rest of
all vendors share the same option driver ? Does Sierra do something unique and
different from rest of all vendors?

Thanks

On Fri, Jan 30, 2015 at 12:19 AM, Dan Williams  wrote:
> On Thu, 2015-01-29 at 06:23 -0800, Greg KH wrote:
>> On Thu, Jan 29, 2015 at 02:50:13PM +0530, temp sha wrote:
>> > Can any one let me know the difference in option and sierra kernel
>> > modules ? looks like both drivers support GSM modem. And from the
>> > source code perspective both look similar. I am able to load sierra
>> > module for my Huawei USB dongle E156 and able to connect to internet
>> > using pppd. Is it OK to use sierra driver for Huawei in case there is
>> > no technical issue? If yes why there are two different modules?
>>
>> They support two different chipsets and control them differently.  If
>> the sierra module works for your hardware, great!  Please send us a
>> patch that adds the device id to the driver and we will be glad to merge
>> it into the kernel tree.
>
> I'd really, really rather not have non-Sierra devices controlled by
> 'sierra'.  There are some Sierra-specific things the driver does, like
> interface enumeration, enabling/disabling power state and NMEA ports
> using Sierra-proprietary commands, and a few other things.
>
> Since PPP-using Huawei devices are usually done by 'option', I'd prefer
> to have them added there, and if there is some issue, then I'd prefer to
> have that issue fixed in option.
>
> Dan
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] USB: gadget: f_mass_storage: use static attribute groups for sysfs entries

2015-02-05 Thread Takashi Iwai
Instead of manual device_create_file() and device_remove_file() calls,
assign the static attribute groups to the lun device to register.
The RO or RW permissions for some entries are decided in is_visible
callback.  This simplifies the code (also the logic) and avoids the
possible races, too.

Signed-off-by: Takashi Iwai 
---
 drivers/usb/gadget/function/f_mass_storage.c | 107 +--
 1 file changed, 33 insertions(+), 74 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 811929cd4c9e..49a2f19c2b87 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2624,13 +2624,10 @@ static ssize_t file_store(struct device *dev, struct 
device_attribute *attr,
return fsg_store_file(curlun, filesem, buf, count);
 }
 
-static DEVICE_ATTR_RW(ro);
 static DEVICE_ATTR_RW(nofua);
-static DEVICE_ATTR_RW(file);
-
-static struct device_attribute dev_attr_ro_cdrom = __ATTR_RO(ro);
-static struct device_attribute dev_attr_file_nonremovable = __ATTR_RO(file);
-
+/* mode wil be set in fsg_lun_attr_is_visible() */
+static DEVICE_ATTR(ro, 0, ro_show, ro_store);
+static DEVICE_ATTR(file, 0, file_show, file_store);
 
 /** FSG COMMON **/
 
@@ -2745,40 +2742,10 @@ error_release:
 }
 EXPORT_SYMBOL_GPL(fsg_common_set_num_buffers);
 
-static inline void fsg_common_remove_sysfs(struct fsg_lun *lun)
-{
-   device_remove_file(&lun->dev, &dev_attr_nofua);
-   /*
-* device_remove_file() =>
-*
-* here the attr (e.g. dev_attr_ro) is only used to be passed to:
-*
-*  sysfs_remove_file() =>
-*
-*  here e.g. both dev_attr_ro_cdrom and dev_attr_ro are in
-*  the same namespace and
-*  from here only attr->name is passed to:
-*
-*  sysfs_hash_and_remove()
-*
-*  attr->name is the same for dev_attr_ro_cdrom and
-*  dev_attr_ro
-*  attr->name is the same for dev_attr_file and
-*  dev_attr_file_nonremovable
-*
-* so we don't differentiate between removing e.g. dev_attr_ro_cdrom
-* and dev_attr_ro
-*/
-   device_remove_file(&lun->dev, &dev_attr_ro);
-   device_remove_file(&lun->dev, &dev_attr_file);
-}
-
 void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs)
 {
-   if (sysfs) {
-   fsg_common_remove_sysfs(lun);
+   if (sysfs)
device_unregister(&lun->dev);
-   }
fsg_lun_close(lun);
kfree(lun);
 }
@@ -2877,41 +2844,35 @@ int fsg_common_set_cdev(struct fsg_common *common,
 }
 EXPORT_SYMBOL_GPL(fsg_common_set_cdev);
 
-static inline int fsg_common_add_sysfs(struct fsg_common *common,
-  struct fsg_lun *lun)
-{
-   int rc;
+static struct attribute *fsg_lun_dev_attrs[] = {
+   &dev_attr_ro.attr,
+   &dev_attr_file.attr,
+   &dev_attr_nofua.attr,
+   NULL
+};
 
-   rc = device_register(&lun->dev);
-   if (rc) {
-   put_device(&lun->dev);
-   return rc;
-   }
+static umode_t fsg_lun_dev_is_visible(struct kobject *kobj,
+ struct attribute *attr, int idx)
+{
+   struct device *dev = kobj_to_dev(kobj);
+   struct fsg_lun *lun = fsg_lun_from_dev(dev);
 
-   rc = device_create_file(&lun->dev,
-   lun->cdrom
- ? &dev_attr_ro_cdrom
- : &dev_attr_ro);
-   if (rc)
-   goto error;
-   rc = device_create_file(&lun->dev,
-   lun->removable
- ? &dev_attr_file
- : &dev_attr_file_nonremovable);
-   if (rc)
-   goto error;
-   rc = device_create_file(&lun->dev, &dev_attr_nofua);
-   if (rc)
-   goto error;
+   if (attr == &dev_attr_ro.attr)
+   return lun->cdrom ? S_IRUGO : (S_IWUSR | S_IRUGO);
+   if (attr == &dev_attr_file.attr)
+   return lun->removable ? (S_IWUSR | S_IRUGO) : S_IRUGO;
+   return attr->mode;
+}
 
-   return 0;
+static const struct attribute_group fsg_lun_dev_group = {
+   .attrs = fsg_lun_dev_attrs,
+   .is_visible = fsg_lun_dev_is_visible,
+};
 
-error:
-   /* removing nonexistent files is a no-op */
-   fsg_common_remove_sysfs(lun);
-   device_unregister(&lun->dev);
-   return rc;
-}
+static const struct attribute_group *fsg_lun_dev_groups[] = {
+   &fsg_lun_dev_group,
+   NULL
+};
 
 int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config 
*cfg,
  unsigned int id, const char *name,
@@ -2949,13 +2910,15 @@ int fsg_common_create_lun(struct fsg_common *common, 
struct 

[PATCH 2/3] USB: serial: Handle the error from tty_register_device*()

2015-02-05 Thread Takashi Iwai
Signed-off-by: Takashi Iwai 
---
 drivers/usb/serial/bus.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index b730366d524f..4b34afc51535 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -80,8 +80,15 @@ static int usb_serial_device_probe(struct device *dev)
}
 
minor = port->minor;
-   tty_register_device_attr(usb_serial_tty_driver, minor, dev, NULL,
-usb_serial_dev_groups);
+   dev = tty_register_device_attr(usb_serial_tty_driver, minor, dev, NULL,
+  usb_serial_dev_groups);
+   if (IS_ERR(dev)) {
+   retval = PTR_ERR(dev);
+   if (driver->port_remove)
+   driver->port_remove(port);
+   goto exit_with_autopm;
+   }
+
dev_info(&port->serial->dev->dev,
 "%s converter now attached to ttyUSB%d\n",
 driver->description, minor);
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] USB: some device_create_file() removals

2015-02-05 Thread Takashi Iwai
Hi,

here are two patches cleaning up device_create_file() & co by
replacing with the static attribute groups, plus a patch to add the
missing error handling in usb serial driver.


Takashi

===

Takashi Iwai (3):
  USB: serial: use static attribute groups for sysfs entries
  USB: serial: Handle the error from tty_register_device*()
  USB: gadget: f_mass_storage: use static attribute groups for sysfs
entries

 drivers/usb/gadget/function/f_mass_storage.c | 107 +--
 drivers/usb/serial/bus.c |  20 +++--
 2 files changed, 46 insertions(+), 81 deletions(-)

-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] USB: serial: use static attribute groups for sysfs entries

2015-02-05 Thread Takashi Iwai
Instead of manual device_create_file() and device_remove_file() calls,
pass the static attribute groups to tty_register_device_attr().

Signed-off-by: Takashi Iwai 
---
 drivers/usb/serial/bus.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 9374bd2aba20..b730366d524f 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -47,6 +47,13 @@ static ssize_t port_number_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(port_number);
 
+static struct attribute *usb_serial_dev_attrs[] = {
+   &dev_attr_port_number.attr,
+   NULL
+};
+
+ATTRIBUTE_GROUPS(usb_serial_dev);
+
 static int usb_serial_device_probe(struct device *dev)
 {
struct usb_serial_driver *driver;
@@ -72,15 +79,9 @@ static int usb_serial_device_probe(struct device *dev)
goto exit_with_autopm;
}
 
-   retval = device_create_file(dev, &dev_attr_port_number);
-   if (retval) {
-   if (driver->port_remove)
-   retval = driver->port_remove(port);
-   goto exit_with_autopm;
-   }
-
minor = port->minor;
-   tty_register_device(usb_serial_tty_driver, minor, dev);
+   tty_register_device_attr(usb_serial_tty_driver, minor, dev, NULL,
+usb_serial_dev_groups);
dev_info(&port->serial->dev->dev,
 "%s converter now attached to ttyUSB%d\n",
 driver->description, minor);
@@ -114,8 +115,6 @@ static int usb_serial_device_remove(struct device *dev)
minor = port->minor;
tty_unregister_device(usb_serial_tty_driver, minor);
 
-   device_remove_file(&port->dev, &dev_attr_port_number);
-
driver = port->serial->type;
if (driver->port_remove)
retval = driver->port_remove(port);
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: MUSB dual-role on AM335x behaving weirdly

2015-02-05 Thread Maxime Ripard
Hi,

On Thu, Jan 22, 2015 at 08:37:45AM +0100, Yegor Yefremov wrote:
> I have the same experience with 3.15. The switching is working when
> CONFIG_USB_MUSB_DUAL_ROLE is set and dr_mode = "otg". But since 3.16
> it seems to be broken. Still had no time to bisect this.

I've been giving a few versions (from v3.15 to Tuesday's linux-next) a
try, and I always see the same behaviour now:

  - Booting as a gadget (ie, with a USB cable plugged in), and
swapping the cable for a (real, this time) USB OTG cable with a
USB key never works. When the device is plugged, all I get is

[  262.944846] usb 1-1: new high-speed USB device number 2 using musb-hdrc
[  278.064748] usb 1-1: device descriptor read/64, error -110

Putting in back in gadget results with a load of continuous:
[  315.258839] musb_bus_suspend 2484: trying to suspend as a_wait_vfall while 
active

  - Booting as a host, or with nothing connected to it actually work,
up to a few plug-a-device-then-plug-a-host cycles, where you end
up with the following logs when disconnecting the device (somehow,
it always happens when it is set in host mode).

[   12.969075] CAUTION: musb: Babble Interrupt Occurred
[   12.974445] CAUTION: musb: Babble Interrupt Occurred
[   12.979637] musb_stage0_irq 789: unhandled DISCONNECT transition 
(a_wait_bcon)
[   12.988498] usb 1-1: USB disconnect, device number 2
[   13.071849] musb-hdrc musb-hdrc.0.auto: Restarting MUSB to recover from 
Babble

Plugging back our USB cable, with the AM335x acting as a device
work once. Then, when it switches to the host mode, we end up with
the same scenario than in the coldplug as gadget case: USB read
error, before then having all the a_wait_vfall messages.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


[PATCH v2 2/2] usb: dwc2: gadget reuse ahbcfg assigned from platform

2015-02-05 Thread Zhangfei Gao
Gadget directly set GAHBCFG_HBSTLEN_INCR4, reuse ahbcfg if assigned from 
platform

Signed-off-by: Zhangfei Gao 
---
 drivers/usb/dwc2/core.c   | 2 +-
 drivers/usb/dwc2/gadget.c | 8 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index d5197d4..8d388cc 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -2563,7 +2563,7 @@ void dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, 
int val)
 
 void dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val)
 {
-   if (val != -1)
+   if (val)
hsotg->core_params->ahbcfg = val;
else
hsotg->core_params->ahbcfg = GAHBCFG_HBSTLEN_INCR4 <<
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 15aa578..82b520a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2314,9 +2314,13 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
GINTSTS_USBSUSP | GINTSTS_WKUPINT,
hsotg->regs + GINTMSK);
 
+   if (hsotg->core_params && hsotg->core_params->ahbcfg != -1)
+   val = hsotg->core_params->ahbcfg & ~GAHBCFG_CTRL_MASK;
+   else
+   val = GAHBCFG_HBSTLEN_INCR4 << GAHBCFG_HBSTLEN_SHIFT;
+
if (using_dma(hsotg))
-   writel(GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN |
-  (GAHBCFG_HBSTLEN_INCR4 << GAHBCFG_HBSTLEN_SHIFT),
+   writel(GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN | val,
   hsotg->regs + GAHBCFG);
else
writel(((hsotg->dedicated_fifos) ? (GAHBCFG_NP_TXF_EMP_LVL |
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/2] misc change

2015-02-05 Thread Zhangfei Gao
v2: 
remove parentheses mentioned by Sergei
assume @ahbcfg is used for dma case

Zhangfei Gao (2):
  usb: phy: load usb phy earlier
  usb: dwc2: gadget reuse ahbcfg assigned from platform

 drivers/usb/Makefile  | 2 +-
 drivers/usb/dwc2/core.c   | 2 +-
 drivers/usb/dwc2/gadget.c | 8 ++--
 3 files changed, 8 insertions(+), 4 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] usb: phy: load usb phy earlier

2015-02-05 Thread Zhangfei Gao
Since phy is definitely used in usb controller, load the phy
earlier to make boot time shorter.

Signed-off-by: Zhangfei Gao 
---
 drivers/usb/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 2f1e2aa..d8926c6 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -5,6 +5,7 @@
 # Object files in subdirectories
 
 obj-$(CONFIG_USB)  += core/
+obj-$(CONFIG_USB_SUPPORT)  += phy/
 
 obj-$(CONFIG_USB_DWC3) += dwc3/
 obj-$(CONFIG_USB_DWC2) += dwc2/
@@ -48,7 +49,6 @@ obj-$(CONFIG_USB_MICROTEK)+= image/
 obj-$(CONFIG_USB_SERIAL)   += serial/
 
 obj-$(CONFIG_USB)  += misc/
-obj-$(CONFIG_USB_SUPPORT)  += phy/
 obj-$(CONFIG_EARLY_PRINTK_DBGP)+= early/
 
 obj-$(CONFIG_USB_ATM)  += atm/
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: function/uvc_v4l2.c: fix sparse warnings

2015-02-05 Thread Lad Prabhakar
From: "Lad, Prabhakar" 

this patch fixes following sparse warnings:

uvc_v4l2.c:264:29: warning: symbol 'uvc_v4l2_ioctl_ops' was not declared. 
Should it be static?
uvc_v4l2.c:355:29: warning: symbol 'uvc_v4l2_fops' was not declared. Should it 
be static?

Signed-off-by: Lad, Prabhakar 
---
 drivers/usb/gadget/function/uvc_v4l2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/function/uvc_v4l2.c 
b/drivers/usb/gadget/function/uvc_v4l2.c
index 5aad7fe..8b818fd 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -27,6 +27,7 @@
 #include "uvc.h"
 #include "uvc_queue.h"
 #include "uvc_video.h"
+#include "uvc_v4l2.h"
 
 /* --
  * Requests handling
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: fix sparse warnings

2015-02-05 Thread Lad Prabhakar
From: "Lad, Prabhakar" 

this patch fixes following sparse warnings:

g_ffs.c:136:3: warning: symbol 'gfs_configurations' was not declared. Should it 
be static?
g_ffs.c:281:16: warning: Using plain integer as NULL pointer

Signed-off-by: Lad, Prabhakar 
---
 Found this issue on linux-next (gcc  version 4.9.2,
 sparse version  0.4.5-rc1)and applies on top linux-next.
 
 drivers/usb/gadget/legacy/g_ffs.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/legacy/g_ffs.c 
b/drivers/usb/gadget/legacy/g_ffs.c
index 06acfa5..b01b88e 100644
--- a/drivers/usb/gadget/legacy/g_ffs.c
+++ b/drivers/usb/gadget/legacy/g_ffs.c
@@ -133,7 +133,9 @@ struct gfs_configuration {
struct usb_configuration c;
int (*eth)(struct usb_configuration *c);
int num;
-} gfs_configurations[] = {
+};
+
+static struct gfs_configuration gfs_configurations[] = {
 #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
{
.eth= bind_rndis_config,
@@ -278,7 +280,7 @@ static void *functionfs_acquire_dev(struct ffs_dev *dev)
if (!try_module_get(THIS_MODULE))
return ERR_PTR(-ENOENT);

-   return 0;
+   return NULL;
 }
 
 static void functionfs_release_dev(struct ffs_dev *dev)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: fix sparse warnings

2015-02-05 Thread Lad Prabhakar
From: "Lad, Prabhakar" 

this patch fixes following sparse warnings:

uvc_video.c:283:5: warning: symbol 'uvcg_video_pump' was not declared. Should 
it be static?
uvc_video.c:342:5: warning: symbol 'uvcg_video_enable' was not declared. Should 
it be static?
uvc_video.c:381:5: warning: symbol 'uvcg_video_init' was not declared. Should 
it be static?

Signed-off-by: Lad, Prabhakar 
---
 drivers/usb/gadget/function/uvc_video.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/function/uvc_video.c 
b/drivers/usb/gadget/function/uvc_video.c
index 9cb86bc..50a5e63 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -21,6 +21,7 @@
 
 #include "uvc.h"
 #include "uvc_queue.h"
+#include "uvc_video.h"
 
 /* --
  * Video codecs
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2015-02-05 Thread Pali Rohár
On Monday 02 February 2015 20:14:35 Felipe Balbi wrote:
> On Mon, Feb 02, 2015 at 08:07:51PM +0100, Pali Rohár wrote:
> > On Monday 02 February 2015 20:01:11 Felipe Balbi wrote:
> > > Hi,
> > > 
> > > On Mon, Feb 02, 2015 at 07:58:59PM +0100, Pali Rohár wrote:
> > > > On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
> > > > > Hi,
> > > > > 
> > > > > On Sat, Jan 31, 2015 at 10:53:30AM +0100, Pali Rohár 
wrote:
> > > > > > This patch adds removable mass storage support to
> > > > > > g_nokia gadget (for N900). It means that at runtime
> > > > > > block device can be exported or unexported. So it
> > > > > > does not export anything by default and thus allows
> > > > > > to use MyDocs partition as before...
> > > > > > 
> > > > > > Signed-off-by: Pali Rohár 
> > > > > 
> > > > > thanks, but no thanks. Build your own using configfs.
> > > > 
> > > > But it needs some userspace interaction right?
> > > > Then its not possible for nfsboot.
> > > 
> > > oh, right... you're using nfsboot through g_nokia. Hmm,
> > > sounds like you need initramfs.
> > 
> > Also compiling usb gadgets as external .ko modules is
> > broken. So I cannot use configfs, when I compile g_nokia
> > even if I use initramfs...
> 
> yeah, there are people working on that and some patches
> already flying around for it. Meanwhile, you can make it
> built-in and use initramfs to add mass_storage through
> configfs to g_nokia, no issues.

Sorry but nfsboot is used without initramfs. I do not need to use 
any initramfs and I do not see reason for it because of kernel 
usb bugs...

My patch for mass storage mode in g_nokia.ko driver (which is 
used for Nokia N900 only) fix usage of both g_nokia functions and 
mass storage functions.

Because in current state on N900 this is easy and *working* 
solution (g_nokia static linked into zImage). So I do not see 
reason why not to include my patch into upstream. Driver g_nokia 
is N900 specific and all developers can benefit this patch, 
because they would be able to use *both* usb networking and mass 
storage mode *without* need to recompile kernel and restart n900 
device!

And please do not tell me that either usb network or mass storage 
support is deprecated or so and nobody should not use it! This is 
only way how to develop & debug n900 device without any other 
Nokia (TM) equipment which is not available for non Nokias...

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH 1/3] usb: gadget: function: phonet: balance usb_ep_disable calls

2015-02-05 Thread Pali Rohár
On Tuesday 03 February 2015 20:57:11 Pali Rohár wrote:
> On Tuesday 03 February 2015 20:35:25 Felipe Balbi wrote:
> > On Tue, Feb 03, 2015 at 08:27:52PM +0100, Pali Rohár wrote:
> > > On Tuesday 03 February 2015 20:18:59 Felipe Balbi wrote:
> > > > On Tue, Feb 03, 2015 at 05:17:28PM +0100, Pali Rohár 
wrote:
> > > > > On Tuesday 03 February 2015 16:43:45 Felipe Balbi 
wrote:
> > > > > > Hi,
> > > > > > 
> > > > > > On Tue, Feb 03, 2015 at 04:31:51PM +0100, Pali Rohár
> 
> wrote:
> > > > > > > On Tuesday 03 February 2015 00:15:19 Felipe Balbi
> 
> wrote:
> > > > > > > > f_phonet's ->set_alt() method will call
> > > > > > > > usb_ep_disable() potentially on an endpoint
> > > > > > > > which is already disabled. That's something the
> > > > > > > > gadget/function driver must guarantee that it's
> > > > > > > > always balanced.
> > > > > > > > 
> > > > > > > > In order to balance the calls, just make sure
> > > > > > > > the endpoint was enabled before by means of
> > > > > > > > checking the validity of driver_data.
> > > > > > > > 
> > > > > > > > Reported-by: Pali Rohár 
> > > > > > > > Signed-off-by: Felipe Balbi 
> > > > > > > > ---
> > > > > > > 
> > > > > > > Your patches cause that kernel does not print any
> > > > > > > error message to n900 screen anymore and reboot
> > > > > > > device in 10 seconds. I did not loaded any
> > > > > > > external modules.
> > > > > > 
> > > > > > > In qemu I see this crash in early boot:
> > > > > > alright, so n900's working fine. I'll wait until you
> > > > > > debug qemu a little more, thank you
> > > > > 
> > > > > NO! It does not working, see . It break n900
> > > > > totally!
> > > > 
> > > > settle down a bit more. I don't have the HW you have and
> > > > things are working fine on boards I _do_ have, there's
> > > > not much more I can do to help without you doing your
> > > > homework. Debug a bit more and bring more information
> > > > as to what's going on, until then you're on your own.
> > > 
> > > And what more do you need? It crash on my n900 and also in
> > > qemu. I sent you kernel crash dump from qemu which
> > > introduced *your* patches. Before applying your patches
> > > there was no crash in early boot stage.
> > > 
> > > In current state I review all 3 patches as:
> > > 
> > > Rejected-by: Pali Rohár 
> > > [It breaks booting Nokia N900 device]
> > 
> > next step, figure why it's broken. Working just fine here on
> > AM335x which has the same musb IP.
> 
> Why is broken? That is easy. You send 3 patches which broke
> it.

Actually when I reverted only that patch which adds line:

pm_runtime_irq_safe(musb->controller)

then early boot crash disappeared.

But other two patches did not fixed support for external .ko 
gadget modules. State is same -- crash after modprobe.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCHv6 2/5] USB: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ instead of an auto enabled IRQ request followed by IRQ disable

2015-02-05 Thread Nicolas Ferre
Le 22/01/2015 17:56, Sylvain Rochet a écrit :
> Vbus IRQ handler needs a started UDC driver to work because it uses
> udc->driver, which is set by the UDC start handler. The previous way
> chosen was to return from interrupt if udc->driver is NULL using a
> spinlock around the check.
> 
> We now request an auto disabled (IRQ_NOAUTOEN) Vbus signal IRQ instead
> of an auto enabled IRQ followed by disable_irq(). This way we remove the
> very small timeslot of enabled IRQ which existed previously between
> request() and disable(). We don't need anymore to check if udc->driver
> is NULL in IRQ handler.
> 
> Signed-off-by: Sylvain Rochet 
> Suggested-by: Boris Brezillon 
> Acked-by: Boris Brezillon 

Acked-by: Nicolas Ferre 

> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 9 ++---
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 40e5fc7..f9f305f 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -1745,10 +1745,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
>  
>   spin_lock(&udc->lock);
>  
> - /* May happen if Vbus pin toggles during probe() */
> - if (!udc->driver)
> - goto out;
> -
>   vbus = vbus_is_present(udc);
>   if (vbus != udc->vbus_prev) {
>   if (vbus) {
> @@ -1769,7 +1765,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
>   udc->vbus_prev = vbus;
>   }
>  
> -out:
>   spin_unlock(&udc->lock);
>  
>   return IRQ_HANDLED;
> @@ -2109,6 +2104,8 @@ static int usba_udc_probe(struct platform_device *pdev)
>  
>   if (gpio_is_valid(udc->vbus_pin)) {
>   if (!devm_gpio_request(&pdev->dev, udc->vbus_pin, 
> "atmel_usba_udc")) {
> + irq_set_status_flags(gpio_to_irq(udc->vbus_pin),
> + IRQ_NOAUTOEN);
>   ret = devm_request_irq(&pdev->dev,
>   gpio_to_irq(udc->vbus_pin),
>   usba_vbus_irq, 0,
> @@ -2118,8 +2115,6 @@ static int usba_udc_probe(struct platform_device *pdev)
>   dev_warn(&udc->pdev->dev,
>"failed to request vbus irq; "
>"assuming always on\n");
> - } else {
> - disable_irq(gpio_to_irq(udc->vbus_pin));
>   }
>   } else {
>   /* gpio_request fail so use -EINVAL for gpio_is_valid */
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


usb serial: pl2303 driver TxD "break" stays after close() bug

2015-02-05 Thread Jari Ruusu
Tested on 3.10.67 and 3.18.5 kernels with ATEN UC-232A usb-serial adapter.
No patch, sorry. To actually see the stuck "break" signal on TxD line, you
need either some sort of LED or voltmeter connected to the data transmit
line. Other RS-232 serial ports that I have access to (normal PC hardware
serial ports and FTDI usb-serial adapters) do not have this bug.


/* pl2303 TxD "break" stays after close() demo */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

int main(int argc, char **argv)
{
struct termios tt;
int fd;

if(argc < 2) {
fprintf(stderr, "usage: %s /dev/ttyUSB0\n", argv[0]);
exit(1);
}
if((fd = open(argv[1], O_RDWR | O_NOCTTY, 0)) == -1) {
perror("serial port open failed");
exit(1);
}
tcgetattr(fd, &tt);
cfmakeraw(&tt);
tcsetattr(fd, TCSANOW, &tt);
if(ioctl(fd, TIOCSBRK, 0) == -1) {
perror("set BRK failed");
exit(1);
}
close(fd);
exit(0);
}

-- 
Jari Ruusu  4096R/8132F189 12D6 4C3A DCDA 0AA4 27BD  ACDF F073 3C80 8132 F189
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] ehci-pci: disable for Intel MID platforms (update)

2015-02-05 Thread Andy Shevchenko
On Thu, 2015-02-05 at 01:21 +, Peter Chen wrote:
> So no patch I need to queue in chipidea tree, right?

In this series no, but 'chipidea: pci: register nop PHY' from the other
patch if not queued yet. Thanks!

> 
> For this patch:
> 
> Acked-by: Peter Chen 
> 
> Peter
> 


-- 
Andy Shevchenko 
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] hso: Use static attribute groups for sysfs entry

2015-02-05 Thread Takashi Iwai
Pass the static attribute groups and the driver data via
tty_port_register_device_attr() instead of manual device_create_file()
and device_remove_file() calls.

Signed-off-by: Takashi Iwai 
---
v1->v2: rebased to linux-next

 drivers/net/usb/hso.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 7833bd1d9791..6b8efcabb816 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -531,6 +531,13 @@ static ssize_t hso_sysfs_show_porttype(struct device *dev,
 }
 static DEVICE_ATTR(hsotype, S_IRUGO, hso_sysfs_show_porttype, NULL);
 
+static struct attribute *hso_serial_dev_attrs[] = {
+   &dev_attr_hsotype.attr,
+   NULL
+};
+
+ATTRIBUTE_GROUPS(hso_serial_dev);
+
 static int hso_urb_to_index(struct hso_serial *serial, struct urb *urb)
 {
int idx;
@@ -2236,9 +2243,6 @@ static int hso_stop_serial_device(struct hso_device 
*hso_dev)
 
 static void hso_serial_tty_unregister(struct hso_serial *serial)
 {
-   if (serial->parent->dev)
-   device_remove_file(serial->parent->dev, &dev_attr_hsotype);
-
tty_unregister_device(tty_drv, serial->minor);
 }
 
@@ -2274,11 +2278,10 @@ static int hso_serial_common_create(struct hso_serial 
*serial, int num_urbs,
goto exit;
 
/* register our minor number */
-   serial->parent->dev = tty_port_register_device(&serial->port, tty_drv,
-   minor, &serial->parent->interface->dev);
+   serial->parent->dev = tty_port_register_device_attr(&serial->port,
+   tty_drv, minor, &serial->parent->interface->dev,
+   serial->parent, hso_serial_dev_groups);
dev = serial->parent->dev;
-   dev_set_drvdata(dev, serial->parent);
-   i = device_create_file(dev, &dev_attr_hsotype);
 
/* fill in specific data for later use */
serial->minor = minor;
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] fs: remove ki_nbytes

2015-02-05 Thread Robert Baldyga
On 02/05/2015 10:03 AM, Al Viro wrote:
> On Thu, Feb 05, 2015 at 08:47:29AM +, Al Viro wrote:
>>  You are confusing datagram-per-syscall (which they are) with
>> datagram-per-iovec (which they are definitely not).  IOW, they behave
>> as UDP sockets - writev() is purely scatter-gather variant of write(),
>> with datagram per syscall and all vector elements silently concatenated.
>> That's class 2, and _not_ in its intersection with class 1.
> 
> PS: you want class 1, look at something like /proc/sys/kernel/domainname
> (or any other sysctl of that sort).  write "foobar" there and
> cat /proc/sys/kernel/domainname will print foorbat.  writev an array 
> consisting
> of "foo" and "bar", and you'll see bar afterwards, same as you would
> after writing first "foo", then "bar".  There the iovec boundaries affect
> the result - ->no aio_write() for that sucker, so we get two calls of
> ->write(), with expected results.  And there are character devices like that
> as well.  _That_ is class 1 outside of intersection with class 2.
> 

Oh, I see. Thanks.

So we only need to add endpoint halting to aio_read()/aio_write(), to
make their behaviour similar to sync ones, right?

Robert Baldyga
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] fs: remove ki_nbytes

2015-02-05 Thread Al Viro
On Thu, Feb 05, 2015 at 08:47:29AM +, Al Viro wrote:
>   You are confusing datagram-per-syscall (which they are) with
> datagram-per-iovec (which they are definitely not).  IOW, they behave
> as UDP sockets - writev() is purely scatter-gather variant of write(),
> with datagram per syscall and all vector elements silently concatenated.
> That's class 2, and _not_ in its intersection with class 1.

PS: you want class 1, look at something like /proc/sys/kernel/domainname
(or any other sysctl of that sort).  write "foobar" there and
cat /proc/sys/kernel/domainname will print foorbat.  writev an array consisting
of "foo" and "bar", and you'll see bar afterwards, same as you would
after writing first "foo", then "bar".  There the iovec boundaries affect
the result - ->no aio_write() for that sucker, so we get two calls of
->write(), with expected results.  And there are character devices like that
as well.  _That_ is class 1 outside of intersection with class 2.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: f_hid, f_mass_storage, and f_rdnis via configfs on platform/intel-mid

2015-02-05 Thread Andrzej Pietrasiewicz

W dniu 04.02.2015 o 15:33, Chris McClimans pisze:

Hi Andrzej,

Thank you for your time.

I'd like to take a stab at FunctionFS before I start looking at
backporting hid and uvc from 3.19+

I found a lot of information (mainly from you [1] [2]) on gadget
ConfigFS and hid, but I'm
having less luck finding information on FunctionFS and the required daemons.

On Thu, Jan 22, 2015 at 7:33 AM, Andrzej Pietrasiewicz
 wrote:


These days instead of gadgetfs one should probably use FunctionFS.
The purpose of the two is delegating actual usb function implementation
to userspace with some filesystem being the interface to the kernel.


It looks like I should be able to combine Ethernet, Mass Storage, and
HID this way.
(and it's supported all the way back to 3.10)
However I haven't found any ffs-daemon examples, including the
hid-daemon mentioned
in the kernel source.



Yeah, those are hypothetical userspace usb function drivers...
...some of which you are generously going to contribute to the open source
community ;-)

What I am aware of is a userspace program in Documentation/usb/gadget_hid.txt,
but it only uses hid's /dev node. Using hid's /dev node has nothing
to do with the way your gadget is composed. No matter how you compose
your gadget containing hid, you end up providing a /dev node and this
interface has nothing to do with FunctionFS.

By "ffs-daemon" I mean a userspace program which implements a USB function.

Example "ffs-daemons":

- tools/usb/ffs-test.c
- tools/usb/ffs-aio-example (using async io)
- https://android-review.googlesource.com/#/c/31640/ (my proof-of-concept
for converting adbd to using FunctionFS; actually as far as I know
it ended up with some changes in Android code base:
https://android.googlesource.com/platform/system/core/+/fd96db17b7f07eb6615af01fd1908b74383bf04b)
- http://www.spinics.net/lists/linux-usb/msg41962.html (PTP)
- http://www.spinics.net/lists/linux-usb/msg87093.html (another PTP)


Also I'm not quite sure how the loading g_ffs enables Ethernet in the docs.
Is g_ffs loaded after a g_multi that included Ethernet?


Not at all. You cannot have two gadgets active at the same time
unless you have at least two UDC/OTG (USB device controller) chips
in your Linux box acting as your USB gadget. And if you do have two
UDC chips then almost for sure each handles a separate USB cable
which is probably not what you want. I think you want a single
gadget which provides Ethernet _and_ FunctionFS.

Now some clarification.
g_ffs is a legacy gadget, whose composition is defined statically
in source code, as opposed to gadgets composed with configfs at runtime.
In its Kconfig entry it allows some flexibility: as a matter of fact
g_ffs is a composite gadget, which always contains FunctionFS proper and,
optionally, CDC ECM (Ethernet), and RNDIS (Ethernet).

A USB gadget contains one or more configurations, each configuration
groups a number of usb functions like Ethernet, Mass Storage, HID etc.
g_ffs can contain up to 3 configurations:

0) FunctionFS + RNDIS
1) FunctionFS + ECM
2) FunctionFS

Please note that a popular, proprietary operating system asks only
for the first configuration in any gadget.

So in order to have Ethernet and FunctionFS in g_ffs you need
to provide a suitable configuration. make menuconfig is your friend.

AP

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] fs: remove ki_nbytes

2015-02-05 Thread Al Viro
On Thu, Feb 05, 2015 at 09:24:32AM +0100, Robert Baldyga wrote:

> No, function/f_fs.c and legacy/inode.c are in class (1). They have
> datagram semantics - each vector element is submitted in separate USB
> request. Each single request is sent in separate USB data packet (for
> bulk endpoints it can be more than one packet). In fact sync
> read()/write() also will give different results while called once with
> some block of data or in loop with the same block of data splitted into
> a few parts.

No, they don't.  This is from ffs_epfile_io():

data = kmalloc(data_len, GFP_KERNEL);
if (unlikely(!data))
return -ENOMEM;
if (io_data->aio && !io_data->read) {
int i;
size_t pos = 0;
for (i = 0; i < io_data->nr_segs; i++) {
if (unlikely(copy_from_user(&data[pos],
 io_data->iovec[i].iov_base,
 io_data->iovec[i].iov_len))) {
ret = -EFAULT;
goto error;
}
pos += io_data->iovec[i].iov_len;
}

and that's the last point where it looks at iovec.  After that all work
is done to the copy in data, where no information about the boundaries
survives.  And ep_aio_write() (in legacy/inode.c) is the same way.

You are confusing datagram-per-syscall (which they are) with
datagram-per-iovec (which they are definitely not).  IOW, they behave
as UDP sockets - writev() is purely scatter-gather variant of write(),
with datagram per syscall and all vector elements silently concatenated.
That's class 2, and _not_ in its intersection with class 1.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] hso: Use static attribute groups for sysfs entry

2015-02-05 Thread David Miller
From: Takashi Iwai 
Date: Wed,  4 Feb 2015 14:39:33 +0100

> Pass the static attribute groups and the driver data via
> tty_port_register_device_attr() instead of manual device_create_file()
> and device_remove_file() calls.
> 
> Signed-off-by: Takashi Iwai 

This does not apply cleanly to the net-next tree, please respin.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] fs: remove ki_nbytes

2015-02-05 Thread Robert Baldyga
On 02/05/2015 12:07 AM, Al Viro wrote:
> On Wed, Feb 04, 2015 at 03:30:32PM -0500, Alan Stern wrote:
>>> * this one.  Note that you are not guaranteed that ep_config() won't
>>> be called more than once - two threads might race in write(2), with the 
>>> loser
>>> getting through mutex_lock_interruptible(&data->lock); in ep_config() only
>>> after the winner has already gotten through write(), switched ->f_op, 
>>> returned
>>> to userland and started doing read()/write()/etc.  If nothing else,
>>> the contents of data->desc and data->hs_desc can be buggered by arbitrary
>>> data, no matter how bogus, right as the first thread is doing IO.
>>
>> Well, this one certainly can be fixed to avoid altering ->f_op, at the 
>> cost of adding an extra check at the start of each I/O operation.
>  
>>> Um...  readv() is also going through ->aio_read().
>>
>> Why does readv() do this but not read()?  Wouldn't it make more sense 
>> to have all the read* calls use the same internal interface?
> 
> Because there are two partially overlapping classes wrt vector IO semantics:
>   1) datagram-style.  Vectored read/write is equivalent to simple
> read/write done on each vector component.  And IO boundaries matter - if
> your driver treats any write() as datagram that starts e.g. with
> fixed-sized table in the beginning + arbitrary amount of data following
> it, you will get very different results from write(fd, buf, 200) and
> writev(fd, (struct iovec[2]){{buf, 100}, {buf+100, 100}}, 2).  A _lot_ of
> drivers are like that - they supply ->read() and ->write() for single-range
> IO and VFS construct the rest of operations out of those.
> 
>   2) stream-style.  Vectored read is guaranteed to behave the same
> way as simple read on a range with size being the sum of vector element
> sizes, except that the data ends in ranges covered by vector elements instead
> of a single array.  Vectored write is guaranteed to behave the same way
> as simple write from a buffer containing the concatenation of ranges covered
> by vector elements.  Boundaries between the elements do not matter at all.
> Regular files on storage filesystems are like that.  So are FIFOs and pipes
> and so are sockets.  Even for datagram protocols, boundaries between the
> vector elements are ignored; boundaries between syscalls provide the datagram
> boundaries, but you can e.g. do writev(udp_socket_fd, (struct iovec[3]){
> {const_header, sizeof(const_header)}, {&n, 4}, {s, strlen(s)}}, 3) and have
> only one UDP packet sent.  IOW, it's general-purpose scatter-gather for read
> and write.
> 
>   The last example shows that (2) isn't a subset of (1) - it's not
> always possible to call ->write() in loop and get the right behaviour.
> For regular files (and pure stream sockets, etc.) it would work, but for
> stuff like UDP sockets it would break.  Moreover, even for regular files on
> storage filesystems it would be quite inefficient - we'd need to acquire and
> release a bunch of locks, poke through metadata, etc., for each segment.
> 
>   As the result, there was a couple of new methods added, inventively
> called ->readv() and ->writev().  do_sync_read() was supposed to be used
> as ->read() instance - it's "feed a single-element vector to ->readv()" and
> similar for s/read/write/.
> 
>   Note that both (1) and (2) satisfy the following sanity requirement -
> single-element readv() is always equivalent to single-element() read().  You
> could violate that, by providing completely unrelated ->read() and ->readv(),
> but very few drivers went for that - too insane.
> 
>   Then, when AIO had been added, those had grown an argument pointing
> to iocb (instead of file and ppos - for those we use iocb->ki_filp and
> &iocb->ki_pos resp.) and they got renamed into ->aio_read() and ->aio_write().
> Note that non-vectored AIO uses the same methods - ->read() and ->write() had
> too many instances to convert and most of those would end up just using those
> two iocb fields instead of the old arguments - tons of churn for no good
> reason.  ->readv() and ->writev() had fewer instances (very common was the
> use of generic_file_aio_{read,write}()) and conversion was less painful.
> So there was no ->aio_read() and ->aio_write().  That, in principle, was a
> bit of constraint - you couldn't make single-element AIO_PREADV behave
> different from AIO_PREAD, but nobody had been insane enough to ask for that.
> 
>   Moreover, keeping ->readv() and ->writev() was pointless. There is
> cheap way to tell whether ->aio_{read,write}() call is due to io_submit(2)
> or to readv()/writev() - is_sync_kiocb(iocb) tells which one it is, so if
> driver really wanted different semantics for sync vs. async, it could check
> that.
> 
>   So we ended up with ->read/->write for sync non-vectored and
> ->aio_read()/->aio_write() for sync vectored *and* async anything.  Usually
> you provide one or the other - NULL ->aio_... means loop calling ->read/write
> o