linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Vogel <vogelchr@vogel.cx>
To: greg@kroah.com, linux-kernel@vger.kernel.org
Cc: zbr@ioremap.net, vogelchr@vogel.cx
Subject: [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status & less verbose
Date: Fri, 11 Mar 2022 20:28:33 +0100	[thread overview]
Message-ID: <20220311192833.1792-3-vogelchr@vogel.cx> (raw)
In-Reply-To: <20220311192833.1792-1-vogelchr@vogel.cx>

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


  parent reply	other threads:[~2022-03-11 19:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-03-18 13:06   ` [PATCH 2/2] w1/ds2490: remove dump from ds_recv_status & less verbose 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220311192833.1792-3-vogelchr@vogel.cx \
    --to=vogelchr@vogel.cx \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbr@ioremap.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).