All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] CDC NCM: release interfaces fix in unbind()
@ 2011-05-15 20:28 Alexey Orishko
  2011-05-16 19:13 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Orishko @ 2011-05-15 20:28 UTC (permalink / raw)
  To: netdev; +Cc: linux-usb, davem, gregkh, oliver, Alexey Orishko

Signed-off-by: Alexey Orishko <alexey.orishko@stericsson.com>
---
 drivers/net/usb/cdc_ncm.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 4ab557d..500b1a6 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -54,7 +54,7 @@
 #include <linux/usb/usbnet.h>
 #include <linux/usb/cdc.h>
 
-#define	DRIVER_VERSION				"06-May-2011"
+#define	DRIVER_VERSION				"15-May-2011"
 
 /* CDC NCM subclass 3.2.1 */
 #define USB_CDC_NCM_NDP16_LENGTH_MIN		0x10
@@ -652,28 +652,25 @@ error:
 static void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
 	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
-	struct usb_driver *driver;
+	struct usb_driver *driver = driver_of(intf);
 
 	if (ctx == NULL)
 		return;		/* no setup */
 
-	driver = driver_of(intf);
-
-	usb_set_intfdata(ctx->data, NULL);
-	usb_set_intfdata(ctx->control, NULL);
-	usb_set_intfdata(ctx->intf, NULL);
-
 	/* release interfaces, if any */
 	if (ctx->data_claimed) {
+		usb_set_intfdata(ctx->data, NULL);
 		usb_driver_release_interface(driver, ctx->data);
 		ctx->data_claimed = 0;
 	}
 
 	if (ctx->control_claimed) {
+		usb_set_intfdata(ctx->control, NULL);
 		usb_driver_release_interface(driver, ctx->control);
 		ctx->control_claimed = 0;
 	}
 
+	usb_set_intfdata(ctx->intf, NULL);
 	cdc_ncm_free(ctx);
 }
 
-- 
1.7.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] CDC NCM: release interfaces fix in unbind()
  2011-05-15 20:28 [PATCH] CDC NCM: release interfaces fix in unbind() Alexey Orishko
@ 2011-05-16 19:13 ` David Miller
       [not found]   ` <20110516.151302.89070822321885499.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2011-05-16 19:13 UTC (permalink / raw)
  To: alexey.orishko; +Cc: netdev, linux-usb, gregkh, oliver, alexey.orishko

From: Alexey Orishko <alexey.orishko@gmail.com>
Date: Sun, 15 May 2011 22:28:27 +0200

> Signed-off-by: Alexey Orishko <alexey.orishko@stericsson.com>

I don't know about this.

The usb_set_intfdata() calls at cdc_ncm_bind() time are unconditional,
and are performed regardless of whether ->data_claimed or
->control_claimed are set.

So conditionalizing the setting of them to NULL here doesn't seem
right at all.

I'm not applying this patch.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] CDC NCM: release interfaces fix in unbind()
       [not found]   ` <20110516.151302.89070822321885499.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2011-05-17  0:52     ` Alexey ORISHKO
       [not found]       ` <2AC7D4AD8BA1C640B4C60C61C8E520153E3A93E8EE-8ZTw5gFVCTjVH5byLeRTJxkTb7+GphCuwzqs5ZKRSiY@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey ORISHKO @ 2011-05-17  0:52 UTC (permalink / raw)
  To: David Miller
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	gregkh-l3A5Bk7waGM, oliver-GvhC2dPhHPQdnm+yROfE0A

> The usb_set_intfdata() calls at cdc_ncm_bind() time are unconditional,
> and are performed regardless of whether ->data_claimed or
> ->control_claimed are set.
> 
> So conditionalizing the setting of them to NULL here doesn't seem
> right at all.
> 
> I'm not applying this patch.

Looks like I have to pay more attention to bind/unbind code as it was
copy-paste to some extent. Looking at cdc-acm and cdc_ether drivers,
there is no need to claim control (master) interface neither release it
in unbind().
Some confusion was added by other driver code that handles crippled
devices, which mix ctrl and data interfaces... Shall not be the case here.
I see, that some clean up can be done and "xxx_claimed" fields in context
structure can be removed, so will post a new version of patch shortly.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] CDC NCM: release interfaces fix in unbind()
       [not found]       ` <2AC7D4AD8BA1C640B4C60C61C8E520153E3A93E8EE-8ZTw5gFVCTjVH5byLeRTJxkTb7+GphCuwzqs5ZKRSiY@public.gmane.org>
@ 2011-05-17  6:26         ` Oliver Neukum
  0 siblings, 0 replies; 4+ messages in thread
From: Oliver Neukum @ 2011-05-17  6:26 UTC (permalink / raw)
  To: Alexey ORISHKO
  Cc: David Miller, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, gregkh-l3A5Bk7waGM

Am Dienstag, 17. Mai 2011, 02:52:34 schrieb Alexey ORISHKO:

> Some confusion was added by other driver code that handles crippled
> devices, which mix ctrl and data interfaces... Shall not be the case here.
> I see, that some clean up can be done and "xxx_claimed" fields in context
> structure can be removed, so will post a new version of patch shortly.

This code is a bit tricky in those drivers because you cannot assume a certain
order of calls to disconnect() w.r.t. the interfaces. If you claim multiple
interfaces, you need to release all other interfaces, as soon as any interface
is disconnected.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-17  6:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-15 20:28 [PATCH] CDC NCM: release interfaces fix in unbind() Alexey Orishko
2011-05-16 19:13 ` David Miller
     [not found]   ` <20110516.151302.89070822321885499.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2011-05-17  0:52     ` Alexey ORISHKO
     [not found]       ` <2AC7D4AD8BA1C640B4C60C61C8E520153E3A93E8EE-8ZTw5gFVCTjVH5byLeRTJxkTb7+GphCuwzqs5ZKRSiY@public.gmane.org>
2011-05-17  6:26         ` Oliver Neukum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.