linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] media: dvbsky: use a single mutex and state buffers for all R/W ops
@ 2019-11-08 18:15 Andrei Koshkosh
  2019-11-08 18:22 ` Brüns, Stefan
  0 siblings, 1 reply; 5+ messages in thread
From: Andrei Koshkosh @ 2019-11-08 18:15 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Andrei Koshkosh, linux-media, Sean Young, Jan Pieter van Woerkom,
	Stefan Brüns, Greg Kroah-Hartman, Thomas Gleixner,
	linux-kernel

Signed-off-by: Andrei Koshkosh <andreykosh000@mail.ru>
---
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index c41e10b..7d36f5f 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -22,7 +22,6 @@ MODULE_PARM_DESC(disable_rc, "Disable inbuilt IR receiver.");
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct dvbsky_state {
-	struct mutex stream_mutex;
 	u8 ibuf[DVBSKY_BUF_LEN];
 	u8 obuf[DVBSKY_BUF_LEN];
 	u8 last_lock;
@@ -61,16 +60,18 @@ static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
 {
 	struct dvbsky_state *state = d_to_priv(d);
 	int ret;
-	u8 obuf_pre[3] = { 0x37, 0, 0 };
-	u8 obuf_post[3] = { 0x36, 3, 0 };
+	static u8 obuf_pre[3] = { 0x37, 0, 0 };
+	static u8 obuf_post[3] = { 0x36, 3, 0 };
 
-	mutex_lock(&state->stream_mutex);
-	ret = dvbsky_usb_generic_rw(d, obuf_pre, 3, NULL, 0);
+	mutex_lock(&d->usb_mutex);
+	memcpy(state->obuf, obuf_pre, 3);
+	ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
 	if (!ret && onoff) {
 		msleep(20);
-		ret = dvbsky_usb_generic_rw(d, obuf_post, 3, NULL, 0);
+		memcpy(state->obuf, obuf_post, 3);
+		ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
 	}
-	mutex_unlock(&state->stream_mutex);
+	mutex_unlock(&d->usb_mutex);
 	return ret;
 }
 
@@ -592,15 +593,7 @@ static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name)
 static int dvbsky_init(struct dvb_usb_device *d)
 {
 	struct dvbsky_state *state = d_to_priv(d);
-
-	/* use default interface */
-	/*
-	ret = usb_set_interface(d->udev, 0, 0);
-	if (ret)
-		return ret;
-	*/
-	mutex_init(&state->stream_mutex);
-
+	
 	state->last_lock = 0;
 
 	return 0;
-- 
2.7.4


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

* Re: [PATCH 1/1] media: dvbsky: use a single mutex and state buffers for all R/W ops
  2019-11-08 18:15 [PATCH 1/1] media: dvbsky: use a single mutex and state buffers for all R/W ops Andrei Koshkosh
@ 2019-11-08 18:22 ` Brüns, Stefan
  2019-11-08 19:15   ` JP
  0 siblings, 1 reply; 5+ messages in thread
From: Brüns, Stefan @ 2019-11-08 18:22 UTC (permalink / raw)
  To: Andrei Koshkosh
  Cc: Mauro Carvalho Chehab, linux-media, Sean Young,
	Jan Pieter van Woerkom, Greg Kroah-Hartman, Thomas Gleixner,
	linux-kernel

On Freitag, 8. November 2019 19:15:13 CET Andrei Koshkosh wrote:
> Signed-off-by: Andrei Koshkosh <andreykosh000@mail.ru>

Do not claim to be author of something you have not written.

This is mostly commit 7d95fb746c4e "media: dvbsky: use just one mutex for 
serializing device R/W ops" originally from Mauro and later reverted.

Regards,

Stefan

> ---
>  drivers/media/usb/dvb-usb-v2/dvbsky.c | 25 +++++++++----------------
>  1 file changed, 9 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c
> b/drivers/media/usb/dvb-usb-v2/dvbsky.c index c41e10b..7d36f5f 100644
> --- a/drivers/media/usb/dvb-usb-v2/dvbsky.c

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

* Re: [PATCH 1/1] media: dvbsky: use a single mutex and state buffers for all R/W ops
  2019-11-08 18:22 ` Brüns, Stefan
@ 2019-11-08 19:15   ` JP
  0 siblings, 0 replies; 5+ messages in thread
From: JP @ 2019-11-08 19:15 UTC (permalink / raw)
  To: Brüns, Stefan, Andrei Koshkosh
  Cc: Mauro Carvalho Chehab, linux-media, Sean Young,
	Greg Kroah-Hartman, Thomas Gleixner, linux-kernel



On 11/8/19 7:22 PM, Brüns, Stefan wrote:
> On Freitag, 8. November 2019 19:15:13 CET Andrei Koshkosh wrote:
>> Signed-off-by: Andrei Koshkosh <andreykosh000@mail.ru>
> Do not claim to be author of something you have not written.
>
> This is mostly commit 7d95fb746c4e "media: dvbsky: use just one mutex for
> serializing device R/W ops" originally from Mauro and later reverted.

See https://patchwork.linuxtv.org/patch/59590/
Apart from that,  this is allready in current linux_media tree.

Jan Pieter.


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

* Re: [PATCH 1/1] media: dvbsky: use a single mutex and state buffers for all R/W ops
  2019-09-29  8:04 Andrei Koshkosh
@ 2019-09-29 21:40 ` JP
  0 siblings, 0 replies; 5+ messages in thread
