Re: [PATCH v4 0/9] Migrate i8255 GPIO drivers to regmap API
From: Bartosz Golaszewski
Date: Mon Dec 05 2022 - 05:29:03 EST
On Fri, Dec 2, 2022 at 5:27 PM William Breathitt Gray
<william.gray@xxxxxxxxxx> wrote:
>
> Changes in v4:
> - Align trailing '\' characters in macros to same column in 104-dio-48e
> and 104-idi-48
> - Remove superfluous trailing commas in macros in 104-dio-48e and
> 104-idi-48
> - Simplify dio48e_handle_mask_sync() regmap_* calls error checks to
> return error codes directly
> - Refactor dio48e_irq_init_hw() for regmap and comment about spurious
> interrupts; in theory this should be enough to prevent spurious
> interrupts before the system is ready, but we can pass this function
> as a callback where needed in the future
> - Cleanup '{0}' as '{}' in probe() callbacks for 104-dio-48e,
> 104-idi-48, and gpio-mm
> - Utilize dev_err_probe() in probe() callbacks for 104-dio-48e and
> 104-idi-48
> - Provide convenience comments for idi48_regmap_irqs initialization
> list
> - Replace header includes with forward declarations in gpio-i8255.h
>
> The regmap API supports IO port accessors so we can take advantage of
> regmap abstractions rather than handling access to the device registers
> directly in the driver. The 104-dio-48e and gpio-mm modules depend on
> the i8255 library and are thus updated accordingly.
>
> The 104-IDI-48 is hardwired as an input-only device. Because the i8255
> control registers are not exposed on the 104-IDI-48, the i8255 library
> doesn't provide much benefit here. In this case it's simpler to utilize
> the gpio_regmap API directly, so this patch series does such and removes
> the i8255 library dependency from the 104-idi-48 module.
>
> The first patch in this series adjusts gpio_regmap to always set
> gpio_chip get_direction. This patch is mostly independent of the rest of
> the patches in the series and can be picked up separately if desired.
> I'm including it here because it allows the input-only 104-idi-48 driver
> to continue reporting offset directions after migrating to gpio_regmap.
>
> A handle_mask_sync() callback is introduced for the regmap_irq API. This
> is used by the 104-dio-48e driver to handle its enable/disable interrupt
> functionality. The 104-DIO-48E has a single register to handle
> enabling/disabling interrupts: a write of any value to this register
> enables interrupts, while any read disables interrupts.
>
> By leveraging the gpio_regmap API, the i8255 library is reduced to
> simply a devm_i8255_regmap_register() function, a configuration
> structure struct i8255_regmap_config, and a helper macro
> i8255_volatile_regmap_range() provided to simplify volatile PPI register
> hinting for the regmap.
>
> The regmap_irq API is leveraged by the 104-idi-48 and 104-dio-48e
> modules to support their IRQ functionality. Do their respective regmap
> configurations need use_hwlock set to true in this case, or is adequate
> locking already handled by the regmap_irq API?
>
> William Breathitt Gray (9):
> gpio: regmap: Always set gpio_chip get_direction
> regmap-irq: Add handle_mask_sync() callback
> gpio: 104-dio-48e: Migrate to the regmap-irq API
> gpio: 104-idi-48: Migrate to the regmap-irq API
> gpio: 104-idi-48: Migrate to gpio-regmap API
> gpio: i8255: Migrate to gpio-regmap API
> gpio: 104-dio-48e: Migrate to regmap API
> gpio: gpio-mm: Migrate to regmap API
> gpio: i8255: Remove unused legacy interface
>
> drivers/base/regmap/regmap-irq.c | 44 +++-
> drivers/gpio/Kconfig | 5 +-
> drivers/gpio/gpio-104-dio-48e.c | 391 ++++++++++---------------------
> drivers/gpio/gpio-104-idi-48.c | 336 +++++++++-----------------
> drivers/gpio/gpio-gpio-mm.c | 154 +++---------
> drivers/gpio/gpio-i8255.c | 320 +++++++------------------
> drivers/gpio/gpio-i8255.h | 54 ++---
> drivers/gpio/gpio-regmap.c | 7 +-
> include/linux/regmap.h | 5 +
> 9 files changed, 416 insertions(+), 900 deletions(-)
>
>
> base-commit: 3b7c7478eda00945987d45f902bc3942c89243d3
> --
> 2.38.1
>
It's pretty late in the release cycle and this touches several
existing drivers so I will not take it for v6.2. Please rebase and
resend once v6.3-rc1 is out.
Bart