All of lore.kernel.org
 help / color / mirror / Atom feed
* w1/ds2490: fix excessive logging
@ 2022-03-11 19:28 Christian Vogel
  2022-03-11 19:28 ` [PATCH 1/2] w1/ds2490: remove spurious newlines within hexdump Christian Vogel
  2022-03-11 19:28 ` [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status & less verbose Christian Vogel
  0 siblings, 2 replies; 6+ messages in thread
From: Christian Vogel @ 2022-03-11 19:28 UTC (permalink / raw)
  To: greg, linux-kernel; +Cc: zbr, vogelchr

Two issues related to logging to the kernel-log are within w1/ds2490.

First, probably when automatically converting some logging to pr_info
it was overlooked that a lot of newlines are inserted.

Second by default ds2490 is excessively verbose on errors.

These two patches address the issues which were clogging up my harddisk
needlessly.



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

* [PATCH 1/2] w1/ds2490: remove spurious newlines within hexdump
  2022-03-11 19:28 w1/ds2490: fix excessive logging Christian Vogel
@ 2022-03-11 19:28 ` Christian Vogel
  2022-03-11 19:28 ` [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status & less verbose Christian Vogel
  1 sibling, 0 replies; 6+ messages in thread
From: Christian Vogel @ 2022-03-11 19:28 UTC (permalink / raw)
  To: greg, linux-kernel; +Cc: zbr, vogelchr

Multiple pr_infos generate newlines, so the hexdump looks like...

> 0x81: count=16, status:
> 01
> 00
> 20
(...16 lines...)

We switch to a single %*ph hexdump, using the built-in %ph format,
which leads to this:

	[52769.348789] usb 2-1.3.1: Clearing ep0x83.
	[52769.349729] usb 2-1.3.1: ep_status=0x81, count=16,...
		...status=01:00:20:40:05:04:04:00:20:53:00:00:00:00:00:00

Signed-off-by: Christian Vogel <vogelchr@vogel.cx>
---
 drivers/w1/masters/ds2490.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index cd8821580f71..f6664fc9596a 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -219,10 +219,8 @@ static void ds_dump_status(struct ds_device *dev, unsigned char *buf, int count)
 {
 	int i;
 
-	pr_info("0x%x: count=%d, status: ", dev->ep[EP_STATUS], count);
-	for (i = 0; i < count; ++i)
-		pr_info("%02x ", buf[i]);
-	pr_info("\n");
+	dev_info(&dev->udev->dev, "ep_status=0x%x, count=%d, status=%*phC",
+		dev->ep[EP_STATUS], count, count, buf);
 
 	if (count >= 16) {
 		ds_print_msg(buf, "enable flag", 0);
@@ -331,7 +329,7 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
 	err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]),
 				buf, size, &count, 1000);
 	if (err < 0) {
-		pr_info("Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]);
+		dev_info(&dev->udev->dev, "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]);
 		usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]));
 		ds_recv_status(dev, NULL, true);
 		return err;
-- 
2.35.1


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

* [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status & less verbose
  2022-03-11 19:28 w1/ds2490: fix excessive logging Christian Vogel
  2022-03-11 19:28 ` [PATCH 1/2] w1/ds2490: remove spurious newlines within hexdump Christian Vogel
@ 2022-03-11 19:28 ` Christian Vogel
  2022-03-18 13:06   ` Greg KH
  1 sibling, 1 reply; 6+ messages in thread
From: Christian Vogel @ 2022-03-11 19:28 UTC (permalink / raw)
  To: greg, linux-kernel; +Cc: zbr, vogelchr

The ds_recv_status function has a "dump" parameter that is used only
once, and mixes in extremely verbose debugging to the kernel log with
fetching the status registers.

Removing the logging from ds_recv_status(), making logging explitic at
the one place where it was used. Also decoding of the status register
is turned off by default, and a module parameter added to re-enable.

Signed-off-by: Christian Vogel <vogelchr@vogel.cx>
---
 Documentation/w1/masters/ds2490.rst |  7 +++++++
 drivers/w1/masters/ds2490.c         | 28 +++++++++++++++++++---------
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/Documentation/w1/masters/ds2490.rst b/Documentation/w1/masters/ds2490.rst
index 7e5b50f9c0f5..8aa455627aad 100644
--- a/Documentation/w1/masters/ds2490.rst
+++ b/Documentation/w1/masters/ds2490.rst
@@ -70,3 +70,10 @@ Notes and limitations.
   or the host OS and more likely the host OS.
 
 03-06-2008 David Fries <David@Fries.net>
+
+Kernel Parameter
+----------------
+
+A kernel parameter verbose_dump=1 can be added to make the module
+decode the status register on errors in a very verbose way. By default
+this verbose decode is turned off.
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index f6664fc9596a..354a35726967 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -120,6 +120,10 @@
 #define EP_DATA_OUT			2
 #define EP_DATA_IN			3
 
+static int verbose_dump;
+module_param(verbose_dump, int, 0644);
+MODULE_PARM_DESC(verbose_dump, "Generate a very verbose dump of the status registers on errors.");
+
 struct ds_device {
 	struct list_head	ds_entry;
 
@@ -222,6 +226,9 @@ static void ds_dump_status(struct ds_device *dev, unsigned char *buf, int count)
 	dev_info(&dev->udev->dev, "ep_status=0x%x, count=%d, status=%*phC",
 		dev->ep[EP_STATUS], count, count, buf);
 
+	if (!verbose_dump)
+		return;
+
 	if (count >= 16) {
 		ds_print_msg(buf, "enable flag", 0);
 		ds_print_msg(buf, "1-wire speed", 1);
@@ -266,8 +273,7 @@ static void ds_dump_status(struct ds_device *dev, unsigned char *buf, int count)
 	}
 }
 
-static int ds_recv_status(struct ds_device *dev, struct ds_status *st,
-			  bool dump)
+static int ds_recv_status(struct ds_device *dev, struct ds_status *st)
 {
 	int count, err;
 
@@ -286,9 +292,6 @@ static int ds_recv_status(struct ds_device *dev, struct ds_status *st,
 		return err;
 	}
 
-	if (dump)
-		ds_dump_status(dev, dev->st_buf, count);
-
 	if (st && count >= sizeof(*st))
 		memcpy(st, dev->st_buf, sizeof(*st));
 
@@ -329,9 +332,16 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
 	err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]),
 				buf, size, &count, 1000);
 	if (err < 0) {
+		int recv_len;
+
 		dev_info(&dev->udev->dev, "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]);
 		usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]));
-		ds_recv_status(dev, NULL, true);
+
+		/* status might tell us why endpoint is stuck? */
+		recv_len = ds_recv_status(dev, NULL);
+		if (recv_len >= 0)
+			ds_dump_status(dev, dev->st_buf, recv_len);
+
 		return err;
 	}
 
@@ -377,7 +387,7 @@ int ds_stop_pulse(struct ds_device *dev, int limit)
 		err = ds_send_control(dev, CTL_RESUME_EXE, 0);
 		if (err)
 			break;
-		err = ds_recv_status(dev, &st, false);
+		err = ds_recv_status(dev, &st);
 		if (err)
 			break;
 
@@ -424,7 +434,7 @@ static int ds_wait_status(struct ds_device *dev, struct ds_status *st)
 
 	do {
 		st->status = 0;
-		err = ds_recv_status(dev, st, false);
+		err = ds_recv_status(dev, st);
 #if 0
 		if (err >= 0) {
 			int i;
@@ -721,7 +731,7 @@ static void ds9490r_search(void *data, struct w1_master *master,
 	do {
 		schedule_timeout(jtime);
 
-		err = ds_recv_status(dev, &st, false);
+		err = ds_recv_status(dev, &st);
 		if (err < 0 || err < sizeof(st))
 			break;
 
-- 
2.35.1


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

* Re: [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status & less verbose
  2022-03-11 19:28 ` [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status & less verbose Christian Vogel
@ 2022-03-18 13:06   ` Greg KH
  2022-03-24 19:32     ` w1/ds2490: fix excessive logging Christian Vogel
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2022-03-18 13:06 UTC (permalink / raw)
  To: Christian Vogel; +Cc: linux-kernel, zbr

On Fri, Mar 11, 2022 at 08:28:33PM +0100, Christian Vogel wrote:
> The ds_recv_status function has a "dump" parameter that is used only
> once, and mixes in extremely verbose debugging to the kernel log with
> fetching the status registers.
> 
> Removing the logging from ds_recv_status(), making logging explitic at
> the one place where it was used. Also decoding of the status register
> is turned off by default, and a module parameter added to re-enable.
> 
> Signed-off-by: Christian Vogel <vogelchr@vogel.cx>
> ---
>  Documentation/w1/masters/ds2490.rst |  7 +++++++
>  drivers/w1/masters/ds2490.c         | 28 +++++++++++++++++++---------
>  2 files changed, 26 insertions(+), 9 deletions(-)
> 
> diff --git a/Documentation/w1/masters/ds2490.rst b/Documentation/w1/masters/ds2490.rst
> index 7e5b50f9c0f5..8aa455627aad 100644
> --- a/Documentation/w1/masters/ds2490.rst
> +++ b/Documentation/w1/masters/ds2490.rst
> @@ -70,3 +70,10 @@ Notes and limitations.
>    or the host OS and more likely the host OS.
>  
>  03-06-2008 David Fries <David@Fries.net>
> +
> +Kernel Parameter
> +----------------
> +
> +A kernel parameter verbose_dump=1 can be added to make the module
> +decode the status register on errors in a very verbose way. By default
> +this verbose decode is turned off.
> diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
> index f6664fc9596a..354a35726967 100644
> --- a/drivers/w1/masters/ds2490.c
> +++ b/drivers/w1/masters/ds2490.c
> @@ -120,6 +120,10 @@
>  #define EP_DATA_OUT			2
>  #define EP_DATA_IN			3
>  
> +static int verbose_dump;
> +module_param(verbose_dump, int, 0644);
> +MODULE_PARM_DESC(verbose_dump, "Generate a very verbose dump of the status registers on errors.");
> +
>  struct ds_device {
>  	struct list_head	ds_entry;
>  
> @@ -222,6 +226,9 @@ static void ds_dump_status(struct ds_device *dev, unsigned char *buf, int count)
>  	dev_info(&dev->udev->dev, "ep_status=0x%x, count=%d, status=%*phC",
>  		dev->ep[EP_STATUS], count, count, buf);
>  
> +	if (!verbose_dump)
> +		return;
> +

Please just turn all of these dev_info() lines into dev_dbg() and then
the kernel-wide dynamic debugging logic will be used instead of a custom
module parameter.

thanks,

greg k-h

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

* w1/ds2490: fix excessive logging
  2022-03-18 13:06   ` Greg KH
@ 2022-03-24 19:32     ` Christian Vogel
  2022-03-24 19:32       ` [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status, pr_ to dev_XXX logging Christian Vogel
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Vogel @ 2022-03-24 19:32 UTC (permalink / raw)
  To: greg, linux-kernel; +Cc: zbr, vogelchr

As suggested by Greg, I've sorted the many pr_info calls in ds2490
that were used for rather eclectic logging into dev_info/dev_debug
instead of my first attempt of introducing a module parameter. Now
debugging should cease for the normal configurations without DEBUG.

Only the first two lines will show up, and the status will not be
extensively decoded/commented.

kern  :info  : [293529.095345] usb 2-1.3.1: Clearing ep0x83.
kern  :info  : [293529.097271] usb 2-1.3.1: ep_status=0x81,
        count=16, status=01:00:20:40:05:04:04:00:20:53:00:00:00:00:00:00
kern  :debug : [293529.097282] usb 2-1.3.1: enable flag: 0x01
kern  :debug : [293529.097286] usb 2-1.3.1: 1-wire speed: 0x00
kern  :debug : [293529.097290] usb 2-1.3.1: strong pullup duration: 0x20
kern  :debug : [293529.097293] usb 2-1.3.1: programming pulse duration: 0x40
kern  :debug : [293529.097297] usb 2-1.3.1: pulldown slew rate control: 0x05
kern  :debug : [293529.097300] usb 2-1.3.1: write-1 low time: 0x04
kern  :debug : [293529.097304] usb 2-1.3.1: data sample offset/write-0 recovery time: 0x04
kern  :debug : [293529.097308] usb 2-1.3.1: reserved (test register): 0x00
kern  :debug : [293529.097311] usb 2-1.3.1: device status flags: 0x20
kern  :debug : [293529.097315] usb 2-1.3.1: communication command byte 1: 0x53
kern  :debug : [293529.097318] usb 2-1.3.1: communication command byte 2: 0x00
kern  :debug : [293529.097322] usb 2-1.3.1: communication command buffer status: 0x00
kern  :debug : [293529.097325] usb 2-1.3.1: 1-wire data output buffer status: 0x00
kern  :debug : [293529.097329] usb 2-1.3.1: 1-wire data input buffer status: 0x00




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

* [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status, pr_ to dev_XXX logging.
  2022-03-24 19:32     ` w1/ds2490: fix excessive logging Christian Vogel
@ 2022-03-24 19:32       ` Christian Vogel
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Vogel @ 2022-03-24 19:32 UTC (permalink / raw)
  To: greg, linux-kernel; +Cc: zbr, vogelchr

Changed all remaining pr_XXX calls that write out debugging info into
dev_XXX calls, changed the needlessly verbose decoding of status bits
into dev_dbg(), so that it's supressed by the logging levels by default.

Forthermore the ds_recv_status function has a "dump" parameter that
enables extremely verbose logging, and that's used only once.
This has been factored out, and called explicitly at that one place.

Signed-off-by: Christian Vogel <vogelchr@vogel.cx>
---
 drivers/w1/masters/ds2490.c | 124 +++++++++++++++++++-----------------
 1 file changed, 64 insertions(+), 60 deletions(-)

diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index f6664fc9596a..0eb560fc0153 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -172,8 +172,9 @@ static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index)
 	err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]),
 			CONTROL_CMD, VENDOR, value, index, NULL, 0, 1000);
 	if (err < 0) {
-		pr_err("Failed to send command control message %x.%x: err=%d.\n",
-				value, index, err);
+		dev_err(&dev->udev->dev,
+			"Failed to send command control message %x.%x: err=%d.\n",
+			value, index, err);
 		return err;
 	}
 
@@ -187,8 +188,9 @@ static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index)
 	err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]),
 			MODE_CMD, VENDOR, value, index, NULL, 0, 1000);
 	if (err < 0) {
-		pr_err("Failed to send mode control message %x.%x: err=%d.\n",
-				value, index, err);
+		dev_err(&dev->udev->dev,
+			"Failed to send mode control message %x.%x: err=%d.\n",
+			value, index, err);
 		return err;
 	}
 
@@ -202,72 +204,68 @@ static int ds_send_control(struct ds_device *dev, u16 value, u16 index)
 	err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]),
 			COMM_CMD, VENDOR, value, index, NULL, 0, 1000);
 	if (err < 0) {
-		pr_err("Failed to send control message %x.%x: err=%d.\n",
-				value, index, err);
+		dev_err(&dev->udev->dev,
+			"Failed to send control message %x.%x: err=%d.\n",
+			value, index, err);
 		return err;
 	}
 
 	return err;
 }
 
-static inline void ds_print_msg(unsigned char *buf, unsigned char *str, int off)
-{
-	pr_info("%45s: %8x\n", str, buf[off]);
-}
-
-static void ds_dump_status(struct ds_device *dev, unsigned char *buf, int count)
+static void ds_dump_status(struct ds_device *ds_dev, unsigned char *buf, int count)
 {
+	struct device *dev = &ds_dev->udev->dev;
 	int i;
 
-	dev_info(&dev->udev->dev, "ep_status=0x%x, count=%d, status=%*phC",
-		dev->ep[EP_STATUS], count, count, buf);
+	dev_info(dev, "ep_status=0x%x, count=%d, status=%*phC",
+		ds_dev->ep[EP_STATUS], count, count, buf);
 
 	if (count >= 16) {
-		ds_print_msg(buf, "enable flag", 0);
-		ds_print_msg(buf, "1-wire speed", 1);
-		ds_print_msg(buf, "strong pullup duration", 2);
-		ds_print_msg(buf, "programming pulse duration", 3);
-		ds_print_msg(buf, "pulldown slew rate control", 4);
-		ds_print_msg(buf, "write-1 low time", 5);
-		ds_print_msg(buf, "data sample offset/write-0 recovery time",
-			6);
-		ds_print_msg(buf, "reserved (test register)", 7);
-		ds_print_msg(buf, "device status flags", 8);
-		ds_print_msg(buf, "communication command byte 1", 9);
-		ds_print_msg(buf, "communication command byte 2", 10);
-		ds_print_msg(buf, "communication command buffer status", 11);
-		ds_print_msg(buf, "1-wire data output buffer status", 12);
-		ds_print_msg(buf, "1-wire data input buffer status", 13);
-		ds_print_msg(buf, "reserved", 14);
-		ds_print_msg(buf, "reserved", 15);
+		dev_dbg(dev, "enable flag: 0x%02x", buf[0]);
+		dev_dbg(dev, "1-wire speed: 0x%02x", buf[1]);
+		dev_dbg(dev, "strong pullup duration: 0x%02x", buf[2]);
+		dev_dbg(dev, "programming pulse duration: 0x%02x", buf[3]);
+		dev_dbg(dev, "pulldown slew rate control: 0x%02x", buf[4]);
+		dev_dbg(dev, "write-1 low time: 0x%02x", buf[5]);
+		dev_dbg(dev, "data sample offset/write-0 recovery time: 0x%02x", buf[6]);
+		dev_dbg(dev, "reserved (test register): 0x%02x", buf[7]);
+		dev_dbg(dev, "device status flags: 0x%02x", buf[8]);
+		dev_dbg(dev, "communication command byte 1: 0x%02x", buf[9]);
+		dev_dbg(dev, "communication command byte 2: 0x%02x", buf[10]);
+		dev_dbg(dev, "communication command buffer status: 0x%02x", buf[11]);
+		dev_dbg(dev, "1-wire data output buffer status: 0x%02x", buf[12]);
+		dev_dbg(dev, "1-wire data input buffer status: 0x%02x", buf[13]);
+		dev_dbg(dev, "reserved: 0x%02x", buf[14]);
+		dev_dbg(dev, "reserved: 0x%02x", buf[15]);
 	}
+
 	for (i = 16; i < count; ++i) {
 		if (buf[i] == RR_DETECT) {
-			ds_print_msg(buf, "new device detect", i);
+			dev_dbg(dev, "New device detect.\n");
 			continue;
 		}
-		ds_print_msg(buf, "Result Register Value: ", i);
+		dev_dbg(dev, "Result Register Value: 0x%02x", buf[i]);
 		if (buf[i] & RR_NRS)
-			pr_info("NRS: Reset no presence or ...\n");
+			dev_dbg(dev, "NRS: Reset no presence or ...\n");
 		if (buf[i] & RR_SH)
-			pr_info("SH: short on reset or set path\n");
+			dev_dbg(dev, "SH: short on reset or set path\n");
 		if (buf[i] & RR_APP)
-			pr_info("APP: alarming presence on reset\n");
+			dev_dbg(dev, "APP: alarming presence on reset\n");
 		if (buf[i] & RR_VPP)
-			pr_info("VPP: 12V expected not seen\n");
+			dev_dbg(dev, "VPP: 12V expected not seen\n");
 		if (buf[i] & RR_CMP)
-			pr_info("CMP: compare error\n");
+			dev_dbg(dev, "CMP: compare error\n");
 		if (buf[i] & RR_CRC)
-			pr_info("CRC: CRC error detected\n");
+			dev_dbg(dev, "CRC: CRC error detected\n");
 		if (buf[i] & RR_RDP)
-			pr_info("RDP: redirected page\n");
+			dev_dbg(dev, "RDP: redirected page\n");
 		if (buf[i] & RR_EOS)
-			pr_info("EOS: end of search error\n");
+			dev_dbg(dev, "EOS: end of search error\n");
 	}
 }
 
-static int ds_recv_status(struct ds_device *dev, struct ds_status *st,
-			  bool dump)
+static int ds_recv_status(struct ds_device *dev, struct ds_status *st)
 {
 	int count, err;
 
@@ -281,14 +279,12 @@ static int ds_recv_status(struct ds_device *dev, struct ds_status *st,
 				dev->st_buf, sizeof(dev->st_buf),
 				&count, 1000);
 	if (err < 0) {
-		pr_err("Failed to read 1-wire data from 0x%x: err=%d.\n",
-		       dev->ep[EP_STATUS], err);
+		dev_err(&dev->udev->dev,
+			"Failed to read 1-wire data from 0x%x: err=%d.\n",
+			dev->ep[EP_STATUS], err);
 		return err;
 	}
 
-	if (dump)
-		ds_dump_status(dev, dev->st_buf, count);
-
 	if (st && count >= sizeof(*st))
 		memcpy(st, dev->st_buf, sizeof(*st));
 
@@ -302,13 +298,15 @@ static void ds_reset_device(struct ds_device *dev)
 	 * the strong pullup.
 	 */
 	if (ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_SPUE))
-		pr_err("ds_reset_device: Error allowing strong pullup\n");
+		dev_err(&dev->udev->dev,
+			"%s: Error allowing strong pullup\n", __func__);
 	/* Chip strong pullup time was cleared. */
 	if (dev->spu_sleep) {
 		/* lower 4 bits are 0, see ds_set_pullup */
 		u8 del = dev->spu_sleep>>4;
 		if (ds_send_control(dev, COMM_SET_DURATION | COMM_IM, del))
-			pr_err("ds_reset_device: Error setting duration\n");
+			dev_err(&dev->udev->dev,
+				"%s: Error setting duration\n", __func__);
 	}
 }
 
@@ -329,9 +327,16 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
 	err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]),
 				buf, size, &count, 1000);
 	if (err < 0) {
+		int recv_len;
+
 		dev_info(&dev->udev->dev, "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]);
 		usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]));
-		ds_recv_status(dev, NULL, true);
+
+		/* status might tell us why endpoint is stuck? */
+		recv_len = ds_recv_status(dev, NULL);
+		if (recv_len >= 0)
+			ds_dump_status(dev, dev->st_buf, recv_len);
+
 		return err;
 	}
 
@@ -355,7 +360,7 @@ static int ds_send_data(struct ds_device *dev, unsigned char *buf, int len)
 	count = 0;
 	err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, 1000);
 	if (err < 0) {
-		pr_err("Failed to write 1-wire data to ep0x%x: "
+		dev_err(&dev->udev->dev, "Failed to write 1-wire data to ep0x%x: "
 			"err=%d.\n", dev->ep[EP_DATA_OUT], err);
 		return err;
 	}
@@ -377,7 +382,7 @@ int ds_stop_pulse(struct ds_device *dev, int limit)
 		err = ds_send_control(dev, CTL_RESUME_EXE, 0);
 		if (err)
 			break;
-		err = ds_recv_status(dev, &st, false);
+		err = ds_recv_status(dev, &st);
 		if (err)
 			break;
 
@@ -424,7 +429,7 @@ static int ds_wait_status(struct ds_device *dev, struct ds_status *st)
 
 	do {
 		st->status = 0;
-		err = ds_recv_status(dev, st, false);
+		err = ds_recv_status(dev, st);
 #if 0
 		if (err >= 0) {
 			int i;
@@ -437,7 +442,7 @@ static int ds_wait_status(struct ds_device *dev, struct ds_status *st)
 	} while (!(st->status & ST_IDLE) && !(err < 0) && ++count < 100);
 
 	if (err >= 16 && st->status & ST_EPOF) {
-		pr_info("Resetting device after ST_EPOF.\n");
+		dev_info(&dev->udev->dev, "Resetting device after ST_EPOF.\n");
 		ds_reset_device(dev);
 		/* Always dump the device status. */
 		count = 101;
@@ -721,7 +726,7 @@ static void ds9490r_search(void *data, struct w1_master *master,
 	do {
 		schedule_timeout(jtime);
 
-		err = ds_recv_status(dev, &st, false);
+		err = ds_recv_status(dev, &st);
 		if (err < 0 || err < sizeof(st))
 			break;
 
@@ -992,10 +997,9 @@ static int ds_probe(struct usb_interface *intf,
 	int i, err, alt;
 
 	dev = kzalloc(sizeof(struct ds_device), GFP_KERNEL);
-	if (!dev) {
-		pr_info("Failed to allocate new DS9490R structure.\n");
+	if (!dev)
 		return -ENOMEM;
-	}
+
 	dev->udev = usb_get_dev(udev);
 	if (!dev->udev) {
 		err = -ENOMEM;
@@ -1025,7 +1029,7 @@ static int ds_probe(struct usb_interface *intf,
 
 	iface_desc = intf->cur_altsetting;
 	if (iface_desc->desc.bNumEndpoints != NUM_EP-1) {
-		pr_info("Num endpoints=%d. It is not DS9490R.\n",
+		dev_err(&dev->udev->dev, "Num endpoints=%d. It is not DS9490R.\n",
 			iface_desc->desc.bNumEndpoints);
 		err = -EINVAL;
 		goto err_out_clear;
-- 
2.35.1


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

end of thread, other threads:[~2022-03-24 19:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 19:28 w1/ds2490: fix excessive logging Christian Vogel
2022-03-11 19:28 ` [PATCH 1/2] w1/ds2490: remove spurious newlines within hexdump Christian Vogel
2022-03-11 19:28 ` [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status & less verbose Christian Vogel
2022-03-18 13:06   ` Greg KH
2022-03-24 19:32     ` w1/ds2490: fix excessive logging Christian Vogel
2022-03-24 19:32       ` [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status, pr_ to dev_XXX logging Christian Vogel

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.