linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jack Andersen <jackoalan@gmail.com>
To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jack Andersen <jackoalan@gmail.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Lee Jones <lee.jones@linaro.org>
Subject: [PATCH v5 3/3] mfd: dln2: Send restart command if HW init fails
Date: Wed,  5 Jul 2017 11:12:48 -1000	[thread overview]
Message-ID: <1499289168-14392-3-git-send-email-jackoalan@gmail.com> (raw)
In-Reply-To: <1499289168-14392-1-git-send-email-jackoalan@gmail.com>
In-Reply-To: <b5ede0cc2cb36695b86edf44c0dddbc4736a6420>

There's an issue with reinitializing DLN2 hardware if ADC channel event
configurations aren't reset before suspending the driver. A physical reconnect
of the device solves the problem, but restarting the machine without a power
cycle leaves the device state inconsistent.

This patch transmits a restart command in the event of a failed init.
To the kernel's perspective, this is the rough equivalent of a disconnect and
reconnect, so another probe occurs shortly afterwards.

Signed-off-by: Jack Andersen <jackoalan@gmail.com>
---
 drivers/mfd/dln2.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
index a22ab8c..1eb0056 100644
--- a/drivers/mfd/dln2.c
+++ b/drivers/mfd/dln2.c
@@ -40,6 +40,7 @@ struct dln2_response {
 #define DLN2_GENERIC_CMD(cmd)		DLN2_CMD(cmd, DLN2_GENERIC_MODULE_ID)
 #define CMD_GET_DEVICE_VER		DLN2_GENERIC_CMD(0x30)
 #define CMD_GET_DEVICE_SN		DLN2_GENERIC_CMD(0x31)
+#define CMD_RESTART			DLN2_GENERIC_CMD(0x43)
 
 #define DLN2_HW_ID			0x200
 #define DLN2_USB_TIMEOUT		200	/* in ms */
@@ -531,6 +532,12 @@ int dln2_transfer(struct platform_device *pdev, u16 cmd,
 }
 EXPORT_SYMBOL(dln2_transfer);
 
+static int dln2_restart(struct dln2_dev *dln2)
+{
+	return _dln2_transfer(dln2, DLN2_HANDLE_CTRL, CMD_RESTART,
+			      NULL, 0, NULL, NULL);
+}
+
 static int dln2_check_hw(struct dln2_dev *dln2)
 {
 	int ret;
@@ -782,7 +789,9 @@ static int dln2_probe(struct usb_interface *interface,
 
 	ret = dln2_hw_init(dln2);
 	if (ret < 0) {
-		dev_err(dev, "failed to initialize hardware\n");
+		dev_err(dev,
+			"failed to initialize hardware; attempting restart\n");
+		dln2_restart(dln2);
 		goto out_stop_rx;
 	}
 
-- 
1.9.1

  parent reply	other threads:[~2017-07-05 21:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <b5ede0cc2cb36695b86edf44c0dddbc4736a6420>
2017-06-22 22:31 ` [PATCH v2] iio: adc: Add support for DLN2 ADC Jack Andersen
2017-06-23  7:25   ` Peter Meerwald-Stadler
2017-06-28  0:53 ` [PATCH v3] " Jack Andersen
2017-06-28  0:57   ` Jack Andersen
2017-06-28  1:05 ` [PATCH v4] " Jack Andersen
2017-07-01 11:57   ` Jonathan Cameron
2017-07-05 21:12 ` [PATCH v5 1/3] " Jack Andersen
2017-07-06 11:37   ` Jonathan Cameron
2017-07-05 21:12 ` [PATCH v5 2/3] mfd: dln2: Add cell for initializing " Jack Andersen
2017-07-06  7:10   ` Lee Jones
2017-07-05 21:12 ` Jack Andersen [this message]
2017-07-05 21:23   ` [PATCH v5 3/3] mfd: dln2: Send restart command if HW init fails Jack Andersen
2017-07-06  7:09     ` Lee Jones
2017-07-06 21:01       ` Jack Andersen
2017-07-06 22:39 ` [PATCH v6 1/3] iio: adc: Add support for DLN2 ADC Jack Andersen
2017-07-09 17:12   ` Jonathan Cameron
2017-07-10 20:04     ` Jack Andersen
2017-07-06 22:39 ` [PATCH v6 2/3] mfd: dln2: Add cell for initializing " Jack Andersen

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=1499289168-14392-3-git-send-email-jackoalan@gmail.com \
    --to=jackoalan@gmail.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.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).