From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: William Breathitt Gray <william.gray@linaro.org>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
michael@walle.cc, broonie@kernel.org
Subject: Re: [PATCH v3 3/9] gpio: 104-dio-48e: Migrate to the regmap-irq API
Date: Wed, 23 Nov 2022 17:01:53 +0200 [thread overview]
Message-ID: <Y3414YhVjqKakddV@smile.fi.intel.com> (raw)
In-Reply-To: <80fc819bcafe9697b6e02c0750d3cf0ea4ec9e1b.1669100542.git.william.gray@linaro.org>
On Tue, Nov 22, 2022 at 02:11:00AM -0500, William Breathitt Gray wrote:
> 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.
>
> For the 104-dio-48e we have the following IRQ registers (0xB and 0xF):
>
> Base Address +B (Write): Enable Interrupt
> Base Address +B (Read): Disable Interrupt
> Base Address +F (Read/Write): Clear Interrupt
>
> Any write to 0xB will enable interrupts, while any read will disable
> interrupts. Interrupts are cleared by a read or any write to 0xF.
> There's no IRQ status register, so software has to assume that if an
> interrupt is raised then it was for the 104-DIO-48E device.
...
> +/* only bit 3 on each respective Port C supports interrupts */
> +#define DIO48E_REGMAP_IRQ(_ppi) \
> + [19 + (_ppi) * 24] = { \
> + .mask = BIT(_ppi), \
> + .type = { .types_supported = IRQ_TYPE_EDGE_RISING, }, \
When {} on a single line, the trailing comma is not needed.
.type = { .types_supported = IRQ_TYPE_EDGE_RISING }, \
would work as well.
A nit: I would put \ on the same column by using TABs before each of them.
> }
...
> + /* if all previously masked, enable interrupts when unmasking */
> + if (prev_mask == all_masked) {
> + err = regmap_write(map, DIO48E_ENABLE_INTERRUPT, 0x00);
> + if (err)
> + return err;
> + /* if all are currently masked, disable interrupts */
> + } else if (mask_buf == all_masked) {
> + err = regmap_read(map, DIO48E_DISABLE_INTERRUPT, &val);
> + if (err)
> + return err;
> + }
Haven't looked at the rest of the series, but if there is nothing with this
code piece, the above can be optimized to
if (prev_mask == all_masked)
return regmap_write(map, DIO48E_ENABLE_INTERRUPT, 0x00);
if (mask_buf == all_masked)
return regmap_read(map, DIO48E_DISABLE_INTERRUPT, &val);
...
> + /* Initialize device interrupt state */
> + err = regmap_read(map, DIO48E_DISABLE_INTERRUPT, &val);
> + if (err)
> + return err;
Use ->init_hw() callback for this.
...
> + err = devm_regmap_add_irq_chip(dev, map, irq[id], 0, 0, chip,
> + &chip_data);
I would leave this on one line. It's only 82.
> + if (err) {
> + dev_err(dev, "IRQ registration failed (%d)\n", err);
> + return err;
> + }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-11-23 15:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 7:10 [PATCH v3 0/9] Migrate i8255 GPIO drivers to regmap API William Breathitt Gray
2022-11-22 7:10 ` [PATCH v3 1/9] gpio: regmap: Always set gpio_chip get_direction William Breathitt Gray
2022-11-22 7:10 ` [PATCH v3 2/9] regmap-irq: Add handle_mask_sync() callback William Breathitt Gray
2022-11-22 7:11 ` [PATCH v3 3/9] gpio: 104-dio-48e: Migrate to the regmap-irq API William Breathitt Gray
2022-11-23 15:01 ` Andy Shevchenko [this message]
2022-11-22 10:29 ` William Breathitt Gray
2022-11-27 18:31 ` Michael Walle
2022-11-27 22:00 ` William Breathitt Gray
2022-11-28 9:51 ` Andy Shevchenko
2022-11-28 9:56 ` Andy Shevchenko
2022-11-28 10:04 ` Andy Shevchenko
2022-11-28 9:41 ` Andy Shevchenko
2022-11-28 9:56 ` Michael Walle
2022-11-28 10:02 ` Andy Shevchenko
2022-11-22 7:11 ` [PATCH v3 4/9] gpio: 104-idi-48: " William Breathitt Gray
2022-11-23 17:28 ` Andy Shevchenko
2022-11-22 7:11 ` [PATCH v3 5/9] gpio: 104-idi-48: Migrate to gpio-regmap API William Breathitt Gray
2022-11-23 17:31 ` Andy Shevchenko
2022-11-22 7:11 ` [PATCH v3 6/9] gpio: i8255: " William Breathitt Gray
2022-11-23 17:42 ` Andy Shevchenko
2022-11-22 11:34 ` William Breathitt Gray
2022-11-22 7:11 ` [PATCH v3 7/9] gpio: 104-dio-48e: Migrate to regmap API William Breathitt Gray
2022-11-23 17:43 ` Andy Shevchenko
2022-11-22 7:11 ` [PATCH v3 8/9] gpio: gpio-mm: " William Breathitt Gray
2022-11-23 17:46 ` Andy Shevchenko
2022-11-22 7:11 ` [PATCH v3 9/9] gpio: i8255: Remove unused legacy interface William Breathitt Gray
2022-11-23 17:31 ` Andy Shevchenko
2022-12-09 18:59 ` (subset) [PATCH v3 0/9] Migrate i8255 GPIO drivers to regmap API Mark Brown
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=Y3414YhVjqKakddV@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@walle.cc \
--cc=william.gray@linaro.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox