<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>[RESEND PATCH 2/2] Extcon: MAX8997: Add support irq domain for MAX8997 muic</title>
        <description> This patch add support irq domain for Maxim MAX8997 muic
instead of irq_base in platform data and max8997 driver
private data are instead. It is tested on TRATS board.

Signed-off-by: Chanwoo Choi &amp;lt;cw00.choi@samsung.com&amp;gt;
Signed-off-by: Myungjoo Ham &amp;lt;myungjoo.ham@samsung.com&amp;gt;
Signed-off-by: Kyungmin Park &amp;lt;kyungmin.park@samsung.com&amp;gt;
---
 drivers/extcon/Kconfig          |    2 +-
 drivers/extcon/extcon-max8997.c |   29 ++++++++++++++++++-----------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 29c5cf8..bf6b2ea 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -23,7 +23,7 @@ config EXTCON_GPIO
 
 config EXTCON_MAX8997
 	tristate &amp;quot;MAX8997 EXTCON Support&amp;quot;
-	depends on MFD_MAX8997
+	depends on MFD_MAX8997 &amp;amp;&amp;amp; IRQ_DOMAIN
 	help
 	  If you say yes here you get support for the MUIC device of
 	  Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 23416e4..fe24cc6 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -26,6 +26,7 @@
 #include &amp;lt;linux/mfd/max8997.h&amp;gt;
 #include &amp;lt;linux/mfd/max8997-private.h&amp;gt;
 #include &amp;lt;linux/extcon.h&amp;gt;
+#include &amp;lt;linux/irqdomain.h&amp;gt;
 
 #define	DEV_NAME			&amp;quot;max8997-muic&amp;quot;
 
