All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] media: fix USB control-request directions
@ 2021-05-21 13:28 Johan Hovold
  2021-05-21 13:28 ` [PATCH 1/2] media: dtv5100: fix " Johan Hovold
  2021-05-21 13:28 ` [PATCH 2/2] media: gspca/sq905: fix control-request direction Johan Hovold
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2021-05-21 13:28 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Hans Verkuil, linux-media, linux-usb, linux-kernel, Johan Hovold

The direction of the pipe argument must match the request-type
direction bit or USB control requests may fail depending on the
host-controller-driver implementation.

This series fixes two media driver that got this wrong.

Johan


Johan Hovold (2):
  media: dtv5100: fix control-request directions
  media: gspca/sq905: fix control-request direction

 drivers/media/usb/dvb-usb/dtv5100.c | 7 +++++--
 drivers/media/usb/gspca/sq905.c     | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

-- 
2.26.3


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

* [PATCH 1/2] media: dtv5100: fix control-request directions
  2021-05-21 13:28 [PATCH 0/2] media: fix USB control-request directions Johan Hovold
@ 2021-05-21 13:28 ` Johan Hovold
  2021-05-21 13:28 ` [PATCH 2/2] media: gspca/sq905: fix control-request direction Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2021-05-21 13:28 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Hans Verkuil, linux-media, linux-usb, linux-kernel, Johan Hovold, stable

The direction of the pipe argument must match the request-type direction
bit or control requests may fail depending on the host-controller-driver
implementation.

Fix the control requests which erroneously used usb_rcvctrlpipe().

Fixes: 8466028be792 ("V4L/DVB (8734): Initial support for AME DTV-5100 USB2.0 DVB-T")
Cc: stable@vger.kernel.org      # 2.6.28
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/media/usb/dvb-usb/dtv5100.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/dtv5100.c b/drivers/media/usb/dvb-usb/dtv5100.c
index fba06932a9e0..1c13e493322c 100644
--- a/drivers/media/usb/dvb-usb/dtv5100.c
+++ b/drivers/media/usb/dvb-usb/dtv5100.c
@@ -26,6 +26,7 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
 			   u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
 {
 	struct dtv5100_state *st = d->priv;
+	unsigned int pipe;
 	u8 request;
 	u8 type;
 	u16 value;
@@ -34,6 +35,7 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
 	switch (wlen) {
 	case 1:
 		/* write { reg }, read { value } */
+		pipe = usb_rcvctrlpipe(d->udev, 0);
 		request = (addr == DTV5100_DEMOD_ADDR ? DTV5100_DEMOD_READ :
 							DTV5100_TUNER_READ);
 		type = USB_TYPE_VENDOR | USB_DIR_IN;
@@ -41,6 +43,7 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
 		break;
 	case 2:
 		/* write { reg, value } */
+		pipe = usb_sndctrlpipe(d->udev, 0);
 		request = (addr == DTV5100_DEMOD_ADDR ? DTV5100_DEMOD_WRITE :
 							DTV5100_TUNER_WRITE);
 		type = USB_TYPE_VENDOR | USB_DIR_OUT;
@@ -54,7 +57,7 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
 
 	memcpy(st->data, rbuf, rlen);
 	msleep(1); /* avoid I2C errors */
-	return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), request,
+	return usb_control_msg(d->udev, pipe, request,
 			       type, value, index, st->data, rlen,
 			       DTV5100_USB_TIMEOUT);
 }
@@ -141,7 +144,7 @@ static int dtv5100_probe(struct usb_interface *intf,
 
 	/* initialize non qt1010/zl10353 part? */
 	for (i = 0; dtv5100_init[i].request; i++) {
-		ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+		ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				      dtv5100_init[i].request,
 				      USB_TYPE_VENDOR | USB_DIR_OUT,
 				      dtv5100_init[i].value,
-- 
2.26.3


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

* [PATCH 2/2] media: gspca/sq905: fix control-request direction
  2021-05-21 13:28 [PATCH 0/2] media: fix USB control-request directions Johan Hovold
  2021-05-21 13:28 ` [PATCH 1/2] media: dtv5100: fix " Johan Hovold
@ 2021-05-21 13:28 ` Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2021-05-21 13:28 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Hans Verkuil, linux-media, linux-usb, linux-kernel, Johan Hovold, stable

The direction of the pipe argument must match the request-type direction
bit or control requests may fail depending on the host-controller-driver
implementation.

Fix the USB_REQ_SYNCH_FRAME request which erroneously used
usb_sndctrlpipe().

Fixes: 27d35fc3fb06 ("V4L/DVB (10639): gspca - sq905: New subdriver.")
Cc: stable@vger.kernel.org      # 2.6.30
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/media/usb/gspca/sq905.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
index 949111070971..32504ebcfd4d 100644
--- a/drivers/media/usb/gspca/sq905.c
+++ b/drivers/media/usb/gspca/sq905.c
@@ -116,7 +116,7 @@ static int sq905_command(struct gspca_dev *gspca_dev, u16 index)
 	}
 
 	ret = usb_control_msg(gspca_dev->dev,
-			      usb_sndctrlpipe(gspca_dev->dev, 0),
+			      usb_rcvctrlpipe(gspca_dev->dev, 0),
 			      USB_REQ_SYNCH_FRAME,                /* request */
 			      USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 			      SQ905_PING, 0, gspca_dev->usb_buf, 1,
-- 
2.26.3


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

end of thread, other threads:[~2021-05-21 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 13:28 [PATCH 0/2] media: fix USB control-request directions Johan Hovold
2021-05-21 13:28 ` [PATCH 1/2] media: dtv5100: fix " Johan Hovold
2021-05-21 13:28 ` [PATCH 2/2] media: gspca/sq905: fix control-request direction Johan Hovold

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.