mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regmap: irq: Allow using zero value for ack_base
@ 2013-12-15  9:36 Alexander Shiyan
  2013-12-15  9:48 ` Levente Kurusa
  2013-12-16 20:50 ` Mark Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Shiyan @ 2013-12-15  9:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Greg Kroah-Hartman, Alexander Shiyan

In some cases, clear interrupt register may be at address 0.
This patch allows to use such configurations by adding additional
configuration bit to indicate this.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/base/regmap/regmap-irq.c | 6 +++---
 include/linux/regmap.h           | 5 ++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 763c60d..8269206 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -113,7 +113,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 		 * OR if there is masked interrupt which hasn't been Acked,
 		 * it'll be ignored in irq handler, then may introduce irq storm
 		 */
-		if (d->mask_buf[i] && d->chip->ack_base) {
+		if (d->mask_buf[i] && (d->chip->ack_base || d->chip->use_ack)) {
 			reg = d->chip->ack_base +
 				(i * map->reg_stride * d->irq_reg_stride);
 			ret = regmap_write(map, reg, d->mask_buf[i]);
@@ -271,7 +271,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 	for (i = 0; i < data->chip->num_regs; i++) {
 		data->status_buf[i] &= ~data->mask_buf[i];
 
-		if (data->status_buf[i] && chip->ack_base) {
+		if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) {
 			reg = chip->ack_base +
 				(i * map->reg_stride * data->irq_reg_stride);
 			ret = regmap_write(map, reg, data->status_buf[i]);
@@ -448,7 +448,7 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
 			goto err_alloc;
 		}
 
-		if (d->status_buf[i] && chip->ack_base) {
+		if (d->status_buf[i] && (chip->ack_base || chip->use_ack)) {
 			reg = chip->ack_base +
 				(i * map->reg_stride * d->irq_reg_stride);
 			ret = regmap_write(map, reg,
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index e559078..3a36f61 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -497,11 +497,13 @@ struct regmap_irq {
  *
  * @status_base: Base status register address.
  * @mask_base:   Base mask register address.
- * @ack_base:    Base ack address.  If zero then the chip is clear on read.
+ * @ack_base:    Base ack address. If zero then the chip is clear on read.
+ *               Using zero value is possible with @use_ack bit.
  * @wake_base:   Base address for wake enables.  If zero unsupported.
  * @irq_reg_stride:  Stride to use for chips where registers are not contiguous.
  * @init_ack_masked: Ack all masked interrupts once during initalization.
  * @mask_invert: Inverted mask register: cleared bits are masked out.
+ * @use_ack:     Use @ack register even it zero.
  * @wake_invert: Inverted wake register: cleared bits are wake enabled.
  * @runtime_pm:  Hold a runtime PM lock on the device when accessing it.
  *
@@ -520,6 +522,7 @@ struct regmap_irq_chip {
 	unsigned int irq_reg_stride;
 	bool init_ack_masked:1;
 	bool mask_invert:1;
+	bool use_ack:1;
 	bool wake_invert:1;
 	bool runtime_pm:1;
 
-- 
1.8.3.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regmap: irq: Allow using zero value for ack_base
  2013-12-15  9:36 [PATCH] regmap: irq: Allow using zero value for ack_base Alexander Shiyan
@ 2013-12-15  9:48 ` Levente Kurusa
  2013-12-15  9:51   ` Alexander Shiyan
  2013-12-16 20:50 ` Mark Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Levente Kurusa @ 2013-12-15  9:48 UTC (permalink / raw)
  To: Alexander Shiyan, linux-kernel; +Cc: Mark Brown, Greg Kroah-Hartman

On 12/15/2013 10:36 AM, Alexander Shiyan wrote:
> In some cases, clear interrupt register may be at address 0.
> This patch allows to use such configurations by adding additional
> configuration bit to indicate this.
> 
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
>  drivers/base/regmap/regmap-irq.c | 6 +++---
>  include/linux/regmap.h           | 5 ++++-
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
> index 763c60d..8269206 100644
> --- a/drivers/base/regmap/regmap-irq.c
> +++ b/drivers/base/regmap/regmap-irq.c
> @@ -113,7 +113,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
>  		 * OR if there is masked interrupt which hasn't been Acked,
>  		 * it'll be ignored in irq handler, then may introduce irq storm
>  		 */
> -		if (d->mask_buf[i] && d->chip->ack_base) {
> +		if (d->mask_buf[i] && (d->chip->ack_base || d->chip->use_ack)) {
>  			reg = d->chip->ack_base +
>  				(i * map->reg_stride * d->irq_reg_stride);
>  			ret = regmap_write(map, reg, d->mask_buf[i]);
> @@ -271,7 +271,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
>  	for (i = 0; i < data->chip->num_regs; i++) {
>  		data->status_buf[i] &= ~data->mask_buf[i];
>  
> -		if (data->status_buf[i] && chip->ack_base) {
> +		if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) {
>  			reg = chip->ack_base +
>  				(i * map->reg_stride * data->irq_reg_stride);
>  			ret = regmap_write(map, reg, data->status_buf[i]);
> @@ -448,7 +448,7 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
>  			goto err_alloc;
>  		}
>  
> -		if (d->status_buf[i] && chip->ack_base) {
> +		if (d->status_buf[i] && (chip->ack_base || chip->use_ack)) {
>  			reg = chip->ack_base +
>  				(i * map->reg_stride * d->irq_reg_stride);
>  			ret = regmap_write(map, reg,
> diff --git a/include/linux/regmap.h b/include/linux/regmap.h
> index e559078..3a36f61 100644
> --- a/include/linux/regmap.h
> +++ b/include/linux/regmap.h
> @@ -497,11 +497,13 @@ struct regmap_irq {
>   *
>   * @status_base: Base status register address.
>   * @mask_base:   Base mask register address.
> - * @ack_base:    Base ack address.  If zero then the chip is clear on read.
> + * @ack_base:    Base ack address. If zero then the chip is clear on read.
> + *               Using zero value is possible with @use_ack bit.
>   * @wake_base:   Base address for wake enables.  If zero unsupported.
>   * @irq_reg_stride:  Stride to use for chips where registers are not contiguous.
>   * @init_ack_masked: Ack all masked interrupts once during initalization.

Oh a typo!  'initalization' should be 'initialization'
>   * @mask_invert: Inverted mask register: cleared bits are masked out.
> + * @use_ack:     Use @ack register even it zero.
'even it zero' should be 'even if it is zero'


>   * @wake_invert: Inverted wake register: cleared bits are wake enabled.
>   * @runtime_pm:  Hold a runtime PM lock on the device when accessing it.
>   *
> @@ -520,6 +522,7 @@ struct regmap_irq_chip {
>  	unsigned int irq_reg_stride;
>  	bool init_ack_masked:1;
>  	bool mask_invert:1;
> +	bool use_ack:1;
I think this will break something. Better use 0 as default value.
Reason I think so, is because in the above code you effectively add a new
possibility for most code to run.

-- 
Regards,
Levente Kurusa

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regmap: irq: Allow using zero value for ack_base
  2013-12-15  9:48 ` Levente Kurusa
@ 2013-12-15  9:51   ` Alexander Shiyan
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Shiyan @ 2013-12-15  9:51 UTC (permalink / raw)
  To: Levente Kurusa; +Cc: linux-kernel, Mark Brown, Greg Kroah-Hartman

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 1181 bytes --]

> On 12/15/2013 10:36 AM, Alexander Shiyan wrote:
> > In some cases, clear interrupt register may be at address 0.
> > This patch allows to use such configurations by adding additional
> > configuration bit to indicate this.
> > 
> > Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> > ---
> >  drivers/base/regmap/regmap-irq.c | 6 +++---
> >  include/linux/regmap.h           | 5 ++++-
> >  2 files changed, 7 insertions(+), 4 deletions(-)
...
> > diff --git a/include/linux/regmap.h b/include/linux/regmap.h
> > index e559078..3a36f61 100644
> > --- a/include/linux/regmap.h
> > +++ b/include/linux/regmap.h
...
> > @@ -520,6 +522,7 @@ struct regmap_irq_chip {
> >  	unsigned int irq_reg_stride;
> >  	bool init_ack_masked:1;
> >  	bool mask_invert:1;
> > +	bool use_ack:1;
> I think this will break something. Better use 0 as default value.
> Reason I think so, is because in the above code you effectively add a new
> possibility for most code to run.

This is not a default value but bit-size of this field.

---
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regmap: irq: Allow using zero value for ack_base
  2013-12-15  9:36 [PATCH] regmap: irq: Allow using zero value for ack_base Alexander Shiyan
  2013-12-15  9:48 ` Levente Kurusa
@ 2013-12-16 20:50 ` Mark Brown
  2013-12-16 21:02   ` Alexander Shiyan
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2013-12-16 20:50 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: linux-kernel, Greg Kroah-Hartman

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

On Sun, Dec 15, 2013 at 01:36:51PM +0400, Alexander Shiyan wrote:
> In some cases, clear interrupt register may be at address 0.
> This patch allows to use such configurations by adding additional
> configuration bit to indicate this.

Applied, thanks with the grammar for the docs corrected.  We probably ought to do this for most of the fields :/
I guess this is for some driver you're upstreaming so a signed tag would
be useful?  

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regmap: irq: Allow using zero value for ack_base
  2013-12-16 20:50 ` Mark Brown
@ 2013-12-16 21:02   ` Alexander Shiyan
  2013-12-16 21:05     ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Shiyan @ 2013-12-16 21:02 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Greg Kroah-Hartman

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 717 bytes --]

> On Sun, Dec 15, 2013 at 01:36:51PM +0400, Alexander Shiyan wrote:
> > In some cases, clear interrupt register may be at address 0.
> > This patch allows to use such configurations by adding additional
> > configuration bit to indicate this.
> 
> Applied, thanks with the grammar for the docs corrected.  We probably ought to do this for most of the fields :/
> I guess this is for some driver you're upstreaming so a signed tag would
> be useful?  

I plan to use regmap-irq for migration mc13xxx MFD core to use IRQ domains.
It will not be so soon.

---
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regmap: irq: Allow using zero value for ack_base
  2013-12-16 21:02   ` Alexander Shiyan
@ 2013-12-16 21:05     ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2013-12-16 21:05 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: linux-kernel, Greg Kroah-Hartman

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

On Tue, Dec 17, 2013 at 01:02:26AM +0400, Alexander Shiyan wrote:

> > I guess this is for some driver you're upstreaming so a signed tag would
> > be useful?  

> I plan to use regmap-irq for migration mc13xxx MFD core to use IRQ domains.
> It will not be so soon.

OK, well let me know if you do need a signed tag and I'll do one.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-16 21:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-15  9:36 [PATCH] regmap: irq: Allow using zero value for ack_base Alexander Shiyan
2013-12-15  9:48 ` Levente Kurusa
2013-12-15  9:51   ` Alexander Shiyan
2013-12-16 20:50 ` Mark Brown
2013-12-16 21:02   ` Alexander Shiyan
2013-12-16 21:05     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®