[PATCH v2 4/4] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-02-28 Thread Denis OSTERLAND
From: Denis Osterland 

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 47 +++
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 164371b..f2f148b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Register map */
 /* rtc section */
@@ -79,6 +80,7 @@ enum {
 struct isl1208 {
struct rtc_device *rtc;
const struct attribute_group *sysfs_files;
+   int evdet_irq;
 };
 
 /* block read */
@@ -730,6 +732,24 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
@@ -772,6 +792,8 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
return rc;
}
isl1208->sysfs_files = _rtc_sysfs_files;
+   isl1208->evdet_irq = of_irq_get_byname(client->dev.of_node,
+   "evdet");
} else {
isl1208->sysfs_files = _rtc_sysfs_files;
}
@@ -780,22 +802,15 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (isl1208->evdet_irq > 0 && isl1208->evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, isl1208->evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(isl1208->rtc);
 }
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally 

[PATCH v2 4/4] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-02-28 Thread Denis OSTERLAND
From: Denis Osterland 

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 47 +++
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 164371b..f2f148b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Register map */
 /* rtc section */
@@ -79,6 +80,7 @@ enum {
 struct isl1208 {
struct rtc_device *rtc;
const struct attribute_group *sysfs_files;
+   int evdet_irq;
 };
 
 /* block read */
@@ -730,6 +732,24 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
@@ -772,6 +792,8 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
return rc;
}
isl1208->sysfs_files = _rtc_sysfs_files;
+   isl1208->evdet_irq = of_irq_get_byname(client->dev.of_node,
+   "evdet");
} else {
isl1208->sysfs_files = _rtc_sysfs_files;
}
@@ -780,22 +802,15 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (isl1208->evdet_irq > 0 && isl1208->evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, isl1208->evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(isl1208->rtc);
 }
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake