* [PATCH] extcon: arizona: Only set GPIO if it has been requested
@ 2012-11-26 11:28 Mark Brown
2012-11-26 23:26 ` Chanwoo Choi
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2012-11-26 11:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, MyungJoo Ham, Chanwoo Choi
Cc: patches, linux-kernel, Mark Brown
The micd_pol GPIO is only requested if we've specified one greater than 0
so apply the same test before we set it.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/extcon/extcon-arizona.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index cdab9e5..585882e 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -85,8 +85,9 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
{
struct arizona *arizona = info->arizona;
- gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
- info->micd_modes[mode].gpio);
+ if (arizona->pdata.micd_pol_gpio > 0)
+ gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
+ info->micd_modes[mode].gpio);
regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
ARIZONA_MICD_BIAS_SRC_MASK,
info->micd_modes[mode].bias);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] extcon: arizona: Only set GPIO if it has been requested
2012-11-26 11:28 [PATCH] extcon: arizona: Only set GPIO if it has been requested Mark Brown
@ 2012-11-26 23:26 ` Chanwoo Choi
2012-11-27 6:35 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Chanwoo Choi @ 2012-11-26 23:26 UTC (permalink / raw)
To: Mark Brown; +Cc: Greg Kroah-Hartman, MyungJoo Ham, patches, linux-kernel
On 11/26/2012 08:28 PM, Mark Brown wrote:
> The micd_pol GPIO is only requested if we've specified one greater than 0
> so apply the same test before we set it.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> drivers/extcon/extcon-arizona.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index cdab9e5..585882e 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/drivers/extcon/extcon-arizona.c
> @@ -85,8 +85,9 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
> {
> struct arizona *arizona = info->arizona;
>
> - gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
> - info->micd_modes[mode].gpio);
> + if (arizona->pdata.micd_pol_gpio > 0)
> + gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
> + info->micd_modes[mode].gpio);
Why not use gpio_is_valid() function to test arizona->pdata.micd_pol_gpio ?
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] extcon: arizona: Only set GPIO if it has been requested
2012-11-26 23:26 ` Chanwoo Choi
@ 2012-11-27 6:35 ` Mark Brown
2012-11-27 7:15 ` Chanwoo Choi
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2012-11-27 6:35 UTC (permalink / raw)
To: Chanwoo Choi; +Cc: Greg Kroah-Hartman, MyungJoo Ham, patches, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 653 bytes --]
On Tue, Nov 27, 2012 at 08:26:35AM +0900, Chanwoo Choi wrote:
> On 11/26/2012 08:28 PM, Mark Brown wrote:
> > + if (arizona->pdata.micd_pol_gpio > 0)
> > + gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
> > + info->micd_modes[mode].gpio);
> Why not use gpio_is_valid() function to test arizona->pdata.micd_pol_gpio ?
Zero is normally a valid GPIO (since it's an index into a big array
after all) but this is unhelpful when checking to see if someone filled
in platform data as it's also the default value for uninitialised member
variables. It's much more likely that someone didn't fill in a GPIO
than that GPIO 0 got assigned to this.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] extcon: arizona: Only set GPIO if it has been requested
2012-11-27 6:35 ` Mark Brown
@ 2012-11-27 7:15 ` Chanwoo Choi
0 siblings, 0 replies; 4+ messages in thread
From: Chanwoo Choi @ 2012-11-27 7:15 UTC (permalink / raw)
To: Mark Brown; +Cc: Greg Kroah-Hartman, MyungJoo Ham, patches, linux-kernel
On 11/27/2012 03:35 PM, Mark Brown wrote:
> On Tue, Nov 27, 2012 at 08:26:35AM +0900, Chanwoo Choi wrote:
>> On 11/26/2012 08:28 PM, Mark Brown wrote:
>
>>> + if (arizona->pdata.micd_pol_gpio > 0)
>>> + gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
>>> + info->micd_modes[mode].gpio);
>
>> Why not use gpio_is_valid() function to test arizona->pdata.micd_pol_gpio ?
>
> Zero is normally a valid GPIO (since it's an index into a big array
> after all) but this is unhelpful when checking to see if someone filled
> in platform data as it's also the default value for uninitialised member
> variables. It's much more likely that someone didn't fill in a GPIO
> than that GPIO 0 got assigned to this.
OK, Applied it.
You can check it after some minutes.
- git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git (for-next branch)
Thanks,
Chanwoo Choi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-27 7:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-26 11:28 [PATCH] extcon: arizona: Only set GPIO if it has been requested Mark Brown
2012-11-26 23:26 ` Chanwoo Choi
2012-11-27 6:35 ` Mark Brown
2012-11-27 7:15 ` Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox