diff mbox series

Input: silead - try firmware reload after unsuccessful resume

Message ID 20181002122127.31568-1-jsbc@gmx.de (mailing list archive)
State Accepted
Headers show
Series Input: silead - try firmware reload after unsuccessful resume | expand

Commit Message

Julian Sax Oct. 2, 2018, 12:21 p.m. UTC
A certain silead controller (Chip ID: 0x56810000) loses its firmware
after suspend, causing the resume to fail. This patch tries to load
the firmware, should a resume error occur and retries the resuming.

Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Julian Sax <jsbc@gmx.de>
---
 drivers/input/touchscreen/silead.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Hans de Goede Oct. 2, 2018, 2:03 p.m. UTC | #1
Hi,

On 02-10-18 14:21, Julian Sax wrote:
> A certain silead controller (Chip ID: 0x56810000) loses its firmware
> after suspend, causing the resume to fail. This patch tries to load
> the firmware, should a resume error occur and retries the resuming.
> 
> Cc: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Julian Sax <jsbc@gmx.de>

Thanks, patch looks good to me:

Acked-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans




> ---
>   drivers/input/touchscreen/silead.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
> index d196ac3d8b8c..09241d4cdebc 100644
> --- a/drivers/input/touchscreen/silead.c
> +++ b/drivers/input/touchscreen/silead.c
> @@ -558,20 +558,33 @@ static int __maybe_unused silead_ts_suspend(struct device *dev)
>   static int __maybe_unused silead_ts_resume(struct device *dev)
>   {
>   	struct i2c_client *client = to_i2c_client(dev);
> +	bool second_try = false;
>   	int error, status;
>   
>   	silead_ts_set_power(client, SILEAD_POWER_ON);
>   
> + retry:
>   	error = silead_ts_reset(client);
>   	if (error)
>   		return error;
>   
> +	if (second_try) {
> +		error = silead_ts_load_fw(client);
> +		if (error)
> +			return error;
> +	}
> +
>   	error = silead_ts_startup(client);
>   	if (error)
>   		return error;
>   
>   	status = silead_ts_get_status(client);
>   	if (status != SILEAD_STATUS_OK) {
> +		if (!second_try) {
> +			second_try = true;
> +			dev_dbg(dev, "Reloading firmware after unsuccessful resume\n");
> +			goto retry;
> +		}
>   		dev_err(dev, "Resume error, status: 0x%02x\n", status);
>   		return -ENODEV;
>   	}
>
Dmitry Torokhov Oct. 5, 2018, 6:48 p.m. UTC | #2
On Tue, Oct 02, 2018 at 04:03:52PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 02-10-18 14:21, Julian Sax wrote:
> > A certain silead controller (Chip ID: 0x56810000) loses its firmware
> > after suspend, causing the resume to fail. This patch tries to load
> > the firmware, should a resume error occur and retries the resuming.
> > 
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Signed-off-by: Julian Sax <jsbc@gmx.de>
> 
> Thanks, patch looks good to me:
> 
> Acked-by: Hans de Goede <hdegoede@redhat.com>

Applied, thank you.

> 
> Regards,
> 
> Hans
> 
> 
> 
> 
> > ---
> >   drivers/input/touchscreen/silead.c | 13 +++++++++++++
> >   1 file changed, 13 insertions(+)
> > 
> > diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
> > index d196ac3d8b8c..09241d4cdebc 100644
> > --- a/drivers/input/touchscreen/silead.c
> > +++ b/drivers/input/touchscreen/silead.c
> > @@ -558,20 +558,33 @@ static int __maybe_unused silead_ts_suspend(struct device *dev)
> >   static int __maybe_unused silead_ts_resume(struct device *dev)
> >   {
> >   	struct i2c_client *client = to_i2c_client(dev);
> > +	bool second_try = false;
> >   	int error, status;
> >   	silead_ts_set_power(client, SILEAD_POWER_ON);
> > + retry:
> >   	error = silead_ts_reset(client);
> >   	if (error)
> >   		return error;
> > +	if (second_try) {
> > +		error = silead_ts_load_fw(client);
> > +		if (error)
> > +			return error;
> > +	}
> > +
> >   	error = silead_ts_startup(client);
> >   	if (error)
> >   		return error;
> >   	status = silead_ts_get_status(client);
> >   	if (status != SILEAD_STATUS_OK) {
> > +		if (!second_try) {
> > +			second_try = true;
> > +			dev_dbg(dev, "Reloading firmware after unsuccessful resume\n");
> > +			goto retry;
> > +		}
> >   		dev_err(dev, "Resume error, status: 0x%02x\n", status);
> >   		return -ENODEV;
> >   	}
> >
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
index d196ac3d8b8c..09241d4cdebc 100644
--- a/drivers/input/touchscreen/silead.c
+++ b/drivers/input/touchscreen/silead.c
@@ -558,20 +558,33 @@  static int __maybe_unused silead_ts_suspend(struct device *dev)
 static int __maybe_unused silead_ts_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
+	bool second_try = false;
 	int error, status;
 
 	silead_ts_set_power(client, SILEAD_POWER_ON);
 
+ retry:
 	error = silead_ts_reset(client);
 	if (error)
 		return error;
 
+	if (second_try) {
+		error = silead_ts_load_fw(client);
+		if (error)
+			return error;
+	}
+
 	error = silead_ts_startup(client);
 	if (error)
 		return error;
 
 	status = silead_ts_get_status(client);
 	if (status != SILEAD_STATUS_OK) {
+		if (!second_try) {
+			second_try = true;
+			dev_dbg(dev, "Reloading firmware after unsuccessful resume\n");
+			goto retry;
+		}
 		dev_err(dev, "Resume error, status: 0x%02x\n", status);
 		return -ENODEV;
 	}