From: JP @ 2019-09-29 21:40 UTC (permalink / raw)
  To: Andrei Koshkosh, Mauro Carvalho Chehab
  Cc: linux-media, Sean Young, Stefan Brüns, Greg Kroah-Hartman,
	Thomas Gleixner, linux-kernel

This works very well for me.
(and please see unrelated comment below)

On 9/29/19 10:04 AM, Andrei Koshkosh wrote:
> Signed-off-by: Andrei Koshkosh <andreykosh000@mail.ru>
> ---
>   drivers/media/usb/dvb-usb-v2/dvbsky.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
> index c41e10b..6a118a0 100644
> --- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
> +++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
> @@ -22,7 +22,6 @@ MODULE_PARM_DESC(disable_rc, "Disable inbuilt IR receiver.");
>   DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
>   
>   struct dvbsky_state {
> -	struct mutex stream_mutex;
>   	u8 ibuf[DVBSKY_BUF_LEN];
>   	u8 obuf[DVBSKY_BUF_LEN];
>   	u8 last_lock;
> @@ -61,16 +60,18 @@ static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
>   {
>   	struct dvbsky_state *state = d_to_priv(d);
>   	int ret;
> -	u8 obuf_pre[3] = { 0x37, 0, 0 };
> -	u8 obuf_post[3] = { 0x36, 3, 0 };
> +	static u8 obuf_pre[3] = { 0x37, 0, 0 };
> +	static u8 obuf_post[3] = { 0x36, 3, 0 };
>   
> -	mutex_lock(&state->stream_mutex);
> -	ret = dvbsky_usb_generic_rw(d, obuf_pre, 3, NULL, 0);
> +	mutex_lock(&d->usb_mutex);
> +	memcpy(state->obuf, obuf_pre, 3);
> +	ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
>   	if (!ret && onoff) {
>   		msleep(20);
> -		ret = dvbsky_usb_generic_rw(d, obuf_post, 3, NULL, 0);
> +		memcpy(state->obuf, obuf_post, 3);
> +		ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
>   	}
> -	mutex_unlock(&state->stream_mutex);
> +	mutex_unlock(&d->usb_mutex);
>   	return ret;
>   }
>   
> @@ -599,7 +600,6 @@ static int dvbsky_init(struct dvb_usb_device *d)
>   	if (ret)
>   		return ret;
>   	*/
commented-out code has call to non-existing function.

> -	mutex_init(&state->stream_mutex);
>   
>   	state->last_lock = 0;
>   
Thanks,
Jan Pieter.

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

* [PATCH 1/1] media: dvbsky: use a single mutex and state buffers for all R/W ops
@ 2019-09-29  8:04 Andrei Koshkosh
  2019-09-29 21:40 ` JP
  0 siblings, 1 reply; 5+ messages in thread
From: Andrei Koshkosh @ 2019-09-29  8:04 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Andrei Koshkosh, linux-media, Sean Young, Jan Pieter van Woerkom,
	Stefan Brüns, Greg Kroah-Hartman, Thomas Gleixner,
	linux-kernel

Signed-off-by: Andrei Koshkosh <andreykosh000@mail.ru>
---
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index c41e10b..6a118a0 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -22,7 +22,6 @@ MODULE_PARM_DESC(disable_rc, "Disable inbuilt IR receiver.");
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct dvbsky_state {
-	struct mutex stream_mutex;
 	u8 ibuf[DVBSKY_BUF_LEN];
 	u8 obuf[DVBSKY_BUF_LEN];
 	u8 last_lock;
@@ -61,16 +60,18 @@ static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
 {
 	struct dvbsky_state *state = d_to_priv(d);
 	int ret;
-	u8 obuf_pre[3] = { 0x37, 0, 0 };
-	u8 obuf_post[3] = { 0x36, 3, 0 };
+	static u8 obuf_pre[3] = { 0x37, 0, 0 };
+	static u8 obuf_post[3] = { 0x36, 3, 0 };
 
-	mutex_lock(&state->stream_mutex);
-	ret = dvbsky_usb_generic_rw(d, obuf_pre, 3, NULL, 0);
+	mutex_lock(&d->usb_mutex);
+	memcpy(state->obuf, obuf_pre, 3);
+	ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
 	if (!ret && onoff) {
 		msleep(20);
-		ret = dvbsky_usb_generic_rw(d, obuf_post, 3, NULL, 0);
+		memcpy(state->obuf, obuf_post, 3);
+		ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
 	}
-	mutex_unlock(&state->stream_mutex);
+	mutex_unlock(&d->usb_mutex);
 	return ret;
 }
 
@@ -599,7 +600,6 @@ static int dvbsky_init(struct dvb_usb_device *d)
 	if (ret)
 		return ret;
 	*/
-	mutex_init(&state->stream_mutex);
 
 	state->last_lock = 0;
 
-- 
2.7.4


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

end of thread, other threads:[~2019-11-08 19:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 18:15 [PATCH 1/1] media: dvbsky: use a single mutex and state buffers for all R/W ops Andrei Koshkosh
2019-11-08 18:22 ` Brüns, Stefan
2019-11-08 19:15   ` JP
  -- strict thread matches above, loose matches on Subject: below --
2019-09-29  8:04 Andrei Koshkosh
2019-09-29 21:40 ` JP

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).