ASoC: rt5663: Fix error handling of regulator_set_load
Subsystems (3)
PATCH 1/1 ASoC: rt5663: Fix error handling of regulator_set_load
The default implementation of regulator_set_load returns REGULATOR_MODE_NORMAL, which is positive.
rt5663_i2c_probe should only do error handling when return value of regulator_set_load is negative.
In this case, rt5663_i2c_probe should return error.
Also, consolidate err_irq into err_enable.
Fix the missing goto for temporary regmap and rt5663->regmap.
---
This patch is the fixup of the patch e81a2a6d12e85 ASoC: rt5663: Add regulator support
sound/soc/codecs/rt5663.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
sound/soc/codecs/rt5663.c +12 -9
@@ -3522,10 +3522,11 @@ static int rt5663_i2c_probe(struct i2c_client *i2c,for (i =0 ; i <ARRAY_SIZE (rt5663->supplies); i++) { ret =regulator_set_load (rt5663->supplies[i].consumer,RT5663_SUPPLY_CURRENT_UA ); -if (ret) { +if (ret <0 ) {dev_err (&i2c->dev, -"Failed to set regulator %s, ret: %d\n" , +"Failed to set regulator load on %s, ret: %d\n" , rt5663->supplies[i].supply, ret); +return ret; } }
@@ -3543,7 +3544,7 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ret =PTR_ERR (regmap);dev_err (&i2c->dev,"Failed to allocate temp register map: %d\n" , ret); -return ret; + goto err_enable; } ret =regmap_read (regmap,RT5663_VENDOR_ID_2 , &val);
@@ -3576,7 +3577,7 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ret =PTR_ERR (rt5663->regmap);dev_err (&i2c->dev,"Failed to allocate register map: %d\n" , ret); -return ret; + goto err_enable; }/* reset and calibrate */
@@ -3686,17 +3687,19 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, rt5663_dai, ARRAY_SIZE(rt5663_dai));if (ret) - goto err_irq; + goto err_enable;return 0 ; -err_irq: + +/* +* Error after enabling regulators should goto err_enable +* to disable regulators. +*/ +err_enable:if (i2c->irq)free_irq (i2c->irq, rt5663); -err_enable: -dev_err (&i2c->dev, -"%s: Disable regulator after probe error\n" , __func__);regulator_bulk_disable (ARRAY_SIZE (rt5663->supplies), rt5663->supplies);return ret; }
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
Mark Brown
maintainerQuoted 2 lines · Cheng-Yi Chiang
The default implementation of
regulator_set_loadreturnsREGULATOR_MODE_NORMAL, which is positive.
The stub does indeed do that however that just looks like a bug - the actual implementation returns 0 on success and the other users don't seem to expect to get a mode value back.
Quoted 3 lines
rt5663_i2c_probeshould only do error handling when return value ofregulator_set_loadis negative.
In this case,rt5663_i2c_probeshould return error.
However that's also true so the patch is valid.
Mark Brown
maintainerApplied "ASoC: rt5663: Fix error handling of regulator_set_load" to the asoc tree
In reply to Cheng-Yi ChiangThe patch
ASoC: rt5663: Fix error handling of regulator_set_load
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
746dca0aebd4d77adccb76c500a60028a900dabbMon Sep 17 00:00:00 2001
From: Cheng-Yi Chiang <[email protected]>
Date: Fri, 16 Nov 2018 17:28:56 +0800
Subject: [PATCH] ASoC: rt5663: Fix error handling of regulator_set_load
The default implementation of regulator_set_load returns REGULATOR_MODE_NORMAL, which is positive. [This was a bug which is being fixed but the change is valid anyway -- bronie]
rt5663_i2c_probe should only do error handling when return value of regulator_set_load is negative.
In this case, rt5663_i2c_probe should return error.
Also, consolidate err_irq into err_enable.
Fix the missing goto for temporary regmap and rt5663->regmap.
--- sound/soc/codecs/rt5663.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
sound/soc/codecs/rt5663.c +12 -9
@@ -3525,10 +3525,11 @@ static int rt5663_i2c_probe(struct i2c_client *i2c,for (i =0 ; i <ARRAY_SIZE (rt5663->supplies); i++) { ret =regulator_set_load (rt5663->supplies[i].consumer,RT5663_SUPPLY_CURRENT_UA ); -if (ret) { +if (ret <0 ) {dev_err (&i2c->dev, -"Failed to set regulator %s, ret: %d\n" , +"Failed to set regulator load on %s, ret: %d\n" , rt5663->supplies[i].supply, ret); +return ret; } }
@@ -3546,7 +3547,7 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ret =PTR_ERR (regmap);dev_err (&i2c->dev,"Failed to allocate temp register map: %d\n" , ret); -return ret; + goto err_enable; } ret =regmap_read (regmap,RT5663_VENDOR_ID_2 , &val);
@@ -3579,7 +3580,7 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ret =PTR_ERR (rt5663->regmap);dev_err (&i2c->dev,"Failed to allocate register map: %d\n" , ret); -return ret; + goto err_enable; }/* reset and calibrate */
@@ -3689,17 +3690,19 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, rt5663_dai, ARRAY_SIZE(rt5663_dai));if (ret) - goto err_irq; + goto err_enable;return 0 ; -err_irq: + +/* +* Error after enabling regulators should goto err_enable +* to disable regulators. +*/ +err_enable:if (i2c->irq)free_irq (i2c->irq, rt5663); -err_enable: -dev_err (&i2c->dev, -"%s: Disable regulator after probe error\n" , __func__);regulator_bulk_disable (ARRAY_SIZE (rt5663->supplies), rt5663->supplies);return ret; }
Signature · 1 line
2.19.1