From: Rikard Falkeborn <rikard.falkeborn@gmail.com> To: Linus Walleij <linus.walleij@linaro.org> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>, Nicolas Ferre <nicolas.ferre@microchip.com>, Alexandre Belloni <alexandre.belloni@bootlin.com>, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Rikard Falkeborn <rikard.falkeborn@gmail.com> Subject: [PATCH] pinctrl: at91: Constify struct at91_pinctrl_mux_ops Date: Wed, 12 May 2021 20:01:40 +0200 [thread overview] Message-ID: <20210512180140.33293-1-rikard.falkeborn@gmail.com> (raw) The at91_pinctrl_mux_ops struct is never modified by the driver. Make it const wherever it is possible to allow the compiler to put the static variables in read-only memory. Note that sam9x60_ops was already const, but the const was cast away when the return value of of_match_device() was cast to a pointer to a non-const struct at91_pinctrl_mux_ops. Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> --- drivers/pinctrl/pinctrl-at91.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index fc61aaec34cc..72e6df7abe8c 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -42,7 +42,7 @@ struct at91_gpio_chip { int pioc_idx; /* PIO bank index */ void __iomem *regbase; /* PIO bank virtual address */ struct clk *clock; /* associated clock */ - struct at91_pinctrl_mux_ops *ops; /* ops */ + const struct at91_pinctrl_mux_ops *ops; /* ops */ }; static struct at91_gpio_chip *gpio_chips[MAX_GPIO_BANKS]; @@ -210,7 +210,7 @@ struct at91_pinctrl { struct at91_pin_group *groups; int ngroups; - struct at91_pinctrl_mux_ops *ops; + const struct at91_pinctrl_mux_ops *ops; }; static inline const struct at91_pin_group *at91_pinctrl_find_group_by_name( @@ -688,7 +688,7 @@ static void at91_mux_sam9x60_set_slewrate(void __iomem *pio, unsigned pin, writel_relaxed(tmp, pio + SAM9X60_PIO_SLEWR); } -static struct at91_pinctrl_mux_ops at91rm9200_ops = { +static const struct at91_pinctrl_mux_ops at91rm9200_ops = { .get_periph = at91_mux_get_periph, .mux_A_periph = at91_mux_set_A_periph, .mux_B_periph = at91_mux_set_B_periph, @@ -697,7 +697,7 @@ static struct at91_pinctrl_mux_ops at91rm9200_ops = { .irq_type = gpio_irq_type, }; -static struct at91_pinctrl_mux_ops at91sam9x5_ops = { +static const struct at91_pinctrl_mux_ops at91sam9x5_ops = { .get_periph = at91_mux_pio3_get_periph, .mux_A_periph = at91_mux_pio3_set_A_periph, .mux_B_periph = at91_mux_pio3_set_B_periph, @@ -737,7 +737,7 @@ static const struct at91_pinctrl_mux_ops sam9x60_ops = { .irq_type = alt_gpio_irq_type, }; -static struct at91_pinctrl_mux_ops sama5d3_ops = { +static const struct at91_pinctrl_mux_ops sama5d3_ops = { .get_periph = at91_mux_pio3_get_periph, .mux_A_periph = at91_mux_pio3_set_A_periph, .mux_B_periph = at91_mux_pio3_set_B_periph, @@ -1284,7 +1284,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, return -ENODEV; info->dev = &pdev->dev; - info->ops = (struct at91_pinctrl_mux_ops *) + info->ops = (const struct at91_pinctrl_mux_ops *) of_match_device(at91_pinctrl_of_match, &pdev->dev)->data; at91_pinctrl_child_count(info, np); @@ -1849,7 +1849,7 @@ static int at91_gpio_probe(struct platform_device *pdev) goto err; } - at91_chip->ops = (struct at91_pinctrl_mux_ops *) + at91_chip->ops = (const struct at91_pinctrl_mux_ops *) of_match_device(at91_gpio_of_match, &pdev->dev)->data; at91_chip->pioc_virq = irq; at91_chip->pioc_idx = alias_idx; -- 2.31.1
WARNING: multiple messages have this Message-ID (diff)
From: Rikard Falkeborn <rikard.falkeborn@gmail.com> To: Linus Walleij <linus.walleij@linaro.org> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>, Rikard Falkeborn <rikard.falkeborn@gmail.com>, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Ludovic Desroches <ludovic.desroches@microchip.com>, linux-arm-kernel@lists.infradead.org Subject: [PATCH] pinctrl: at91: Constify struct at91_pinctrl_mux_ops Date: Wed, 12 May 2021 20:01:40 +0200 [thread overview] Message-ID: <20210512180140.33293-1-rikard.falkeborn@gmail.com> (raw) The at91_pinctrl_mux_ops struct is never modified by the driver. Make it const wherever it is possible to allow the compiler to put the static variables in read-only memory. Note that sam9x60_ops was already const, but the const was cast away when the return value of of_match_device() was cast to a pointer to a non-const struct at91_pinctrl_mux_ops. Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> --- drivers/pinctrl/pinctrl-at91.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index fc61aaec34cc..72e6df7abe8c 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -42,7 +42,7 @@ struct at91_gpio_chip { int pioc_idx; /* PIO bank index */ void __iomem *regbase; /* PIO bank virtual address */ struct clk *clock; /* associated clock */ - struct at91_pinctrl_mux_ops *ops; /* ops */ + const struct at91_pinctrl_mux_ops *ops; /* ops */ }; static struct at91_gpio_chip *gpio_chips[MAX_GPIO_BANKS]; @@ -210,7 +210,7 @@ struct at91_pinctrl { struct at91_pin_group *groups; int ngroups; - struct at91_pinctrl_mux_ops *ops; + const struct at91_pinctrl_mux_ops *ops; }; static inline const struct at91_pin_group *at91_pinctrl_find_group_by_name( @@ -688,7 +688,7 @@ static void at91_mux_sam9x60_set_slewrate(void __iomem *pio, unsigned pin, writel_relaxed(tmp, pio + SAM9X60_PIO_SLEWR); } -static struct at91_pinctrl_mux_ops at91rm9200_ops = { +static const struct at91_pinctrl_mux_ops at91rm9200_ops = { .get_periph = at91_mux_get_periph, .mux_A_periph = at91_mux_set_A_periph, .mux_B_periph = at91_mux_set_B_periph, @@ -697,7 +697,7 @@ static struct at91_pinctrl_mux_ops at91rm9200_ops = { .irq_type = gpio_irq_type, }; -static struct at91_pinctrl_mux_ops at91sam9x5_ops = { +static const struct at91_pinctrl_mux_ops at91sam9x5_ops = { .get_periph = at91_mux_pio3_get_periph, .mux_A_periph = at91_mux_pio3_set_A_periph, .mux_B_periph = at91_mux_pio3_set_B_periph, @@ -737,7 +737,7 @@ static const struct at91_pinctrl_mux_ops sam9x60_ops = { .irq_type = alt_gpio_irq_type, }; -static struct at91_pinctrl_mux_ops sama5d3_ops = { +static const struct at91_pinctrl_mux_ops sama5d3_ops = { .get_periph = at91_mux_pio3_get_periph, .mux_A_periph = at91_mux_pio3_set_A_periph, .mux_B_periph = at91_mux_pio3_set_B_periph, @@ -1284,7 +1284,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, return -ENODEV; info->dev = &pdev->dev; - info->ops = (struct at91_pinctrl_mux_ops *) + info->ops = (const struct at91_pinctrl_mux_ops *) of_match_device(at91_pinctrl_of_match, &pdev->dev)->data; at91_pinctrl_child_count(info, np); @@ -1849,7 +1849,7 @@ static int at91_gpio_probe(struct platform_device *pdev) goto err; } - at91_chip->ops = (struct at91_pinctrl_mux_ops *) + at91_chip->ops = (const struct at91_pinctrl_mux_ops *) of_match_device(at91_gpio_of_match, &pdev->dev)->data; at91_chip->pioc_virq = irq; at91_chip->pioc_idx = alias_idx; -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2021-05-12 20:13 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-12 18:01 Rikard Falkeborn [this message] 2021-05-12 18:01 ` [PATCH] pinctrl: at91: Constify struct at91_pinctrl_mux_ops Rikard Falkeborn 2021-05-25 0:09 ` Linus Walleij 2021-05-25 0:09 ` Linus Walleij
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210512180140.33293-1-rikard.falkeborn@gmail.com \ --to=rikard.falkeborn@gmail.com \ --cc=alexandre.belloni@bootlin.com \ --cc=linus.walleij@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-gpio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=ludovic.desroches@microchip.com \ --cc=nicolas.ferre@microchip.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.