@@ -77,6 +78,7 @@
 struct max8997_muic_irq {
 	unsigned int irq;
 	const char *name;
+	unsigned int virq;
 };
 
 static struct max8997_muic_irq muic_irqs[] = {
@@ -343,12 +345,10 @@ static void max8997_muic_irq_work(struct work_struct *work)
 {
 	struct max8997_muic_info *info = container_of(work,
 			struct max8997_muic_info, irq_work);
-	struct max8997_dev *max8997 = i2c_get_clientdata(info-&amp;gt;muic);
 	u8 status[2];
 	u8 adc, chg_type;
-
-	int irq_type = info-&amp;gt;irq - max8997-&amp;gt;irq_base;
-	int ret;
+	int irq_type = 0;
+	int i, ret;
 
 	mutex_lock(&amp;amp;info-&amp;gt;mutex);
 
@@ -363,6 +363,10 @@ static void max8997_muic_irq_work(struct work_struct *work)
 	dev_dbg(info-&amp;gt;dev, &amp;quot;%s: STATUS1:0x%x, 2:0x%x\n&amp;quot;, __func__,
 			status[0], status[1]);
 
+	for (i = 0 ; i &amp;lt; ARRAY_SIZE(muic_irqs) ; i++)
+		if (info-&amp;gt;irq == muic_irqs.virq)
+			irq_type = muic_irqs.irq;
+
 	switch (irq_type) {
 	case MAX8997_MUICIRQ_ADC:
 		adc = status[0] &amp;amp; STATUS1_ADC_MASK;
@@ -448,11 +452,15 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
 
 	for (i = 0; i &amp;lt; ARRAY_SIZE(muic_irqs); i++) {
 		struct max8997_muic_irq *muic_irq = &amp;amp;muic_irqs;
+		int virq = 0;
+
+		virq = irq_create_mapping(max8997-&amp;gt;irq_domain, muic_irq-&amp;gt;irq);
+		if (!virq)
+			goto err_irq;
+		muic_irq-&amp;gt;virq = virq;
 
-		ret = request_threaded_irq(pdata-&amp;gt;irq_base + muic_irq-&amp;gt;irq,
-				NULL, max8997_muic_irq_handler,
-				0, muic_irq-&amp;gt;name,
-				info);
+		ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler,
+				0, muic_irq-&amp;gt;name, info);
 		if (ret) {
 			dev_err(&amp;amp;pdev-&amp;gt;dev,
 				&amp;quot;failed: irq request (IRQ: %d,&amp;quot;
@@ -496,7 +504,7 @@ err_extcon:
 	kfree(info-&amp;gt;edev);
 err_irq:
 	while (--i &amp;gt;= 0)
-		free_irq(pdata-&amp;gt;irq_base + muic_irqs.irq, info);
+		free_irq(muic_irqs.virq, info);
 	kfree(info);
 err_kfree:
 	return ret;
@@ -505,11 +513,10 @@ err_kfree:
 static int __devexit max8997_muic_remove(struct platform_device *pdev)
 {
 	struct max8997_muic_info *info = platform_get_drvdata(pdev);
-	struct max8997_dev *max8997 = i2c_get_clientdata(info-&amp;gt;muic);
 	int i;
 
 	for (i = 0; i &amp;lt; ARRAY_SIZE(muic_irqs); i++)
-		free_irq(max8997-&amp;gt;irq_base + muic_irqs.irq, info);
+		free_irq(muic_irqs.virq, info);
 	cancel_work_sync(&amp;amp;info-&amp;gt;irq_work);
 
 	extcon_dev_unregister(info-&amp;gt;edev);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line &amp;quot;unsubscribe linux-kernel&amp;quot; in
the body of a message to &amp;#109;&amp;#97;&amp;#106;&amp;#111;&amp;#114;&amp;#100;&amp;#111;&amp;#109;&amp;#111;&amp;#64;&amp;#118;&amp;#103;&amp;#101;&amp;#114;&amp;#46;&amp;#107;&amp;#101;&amp;#114;&amp;#110;&amp;#101;&amp;#108;&amp;#46;&amp;#111;&amp;#114;&amp;#103;
More majordomo info at  [vger.kernel.org]
Please read the FAQ at  [www.tux.org]</description>
        <link>http://choon.net/forum/read.php?21,1146356,1146356#msg-1146356</link>
        <lastBuildDate>Wed, 19 Jun 2013 18:43:13 +0800</lastBuildDate>
        <generator>Phorum 5.2.19</generator>
        <item>
            <guid>http://choon.net/forum/read.php?21,1146356,1146356#msg-1146356</guid>
            <title>[RESEND PATCH 2/2] Extcon: MAX8997: Add support irq domain for MAX8997 muic</title>
            <link>http://choon.net/forum/read.php?21,1146356,1146356#msg-1146356</link>
            <description><![CDATA[ This patch add support irq domain for Maxim MAX8997 muic<br />
instead of irq_base in platform data and max8997 driver<br />
private data are instead. It is tested on TRATS board.<br />
<br />
Signed-off-by: Chanwoo Choi &lt;cw00.choi@samsung.com&gt;<br />
Signed-off-by: Myungjoo Ham &lt;myungjoo.ham@samsung.com&gt;<br />
Signed-off-by: Kyungmin Park &lt;kyungmin.park@samsung.com&gt;<br />
---<br />
 drivers/extcon/Kconfig          |    2 +-<br />
 drivers/extcon/extcon-max8997.c |   29 ++++++++++++++++++-----------<br />
 2 files changed, 19 insertions(+), 12 deletions(-)<br />
<br />
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig<br />
index 29c5cf8..bf6b2ea 100644<br />
--- a/drivers/extcon/Kconfig<br />
+++ b/drivers/extcon/Kconfig<br />
@@ -23,7 +23,7 @@ config EXTCON_GPIO<br />
 <br />
 config EXTCON_MAX8997<br />
 	tristate &quot;MAX8997 EXTCON Support&quot;<br />
-	depends on MFD_MAX8997<br />
+	depends on MFD_MAX8997 &amp;&amp; IRQ_DOMAIN<br />
 	help<br />
 	  If you say yes here you get support for the MUIC device of<br />
 	  Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory<br />
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c<br />
index 23416e4..fe24cc6 100644<br />
--- a/drivers/extcon/extcon-max8997.c<br />
+++ b/drivers/extcon/extcon-max8997.c<br />
@@ -26,6 +26,7 @@<br />
 #include &lt;linux/mfd/max8997.h&gt;<br />
 #include &lt;linux/mfd/max8997-private.h&gt;<br />
 #include &lt;linux/extcon.h&gt;<br />
+#include &lt;linux/irqdomain.h&gt;<br />
 <br />
 #define	DEV_NAME			&quot;max8997-muic&quot;<br />
 <br />
@@ -77,6 +78,7 @@<br />
 struct max8997_muic_irq {<br />
 	unsigned int irq;<br />
 	const char *name;<br />
+	unsigned int virq;<br />
 };<br />
 <br />
 static struct max8997_muic_irq muic_irqs[] = {<br />
@@ -343,12 +345,10 @@ static void max8997_muic_irq_work(struct work_struct *work)<br />
 {<br />
 	struct max8997_muic_info *info = container_of(work,<br />
 			struct max8997_muic_info, irq_work);<br />
-	struct max8997_dev *max8997 = i2c_get_clientdata(info-&gt;muic);<br />
 	u8 status[2];<br />
 	u8 adc, chg_type;<br />
-<br />
-	int irq_type = info-&gt;irq - max8997-&gt;irq_base;<br />
-	int ret;<br />
+	int irq_type = 0;<br />
+	int i, ret;<br />
 <br />
 	mutex_lock(&amp;info-&gt;mutex);<br />
 <br />
@@ -363,6 +363,10 @@ static void max8997_muic_irq_work(struct work_struct *work)<br />
 	dev_dbg(info-&gt;dev, &quot;%s: STATUS1:0x%x, 2:0x%x\n&quot;, __func__,<br />
 			status[0], status[1]);<br />
 <br />
+	for (i = 0 ; i &lt; ARRAY_SIZE(muic_irqs) ; i++)<br />
+		if (info-&gt;irq == muic_irqs<i>.virq)<br />
+			irq_type = muic_irqs<i>.irq;<br />
+<br />
 	switch (irq_type) {<br />
 	case MAX8997_MUICIRQ_ADC:<br />
 		adc = status[0] &amp; STATUS1_ADC_MASK;<br />
@@ -448,11 +452,15 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)<br />
 <br />
 	for (i = 0; i &lt; ARRAY_SIZE(muic_irqs); i++) {<br />
 		struct max8997_muic_irq *muic_irq = &amp;muic_irqs<i>;<br />
+		int virq = 0;<br />
+<br />
+		virq = irq_create_mapping(max8997-&gt;irq_domain, muic_irq-&gt;irq);<br />
+		if (!virq)<br />
+			goto err_irq;<br />
+		muic_irq-&gt;virq = virq;<br />
 <br />
-		ret = request_threaded_irq(pdata-&gt;irq_base + muic_irq-&gt;irq,<br />
-				NULL, max8997_muic_irq_handler,<br />
-				0, muic_irq-&gt;name,<br />
-				info);<br />
+		ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler,<br />
+				0, muic_irq-&gt;name, info);<br />
 		if (ret) {<br />
 			dev_err(&amp;pdev-&gt;dev,<br />
 				&quot;failed: irq request (IRQ: %d,&quot;<br />
@@ -496,7 +504,7 @@ err_extcon:<br />
 	kfree(info-&gt;edev);<br />
 err_irq:<br />
 	while (--i &gt;= 0)<br />
-		free_irq(pdata-&gt;irq_base + muic_irqs<i>.irq, info);<br />
+		free_irq(muic_irqs<i>.virq, info);<br />
 	kfree(info);<br />
 err_kfree:<br />
 	return ret;<br />
@@ -505,11 +513,10 @@ err_kfree:<br />
 static int __devexit max8997_muic_remove(struct platform_device *pdev)<br />
 {<br />
 	struct max8997_muic_info *info = platform_get_drvdata(pdev);<br />
-	struct max8997_dev *max8997 = i2c_get_clientdata(info-&gt;muic);<br />
 	int i;<br />
 <br />
 	for (i = 0; i &lt; ARRAY_SIZE(muic_irqs); i++)<br />
-		free_irq(max8997-&gt;irq_base + muic_irqs<i>.irq, info);<br />
+		free_irq(muic_irqs<i>.virq, info);<br />
 	cancel_work_sync(&amp;info-&gt;irq_work);<br />
 <br />
 	extcon_dev_unregister(info-&gt;edev);<br />
-- <br />
1.7.0.4<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  [<a href="http://vger.kernel.org/majordomo-info.html"  rel="nofollow">vger.kernel.org</a>]<br />
Please read the FAQ at  [<a href="http://www.tux.org/lkml/"  rel="nofollow">www.tux.org</a>]</i></i></i></i></i></i></i>]]></description>
            <dc:creator>Chanwoo Choi</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Mon, 02 Jul 2012 08:04:02 +0800</pubDate>
        </item>
    </channel>
</rss>
