Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1590732 > unrolled thread

[PATCHv2 1/2] mfd: cpcap: implement irq sense helper

Started bySebastian Reichel <sre@kernel.org>
First post2017-03-02 01:30 +0100
Last post2017-03-02 17:40 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel <sre@kernel.org> - 2017-03-02 01:30 +0100
    Re: [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Tony Lindgren <tony@atomide.com> - 2017-03-02 16:40 +0100
    Re: [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Tony Lindgren <tony@atomide.com> - 2017-03-02 17:40 +0100

#1590732 — [PATCHv2 1/2] mfd: cpcap: implement irq sense helper

FromSebastian Reichel <sre@kernel.org>
Date2017-03-02 01:30 +0100
Subject[PATCHv2 1/2] mfd: cpcap: implement irq sense helper
Message-ID<tgmN4-2vO-9@gated-at.bofh.it>
CPCAP can sense if IRQ is currently set or not. This
functionality is required for a few subdevices, such
as the power button and usb phy modules.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
Changes since PATCHv1:
 - Newly introduced patch
---
 drivers/mfd/motorola-cpcap.c       | 25 +++++++++++++++++++++++++
 include/linux/mfd/motorola-cpcap.h |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
index 6aeada7d7ce5..b2a53750d579 100644
--- a/drivers/mfd/motorola-cpcap.c
+++ b/drivers/mfd/motorola-cpcap.c
@@ -32,6 +32,31 @@ struct cpcap_ddata {
 	struct regmap *regmap;
 };
 
+static int cpcap_sense_irq(struct regmap *regmap, int irq)
+{
+	int reg = CPCAP_REG_INTS1 + (irq / 16) * 4;
+	int mask = 1 << (irq % 16);
+	int err, val;
+
+	if (irq < 0 || irq > 64)
+		return -EINVAL;
+
+	err = regmap_read(regmap, reg, &val);
+	if (err)
+		return err;
+
+	return !!(val & mask);
+}
+
+int cpcap_sense_virq(struct regmap *regmap, int virq)
+{
+	struct regmap_irq_chip_data *d = irq_get_chip_data(virq);
+	int base = regmap_irq_chip_get_base(d);
+
+	return cpcap_sense_irq(regmap, virq - base);
+}
+EXPORT_SYMBOL_GPL(cpcap_sense_irq);
+
 static int cpcap_check_revision(struct cpcap_ddata *cpcap)
 {
 	u16 vendor, rev;
diff --git a/include/linux/mfd/motorola-cpcap.h b/include/linux/mfd/motorola-cpcap.h
index b4031c2b2214..7629e0d24d26 100644
--- a/include/linux/mfd/motorola-cpcap.h
+++ b/include/linux/mfd/motorola-cpcap.h
@@ -290,3 +290,5 @@ static inline int cpcap_get_vendor(struct device *dev,
 
 	return 0;
 }
+
+int cpcap_sense_virq(struct regmap *regmap, int virq);
-- 
2.11.0

[toc] | [next] | [standalone]


#1591196

FromTony Lindgren <tony@atomide.com>
Date2017-03-02 16:40 +0100
Message-ID<tgAZH-4mT-13@gated-at.bofh.it>
In reply to#1590732
* Sebastian Reichel <sre@kernel.org> [170301 16:24]:
> CPCAP can sense if IRQ is currently set or not. This
> functionality is required for a few subdevices, such
> as the power button and usb phy modules.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
> Changes since PATCHv1:
>  - Newly introduced patch

Works for me:

Acked-by: Tony Lindgren <tony@atomide.com>

[toc] | [prev] | [next] | [standalone]


#1591262

FromTony Lindgren <tony@atomide.com>
Date2017-03-02 17:40 +0100
Message-ID<tgBVM-4ZX-13@gated-at.bofh.it>
In reply to#1590732
* Sebastian Reichel <sre@kernel.org> [170301 16:24]:
> CPCAP can sense if IRQ is currently set or not. This
> functionality is required for a few subdevices, such
> as the power button and usb phy modules.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
> Changes since PATCHv1:
>  - Newly introduced patch
> ---
>  drivers/mfd/motorola-cpcap.c       | 25 +++++++++++++++++++++++++
>  include/linux/mfd/motorola-cpcap.h |  2 ++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
> index 6aeada7d7ce5..b2a53750d579 100644
> --- a/drivers/mfd/motorola-cpcap.c
> +++ b/drivers/mfd/motorola-cpcap.c
> @@ -32,6 +32,31 @@ struct cpcap_ddata {
>  	struct regmap *regmap;
>  };
>  
> +static int cpcap_sense_irq(struct regmap *regmap, int irq)
> +{
> +	int reg = CPCAP_REG_INTS1 + (irq / 16) * 4;
> +	int mask = 1 << (irq % 16);
> +	int err, val;
> +
> +	if (irq < 0 || irq > 64)
> +		return -EINVAL;
> +
> +	err = regmap_read(regmap, reg, &val);
> +	if (err)
> +		return err;
> +
> +	return !!(val & mask);
> +}
> +
> +int cpcap_sense_virq(struct regmap *regmap, int virq)
> +{
> +	struct regmap_irq_chip_data *d = irq_get_chip_data(virq);
> +	int base = regmap_irq_chip_get_base(d);
> +
> +	return cpcap_sense_irq(regmap, virq - base);
> +}
> +EXPORT_SYMBOL_GPL(cpcap_sense_irq);

You have a typo here, should be cpcap_sense_virq for the exported one :)

Other than that my ack is still valid.

Regards,

Tony

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web