2023-03-19 21:02:24

by William Breathitt Gray

[permalink] [raw]
Subject: [PATCH v2 0/2] regmap-irq: Drop map from handle_mask_sync() parameters

Changes in v2:
- Pull out 104-dio-48e refactor to a precursor patch

Remove the map parameter from the struct regmap_irq_chip callback
handle_mask_sync() because it can be passed via the irq_drv_data
parameter instead. The gpio-104-dio-48e driver is the only consumer of
this callback and is thus updated accordingly.

A couple pending patchsets also utilize handle_mask_sync() [0][1], so
it'll be useful to merge the changes in this series first to avoid
subsequent noise adjusting the dependent drivers.

[0] https://lore.kernel.org/r/[email protected]/
[1] https://lore.kernel.org/r/[email protected]/

William Breathitt Gray (2):
gpio: 104-dio-48e: Implement struct dio48e_gpio
regmap-irq: Drop map from handle_mask_sync() parameters

drivers/base/regmap/regmap-irq.c | 5 ++---
drivers/gpio/gpio-104-dio-48e.c | 32 +++++++++++++++++++++++---------
include/linux/regmap.h | 3 +--
3 files changed, 26 insertions(+), 14 deletions(-)


base-commit: 03810031c91dfe448cd116ee987d5dc4139006f4
--
2.39.2



2023-03-19 21:02:27

by William Breathitt Gray

[permalink] [raw]
Subject: [PATCH v2 1/2] gpio: 104-dio-48e: Implement struct dio48e_gpio

A private data structure struct dio48e_gpio is introduced to facilitate
passage of the regmap and IRQ mask state for the device to the callback
dio48e_handle_mask_sync(). This is in preparation for the removal of the
handle_mask_sync() map parameter in a subsequent patch.

Signed-off-by: William Breathitt Gray <[email protected]>
---
drivers/gpio/gpio-104-dio-48e.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index 74e2721f2613..ef64c33e2685 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -99,14 +99,25 @@ static const struct regmap_irq dio48e_regmap_irqs[] = {
DIO48E_REGMAP_IRQ(0), DIO48E_REGMAP_IRQ(1),
};

+/**
+ * struct dio48e_gpio - GPIO device private data structure
+ * @map: Regmap for the device
+ * @irq_mask: Current IRQ mask state on the device
+ */
+struct dio48e_gpio {
+ struct regmap *map;
+ unsigned int irq_mask;
+};
+
static int dio48e_handle_mask_sync(struct regmap *const map, const int index,
const unsigned int mask_buf_def,
const unsigned int mask_buf,
void *const irq_drv_data)
{
- unsigned int *const irq_mask = irq_drv_data;
- const unsigned int prev_mask = *irq_mask;
+ struct dio48e_gpio *const dio48egpio = irq_drv_data;
+ const unsigned int prev_mask = dio48egpio->irq_mask;
int err;
+ struct regmap *const map = dio48egpio->map;
unsigned int val;

/* exit early if no change since the previous mask */
@@ -114,7 +125,7 @@ static int dio48e_handle_mask_sync(struct regmap *const map, const int index,
return 0;

/* remember the current mask for the next mask sync */
- *irq_mask = mask_buf;
+ dio48egpio->irq_mask = mask_buf;

/* if all previously masked, enable interrupts when unmasking */
if (prev_mask == mask_buf_def) {
@@ -167,7 +178,7 @@ static int dio48e_probe(struct device *dev, unsigned int id)
struct regmap *map;
int err;
struct regmap_irq_chip *chip;
- unsigned int irq_mask;
+ struct dio48e_gpio *dio48egpio;
struct regmap_irq_chip_data *chip_data;

if (!devm_request_region(dev, base[id], DIO48E_EXTENT, name)) {
@@ -185,12 +196,14 @@ static int dio48e_probe(struct device *dev, unsigned int id)
return dev_err_probe(dev, PTR_ERR(map),
"Unable to initialize register map\n");

- chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
- if (!chip)
+ dio48egpio = devm_kzalloc(dev, sizeof(*dio48egpio), GFP_KERNEL);
+ if (!dio48egpio)
return -ENOMEM;

- chip->irq_drv_data = devm_kzalloc(dev, sizeof(irq_mask), GFP_KERNEL);
- if (!chip->irq_drv_data)
+ dio48egpio->map = map;
+
+ chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
+ if (!chip)
return -ENOMEM;

chip->name = name;
@@ -205,6 +218,7 @@ static int dio48e_probe(struct device *dev, unsigned int id)
chip->irqs = dio48e_regmap_irqs;
chip->num_irqs = ARRAY_SIZE(dio48e_regmap_irqs);
chip->handle_mask_sync = dio48e_handle_mask_sync;
+ chip->irq_drv_data = dio48egpio;

/* Initialize to prevent spurious interrupts before we're ready */
err = dio48e_irq_init_hw(map);
--
2.39.2


2023-03-19 21:02:31

by William Breathitt Gray

[permalink] [raw]
Subject: [PATCH v2 2/2] regmap-irq: Drop map from handle_mask_sync() parameters

Remove the map parameter from the struct regmap_irq_chip callback
handle_mask_sync() because it can be passed via the irq_drv_data
parameter instead. The gpio-104-dio-48e driver is the only consumer of
this callback and is thus updated accordingly.

Signed-off-by: William Breathitt Gray <[email protected]>
---
drivers/base/regmap/regmap-irq.c | 5 ++---
drivers/gpio/gpio-104-dio-48e.c | 2 +-
include/linux/regmap.h | 3 +--
3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 8c903b8c9714..a9337192ddd3 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -116,8 +116,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
for (i = 0; i < d->chip->num_regs; i++) {
if (d->mask_base) {
if (d->chip->handle_mask_sync)
- d->chip->handle_mask_sync(d->map, i,
- d->mask_buf_def[i],
+ d->chip->handle_mask_sync(i, d->mask_buf_def[i],
d->mask_buf[i],
d->chip->irq_drv_data);
else {
@@ -915,7 +914,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,

if (d->mask_base) {
if (chip->handle_mask_sync) {
- ret = chip->handle_mask_sync(d->map, i,
+ ret = chip->handle_mask_sync(i,
d->mask_buf_def[i],
d->mask_buf[i],
chip->irq_drv_data);
diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index ef64c33e2685..8d7f83564886 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -109,7 +109,7 @@ struct dio48e_gpio {
unsigned int irq_mask;
};

-static int dio48e_handle_mask_sync(struct regmap *const map, const int index,
+static int dio48e_handle_mask_sync(const int index,
const unsigned int mask_buf_def,
const unsigned int mask_buf,
void *const irq_drv_data)
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 4d10790adeb0..6e18d8b405b1 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1644,8 +1644,7 @@ struct regmap_irq_chip {

int (*handle_pre_irq)(void *irq_drv_data);
int (*handle_post_irq)(void *irq_drv_data);
- int (*handle_mask_sync)(struct regmap *map, int index,
- unsigned int mask_buf_def,
+ int (*handle_mask_sync)(int index, unsigned int mask_buf_def,
unsigned int mask_buf, void *irq_drv_data);
int (*set_type_virt)(unsigned int **buf, unsigned int type,
unsigned long hwirq, int reg);
--
2.39.2


2023-03-19 21:23:09

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] regmap-irq: Drop map from handle_mask_sync() parameters

On Sun, Mar 19, 2023 at 10:02 PM William Breathitt Gray
<[email protected]> wrote:

> Changes in v2:
> - Pull out 104-dio-48e refactor to a precursor patch
>
> Remove the map parameter from the struct regmap_irq_chip callback
> handle_mask_sync() because it can be passed via the irq_drv_data
> parameter instead. The gpio-104-dio-48e driver is the only consumer of
> this callback and is thus updated accordingly.

Looks reasonable:
Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2023-03-20 00:18:39

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] gpio: 104-dio-48e: Implement struct dio48e_gpio

Hi William,

I love your patch! Yet something to improve:

[auto build test ERROR on 03810031c91dfe448cd116ee987d5dc4139006f4]

url: https://github.com/intel-lab-lkp/linux/commits/William-Breathitt-Gray/gpio-104-dio-48e-Implement-struct-dio48e_gpio/20230320-050433
base: 03810031c91dfe448cd116ee987d5dc4139006f4
patch link: https://lore.kernel.org/r/296c8d808a4a9753ae3aa66d04b746c52df6b8ae.1679259085.git.william.gray%40linaro.org
patch subject: [PATCH v2 1/2] gpio: 104-dio-48e: Implement struct dio48e_gpio
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230320/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/844453d513d06fbc8fbfe14ecff74b3bc3a92bbb
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review William-Breathitt-Gray/gpio-104-dio-48e-Implement-struct-dio48e_gpio/20230320-050433
git checkout 844453d513d06fbc8fbfe14ecff74b3bc3a92bbb
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 olddefconfig
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/gpio/gpio-104-dio-48e.c: In function 'dio48e_handle_mask_sync':
>> drivers/gpio/gpio-104-dio-48e.c:120:30: error: 'map' redeclared as different kind of symbol
120 | struct regmap *const map = dio48egpio->map;
| ^~~
drivers/gpio/gpio-104-dio-48e.c:112:57: note: previous definition of 'map' with type 'struct regmap * const'
112 | static int dio48e_handle_mask_sync(struct regmap *const map, const int index,
| ~~~~~~~~~~~~~~~~~~~~~^~~


vim +/map +120 drivers/gpio/gpio-104-dio-48e.c

111
112 static int dio48e_handle_mask_sync(struct regmap *const map, const int index,
113 const unsigned int mask_buf_def,
114 const unsigned int mask_buf,
115 void *const irq_drv_data)
116 {
117 struct dio48e_gpio *const dio48egpio = irq_drv_data;
118 const unsigned int prev_mask = dio48egpio->irq_mask;
119 int err;
> 120 struct regmap *const map = dio48egpio->map;
121 unsigned int val;
122
123 /* exit early if no change since the previous mask */
124 if (mask_buf == prev_mask)
125 return 0;
126
127 /* remember the current mask for the next mask sync */
128 dio48egpio->irq_mask = mask_buf;
129
130 /* if all previously masked, enable interrupts when unmasking */
131 if (prev_mask == mask_buf_def) {
132 err = regmap_write(map, DIO48E_CLEAR_INTERRUPT, 0x00);
133 if (err)
134 return err;
135 return regmap_write(map, DIO48E_ENABLE_INTERRUPT, 0x00);
136 }
137
138 /* if all are currently masked, disable interrupts */
139 if (mask_buf == mask_buf_def)
140 return regmap_read(map, DIO48E_DISABLE_INTERRUPT, &val);
141
142 return 0;
143 }
144

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

2023-03-20 12:45:30

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] regmap-irq: Drop map from handle_mask_sync() parameters

On Sun, Mar 19, 2023 at 05:02:00PM -0400, William Breathitt Gray wrote:
> Changes in v2:
> - Pull out 104-dio-48e refactor to a precursor patch
>
> Remove the map parameter from the struct regmap_irq_chip callback
> handle_mask_sync() because it can be passed via the irq_drv_data
> parameter instead. The gpio-104-dio-48e driver is the only consumer of
> this callback and is thus updated accordingly.
>
> A couple pending patchsets also utilize handle_mask_sync() [0][1], so
> it'll be useful to merge the changes in this series first to avoid
> subsequent noise adjusting the dependent drivers.
>
> [0] https://lore.kernel.org/r/[email protected]/
> [1] https://lore.kernel.org/r/[email protected]/

Good idea and intention, but something went wrong with bisectability as pointed
out by the build bot. As a last resort you would need to squash these two, but
try first another possible patch series split.

--
With Best Regards,
Andy Shevchenko



2023-03-20 14:35:00

by William Breathitt Gray

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] regmap-irq: Drop map from handle_mask_sync() parameters

On Mon, Mar 20, 2023 at 02:44:43PM +0200, Andy Shevchenko wrote:
> On Sun, Mar 19, 2023 at 05:02:00PM -0400, William Breathitt Gray wrote:
> > Changes in v2:
> > - Pull out 104-dio-48e refactor to a precursor patch
> >
> > Remove the map parameter from the struct regmap_irq_chip callback
> > handle_mask_sync() because it can be passed via the irq_drv_data
> > parameter instead. The gpio-104-dio-48e driver is the only consumer of
> > this callback and is thus updated accordingly.
> >
> > A couple pending patchsets also utilize handle_mask_sync() [0][1], so
> > it'll be useful to merge the changes in this series first to avoid
> > subsequent noise adjusting the dependent drivers.
> >
> > [0] https://lore.kernel.org/r/[email protected]/
> > [1] https://lore.kernel.org/r/[email protected]/
>
> Good idea and intention, but something went wrong with bisectability as pointed
> out by the build bot. As a last resort you would need to squash these two, but
> try first another possible patch series split.
>
> --
> With Best Regards,
> Andy Shevchenko

I should have build tested each commit when I rebased rather than just
the last. I'd rather avoid a squash so that these changes are distinct
for the sake of a clear git history on the regmap API change; I'll
submit a v3 soon with the minor changes needed.

William Breathitt Gray


Attachments:
(No filename) (1.37 kB)
signature.asc (228.00 B)
Download all attachments

2023-03-20 14:47:15

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] regmap-irq: Drop map from handle_mask_sync() parameters

On Sun, Mar 19, 2023 at 05:18:53PM -0400, William Breathitt Gray wrote:
> On Mon, Mar 20, 2023 at 02:44:43PM +0200, Andy Shevchenko wrote:
> > On Sun, Mar 19, 2023 at 05:02:00PM -0400, William Breathitt Gray wrote:
> > > Changes in v2:
> > > - Pull out 104-dio-48e refactor to a precursor patch
> > >
> > > Remove the map parameter from the struct regmap_irq_chip callback
> > > handle_mask_sync() because it can be passed via the irq_drv_data
> > > parameter instead. The gpio-104-dio-48e driver is the only consumer of
> > > this callback and is thus updated accordingly.
> > >
> > > A couple pending patchsets also utilize handle_mask_sync() [0][1], so
> > > it'll be useful to merge the changes in this series first to avoid
> > > subsequent noise adjusting the dependent drivers.
> > >
> > > [0] https://lore.kernel.org/r/[email protected]/
> > > [1] https://lore.kernel.org/r/[email protected]/
> >
> > Good idea and intention, but something went wrong with bisectability as pointed
> > out by the build bot. As a last resort you would need to squash these two, but
> > try first another possible patch series split.

> I should have build tested each commit when I rebased rather than just
> the last.

Right, that's what we call a "compile time bisectability".

> I'd rather avoid a squash so that these changes are distinct
> for the sake of a clear git history on the regmap API change;

That's my point! I glad we are on the same page.

> I'll submit a v3 soon with the minor changes needed.

--
With Best Regards,
Andy Shevchenko