* [PATCH] gpio: rcar: Improve clock error handling and reporting
@ 2015-11-24 15:05 Geert Uytterhoeven
2015-12-01 9:54 ` Linus Walleij
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2015-11-24 15:05 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot, Magnus Damm
Cc: linux-gpio, linux-sh, Geert Uytterhoeven
If the Renesas R-Car GPIO driver cannot find a functional clock, it
prints a warning, .e.g.
gpio_rcar ffc40000.gpio: unable to get clock
and continues, as the clock is optional, depending on the SoC type.
This warning may confuse users.
To fix this, add a flag to indicate that the clock is mandatory or
optional:
- If the clock is mandatory (on R-Car Gen2), a missing clock is now
treated as a fatal error,
- If the clock is optional (on R-Car Gen1), the warning is no longer
printed.
The new flag is merged with the existing has_both_edge_trigger boolean
into a bitfield to save space.
Suggested-by: Magnus Damm <magnus.damm@gmail.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
This depends on "gpio: rcar: Remove obsolete platform data support".
Tested on r8a7779/marzen (no functional clock) and r8a7791/koelsch (with
and without mandatory functional clock).
drivers/gpio/gpio-rcar.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index bb6e363d5178634c..c890ac14b23a65ea 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -39,6 +39,7 @@ struct gpio_rcar_priv {
struct clk *clk;
unsigned int irq_parent;
unsigned has_both_edge_trigger:1;
+ unsigned needs_clk:1;
};
#define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */
@@ -316,15 +317,18 @@ static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset,
}
struct gpio_rcar_info {
- bool has_both_edge_trigger;
+ unsigned has_both_edge_trigger:1;
+ unsigned needs_clk:1;
};
static const struct gpio_rcar_info gpio_rcar_info_gen1 = {
- .has_both_edge_trigger = false,
+ .has_both_edge_trigger = 0,
+ .needs_clk = 0,
};
static const struct gpio_rcar_info gpio_rcar_info_gen2 = {
- .has_both_edge_trigger = true,
+ .has_both_edge_trigger = 1,
+ .needs_clk = 1,
};
static const struct of_device_id gpio_rcar_of_table[] = {
@@ -371,6 +375,7 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins)
ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args);
*npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK;
p->has_both_edge_trigger = info->has_both_edge_trigger;
+ p->needs_clk = info->needs_clk;
if (*npins == 0 || *npins > RCAR_MAX_GPIO_PER_BANK) {
dev_warn(&p->pdev->dev,
@@ -409,7 +414,11 @@ static int gpio_rcar_probe(struct platform_device *pdev)
p->clk = devm_clk_get(dev, NULL);
if (IS_ERR(p->clk)) {
- dev_warn(dev, "unable to get clock\n");
+ if (p->needs_clk) {
+ dev_err(dev, "unable to get clock\n");
+ ret = PTR_ERR(p->clk);
+ goto err0;
+ }
p->clk = NULL;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: rcar: Improve clock error handling and reporting
2015-11-24 15:05 [PATCH] gpio: rcar: Improve clock error handling and reporting Geert Uytterhoeven
@ 2015-12-01 9:54 ` Linus Walleij
2015-12-01 10:09 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2015-12-01 9:54 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Alexandre Courbot, Magnus Damm, linux-gpio@vger.kernel.org,
linux-sh@vger.kernel.org
On Tue, Nov 24, 2015 at 4:05 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> If the Renesas R-Car GPIO driver cannot find a functional clock, it
> prints a warning, .e.g.
>
> gpio_rcar ffc40000.gpio: unable to get clock
>
> and continues, as the clock is optional, depending on the SoC type.
> This warning may confuse users.
>
> To fix this, add a flag to indicate that the clock is mandatory or
> optional:
> - If the clock is mandatory (on R-Car Gen2), a missing clock is now
> treated as a fatal error,
> - If the clock is optional (on R-Car Gen1), the warning is no longer
> printed.
>
> The new flag is merged with the existing has_both_edge_trigger boolean
> into a bitfield to save space.
*DON'T* try to save bits in a megabyte kernel like this.
The better readability is worth the extra bits or bytes it takes.
Besides, did you really try to compile it before/after that change
to verify that it actually saved that space?
> Suggested-by: Magnus Damm <magnus.damm@gmail.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> This depends on "gpio: rcar: Remove obsolete platform data support".
Where is that patch? This does not apply to my tree,
probably because of this.
Please sent the patches in a series.
> unsigned has_both_edge_trigger:1;
> + unsigned needs_clk:1;
both should be bool and assigned true/false.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: rcar: Improve clock error handling and reporting
2015-12-01 9:54 ` Linus Walleij
@ 2015-12-01 10:09 ` Geert Uytterhoeven
2015-12-10 17:11 ` Linus Walleij
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2015-12-01 10:09 UTC (permalink / raw)
To: Linus Walleij
Cc: Geert Uytterhoeven, Alexandre Courbot, Magnus Damm,
linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org
Hi Linus,
On Tue, Dec 1, 2015 at 10:54 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Tue, Nov 24, 2015 at 4:05 PM, Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
>
>> If the Renesas R-Car GPIO driver cannot find a functional clock, it
>> prints a warning, .e.g.
>>
>> gpio_rcar ffc40000.gpio: unable to get clock
>>
>> and continues, as the clock is optional, depending on the SoC type.
>> This warning may confuse users.
>>
>> To fix this, add a flag to indicate that the clock is mandatory or
>> optional:
>> - If the clock is mandatory (on R-Car Gen2), a missing clock is now
>> treated as a fatal error,
>> - If the clock is optional (on R-Car Gen1), the warning is no longer
>> printed.
>>
>> The new flag is merged with the existing has_both_edge_trigger boolean
>> into a bitfield to save space.
>
> *DON'T* try to save bits in a megabyte kernel like this.
> The better readability is worth the extra bits or bytes it takes.
> Besides, did you really try to compile it before/after that change
> to verify that it actually saved that space?
Is it better readable?
Size also depends on how many more flags we'll add later.
>> Suggested-by: Magnus Damm <magnus.damm@gmail.com>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>> This depends on "gpio: rcar: Remove obsolete platform data support".
>
> Where is that patch? This does not apply to my tree,
> probably because of this.
IIRC, you said "include it in your pull request" for that series.
> Please sent the patches in a series.
I can send both to you, as they're not pinctrl but gpio.
>> unsigned has_both_edge_trigger:1;
>> + unsigned needs_clk:1;
>
> both should be bool and assigned true/false.
OK, if you prefer it that way.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: rcar: Improve clock error handling and reporting
2015-12-01 10:09 ` Geert Uytterhoeven
@ 2015-12-10 17:11 ` Linus Walleij
0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2015-12-10 17:11 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Geert Uytterhoeven, Alexandre Courbot, Magnus Damm,
linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org
On Tue, Dec 1, 2015 at 11:09 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Tue, Dec 1, 2015 at 10:54 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
>> On Tue, Nov 24, 2015 at 4:05 PM, Geert Uytterhoeven
>> <geert+renesas@glider.be> wrote:
>>> The new flag is merged with the existing has_both_edge_trigger boolean
>>> into a bitfield to save space.
>>
>> *DON'T* try to save bits in a megabyte kernel like this.
>> The better readability is worth the extra bits or bytes it takes.
>> Besides, did you really try to compile it before/after that change
>> to verify that it actually saved that space?
>
> Is it better readable?
OK sorry for being such an ass, I'm a bit stressed out.
> Size also depends on how many more flags we'll add later.
Yeah. But I really like the bools, I think the static checkers can also
make better use of them, but that's just me.
>> Where is that patch? This does not apply to my tree,
>> probably because of this.
>
> IIRC, you said "include it in your pull request" for that series.
OK so this needs to go in with the pin control stuff? Then it's cool...
>> Please sent the patches in a series.
>
> I can send both to you, as they're not pinctrl but gpio.
>
>>> unsigned has_both_edge_trigger:1;
>>> + unsigned needs_clk:1;
>>
>> both should be bool and assigned true/false.
>
> OK, if you prefer it that way.
Thanks!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-10 17:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 15:05 [PATCH] gpio: rcar: Improve clock error handling and reporting Geert Uytterhoeven
2015-12-01 9:54 ` Linus Walleij
2015-12-01 10:09 ` Geert Uytterhoeven
2015-12-10 17:11 ` Linus Walleij
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).