All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hso: always read interface number from the current altsetting
@ 2015-02-17 10:31 Aleksander Morgado
       [not found] ` <1424169089-25039-1-git-send-email-aleksander-Dvg4H30XQSRVIjRurl1/8g@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Aleksander Morgado @ 2015-02-17 10:31 UTC (permalink / raw)
  To: j.dumon-x9gZzRpC1QbQT0dZR+AlfA
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	Aleksander Morgado

Always read bInterfaceNumber from the current altsetting, not from the first one
available in the altsetting array. This is coming from code review, not related
to any specific bug.

Signed-off-by: Aleksander Morgado <aleksander-Dvg4H30XQSRVIjRurl1/8g@public.gmane.org>
---
 drivers/net/usb/hso.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 9cdfb3f..3c8dfe5 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1477,6 +1477,7 @@ static void tiocmget_intr_callback(struct urb *urb)
 	struct uart_icount *icount;
 	struct hso_serial_state_notification *serial_state_notification;
 	struct usb_device *usb;
+	struct usb_interface *interface;
 	int if_num;
 
 	/* Sanity checks */
@@ -1494,7 +1495,9 @@ static void tiocmget_intr_callback(struct urb *urb)
 	BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM);
 
 	usb = serial->parent->usb;
-	if_num = serial->parent->interface->altsetting->desc.bInterfaceNumber;
+	interface = serial->parent->interface;
+
+	if_num = interface->cur_altsetting->desc.bInterfaceNumber;
 
 	/* wIndex should be the USB interface number of the port to which the
 	 * notification applies, which should always be the Modem port.
@@ -1675,6 +1678,7 @@ static int hso_serial_tiocmset(struct tty_struct *tty,
 	unsigned long flags;
 	int if_num;
 	struct hso_serial *serial = tty->driver_data;
+	struct usb_interface *interface;
 
 	/* sanity check */
 	if (!serial) {
@@ -1685,7 +1689,8 @@ static int hso_serial_tiocmset(struct tty_struct *tty,
 	if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM)
 		return -EINVAL;
 
-	if_num = serial->parent->interface->altsetting->desc.bInterfaceNumber;
+	interface = serial->parent->interface;
+	if_num = interface->cur_altsetting->desc.bInterfaceNumber;
 
 	spin_lock_irqsave(&serial->serial_lock, flags);
 	if (set & TIOCM_RTS)
@@ -2808,7 +2813,7 @@ static int hso_get_config_data(struct usb_interface *interface)
 {
 	struct usb_device *usbdev = interface_to_usbdev(interface);
 	u8 *config_data = kmalloc(17, GFP_KERNEL);
-	u32 if_num = interface->altsetting->desc.bInterfaceNumber;
+	u32 if_num = interface->cur_altsetting->desc.bInterfaceNumber;
 	s32 result;
 
 	if (!config_data)
@@ -2886,7 +2891,7 @@ static int hso_probe(struct usb_interface *interface,
 		return -ENODEV;
 	}
 
-	if_num = interface->altsetting->desc.bInterfaceNumber;
+	if_num = interface->cur_altsetting->desc.bInterfaceNumber;
 
 	/* Get the interface/port specification from either driver_info or from
 	 * the device itself */
-- 
2.3.0

--
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 related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hso: always read interface number from the current altsetting
       [not found] ` <1424169089-25039-1-git-send-email-aleksander-Dvg4H30XQSRVIjRurl1/8g@public.gmane.org>
@ 2015-02-20 20:21   ` David Miller
       [not found]     ` <20150220.152156.1455455304724247882.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2015-02-20 20:21 UTC (permalink / raw)
  To: aleksander-Dvg4H30XQSRVIjRurl1/8g
  Cc: j.dumon-x9gZzRpC1QbQT0dZR+AlfA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

From: Aleksander Morgado <aleksander-Dvg4H30XQSRVIjRurl1/8g@public.gmane.org>
Date: Tue, 17 Feb 2015 11:31:29 +0100

> Always read bInterfaceNumber from the current altsetting, not from the first one
> available in the altsetting array. This is coming from code review, not related
> to any specific bug.
> 
> Signed-off-by: Aleksander Morgado <aleksander-Dvg4H30XQSRVIjRurl1/8g@public.gmane.org>

Applied.
--
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] 3+ messages in thread

* Re: [PATCH] hso: always read interface number from the current altsetting
       [not found]     ` <20150220.152156.1455455304724247882.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2015-02-20 21:49       ` Alan Stern
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Stern @ 2015-02-20 21:49 UTC (permalink / raw)
  To: David Miller
  Cc: aleksander-Dvg4H30XQSRVIjRurl1/8g,
	j.dumon-x9gZzRpC1QbQT0dZR+AlfA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

On Fri, 20 Feb 2015, David Miller wrote:

> From: Aleksander Morgado <aleksander-Dvg4H30XQSRVIjRurl1/8g@public.gmane.org>
> Date: Tue, 17 Feb 2015 11:31:29 +0100
> 
> > Always read bInterfaceNumber from the current altsetting, not from the first one
> > available in the altsetting array. This is coming from code review, not related
> > to any specific bug.
> > 
> > Signed-off-by: Aleksander Morgado <aleksander-Dvg4H30XQSRVIjRurl1/8g@public.gmane.org>

It doesn't matter.  The bInterfaceNumber values are guaranteed to be 
the same for all altsettings in a particular interface, because of the 
way the altsetting arrays are constructed.

Alan Stern

--
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] 3+ messages in thread

end of thread, other threads:[~2015-02-20 21:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-17 10:31 [PATCH] hso: always read interface number from the current altsetting Aleksander Morgado
     [not found] ` <1424169089-25039-1-git-send-email-aleksander-Dvg4H30XQSRVIjRurl1/8g@public.gmane.org>
2015-02-20 20:21   ` David Miller
     [not found]     ` <20150220.152156.1455455304724247882.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2015-02-20 21:49       ` Alan Stern

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.