diff mbox series

input: cypress-sf: Register a callback to disable the regulators

Message ID 20220409022629.3493557-1-zheyuma97@gmail.com (mailing list archive)
State Accepted
Commit fd0a4b39870d49ff15f6966470185409e261f20f
Headers show
Series input: cypress-sf: Register a callback to disable the regulators | expand

Commit Message

Zheyu Ma April 9, 2022, 2:26 a.m. UTC
When the driver fails to probe, we will get the following splat:

[   19.311970] ------------[ cut here ]------------
[   19.312566] WARNING: CPU: 3 PID: 375 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
[   19.317591] RIP: 0010:_regulator_put+0x3ec/0x4e0
[   19.328831] Call Trace:
[   19.329112]  <TASK>
[   19.329369]  regulator_bulk_free+0x82/0xe0
[   19.329860]  devres_release_group+0x319/0x3d0
[   19.330357]  i2c_device_probe+0x766/0x940

Fix this by adding a callback that will deal with the disabling when the
driver fails to probe.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 drivers/input/keyboard/cypress-sf.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Dmitry Torokhov April 9, 2022, 2:34 a.m. UTC | #1
Hi Zheyu,

On Sat, Apr 09, 2022 at 10:26:29AM +0800, Zheyu Ma wrote:
> When the driver fails to probe, we will get the following splat:
> 
> [   19.311970] ------------[ cut here ]------------
> [   19.312566] WARNING: CPU: 3 PID: 375 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> [   19.317591] RIP: 0010:_regulator_put+0x3ec/0x4e0
> [   19.328831] Call Trace:
> [   19.329112]  <TASK>
> [   19.329369]  regulator_bulk_free+0x82/0xe0
> [   19.329860]  devres_release_group+0x319/0x3d0
> [   19.330357]  i2c_device_probe+0x766/0x940
> 
> Fix this by adding a callback that will deal with the disabling when the
> driver fails to probe.
> 
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---
>  drivers/input/keyboard/cypress-sf.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/input/keyboard/cypress-sf.c b/drivers/input/keyboard/cypress-sf.c
> index c28996028e80..798611b76de6 100644
> --- a/drivers/input/keyboard/cypress-sf.c
> +++ b/drivers/input/keyboard/cypress-sf.c
> @@ -61,6 +61,13 @@ static irqreturn_t cypress_sf_irq_handler(int irq, void *devid)
>  	return IRQ_HANDLED;
>  }
>  
> +static void cypress_sf_disable_regulator(void *arg)
> +{
> +	struct cypress_sf_data *data = arg;
> +
> +	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> +}
> +
>  static int cypress_sf_probe(struct i2c_client *client)
>  {
>  	struct cypress_sf_data *touchkey;
> @@ -84,6 +91,10 @@ static int cypress_sf_probe(struct i2c_client *client)
>  		return error;
>  	}
>  
> +	error = devm_add_action_or_reset(&client->dev, cypress_sf_disable_regulator, touchkey);
> +	if (error)
> +		return error;

This needs to be moved to the spot after we enabled regulators. I
adjusted and applied.

> +
>  	touchkey->num_keys = device_property_read_u32_array(&client->dev,
>  							    "linux,keycodes",
>  							    NULL, 0);
> -- 
> 2.25.1
> 

Thanks.
Zheyu Ma April 9, 2022, 2:56 a.m. UTC | #2
On Sat, Apr 9, 2022 at 10:34 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> Hi Zheyu,
>
> On Sat, Apr 09, 2022 at 10:26:29AM +0800, Zheyu Ma wrote:
> > When the driver fails to probe, we will get the following splat:
> >
> > [   19.311970] ------------[ cut here ]------------
> > [   19.312566] WARNING: CPU: 3 PID: 375 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> > [   19.317591] RIP: 0010:_regulator_put+0x3ec/0x4e0
> > [   19.328831] Call Trace:
> > [   19.329112]  <TASK>
> > [   19.329369]  regulator_bulk_free+0x82/0xe0
> > [   19.329860]  devres_release_group+0x319/0x3d0
> > [   19.330357]  i2c_device_probe+0x766/0x940
> >
> > Fix this by adding a callback that will deal with the disabling when the
> > driver fails to probe.
> >
> > Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> > ---
> >  drivers/input/keyboard/cypress-sf.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/input/keyboard/cypress-sf.c b/drivers/input/keyboard/cypress-sf.c
> > index c28996028e80..798611b76de6 100644
> > --- a/drivers/input/keyboard/cypress-sf.c
> > +++ b/drivers/input/keyboard/cypress-sf.c
> > @@ -61,6 +61,13 @@ static irqreturn_t cypress_sf_irq_handler(int irq, void *devid)
> >       return IRQ_HANDLED;
> >  }
> >
> > +static void cypress_sf_disable_regulator(void *arg)
> > +{
> > +     struct cypress_sf_data *data = arg;
> > +
> > +     regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> > +}
> > +
> >  static int cypress_sf_probe(struct i2c_client *client)
> >  {
> >       struct cypress_sf_data *touchkey;
> > @@ -84,6 +91,10 @@ static int cypress_sf_probe(struct i2c_client *client)
> >               return error;
> >       }
> >
> > +     error = devm_add_action_or_reset(&client->dev, cypress_sf_disable_regulator, touchkey);
> > +     if (error)
> > +             return error;
>
> This needs to be moved to the spot after we enabled regulators. I
> adjusted and applied.

Thanks for your reminder!

Zheyu Ma
diff mbox series

Patch

diff --git a/drivers/input/keyboard/cypress-sf.c b/drivers/input/keyboard/cypress-sf.c
index c28996028e80..798611b76de6 100644
--- a/drivers/input/keyboard/cypress-sf.c
+++ b/drivers/input/keyboard/cypress-sf.c
@@ -61,6 +61,13 @@  static irqreturn_t cypress_sf_irq_handler(int irq, void *devid)
 	return IRQ_HANDLED;
 }
 
+static void cypress_sf_disable_regulator(void *arg)
+{
+	struct cypress_sf_data *data = arg;
+
+	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
+}
+
 static int cypress_sf_probe(struct i2c_client *client)
 {
 	struct cypress_sf_data *touchkey;
@@ -84,6 +91,10 @@  static int cypress_sf_probe(struct i2c_client *client)
 		return error;
 	}
 
+	error = devm_add_action_or_reset(&client->dev, cypress_sf_disable_regulator, touchkey);
+	if (error)
+		return error;
+
 	touchkey->num_keys = device_property_read_u32_array(&client->dev,
 							    "linux,keycodes",
 							    NULL, 0);