* [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable
@ 2022-06-01 15:04 Andy Shevchenko
2022-06-01 15:04 ` [PATCH v1 2/3] gpio: crystalcove: Use specific type and API for IRQ number Andy Shevchenko
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-06-01 15:04 UTC (permalink / raw)
To: Andy Shevchenko, linux-gpio, linux-kernel
Cc: Andy Shevchenko, Linus Walleij, Bartosz Golaszewski
Since recently, the kernel is nagging about mutable irq_chips:
"not an immutable chip, please consider fixing it!"
Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new
helper functions and call the appropriate gpiolib functions.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-crystalcove.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c
index b55c74a5e064..f40d3b133527 100644
--- a/drivers/gpio/gpio-crystalcove.c
+++ b/drivers/gpio/gpio-crystalcove.c
@@ -15,6 +15,7 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/seq_file.h>
+#include <linux/types.h>
#define CRYSTALCOVE_GPIO_NUM 16
#define CRYSTALCOVE_VGPIO_NUM 95
@@ -238,10 +239,13 @@ static void crystalcove_bus_sync_unlock(struct irq_data *data)
static void crystalcove_irq_unmask(struct irq_data *data)
{
- struct crystalcove_gpio *cg =
- gpiochip_get_data(irq_data_get_irq_chip_data(data));
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
+ struct crystalcove_gpio *cg = gpiochip_get_data(gc);
+ irq_hw_number_t hwirq = irqd_to_hwirq(data);
+
+ gpiochip_enable_irq(gc, hwirq);
- if (data->hwirq < CRYSTALCOVE_GPIO_NUM) {
+ if (hwirq < CRYSTALCOVE_GPIO_NUM) {
cg->set_irq_mask = false;
cg->update |= UPDATE_IRQ_MASK;
}
@@ -249,23 +253,27 @@ static void crystalcove_irq_unmask(struct irq_data *data)
static void crystalcove_irq_mask(struct irq_data *data)
{
- struct crystalcove_gpio *cg =
- gpiochip_get_data(irq_data_get_irq_chip_data(data));
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
+ struct crystalcove_gpio *cg = gpiochip_get_data(gc);
+ irq_hw_number_t hwirq = irqd_to_hwirq(data);
- if (data->hwirq < CRYSTALCOVE_GPIO_NUM) {
+ if (hwirq < CRYSTALCOVE_GPIO_NUM) {
cg->set_irq_mask = true;
cg->update |= UPDATE_IRQ_MASK;
}
+
+ gpiochip_disable_irq(gc, hwirq);
}
-static struct irq_chip crystalcove_irqchip = {
+static const struct irq_chip crystalcove_irqchip = {
.name = "Crystal Cove",
.irq_mask = crystalcove_irq_mask,
.irq_unmask = crystalcove_irq_unmask,
.irq_set_type = crystalcove_irq_type,
.irq_bus_lock = crystalcove_bus_lock,
.irq_bus_sync_unlock = crystalcove_bus_sync_unlock,
- .flags = IRQCHIP_SKIP_SET_WAKE,
+ .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static irqreturn_t crystalcove_gpio_irq_handler(int irq, void *data)
@@ -353,7 +361,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
cg->regmap = pmic->regmap;
girq = &cg->chip.irq;
- girq->chip = &crystalcove_irqchip;
+ gpio_irq_chip_set_chip(girq, &crystalcove_irqchip);
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 2/3] gpio: crystalcove: Use specific type and API for IRQ number
2022-06-01 15:04 [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable Andy Shevchenko
@ 2022-06-01 15:04 ` Andy Shevchenko
2022-06-01 15:04 ` [PATCH v1 3/3] gpio: crystalcove: Join function declarations and long lines Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-06-01 15:04 UTC (permalink / raw)
To: Andy Shevchenko, linux-gpio, linux-kernel
Cc: Andy Shevchenko, Linus Walleij, Bartosz Golaszewski
Use specific type and API for IRQ number in the callbacks.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-crystalcove.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c
index f40d3b133527..d4d01e734e22 100644
--- a/drivers/gpio/gpio-crystalcove.c
+++ b/drivers/gpio/gpio-crystalcove.c
@@ -188,8 +188,9 @@ static int crystalcove_irq_type(struct irq_data *data, unsigned int type)
{
struct crystalcove_gpio *cg =
gpiochip_get_data(irq_data_get_irq_chip_data(data));
+ irq_hw_number_t hwirq = irqd_to_hwirq(data);
- if (data->hwirq >= CRYSTALCOVE_GPIO_NUM)
+ if (hwirq >= CRYSTALCOVE_GPIO_NUM)
return 0;
switch (type) {
@@ -226,12 +227,12 @@ static void crystalcove_bus_sync_unlock(struct irq_data *data)
{
struct crystalcove_gpio *cg =
gpiochip_get_data(irq_data_get_irq_chip_data(data));
- int gpio = data->hwirq;
+ irq_hw_number_t hwirq = irqd_to_hwirq(data);
if (cg->update & UPDATE_IRQ_TYPE)
- crystalcove_update_irq_ctrl(cg, gpio);
+ crystalcove_update_irq_ctrl(cg, hwirq);
if (cg->update & UPDATE_IRQ_MASK)
- crystalcove_update_irq_mask(cg, gpio);
+ crystalcove_update_irq_mask(cg, hwirq);
cg->update = 0;
mutex_unlock(&cg->buslock);
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 3/3] gpio: crystalcove: Join function declarations and long lines
2022-06-01 15:04 [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable Andy Shevchenko
2022-06-01 15:04 ` [PATCH v1 2/3] gpio: crystalcove: Use specific type and API for IRQ number Andy Shevchenko
@ 2022-06-01 15:04 ` Andy Shevchenko
2022-06-01 15:46 ` [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable Andy Shevchenko
2022-06-01 15:48 ` Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-06-01 15:04 UTC (permalink / raw)
To: Andy Shevchenko, linux-gpio, linux-kernel
Cc: Andy Shevchenko, Linus Walleij, Bartosz Golaszewski
There is no more hard limit of 80 characters for long lines, so
join a few of them for better readability.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-crystalcove.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c
index d4d01e734e22..e21badc10ab4 100644
--- a/drivers/gpio/gpio-crystalcove.c
+++ b/drivers/gpio/gpio-crystalcove.c
@@ -111,8 +111,7 @@ static inline int to_reg(int gpio, enum ctrl_register reg_type)
return reg + gpio % 8;
}
-static void crystalcove_update_irq_mask(struct crystalcove_gpio *cg,
- int gpio)
+static void crystalcove_update_irq_mask(struct crystalcove_gpio *cg, int gpio)
{
u8 mirqs0 = gpio < 8 ? MGPIO0IRQS0 : MGPIO1IRQS0;
int mask = BIT(gpio % 8);
@@ -141,8 +140,7 @@ static int crystalcove_gpio_dir_in(struct gpio_chip *chip, unsigned int gpio)
return regmap_write(cg->regmap, reg, CTLO_INPUT_SET);
}
-static int crystalcove_gpio_dir_out(struct gpio_chip *chip, unsigned int gpio,
- int value)
+static int crystalcove_gpio_dir_out(struct gpio_chip *chip, unsigned int gpio, int value)
{
struct crystalcove_gpio *cg = gpiochip_get_data(chip);
int reg = to_reg(gpio, CTRL_OUT);
@@ -169,8 +167,7 @@ static int crystalcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
return val & 0x1;
}
-static void crystalcove_gpio_set(struct gpio_chip *chip,
- unsigned int gpio, int value)
+static void crystalcove_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
{
struct crystalcove_gpio *cg = gpiochip_get_data(chip);
int reg = to_reg(gpio, CTRL_OUT);
@@ -186,8 +183,7 @@ static void crystalcove_gpio_set(struct gpio_chip *chip,
static int crystalcove_irq_type(struct irq_data *data, unsigned int type)
{
- struct crystalcove_gpio *cg =
- gpiochip_get_data(irq_data_get_irq_chip_data(data));
+ struct crystalcove_gpio *cg = gpiochip_get_data(irq_data_get_irq_chip_data(data));
irq_hw_number_t hwirq = irqd_to_hwirq(data);
if (hwirq >= CRYSTALCOVE_GPIO_NUM)
@@ -217,16 +213,14 @@ static int crystalcove_irq_type(struct irq_data *data, unsigned int type)
static void crystalcove_bus_lock(struct irq_data *data)
{
- struct crystalcove_gpio *cg =
- gpiochip_get_data(irq_data_get_irq_chip_data(data));
+ struct crystalcove_gpio *cg = gpiochip_get_data(irq_data_get_irq_chip_data(data));
mutex_lock(&cg->buslock);
}
static void crystalcove_bus_sync_unlock(struct irq_data *data)
{
- struct crystalcove_gpio *cg =
- gpiochip_get_data(irq_data_get_irq_chip_data(data));
+ struct crystalcove_gpio *cg = gpiochip_get_data(irq_data_get_irq_chip_data(data));
irq_hw_number_t hwirq = irqd_to_hwirq(data);
if (cg->update & UPDATE_IRQ_TYPE)
@@ -302,8 +296,7 @@ static irqreturn_t crystalcove_gpio_irq_handler(int irq, void *data)
return IRQ_HANDLED;
}
-static void crystalcove_gpio_dbg_show(struct seq_file *s,
- struct gpio_chip *chip)
+static void crystalcove_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
{
struct crystalcove_gpio *cg = gpiochip_get_data(chip);
int gpio, offset;
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable
2022-06-01 15:04 [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable Andy Shevchenko
2022-06-01 15:04 ` [PATCH v1 2/3] gpio: crystalcove: Use specific type and API for IRQ number Andy Shevchenko
2022-06-01 15:04 ` [PATCH v1 3/3] gpio: crystalcove: Join function declarations and long lines Andy Shevchenko
@ 2022-06-01 15:46 ` Andy Shevchenko
2022-06-01 15:48 ` Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-06-01 15:46 UTC (permalink / raw)
To: Andy Shevchenko
Cc: open list:GPIO SUBSYSTEM, Linux Kernel Mailing List,
Andy Shevchenko, Linus Walleij, Bartosz Golaszewski
On Wed, Jun 1, 2022 at 5:04 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Since recently, the kernel is nagging about mutable irq_chips:
>
> "not an immutable chip, please consider fixing it!"
>
> Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new
> helper functions and call the appropriate gpiolib functions.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/gpio/gpio-crystalcove.c | 26 +++++++++++++++++---------
> 1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c
> index b55c74a5e064..f40d3b133527 100644
> --- a/drivers/gpio/gpio-crystalcove.c
> +++ b/drivers/gpio/gpio-crystalcove.c
> @@ -15,6 +15,7 @@
> #include <linux/platform_device.h>
> #include <linux/regmap.h>
> #include <linux/seq_file.h>
> +#include <linux/types.h>
>
> #define CRYSTALCOVE_GPIO_NUM 16
> #define CRYSTALCOVE_VGPIO_NUM 95
> @@ -238,10 +239,13 @@ static void crystalcove_bus_sync_unlock(struct irq_data *data)
>
> static void crystalcove_irq_unmask(struct irq_data *data)
> {
> - struct crystalcove_gpio *cg =
> - gpiochip_get_data(irq_data_get_irq_chip_data(data));
> + struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
> + struct crystalcove_gpio *cg = gpiochip_get_data(gc);
> + irq_hw_number_t hwirq = irqd_to_hwirq(data);
> +
> + gpiochip_enable_irq(gc, hwirq);
>
> - if (data->hwirq < CRYSTALCOVE_GPIO_NUM) {
> + if (hwirq < CRYSTALCOVE_GPIO_NUM) {
> cg->set_irq_mask = false;
> cg->update |= UPDATE_IRQ_MASK;
> }
> @@ -249,23 +253,27 @@ static void crystalcove_irq_unmask(struct irq_data *data)
>
> static void crystalcove_irq_mask(struct irq_data *data)
> {
> - struct crystalcove_gpio *cg =
> - gpiochip_get_data(irq_data_get_irq_chip_data(data));
> + struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
> + struct crystalcove_gpio *cg = gpiochip_get_data(gc);
> + irq_hw_number_t hwirq = irqd_to_hwirq(data);
>
> - if (data->hwirq < CRYSTALCOVE_GPIO_NUM) {
> + if (hwirq < CRYSTALCOVE_GPIO_NUM) {
> cg->set_irq_mask = true;
> cg->update |= UPDATE_IRQ_MASK;
> }
> +
> + gpiochip_disable_irq(gc, hwirq);
> }
>
> -static struct irq_chip crystalcove_irqchip = {
> +static const struct irq_chip crystalcove_irqchip = {
> .name = "Crystal Cove",
> .irq_mask = crystalcove_irq_mask,
> .irq_unmask = crystalcove_irq_unmask,
> .irq_set_type = crystalcove_irq_type,
> .irq_bus_lock = crystalcove_bus_lock,
> .irq_bus_sync_unlock = crystalcove_bus_sync_unlock,
> - .flags = IRQCHIP_SKIP_SET_WAKE,
> + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> static irqreturn_t crystalcove_gpio_irq_handler(int irq, void *data)
> @@ -353,7 +361,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
> cg->regmap = pmic->regmap;
>
> girq = &cg->chip.irq;
> - girq->chip = &crystalcove_irqchip;
> + gpio_irq_chip_set_chip(girq, &crystalcove_irqchip);
> /* This will let us handle the parent IRQ in the driver */
> girq->parent_handler = NULL;
> girq->num_parents = 0;
> --
> 2.35.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable
2022-06-01 15:04 [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable Andy Shevchenko
` (2 preceding siblings ...)
2022-06-01 15:46 ` [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable Andy Shevchenko
@ 2022-06-01 15:48 ` Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-06-01 15:48 UTC (permalink / raw)
To: Andy Shevchenko
Cc: open list:GPIO SUBSYSTEM, Linux Kernel Mailing List,
Andy Shevchenko, Linus Walleij, Bartosz Golaszewski
On Wed, Jun 1, 2022 at 5:04 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
...
> + gpiochip_enable_irq(gc, hwirq);
I think we do not need to do this for pins that we do not touch as
IRQs (they are vGPIOs with GPE capabilities, AFAIR).
> - if (data->hwirq < CRYSTALCOVE_GPIO_NUM) {
> + if (hwirq < CRYSTALCOVE_GPIO_NUM) {
> cg->set_irq_mask = false;
> cg->update |= UPDATE_IRQ_MASK;
> }
...
> - if (data->hwirq < CRYSTALCOVE_GPIO_NUM) {
> + if (hwirq < CRYSTALCOVE_GPIO_NUM) {
> cg->set_irq_mask = true;
> cg->update |= UPDATE_IRQ_MASK;
> }
> +
> + gpiochip_disable_irq(gc, hwirq);
Ditto.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-01 15:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 15:04 [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable Andy Shevchenko
2022-06-01 15:04 ` [PATCH v1 2/3] gpio: crystalcove: Use specific type and API for IRQ number Andy Shevchenko
2022-06-01 15:04 ` [PATCH v1 3/3] gpio: crystalcove: Join function declarations and long lines Andy Shevchenko
2022-06-01 15:46 ` [PATCH v1 1/3] gpio: crystalcove: make irq_chip immutable Andy Shevchenko
2022-06-01 15:48 ` Andy Shevchenko
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).