All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V4 0/6] rtc: max77686: make max77686 rtc driver as IP driver
@ 2016-02-06 14:37 ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

Based on discussion on patch series of MAX77620 when adding separate
driver for max77620 RTC, it is discussed to reuse the max77686 driver
for all CHips MAX77802, MAX77686 and MAX77620. For this, the rtc-max77686
need to make as IP driver independent of their MFD parent driver.

This series makes the rtc-max77686 as independent driver from its 
parent. Required information is passed through the device parent
which is generic and does not depends on any max77686 specific
header ifnromation.

CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>

Changes from V1: 
- Added reviewed/tested by tag which we got from V1.
- Remove changes from Kconfig.
- Maintain all register definition in max77686 private header and remove
  the movement to rtc driver.
- Taken care of all comments on V1 from Krzysztof and Javier.

Changes from V2: 
- Fix the issue of crash in unbind.

Changes from V3:
- Fix suspend-resume after unbind/bind by unmapping virq in remove callback.

Laxman Dewangan (6):
  regmap: irq: add apis to unmap the mapped irq
  rtc: max77686: fix checkpatch error
  rtc: max77686: use rtc regmap to access RTC registers
  rtc: max77686: avoid reference of parent device info multiple places
  mfd: max77686: do not set i2c client data for rtc i2c client
  rtc: max77686: move initialisation of rtc regmap, irq chip locally

 drivers/base/regmap/regmap-irq.c     |  14 +++
 drivers/mfd/max77686.c               |  86 +-------------
 drivers/rtc/rtc-max77686.c           | 215 ++++++++++++++++++++++++++---------
 include/linux/mfd/max77686-private.h |   3 -
 include/linux/regmap.h               |   1 +
 5 files changed, 177 insertions(+), 142 deletions(-)

-- 
2.1.4

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

* [rtc-linux] [PATCH V4 0/6] rtc: max77686: make max77686 rtc driver as IP driver
@ 2016-02-06 14:37 ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

Based on discussion on patch series of MAX77620 when adding separate
driver for max77620 RTC, it is discussed to reuse the max77686 driver
for all CHips MAX77802, MAX77686 and MAX77620. For this, the rtc-max77686
need to make as IP driver independent of their MFD parent driver.

This series makes the rtc-max77686 as independent driver from its 
parent. Required information is passed through the device parent
which is generic and does not depends on any max77686 specific
header ifnromation.

CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>

Changes from V1: 
- Added reviewed/tested by tag which we got from V1.
- Remove changes from Kconfig.
- Maintain all register definition in max77686 private header and remove
  the movement to rtc driver.
- Taken care of all comments on V1 from Krzysztof and Javier.

Changes from V2: 
- Fix the issue of crash in unbind.

Changes from V3:
- Fix suspend-resume after unbind/bind by unmapping virq in remove callback.

Laxman Dewangan (6):
  regmap: irq: add apis to unmap the mapped irq
  rtc: max77686: fix checkpatch error
  rtc: max77686: use rtc regmap to access RTC registers
  rtc: max77686: avoid reference of parent device info multiple places
  mfd: max77686: do not set i2c client data for rtc i2c client
  rtc: max77686: move initialisation of rtc regmap, irq chip locally

 drivers/base/regmap/regmap-irq.c     |  14 +++
 drivers/mfd/max77686.c               |  86 +-------------
 drivers/rtc/rtc-max77686.c           | 215 ++++++++++++++++++++++++++---------
 include/linux/mfd/max77686-private.h |   3 -
 include/linux/regmap.h               |   1 +
 5 files changed, 177 insertions(+), 142 deletions(-)

-- 
2.1.4

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-06 14:37 ` [rtc-linux] " Laxman Dewangan
@ 2016-02-06 14:37   ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

Before removing irq domains, it is require to unmap all
mapped interrupt from that domain. Currently there is API
to map the interrupt on chip as regmap_irq_get_virq() for
creating mapping. Add equivalent API to dispose the mapped
irq in irq domains.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>

---
This is new in the series which was identified when testing V3
series that it is require to unmap virq before deleting irq chip
domain. Adding this APIs in regmap irq framework.

 drivers/base/regmap/regmap-irq.c | 14 ++++++++++++++
 include/linux/regmap.h           |  1 +
 2 files changed, 15 insertions(+)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 9b0d202..9b36fc8 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -707,6 +707,20 @@ int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq)
 EXPORT_SYMBOL_GPL(regmap_irq_get_virq);
 
 /**
+ * regmap_irq_put_virq(): Unmap mapped interrupt of a chip in irq-domain.
+ *
+ * This routine is used to dispose the created mapping from irq domain
+ * which must be call before removing irq domain.
+ *
+ * @irq: virtual irq number which was mapped with irq domains.
+ */
+void regmap_irq_put_virq(int virq)
+{
+	irq_dispose_mapping(virq);
+}
+EXPORT_SYMBOL_GPL(regmap_irq_put_virq);
+
+/**
  * regmap_irq_get_domain(): Retrieve the irq_domain for the chip
  *
  * Useful for drivers to request their own IRQs and for integration
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 27aaac9..546eab5 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -870,6 +870,7 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
 int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
 int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
+void regmap_irq_put_virq(int virq);
 struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
 
 #else
-- 
2.1.4

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

* [rtc-linux] [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-06 14:37   ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

Before removing irq domains, it is require to unmap all
mapped interrupt from that domain. Currently there is API
to map the interrupt on chip as regmap_irq_get_virq() for
creating mapping. Add equivalent API to dispose the mapped
irq in irq domains.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>

---
This is new in the series which was identified when testing V3
series that it is require to unmap virq before deleting irq chip
domain. Adding this APIs in regmap irq framework.

 drivers/base/regmap/regmap-irq.c | 14 ++++++++++++++
 include/linux/regmap.h           |  1 +
 2 files changed, 15 insertions(+)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 9b0d202..9b36fc8 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -707,6 +707,20 @@ int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq)
 EXPORT_SYMBOL_GPL(regmap_irq_get_virq);
 
 /**
+ * regmap_irq_put_virq(): Unmap mapped interrupt of a chip in irq-domain.
+ *
+ * This routine is used to dispose the created mapping from irq domain
+ * which must be call before removing irq domain.
+ *
+ * @irq: virtual irq number which was mapped with irq domains.
+ */
+void regmap_irq_put_virq(int virq)
+{
+	irq_dispose_mapping(virq);
+}
+EXPORT_SYMBOL_GPL(regmap_irq_put_virq);
+
+/**
  * regmap_irq_get_domain(): Retrieve the irq_domain for the chip
  *
  * Useful for drivers to request their own IRQs and for integration
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 27aaac9..546eab5 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -870,6 +870,7 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
 int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
 int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
+void regmap_irq_put_virq(int virq);
 struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
 
 #else
-- 
2.1.4

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* [PATCH V4 2/6] rtc: max77686: fix checkpatch error
  2016-02-06 14:37 ` [rtc-linux] " Laxman Dewangan
@ 2016-02-06 14:37   ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

Fix following check patch error in rtc-max77686 driver:
- Alignment should match open parenthesis.
- braces {} should be used on all arms of this statement.
- Prefer using the BIT macro

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
Changes from V1:
None, added reviewed/tested by.

Changes from V1:
None

Changes from V1:
None, become 2nd on series.

 drivers/rtc/rtc-max77686.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 188593d..253cf12 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -24,20 +24,20 @@
 
 /* RTC Control Register */
 #define BCD_EN_SHIFT			0
-#define BCD_EN_MASK			(1 << BCD_EN_SHIFT)
+#define BCD_EN_MASK			BIT(BCD_EN_SHIFT)
 #define MODEL24_SHIFT			1
-#define MODEL24_MASK			(1 << MODEL24_SHIFT)
+#define MODEL24_MASK			BIT(MODEL24_SHIFT)
 /* RTC Update Register1 */
 #define RTC_UDR_SHIFT			0
-#define RTC_UDR_MASK			(1 << RTC_UDR_SHIFT)
+#define RTC_UDR_MASK			BIT(RTC_UDR_SHIFT)
 #define RTC_RBUDR_SHIFT			4
-#define RTC_RBUDR_MASK			(1 << RTC_RBUDR_SHIFT)
+#define RTC_RBUDR_MASK			BIT(RTC_RBUDR_SHIFT)
 /* RTC Hour register */
 #define HOUR_PM_SHIFT			6
-#define HOUR_PM_MASK			(1 << HOUR_PM_SHIFT)
+#define HOUR_PM_MASK			BIT(HOUR_PM_SHIFT)
 /* RTC Alarm Enable */
 #define ALARM_ENABLE_SHIFT		7
-#define ALARM_ENABLE_MASK		(1 << ALARM_ENABLE_SHIFT)
+#define ALARM_ENABLE_MASK		BIT(ALARM_ENABLE_SHIFT)
 
 #define REG_RTC_NONE			0xdeadbeef
 
@@ -205,9 +205,9 @@ static void max77686_rtc_data_to_tm(u8 *data, struct rtc_time *tm,
 
 	tm->tm_sec = data[RTC_SEC] & mask;
 	tm->tm_min = data[RTC_MIN] & mask;
-	if (info->rtc_24hr_mode)
+	if (info->rtc_24hr_mode) {
 		tm->tm_hour = data[RTC_HOUR] & 0x1f;
-	else {
+	} else {
 		tm->tm_hour = data[RTC_HOUR] & 0x0f;
 		if (data[RTC_HOUR] & HOUR_PM_MASK)
 			tm->tm_hour += 12;
@@ -256,7 +256,7 @@ static int max77686_rtc_tm_to_data(struct rtc_time *tm, u8 *data,
 }
 
 static int max77686_rtc_update(struct max77686_rtc_info *info,
-	enum MAX77686_RTC_OP op)
+			       enum MAX77686_RTC_OP op)
 {
 	int ret;
 	unsigned int data;
@@ -547,7 +547,7 @@ out:
 }
 
 static int max77686_rtc_alarm_irq_enable(struct device *dev,
-					unsigned int enabled)
+					 unsigned int enabled)
 {
 	struct max77686_rtc_info *info = dev_get_drvdata(dev);
 	int ret;
@@ -612,7 +612,7 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	int ret;
 
 	info = devm_kzalloc(&pdev->dev, sizeof(struct max77686_rtc_info),
-				GFP_KERNEL);
+			    GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -662,7 +662,8 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-				max77686_rtc_alarm_irq, 0, "rtc-alarm1", info);
+					max77686_rtc_alarm_irq, 0,
+					"rtc-alarm1", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
-- 
2.1.4

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

* [rtc-linux] [PATCH V4 2/6] rtc: max77686: fix checkpatch error
@ 2016-02-06 14:37   ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

Fix following check patch error in rtc-max77686 driver:
- Alignment should match open parenthesis.
- braces {} should be used on all arms of this statement.
- Prefer using the BIT macro

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
Changes from V1:
None, added reviewed/tested by.

Changes from V1:
None

Changes from V1:
None, become 2nd on series.

 drivers/rtc/rtc-max77686.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 188593d..253cf12 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -24,20 +24,20 @@
 
 /* RTC Control Register */
 #define BCD_EN_SHIFT			0
-#define BCD_EN_MASK			(1 << BCD_EN_SHIFT)
+#define BCD_EN_MASK			BIT(BCD_EN_SHIFT)
 #define MODEL24_SHIFT			1
-#define MODEL24_MASK			(1 << MODEL24_SHIFT)
+#define MODEL24_MASK			BIT(MODEL24_SHIFT)
 /* RTC Update Register1 */
 #define RTC_UDR_SHIFT			0
-#define RTC_UDR_MASK			(1 << RTC_UDR_SHIFT)
+#define RTC_UDR_MASK			BIT(RTC_UDR_SHIFT)
 #define RTC_RBUDR_SHIFT			4
-#define RTC_RBUDR_MASK			(1 << RTC_RBUDR_SHIFT)
+#define RTC_RBUDR_MASK			BIT(RTC_RBUDR_SHIFT)
 /* RTC Hour register */
 #define HOUR_PM_SHIFT			6
-#define HOUR_PM_MASK			(1 << HOUR_PM_SHIFT)
+#define HOUR_PM_MASK			BIT(HOUR_PM_SHIFT)
 /* RTC Alarm Enable */
 #define ALARM_ENABLE_SHIFT		7
-#define ALARM_ENABLE_MASK		(1 << ALARM_ENABLE_SHIFT)
+#define ALARM_ENABLE_MASK		BIT(ALARM_ENABLE_SHIFT)
 
 #define REG_RTC_NONE			0xdeadbeef
 
@@ -205,9 +205,9 @@ static void max77686_rtc_data_to_tm(u8 *data, struct rtc_time *tm,
 
 	tm->tm_sec = data[RTC_SEC] & mask;
 	tm->tm_min = data[RTC_MIN] & mask;
-	if (info->rtc_24hr_mode)
+	if (info->rtc_24hr_mode) {
 		tm->tm_hour = data[RTC_HOUR] & 0x1f;
-	else {
+	} else {
 		tm->tm_hour = data[RTC_HOUR] & 0x0f;
 		if (data[RTC_HOUR] & HOUR_PM_MASK)
 			tm->tm_hour += 12;
@@ -256,7 +256,7 @@ static int max77686_rtc_tm_to_data(struct rtc_time *tm, u8 *data,
 }
 
 static int max77686_rtc_update(struct max77686_rtc_info *info,
-	enum MAX77686_RTC_OP op)
+			       enum MAX77686_RTC_OP op)
 {
 	int ret;
 	unsigned int data;
@@ -547,7 +547,7 @@ out:
 }
 
 static int max77686_rtc_alarm_irq_enable(struct device *dev,
-					unsigned int enabled)
+					 unsigned int enabled)
 {
 	struct max77686_rtc_info *info = dev_get_drvdata(dev);
 	int ret;
@@ -612,7 +612,7 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	int ret;
 
 	info = devm_kzalloc(&pdev->dev, sizeof(struct max77686_rtc_info),
-				GFP_KERNEL);
+			    GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -662,7 +662,8 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-				max77686_rtc_alarm_irq, 0, "rtc-alarm1", info);
+					max77686_rtc_alarm_irq, 0,
+					"rtc-alarm1", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
-- 
2.1.4

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* [PATCH V4 3/6] rtc: max77686: use rtc regmap to access RTC registers
  2016-02-06 14:37 ` [rtc-linux] " Laxman Dewangan
@ 2016-02-06 14:37   ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

rtc_regmap should be used to access all RTC registers instead
of parent regmap regardless of what chip or property have it.

This makes the register access uniform and extendible for other
chips.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
Changes from V1:
None, added reviewed/tested by.

Changes from V1:
None

Changes from V1:
None, become 3rd on series.

 drivers/rtc/rtc-max77686.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 253cf12..11f74ed 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -370,7 +370,7 @@ static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 			goto out;
 		}
 
-		ret = regmap_read(info->max77686->regmap,
+		ret = regmap_read(info->max77686->rtc_regmap,
 				  map[REG_RTC_AE1], &val);
 		if (ret < 0) {
 			dev_err(info->dev,
@@ -426,7 +426,8 @@ static int max77686_rtc_stop_alarm(struct max77686_rtc_info *info)
 			goto out;
 		}
 
-		ret = regmap_write(info->max77686->regmap, map[REG_RTC_AE1], 0);
+		ret = regmap_write(info->max77686->rtc_regmap,
+				   map[REG_RTC_AE1], 0);
 	} else {
 		ret = regmap_bulk_read(info->max77686->rtc_regmap,
 				       map[REG_ALARM1_SEC], data,
@@ -471,7 +472,7 @@ static int max77686_rtc_start_alarm(struct max77686_rtc_info *info)
 		goto out;
 
 	if (info->drv_data->alarm_enable_reg) {
-		ret = regmap_write(info->max77686->regmap, map[REG_RTC_AE1],
+		ret = regmap_write(info->max77686->rtc_regmap, map[REG_RTC_AE1],
 				   MAX77802_ALARM_ENABLE_VALUE);
 	} else {
 		ret = regmap_bulk_read(info->max77686->rtc_regmap,
-- 
2.1.4

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

* [rtc-linux] [PATCH V4 3/6] rtc: max77686: use rtc regmap to access RTC registers
@ 2016-02-06 14:37   ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

rtc_regmap should be used to access all RTC registers instead
of parent regmap regardless of what chip or property have it.

This makes the register access uniform and extendible for other
chips.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
Changes from V1:
None, added reviewed/tested by.

Changes from V1:
None

Changes from V1:
None, become 3rd on series.

 drivers/rtc/rtc-max77686.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 253cf12..11f74ed 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -370,7 +370,7 @@ static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 			goto out;
 		}
 
-		ret = regmap_read(info->max77686->regmap,
+		ret = regmap_read(info->max77686->rtc_regmap,
 				  map[REG_RTC_AE1], &val);
 		if (ret < 0) {
 			dev_err(info->dev,
@@ -426,7 +426,8 @@ static int max77686_rtc_stop_alarm(struct max77686_rtc_info *info)
 			goto out;
 		}
 
-		ret = regmap_write(info->max77686->regmap, map[REG_RTC_AE1], 0);
+		ret = regmap_write(info->max77686->rtc_regmap,
+				   map[REG_RTC_AE1], 0);
 	} else {
 		ret = regmap_bulk_read(info->max77686->rtc_regmap,
 				       map[REG_ALARM1_SEC], data,
@@ -471,7 +472,7 @@ static int max77686_rtc_start_alarm(struct max77686_rtc_info *info)
 		goto out;
 
 	if (info->drv_data->alarm_enable_reg) {
-		ret = regmap_write(info->max77686->regmap, map[REG_RTC_AE1],
+		ret = regmap_write(info->max77686->rtc_regmap, map[REG_RTC_AE1],
 				   MAX77802_ALARM_ENABLE_VALUE);
 	} else {
 		ret = regmap_bulk_read(info->max77686->rtc_regmap,
-- 
2.1.4

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* [PATCH V4 4/6] rtc: max77686: avoid reference of parent device info multiple places
  2016-02-06 14:37 ` [rtc-linux] " Laxman Dewangan
@ 2016-02-06 14:37   ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

Get rid of referring parent device info for register access
all the places by making regmap as part of max77686 rtc
device info. This will also remove the need of storing parent
device info in max77686 rtc device info as this is no more required.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
Changes from V1:
None, added reviewed/tested by.

Changes form V2:
- Fix typo in description.

Changes form V3:
- None, become 4ths in series.

 drivers/rtc/rtc-max77686.c | 52 ++++++++++++++++++++--------------------------
 1 file changed, 23 insertions(+), 29 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 11f74ed..ab1f2cd 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -74,12 +74,12 @@ struct max77686_rtc_driver_data {
 
 struct max77686_rtc_info {
 	struct device		*dev;
-	struct max77686_dev	*max77686;
 	struct i2c_client	*rtc;
 	struct rtc_device	*rtc_dev;
 	struct mutex		lock;
 
 	struct regmap		*regmap;
+	struct regmap		*rtc_regmap;
 
 	const struct max77686_rtc_driver_data *drv_data;
 
@@ -267,7 +267,7 @@ static int max77686_rtc_update(struct max77686_rtc_info *info,
 	else
 		data = 1 << RTC_RBUDR_SHIFT;
 
-	ret = regmap_update_bits(info->max77686->rtc_regmap,
+	ret = regmap_update_bits(info->rtc_regmap,
 				 info->drv_data->map[REG_RTC_UPDATE0],
 				 data, data);
 	if (ret < 0)
@@ -293,7 +293,7 @@ static int max77686_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	if (ret < 0)
 		goto out;
 
-	ret = regmap_bulk_read(info->max77686->rtc_regmap,
+	ret = regmap_bulk_read(info->rtc_regmap,
 			       info->drv_data->map[REG_RTC_SEC],
 			       data, ARRAY_SIZE(data));
 	if (ret < 0) {
@@ -322,7 +322,7 @@ static int max77686_rtc_set_time(struct device *dev, struct rtc_time *tm)
 
 	mutex_lock(&info->lock);
 
-	ret = regmap_bulk_write(info->max77686->rtc_regmap,
+	ret = regmap_bulk_write(info->rtc_regmap,
 				info->drv_data->map[REG_RTC_SEC],
 				data, ARRAY_SIZE(data));
 	if (ret < 0) {
@@ -351,8 +351,8 @@ static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	if (ret < 0)
 		goto out;
 
-	ret = regmap_bulk_read(info->max77686->rtc_regmap,
-			       map[REG_ALARM1_SEC], data, ARRAY_SIZE(data));
+	ret = regmap_bulk_read(info->rtc_regmap, map[REG_ALARM1_SEC],
+			       data, ARRAY_SIZE(data));
 	if (ret < 0) {
 		dev_err(info->dev, "Fail to read alarm reg(%d)\n", ret);
 		goto out;
@@ -370,8 +370,7 @@ static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 			goto out;
 		}
 
-		ret = regmap_read(info->max77686->rtc_regmap,
-				  map[REG_RTC_AE1], &val);
+		ret = regmap_read(info->rtc_regmap, map[REG_RTC_AE1], &val);
 		if (ret < 0) {
 			dev_err(info->dev,
 				"fail to read alarm enable(%d)\n", ret);
@@ -390,7 +389,7 @@ static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	}
 
 	alrm->pending = 0;
-	ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val);
+	ret = regmap_read(info->regmap, MAX77686_REG_STATUS2, &val);
 	if (ret < 0) {
 		dev_err(info->dev, "Fail to read status2 reg(%d)\n", ret);
 		goto out;
@@ -426,12 +425,10 @@ static int max77686_rtc_stop_alarm(struct max77686_rtc_info *info)
 			goto out;
 		}
 
-		ret = regmap_write(info->max77686->rtc_regmap,
-				   map[REG_RTC_AE1], 0);
+		ret = regmap_write(info->rtc_regmap, map[REG_RTC_AE1], 0);
 	} else {
-		ret = regmap_bulk_read(info->max77686->rtc_regmap,
-				       map[REG_ALARM1_SEC], data,
-				       ARRAY_SIZE(data));
+		ret = regmap_bulk_read(info->rtc_regmap, map[REG_ALARM1_SEC],
+				       data, ARRAY_SIZE(data));
 		if (ret < 0) {
 			dev_err(info->dev, "Fail to read alarm reg(%d)\n", ret);
 			goto out;
@@ -442,9 +439,8 @@ static int max77686_rtc_stop_alarm(struct max77686_rtc_info *info)
 		for (i = 0; i < ARRAY_SIZE(data); i++)
 			data[i] &= ~ALARM_ENABLE_MASK;
 
-		ret = regmap_bulk_write(info->max77686->rtc_regmap,
-					map[REG_ALARM1_SEC], data,
-					ARRAY_SIZE(data));
+		ret = regmap_bulk_write(info->rtc_regmap, map[REG_ALARM1_SEC],
+					data, ARRAY_SIZE(data));
 	}
 
 	if (ret < 0) {
@@ -472,12 +468,11 @@ static int max77686_rtc_start_alarm(struct max77686_rtc_info *info)
 		goto out;
 
 	if (info->drv_data->alarm_enable_reg) {
-		ret = regmap_write(info->max77686->rtc_regmap, map[REG_RTC_AE1],
+		ret = regmap_write(info->rtc_regmap, map[REG_RTC_AE1],
 				   MAX77802_ALARM_ENABLE_VALUE);
 	} else {
-		ret = regmap_bulk_read(info->max77686->rtc_regmap,
-				       map[REG_ALARM1_SEC], data,
-				       ARRAY_SIZE(data));
+		ret = regmap_bulk_read(info->rtc_regmap, map[REG_ALARM1_SEC],
+				       data, ARRAY_SIZE(data));
 		if (ret < 0) {
 			dev_err(info->dev, "Fail to read alarm reg(%d)\n", ret);
 			goto out;
@@ -496,9 +491,8 @@ static int max77686_rtc_start_alarm(struct max77686_rtc_info *info)
 		if (data[RTC_DATE] & 0x1f)
 			data[RTC_DATE] |= (1 << ALARM_ENABLE_SHIFT);
 
-		ret = regmap_bulk_write(info->max77686->rtc_regmap,
-					map[REG_ALARM1_SEC], data,
-					ARRAY_SIZE(data));
+		ret = regmap_bulk_write(info->rtc_regmap, map[REG_ALARM1_SEC],
+					data, ARRAY_SIZE(data));
 	}
 
 	if (ret < 0) {
@@ -527,7 +521,7 @@ static int max77686_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	if (ret < 0)
 		goto out;
 
-	ret = regmap_bulk_write(info->max77686->rtc_regmap,
+	ret = regmap_bulk_write(info->rtc_regmap,
 				info->drv_data->map[REG_ALARM1_SEC],
 				data, ARRAY_SIZE(data));
 
@@ -593,7 +587,7 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 
 	info->rtc_24hr_mode = 1;
 
-	ret = regmap_bulk_write(info->max77686->rtc_regmap,
+	ret = regmap_bulk_write(info->rtc_regmap,
 				info->drv_data->map[REG_RTC_CONTROLM],
 				data, ARRAY_SIZE(data));
 	if (ret < 0) {
@@ -619,13 +613,13 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 
 	mutex_init(&info->lock);
 	info->dev = &pdev->dev;
-	info->max77686 = max77686;
 	info->rtc = max77686->rtc;
 	info->drv_data = (const struct max77686_rtc_driver_data *)
 		id->driver_data;
 
-	if (!info->drv_data->separate_i2c_addr)
-		info->max77686->rtc_regmap = info->max77686->regmap;
+	info->regmap = max77686->regmap;
+	info->rtc_regmap = (info->drv_data->separate_i2c_addr) ?
+			    max77686->rtc_regmap : info->regmap;
 
 	platform_set_drvdata(pdev, info);
 
-- 
2.1.4

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

* [rtc-linux] [PATCH V4 4/6] rtc: max77686: avoid reference of parent device info multiple places
@ 2016-02-06 14:37   ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

Get rid of referring parent device info for register access
all the places by making regmap as part of max77686 rtc
device info. This will also remove the need of storing parent
device info in max77686 rtc device info as this is no more required.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
Changes from V1:
None, added reviewed/tested by.

Changes form V2:
- Fix typo in description.

Changes form V3:
- None, become 4ths in series.

 drivers/rtc/rtc-max77686.c | 52 ++++++++++++++++++++--------------------------
 1 file changed, 23 insertions(+), 29 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 11f74ed..ab1f2cd 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -74,12 +74,12 @@ struct max77686_rtc_driver_data {
 
 struct max77686_rtc_info {
 	struct device		*dev;
-	struct max77686_dev	*max77686;
 	struct i2c_client	*rtc;
 	struct rtc_device	*rtc_dev;
 	struct mutex		lock;
 
 	struct regmap		*regmap;
+	struct regmap		*rtc_regmap;
 
 	const struct max77686_rtc_driver_data *drv_data;
 
@@ -267,7 +267,7 @@ static int max77686_rtc_update(struct max77686_rtc_info *info,
 	else
 		data = 1 << RTC_RBUDR_SHIFT;
 
-	ret = regmap_update_bits(info->max77686->rtc_regmap,
+	ret = regmap_update_bits(info->rtc_regmap,
 				 info->drv_data->map[REG_RTC_UPDATE0],
 				 data, data);
 	if (ret < 0)
@@ -293,7 +293,7 @@ static int max77686_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	if (ret < 0)
 		goto out;
 
-	ret = regmap_bulk_read(info->max77686->rtc_regmap,
+	ret = regmap_bulk_read(info->rtc_regmap,
 			       info->drv_data->map[REG_RTC_SEC],
 			       data, ARRAY_SIZE(data));
 	if (ret < 0) {
@@ -322,7 +322,7 @@ static int max77686_rtc_set_time(struct device *dev, struct rtc_time *tm)
 
 	mutex_lock(&info->lock);
 
-	ret = regmap_bulk_write(info->max77686->rtc_regmap,
+	ret = regmap_bulk_write(info->rtc_regmap,
 				info->drv_data->map[REG_RTC_SEC],
 				data, ARRAY_SIZE(data));
 	if (ret < 0) {
@@ -351,8 +351,8 @@ static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	if (ret < 0)
 		goto out;
 
-	ret = regmap_bulk_read(info->max77686->rtc_regmap,
-			       map[REG_ALARM1_SEC], data, ARRAY_SIZE(data));
+	ret = regmap_bulk_read(info->rtc_regmap, map[REG_ALARM1_SEC],
+			       data, ARRAY_SIZE(data));
 	if (ret < 0) {
 		dev_err(info->dev, "Fail to read alarm reg(%d)\n", ret);
 		goto out;
@@ -370,8 +370,7 @@ static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 			goto out;
 		}
 
-		ret = regmap_read(info->max77686->rtc_regmap,
-				  map[REG_RTC_AE1], &val);
+		ret = regmap_read(info->rtc_regmap, map[REG_RTC_AE1], &val);
 		if (ret < 0) {
 			dev_err(info->dev,
 				"fail to read alarm enable(%d)\n", ret);
@@ -390,7 +389,7 @@ static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	}
 
 	alrm->pending = 0;
-	ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val);
+	ret = regmap_read(info->regmap, MAX77686_REG_STATUS2, &val);
 	if (ret < 0) {
 		dev_err(info->dev, "Fail to read status2 reg(%d)\n", ret);
 		goto out;
@@ -426,12 +425,10 @@ static int max77686_rtc_stop_alarm(struct max77686_rtc_info *info)
 			goto out;
 		}
 
-		ret = regmap_write(info->max77686->rtc_regmap,
-				   map[REG_RTC_AE1], 0);
+		ret = regmap_write(info->rtc_regmap, map[REG_RTC_AE1], 0);
 	} else {
-		ret = regmap_bulk_read(info->max77686->rtc_regmap,
-				       map[REG_ALARM1_SEC], data,
-				       ARRAY_SIZE(data));
+		ret = regmap_bulk_read(info->rtc_regmap, map[REG_ALARM1_SEC],
+				       data, ARRAY_SIZE(data));
 		if (ret < 0) {
 			dev_err(info->dev, "Fail to read alarm reg(%d)\n", ret);
 			goto out;
@@ -442,9 +439,8 @@ static int max77686_rtc_stop_alarm(struct max77686_rtc_info *info)
 		for (i = 0; i < ARRAY_SIZE(data); i++)
 			data[i] &= ~ALARM_ENABLE_MASK;
 
-		ret = regmap_bulk_write(info->max77686->rtc_regmap,
-					map[REG_ALARM1_SEC], data,
-					ARRAY_SIZE(data));
+		ret = regmap_bulk_write(info->rtc_regmap, map[REG_ALARM1_SEC],
+					data, ARRAY_SIZE(data));
 	}
 
 	if (ret < 0) {
@@ -472,12 +468,11 @@ static int max77686_rtc_start_alarm(struct max77686_rtc_info *info)
 		goto out;
 
 	if (info->drv_data->alarm_enable_reg) {
-		ret = regmap_write(info->max77686->rtc_regmap, map[REG_RTC_AE1],
+		ret = regmap_write(info->rtc_regmap, map[REG_RTC_AE1],
 				   MAX77802_ALARM_ENABLE_VALUE);
 	} else {
-		ret = regmap_bulk_read(info->max77686->rtc_regmap,
-				       map[REG_ALARM1_SEC], data,
-				       ARRAY_SIZE(data));
+		ret = regmap_bulk_read(info->rtc_regmap, map[REG_ALARM1_SEC],
+				       data, ARRAY_SIZE(data));
 		if (ret < 0) {
 			dev_err(info->dev, "Fail to read alarm reg(%d)\n", ret);
 			goto out;
@@ -496,9 +491,8 @@ static int max77686_rtc_start_alarm(struct max77686_rtc_info *info)
 		if (data[RTC_DATE] & 0x1f)
 			data[RTC_DATE] |= (1 << ALARM_ENABLE_SHIFT);
 
-		ret = regmap_bulk_write(info->max77686->rtc_regmap,
-					map[REG_ALARM1_SEC], data,
-					ARRAY_SIZE(data));
+		ret = regmap_bulk_write(info->rtc_regmap, map[REG_ALARM1_SEC],
+					data, ARRAY_SIZE(data));
 	}
 
 	if (ret < 0) {
@@ -527,7 +521,7 @@ static int max77686_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	if (ret < 0)
 		goto out;
 
-	ret = regmap_bulk_write(info->max77686->rtc_regmap,
+	ret = regmap_bulk_write(info->rtc_regmap,
 				info->drv_data->map[REG_ALARM1_SEC],
 				data, ARRAY_SIZE(data));
 
@@ -593,7 +587,7 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 
 	info->rtc_24hr_mode = 1;
 
-	ret = regmap_bulk_write(info->max77686->rtc_regmap,
+	ret = regmap_bulk_write(info->rtc_regmap,
 				info->drv_data->map[REG_RTC_CONTROLM],
 				data, ARRAY_SIZE(data));
 	if (ret < 0) {
@@ -619,13 +613,13 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 
 	mutex_init(&info->lock);
 	info->dev = &pdev->dev;
-	info->max77686 = max77686;
 	info->rtc = max77686->rtc;
 	info->drv_data = (const struct max77686_rtc_driver_data *)
 		id->driver_data;
 
-	if (!info->drv_data->separate_i2c_addr)
-		info->max77686->rtc_regmap = info->max77686->regmap;
+	info->regmap = max77686->regmap;
+	info->rtc_regmap = (info->drv_data->separate_i2c_addr) ?
+			    max77686->rtc_regmap : info->regmap;
 
 	platform_set_drvdata(pdev, info);
 
-- 
2.1.4

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* [PATCH V4 5/6] mfd: max77686: do not set i2c client data for rtc i2c client
  2016-02-06 14:37 ` [rtc-linux] " Laxman Dewangan
@ 2016-02-06 14:37   ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

There is different RTC I2C address for RTC block in MAX77686.
Driver is creating dummy i2c client for this address to access
the register of this IP block.

As there is no call to i2c_get_clientdata() for rtc_i2c client,
there is no need to store pointer and hence removing the call
to set client data for rtc i2c client.

Suggested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
This is new in this series based on review comment from V1.

Changes from V2:
- Rephrase description.
- Added reviewed by.

Changes from V3:
- None, become 5th on series.

 drivers/mfd/max77686.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index d959ebb..bda6fd7 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -277,7 +277,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 				"Failed to allocate I2C device for RTC\n");
 			return -ENODEV;
 		}
-		i2c_set_clientdata(max77686->rtc, max77686);
 
 		max77686->rtc_regmap =
 			devm_regmap_init_i2c(max77686->rtc,
-- 
2.1.4

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

* [rtc-linux] [PATCH V4 5/6] mfd: max77686: do not set i2c client data for rtc i2c client
@ 2016-02-06 14:37   ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

There is different RTC I2C address for RTC block in MAX77686.
Driver is creating dummy i2c client for this address to access
the register of this IP block.

As there is no call to i2c_get_clientdata() for rtc_i2c client,
there is no need to store pointer and hence removing the call
to set client data for rtc i2c client.

Suggested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
This is new in this series based on review comment from V1.

Changes from V2:
- Rephrase description.
- Added reviewed by.

Changes from V3:
- None, become 5th on series.

 drivers/mfd/max77686.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index d959ebb..bda6fd7 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -277,7 +277,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 				"Failed to allocate I2C device for RTC\n");
 			return -ENODEV;
 		}
-		i2c_set_clientdata(max77686->rtc, max77686);
 
 		max77686->rtc_regmap =
 			devm_regmap_init_i2c(max77686->rtc,
-- 
2.1.4

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* [PATCH V4 6/6] rtc: max77686: move initialisation of rtc regmap, irq chip locally
  2016-02-06 14:37 ` [rtc-linux] " Laxman Dewangan
@ 2016-02-06 14:37   ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

To make RTC block of MAX77686/MAX77802 as independent driver,
move the registration of i2c device, regmap for register access
and irq_chip for interrupt support inside the RTC driver.
Removed the same initialisation from MFD driver.

Having this change will allow to reuse this driver for different
PMIC/devices from Maxim Semiconductor if they kept same RTC IP on
different PMIC. Some of examples as PMIC MAX77620, MAX20024 where
same RTC IP used and hence driver for these chips will use this
driver only for RTC support.

Suggested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
Changes from V1:
- Remove changes from Kconfig.
- Maintain all register definition in max77686 private header and remove
  the movement to rtc driver.
- Taken care of all comments on V1 from Krzysztof and Javier.

Changes from V2:
- Taken care of missed sequence for removing the resource.
- Fix the crash when doing unbind by using requested_threaded_irq()
  instead of demv_requested_threaded_irq().

Changes from V3:
- Fix the issue of suspend-resume with unbind/bind by unmapping the
  virq.

 drivers/mfd/max77686.c               |  85 +-------------------
 drivers/rtc/rtc-max77686.c           | 149 ++++++++++++++++++++++++++++++-----
 include/linux/mfd/max77686-private.h |   3 -
 3 files changed, 131 insertions(+), 106 deletions(-)

diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index bda6fd7..98ecd13 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -35,8 +35,6 @@
 #include <linux/err.h>
 #include <linux/of.h>
 
-#define I2C_ADDR_RTC	(0x0C >> 1)
-
 static const struct mfd_cell max77686_devs[] = {
 	{ .name = "max77686-pmic", },
 	{ .name = "max77686-rtc", },
@@ -116,11 +114,6 @@ static const struct regmap_config max77686_regmap_config = {
 	.val_bits = 8,
 };
 
-static const struct regmap_config max77686_rtc_regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-};
-
 static const struct regmap_config max77802_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
@@ -156,25 +149,6 @@ static const struct regmap_irq_chip max77686_irq_chip = {
 	.num_irqs		= ARRAY_SIZE(max77686_irqs),
 };
 
-static const struct regmap_irq max77686_rtc_irqs[] = {
-	/* RTC interrupts */
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC60S_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA1_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA2_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_SMPL_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC1S_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_WTSR_MSK, },
-};
-
-static const struct regmap_irq_chip max77686_rtc_irq_chip = {
-	.name			= "max77686-rtc",
-	.status_base		= MAX77686_RTC_INT,
-	.mask_base		= MAX77686_RTC_INTM,
-	.num_regs		= 1,
-	.irqs			= max77686_rtc_irqs,
-	.num_irqs		= ARRAY_SIZE(max77686_rtc_irqs),
-};
-
 static const struct regmap_irq_chip max77802_irq_chip = {
 	.name			= "max77802-pmic",
 	.status_base		= MAX77802_REG_INT1,
@@ -184,15 +158,6 @@ static const struct regmap_irq_chip max77802_irq_chip = {
 	.num_irqs		= ARRAY_SIZE(max77686_irqs),
 };
 
-static const struct regmap_irq_chip max77802_rtc_irq_chip = {
-	.name			= "max77802-rtc",
-	.status_base		= MAX77802_RTC_INT,
-	.mask_base		= MAX77802_RTC_INTM,
-	.num_regs		= 1,
-	.irqs			= max77686_rtc_irqs, /* same masks as 77686 */
-	.num_irqs		= ARRAY_SIZE(max77686_rtc_irqs),
-};
-
 static const struct of_device_id max77686_pmic_dt_match[] = {
 	{
 		.compatible = "maxim,max77686",
@@ -214,8 +179,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	int ret = 0;
 	const struct regmap_config *config;
 	const struct regmap_irq_chip *irq_chip;
-	const struct regmap_irq_chip *rtc_irq_chip;
-	struct regmap **rtc_regmap;
 	const struct mfd_cell *cells;
 	int n_devs;
 
@@ -242,15 +205,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	if (max77686->type == TYPE_MAX77686) {
 		config = &max77686_regmap_config;
 		irq_chip = &max77686_irq_chip;
-		rtc_irq_chip = &max77686_rtc_irq_chip;
-		rtc_regmap = &max77686->rtc_regmap;
 		cells =  max77686_devs;
 		n_devs = ARRAY_SIZE(max77686_devs);
 	} else {
 		config = &max77802_regmap_config;
 		irq_chip = &max77802_irq_chip;
-		rtc_irq_chip = &max77802_rtc_irq_chip;
-		rtc_regmap = &max77686->regmap;
 		cells =  max77802_devs;
 		n_devs = ARRAY_SIZE(max77802_devs);
 	}
@@ -270,59 +229,25 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 		return -ENODEV;
 	}
 
-	if (max77686->type == TYPE_MAX77686) {
-		max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
-		if (!max77686->rtc) {
-			dev_err(max77686->dev,
-				"Failed to allocate I2C device for RTC\n");
-			return -ENODEV;
-		}
-
-		max77686->rtc_regmap =
-			devm_regmap_init_i2c(max77686->rtc,
-					     &max77686_rtc_regmap_config);
-		if (IS_ERR(max77686->rtc_regmap)) {
-			ret = PTR_ERR(max77686->rtc_regmap);
-			dev_err(max77686->dev,
-				"failed to allocate RTC regmap: %d\n",
-				ret);
-			goto err_unregister_i2c;
-		}
-	}
-
 	ret = regmap_add_irq_chip(max77686->regmap, max77686->irq,
 				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
 				  IRQF_SHARED, 0, irq_chip,
 				  &max77686->irq_data);
-	if (ret) {
+	if (ret < 0) {
 		dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret);
-		goto err_unregister_i2c;
-	}
-
-	ret = regmap_add_irq_chip(*rtc_regmap, max77686->irq,
-				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
-				  IRQF_SHARED, 0, rtc_irq_chip,
-				  &max77686->rtc_irq_data);
-	if (ret) {
-		dev_err(&i2c->dev, "failed to add RTC irq chip: %d\n", ret);
-		goto err_del_irqc;
+		return ret;
 	}
 
 	ret = mfd_add_devices(max77686->dev, -1, cells, n_devs, NULL, 0, NULL);
 	if (ret < 0) {
 		dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
-		goto err_del_rtc_irqc;
+		goto err_del_irqc;
 	}
 
 	return 0;
 
-err_del_rtc_irqc:
-	regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data);
 err_del_irqc:
 	regmap_del_irq_chip(max77686->irq, max77686->irq_data);
-err_unregister_i2c:
-	if (max77686->type == TYPE_MAX77686)
-		i2c_unregister_device(max77686->rtc);
 
 	return ret;
 }
@@ -333,12 +258,8 @@ static int max77686_i2c_remove(struct i2c_client *i2c)
 
 	mfd_remove_devices(max77686->dev);
 
-	regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data);
 	regmap_del_irq_chip(max77686->irq, max77686->irq_data);
 
-	if (max77686->type == TYPE_MAX77686)
-		i2c_unregister_device(max77686->rtc);
-
 	return 0;
 }
 
diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index ab1f2cd..536052b 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -12,6 +12,7 @@
  *
  */
 
+#include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/rtc.h>
 #include <linux/delay.h>
@@ -22,6 +23,9 @@
 #include <linux/irqdomain.h>
 #include <linux/regmap.h>
 
+#define MAX77686_I2C_ADDR_RTC		(0x0C >> 1)
+#define MAX77686_INVALID_I2C_ADDR	(-1)
+
 /* RTC Control Register */
 #define BCD_EN_SHIFT			0
 #define BCD_EN_MASK			BIT(BCD_EN_SHIFT)
@@ -68,8 +72,10 @@ struct max77686_rtc_driver_data {
 	const unsigned int	*map;
 	/* Has a separate alarm enable register? */
 	bool			alarm_enable_reg;
-	/* Has a separate I2C regmap for the RTC? */
-	bool			separate_i2c_addr;
+	/* I2C address for RTC block */
+	int			rtc_i2c_addr;
+	/* RTC IRQ CHIP for regmap */
+	const struct regmap_irq_chip *rtc_irq_chip;
 };
 
 struct max77686_rtc_info {
@@ -82,7 +88,9 @@ struct max77686_rtc_info {
 	struct regmap		*rtc_regmap;
 
 	const struct max77686_rtc_driver_data *drv_data;
+	struct regmap_irq_chip_data *rtc_irq_data;
 
+	int rtc_irq;
 	int virq;
 	int rtc_24hr_mode;
 };
@@ -153,12 +161,32 @@ static const unsigned int max77686_map[REG_RTC_END] = {
 	[REG_RTC_AE1]	     = REG_RTC_NONE,
 };
 
+static const struct regmap_irq max77686_rtc_irqs[] = {
+	/* RTC interrupts */
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC60S_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA1_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA2_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_SMPL_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC1S_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_WTSR_MSK, },
+};
+
+static const struct regmap_irq_chip max77686_rtc_irq_chip = {
+	.name		= "max77686-rtc",
+	.status_base	= MAX77686_RTC_INT,
+	.mask_base	= MAX77686_RTC_INTM,
+	.num_regs	= 1,
+	.irqs		= max77686_rtc_irqs,
+	.num_irqs	= ARRAY_SIZE(max77686_rtc_irqs),
+};
+
 static const struct max77686_rtc_driver_data max77686_drv_data = {
 	.delay = 16000,
 	.mask  = 0x7f,
 	.map   = max77686_map,
 	.alarm_enable_reg  = false,
-	.separate_i2c_addr = true,
+	.rtc_i2c_addr = MAX77686_I2C_ADDR_RTC,
+	.rtc_irq_chip = &max77686_rtc_irq_chip,
 };
 
 static const unsigned int max77802_map[REG_RTC_END] = {
@@ -190,12 +218,22 @@ static const unsigned int max77802_map[REG_RTC_END] = {
 	[REG_RTC_AE1]	     = MAX77802_RTC_AE1,
 };
 
+static const struct regmap_irq_chip max77802_rtc_irq_chip = {
+	.name		= "max77802-rtc",
+	.status_base	= MAX77802_RTC_INT,
+	.mask_base	= MAX77802_RTC_INTM,
+	.num_regs	= 1,
+	.irqs		= max77686_rtc_irqs, /* same masks as 77686 */
+	.num_irqs	= ARRAY_SIZE(max77686_rtc_irqs),
+};
+
 static const struct max77686_rtc_driver_data max77802_drv_data = {
 	.delay = 200,
 	.mask  = 0xff,
 	.map   = max77802_map,
 	.alarm_enable_reg  = true,
-	.separate_i2c_addr = false,
+	.rtc_i2c_addr = MAX77686_INVALID_I2C_ADDR,
+	.rtc_irq_chip = &max77802_rtc_irq_chip,
 };
 
 static void max77686_rtc_data_to_tm(u8 *data, struct rtc_time *tm,
@@ -599,9 +637,65 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 	return ret;
 }
 
+static const struct regmap_config max77686_rtc_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+};
+
+static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
+{
+	struct device *parent = info->dev->parent;
+	struct i2c_client *parent_i2c = to_i2c_client(parent);
+	int ret;
+
+	info->rtc_irq = parent_i2c->irq;
+
+	info->regmap = dev_get_regmap(parent, NULL);
+	if (!info->regmap) {
+		dev_err(info->dev, "Failed to get rtc regmap\n");
+		return -ENODEV;
+	}
+
+	if (info->drv_data->rtc_i2c_addr == MAX77686_INVALID_I2C_ADDR) {
+		info->rtc_regmap = info->regmap;
+		goto add_rtc_irq;
+	}
+
+	info->rtc = i2c_new_dummy(parent_i2c->adapter,
+				  info->drv_data->rtc_i2c_addr);
+	if (!info->rtc) {
+		dev_err(info->dev, "Failed to allocate I2C device for RTC\n");
+		return -ENODEV;
+	}
+
+	info->rtc_regmap = devm_regmap_init_i2c(info->rtc,
+						&max77686_rtc_regmap_config);
+	if (IS_ERR(info->rtc_regmap)) {
+		ret = PTR_ERR(info->rtc_regmap);
+		dev_err(info->dev, "Failed to allocate RTC regmap: %d\n", ret);
+		goto err_unregister_i2c;
+	}
+
+add_rtc_irq:
+	ret = regmap_add_irq_chip(info->rtc_regmap, info->rtc_irq,
+				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+				  IRQF_SHARED, 0, info->drv_data->rtc_irq_chip,
+				  &info->rtc_irq_data);
+	if (ret < 0) {
+		dev_err(info->dev, "Failed to add RTC irq chip: %d\n", ret);
+		goto err_unregister_i2c;
+	}
+
+	return 0;
+
+err_unregister_i2c:
+	if (info->rtc)
+		i2c_unregister_device(info->rtc);
+	return ret;
+}
+
 static int max77686_rtc_probe(struct platform_device *pdev)
 {
-	struct max77686_dev *max77686 = dev_get_drvdata(pdev->dev.parent);
 	struct max77686_rtc_info *info;
 	const struct platform_device_id *id = platform_get_device_id(pdev);
 	int ret;
@@ -613,18 +707,16 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 
 	mutex_init(&info->lock);
 	info->dev = &pdev->dev;
-	info->rtc = max77686->rtc;
 	info->drv_data = (const struct max77686_rtc_driver_data *)
 		id->driver_data;
 
-	info->regmap = max77686->regmap;
-	info->rtc_regmap = (info->drv_data->separate_i2c_addr) ?
-			    max77686->rtc_regmap : info->regmap;
+	ret = max77686_init_rtc_regmap(info);
+	if (ret < 0)
+		return ret;
 
 	platform_set_drvdata(pdev, info);
 
 	ret = max77686_rtc_init_reg(info);
-
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to initialize RTC reg:%d\n", ret);
 		goto err_rtc;
@@ -643,30 +735,44 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 		goto err_rtc;
 	}
 
-	if (!max77686->rtc_irq_data) {
-		ret = -EINVAL;
-		dev_err(&pdev->dev, "No RTC regmap IRQ chip\n");
-		goto err_rtc;
-	}
-
-	info->virq = regmap_irq_get_virq(max77686->rtc_irq_data,
+	info->virq = regmap_irq_get_virq(info->rtc_irq_data,
 					 MAX77686_RTCIRQ_RTCA1);
 	if (!info->virq) {
 		ret = -ENXIO;
 		goto err_rtc;
 	}
 
-	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-					max77686_rtc_alarm_irq, 0,
-					"rtc-alarm1", info);
-	if (ret < 0)
+	ret = request_threaded_irq(info->virq, NULL, max77686_rtc_alarm_irq, 0,
+				   "rtc-alarm1", info);
+	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
+		goto err_rtc;
+	}
+
+	return 0;
 
 err_rtc:
+	regmap_del_irq_chip(info->rtc_irq, info->rtc_irq_data);
+	if (info->rtc)
+		i2c_unregister_device(info->rtc);
+
 	return ret;
 }
 
+static int max77686_rtc_remove(struct platform_device *pdev)
+{
+	struct max77686_rtc_info *info = platform_get_drvdata(pdev);
+
+	free_irq(info->virq, info);
+	regmap_irq_put_virq(info->virq);
+	regmap_del_irq_chip(info->rtc_irq, info->rtc_irq_data);
+	if (info->rtc)
+		i2c_unregister_device(info->rtc);
+
+	return 0;
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int max77686_rtc_suspend(struct device *dev)
 {
@@ -707,6 +813,7 @@ static struct platform_driver max77686_rtc_driver = {
 		.pm	= &max77686_rtc_pm_ops,
 	},
 	.probe		= max77686_rtc_probe,
+	.remove		= max77686_rtc_remove,
 	.id_table	= rtc_id,
 };
 
diff --git a/include/linux/mfd/max77686-private.h b/include/linux/mfd/max77686-private.h
index f504349..643dae7 100644
--- a/include/linux/mfd/max77686-private.h
+++ b/include/linux/mfd/max77686-private.h
@@ -437,14 +437,11 @@ enum max77686_irq {
 struct max77686_dev {
 	struct device *dev;
 	struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */
-	struct i2c_client *rtc; /* slave addr 0x0c */
 
 	unsigned long type;
 
 	struct regmap *regmap;		/* regmap for mfd */
-	struct regmap *rtc_regmap;	/* regmap for rtc */
 	struct regmap_irq_chip_data *irq_data;
-	struct regmap_irq_chip_data *rtc_irq_data;
 
 	int irq;
 	struct mutex irqlock;
-- 
2.1.4

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

* [rtc-linux] [PATCH V4 6/6] rtc: max77686: move initialisation of rtc regmap, irq chip locally
@ 2016-02-06 14:37   ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-06 14:37 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux, Laxman Dewangan

To make RTC block of MAX77686/MAX77802 as independent driver,
move the registration of i2c device, regmap for register access
and irq_chip for interrupt support inside the RTC driver.
Removed the same initialisation from MFD driver.

Having this change will allow to reuse this driver for different
PMIC/devices from Maxim Semiconductor if they kept same RTC IP on
different PMIC. Some of examples as PMIC MAX77620, MAX20024 where
same RTC IP used and hence driver for these chips will use this
driver only for RTC support.

Suggested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
CC: Krzysztof Kozlowski <k.kozlowski@samsung.com>
CC: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

---
Changes from V1:
- Remove changes from Kconfig.
- Maintain all register definition in max77686 private header and remove
  the movement to rtc driver.
- Taken care of all comments on V1 from Krzysztof and Javier.

Changes from V2:
- Taken care of missed sequence for removing the resource.
- Fix the crash when doing unbind by using requested_threaded_irq()
  instead of demv_requested_threaded_irq().

Changes from V3:
- Fix the issue of suspend-resume with unbind/bind by unmapping the
  virq.

 drivers/mfd/max77686.c               |  85 +-------------------
 drivers/rtc/rtc-max77686.c           | 149 ++++++++++++++++++++++++++++++-----
 include/linux/mfd/max77686-private.h |   3 -
 3 files changed, 131 insertions(+), 106 deletions(-)

diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index bda6fd7..98ecd13 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -35,8 +35,6 @@
 #include <linux/err.h>
 #include <linux/of.h>
 
-#define I2C_ADDR_RTC	(0x0C >> 1)
-
 static const struct mfd_cell max77686_devs[] = {
 	{ .name = "max77686-pmic", },
 	{ .name = "max77686-rtc", },
@@ -116,11 +114,6 @@ static const struct regmap_config max77686_regmap_config = {
 	.val_bits = 8,
 };
 
-static const struct regmap_config max77686_rtc_regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-};
-
 static const struct regmap_config max77802_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
@@ -156,25 +149,6 @@ static const struct regmap_irq_chip max77686_irq_chip = {
 	.num_irqs		= ARRAY_SIZE(max77686_irqs),
 };
 
-static const struct regmap_irq max77686_rtc_irqs[] = {
-	/* RTC interrupts */
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC60S_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA1_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA2_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_SMPL_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC1S_MSK, },
-	{ .reg_offset = 0, .mask = MAX77686_RTCINT_WTSR_MSK, },
-};
-
-static const struct regmap_irq_chip max77686_rtc_irq_chip = {
-	.name			= "max77686-rtc",
-	.status_base		= MAX77686_RTC_INT,
-	.mask_base		= MAX77686_RTC_INTM,
-	.num_regs		= 1,
-	.irqs			= max77686_rtc_irqs,
-	.num_irqs		= ARRAY_SIZE(max77686_rtc_irqs),
-};
-
 static const struct regmap_irq_chip max77802_irq_chip = {
 	.name			= "max77802-pmic",
 	.status_base		= MAX77802_REG_INT1,
@@ -184,15 +158,6 @@ static const struct regmap_irq_chip max77802_irq_chip = {
 	.num_irqs		= ARRAY_SIZE(max77686_irqs),
 };
 
-static const struct regmap_irq_chip max77802_rtc_irq_chip = {
-	.name			= "max77802-rtc",
-	.status_base		= MAX77802_RTC_INT,
-	.mask_base		= MAX77802_RTC_INTM,
-	.num_regs		= 1,
-	.irqs			= max77686_rtc_irqs, /* same masks as 77686 */
-	.num_irqs		= ARRAY_SIZE(max77686_rtc_irqs),
-};
-
 static const struct of_device_id max77686_pmic_dt_match[] = {
 	{
 		.compatible = "maxim,max77686",
@@ -214,8 +179,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	int ret = 0;
 	const struct regmap_config *config;
 	const struct regmap_irq_chip *irq_chip;
-	const struct regmap_irq_chip *rtc_irq_chip;
-	struct regmap **rtc_regmap;
 	const struct mfd_cell *cells;
 	int n_devs;
 
@@ -242,15 +205,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	if (max77686->type == TYPE_MAX77686) {
 		config = &max77686_regmap_config;
 		irq_chip = &max77686_irq_chip;
-		rtc_irq_chip = &max77686_rtc_irq_chip;
-		rtc_regmap = &max77686->rtc_regmap;
 		cells =  max77686_devs;
 		n_devs = ARRAY_SIZE(max77686_devs);
 	} else {
 		config = &max77802_regmap_config;
 		irq_chip = &max77802_irq_chip;
-		rtc_irq_chip = &max77802_rtc_irq_chip;
-		rtc_regmap = &max77686->regmap;
 		cells =  max77802_devs;
 		n_devs = ARRAY_SIZE(max77802_devs);
 	}
@@ -270,59 +229,25 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 		return -ENODEV;
 	}
 
-	if (max77686->type == TYPE_MAX77686) {
-		max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
-		if (!max77686->rtc) {
-			dev_err(max77686->dev,
-				"Failed to allocate I2C device for RTC\n");
-			return -ENODEV;
-		}
-
-		max77686->rtc_regmap =
-			devm_regmap_init_i2c(max77686->rtc,
-					     &max77686_rtc_regmap_config);
-		if (IS_ERR(max77686->rtc_regmap)) {
-			ret = PTR_ERR(max77686->rtc_regmap);
-			dev_err(max77686->dev,
-				"failed to allocate RTC regmap: %d\n",
-				ret);
-			goto err_unregister_i2c;
-		}
-	}
-
 	ret = regmap_add_irq_chip(max77686->regmap, max77686->irq,
 				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
 				  IRQF_SHARED, 0, irq_chip,
 				  &max77686->irq_data);
-	if (ret) {
+	if (ret < 0) {
 		dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret);
-		goto err_unregister_i2c;
-	}
-
-	ret = regmap_add_irq_chip(*rtc_regmap, max77686->irq,
-				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
-				  IRQF_SHARED, 0, rtc_irq_chip,
-				  &max77686->rtc_irq_data);
-	if (ret) {
-		dev_err(&i2c->dev, "failed to add RTC irq chip: %d\n", ret);
-		goto err_del_irqc;
+		return ret;
 	}
 
 	ret = mfd_add_devices(max77686->dev, -1, cells, n_devs, NULL, 0, NULL);
 	if (ret < 0) {
 		dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
-		goto err_del_rtc_irqc;
+		goto err_del_irqc;
 	}
 
 	return 0;
 
-err_del_rtc_irqc:
-	regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data);
 err_del_irqc:
 	regmap_del_irq_chip(max77686->irq, max77686->irq_data);
-err_unregister_i2c:
-	if (max77686->type == TYPE_MAX77686)
-		i2c_unregister_device(max77686->rtc);
 
 	return ret;
 }
@@ -333,12 +258,8 @@ static int max77686_i2c_remove(struct i2c_client *i2c)
 
 	mfd_remove_devices(max77686->dev);
 
-	regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data);
 	regmap_del_irq_chip(max77686->irq, max77686->irq_data);
 
-	if (max77686->type == TYPE_MAX77686)
-		i2c_unregister_device(max77686->rtc);
-
 	return 0;
 }
 
diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index ab1f2cd..536052b 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -12,6 +12,7 @@
  *
  */
 
+#include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/rtc.h>
 #include <linux/delay.h>
@@ -22,6 +23,9 @@
 #include <linux/irqdomain.h>
 #include <linux/regmap.h>
 
+#define MAX77686_I2C_ADDR_RTC		(0x0C >> 1)
+#define MAX77686_INVALID_I2C_ADDR	(-1)
+
 /* RTC Control Register */
 #define BCD_EN_SHIFT			0
 #define BCD_EN_MASK			BIT(BCD_EN_SHIFT)
@@ -68,8 +72,10 @@ struct max77686_rtc_driver_data {
 	const unsigned int	*map;
 	/* Has a separate alarm enable register? */
 	bool			alarm_enable_reg;
-	/* Has a separate I2C regmap for the RTC? */
-	bool			separate_i2c_addr;
+	/* I2C address for RTC block */
+	int			rtc_i2c_addr;
+	/* RTC IRQ CHIP for regmap */
+	const struct regmap_irq_chip *rtc_irq_chip;
 };
 
 struct max77686_rtc_info {
@@ -82,7 +88,9 @@ struct max77686_rtc_info {
 	struct regmap		*rtc_regmap;
 
 	const struct max77686_rtc_driver_data *drv_data;
+	struct regmap_irq_chip_data *rtc_irq_data;
 
+	int rtc_irq;
 	int virq;
 	int rtc_24hr_mode;
 };
@@ -153,12 +161,32 @@ static const unsigned int max77686_map[REG_RTC_END] = {
 	[REG_RTC_AE1]	     = REG_RTC_NONE,
 };
 
+static const struct regmap_irq max77686_rtc_irqs[] = {
+	/* RTC interrupts */
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC60S_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA1_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA2_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_SMPL_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC1S_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_WTSR_MSK, },
+};
+
+static const struct regmap_irq_chip max77686_rtc_irq_chip = {
+	.name		= "max77686-rtc",
+	.status_base	= MAX77686_RTC_INT,
+	.mask_base	= MAX77686_RTC_INTM,
+	.num_regs	= 1,
+	.irqs		= max77686_rtc_irqs,
+	.num_irqs	= ARRAY_SIZE(max77686_rtc_irqs),
+};
+
 static const struct max77686_rtc_driver_data max77686_drv_data = {
 	.delay = 16000,
 	.mask  = 0x7f,
 	.map   = max77686_map,
 	.alarm_enable_reg  = false,
-	.separate_i2c_addr = true,
+	.rtc_i2c_addr = MAX77686_I2C_ADDR_RTC,
+	.rtc_irq_chip = &max77686_rtc_irq_chip,
 };
 
 static const unsigned int max77802_map[REG_RTC_END] = {
@@ -190,12 +218,22 @@ static const unsigned int max77802_map[REG_RTC_END] = {
 	[REG_RTC_AE1]	     = MAX77802_RTC_AE1,
 };
 
+static const struct regmap_irq_chip max77802_rtc_irq_chip = {
+	.name		= "max77802-rtc",
+	.status_base	= MAX77802_RTC_INT,
+	.mask_base	= MAX77802_RTC_INTM,
+	.num_regs	= 1,
+	.irqs		= max77686_rtc_irqs, /* same masks as 77686 */
+	.num_irqs	= ARRAY_SIZE(max77686_rtc_irqs),
+};
+
 static const struct max77686_rtc_driver_data max77802_drv_data = {
 	.delay = 200,
 	.mask  = 0xff,
 	.map   = max77802_map,
 	.alarm_enable_reg  = true,
-	.separate_i2c_addr = false,
+	.rtc_i2c_addr = MAX77686_INVALID_I2C_ADDR,
+	.rtc_irq_chip = &max77802_rtc_irq_chip,
 };
 
 static void max77686_rtc_data_to_tm(u8 *data, struct rtc_time *tm,
@@ -599,9 +637,65 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 	return ret;
 }
 
+static const struct regmap_config max77686_rtc_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+};
+
+static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
+{
+	struct device *parent = info->dev->parent;
+	struct i2c_client *parent_i2c = to_i2c_client(parent);
+	int ret;
+
+	info->rtc_irq = parent_i2c->irq;
+
+	info->regmap = dev_get_regmap(parent, NULL);
+	if (!info->regmap) {
+		dev_err(info->dev, "Failed to get rtc regmap\n");
+		return -ENODEV;
+	}
+
+	if (info->drv_data->rtc_i2c_addr == MAX77686_INVALID_I2C_ADDR) {
+		info->rtc_regmap = info->regmap;
+		goto add_rtc_irq;
+	}
+
+	info->rtc = i2c_new_dummy(parent_i2c->adapter,
+				  info->drv_data->rtc_i2c_addr);
+	if (!info->rtc) {
+		dev_err(info->dev, "Failed to allocate I2C device for RTC\n");
+		return -ENODEV;
+	}
+
+	info->rtc_regmap = devm_regmap_init_i2c(info->rtc,
+						&max77686_rtc_regmap_config);
+	if (IS_ERR(info->rtc_regmap)) {
+		ret = PTR_ERR(info->rtc_regmap);
+		dev_err(info->dev, "Failed to allocate RTC regmap: %d\n", ret);
+		goto err_unregister_i2c;
+	}
+
+add_rtc_irq:
+	ret = regmap_add_irq_chip(info->rtc_regmap, info->rtc_irq,
+				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+				  IRQF_SHARED, 0, info->drv_data->rtc_irq_chip,
+				  &info->rtc_irq_data);
+	if (ret < 0) {
+		dev_err(info->dev, "Failed to add RTC irq chip: %d\n", ret);
+		goto err_unregister_i2c;
+	}
+
+	return 0;
+
+err_unregister_i2c:
+	if (info->rtc)
+		i2c_unregister_device(info->rtc);
+	return ret;
+}
+
 static int max77686_rtc_probe(struct platform_device *pdev)
 {
-	struct max77686_dev *max77686 = dev_get_drvdata(pdev->dev.parent);
 	struct max77686_rtc_info *info;
 	const struct platform_device_id *id = platform_get_device_id(pdev);
 	int ret;
@@ -613,18 +707,16 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 
 	mutex_init(&info->lock);
 	info->dev = &pdev->dev;
-	info->rtc = max77686->rtc;
 	info->drv_data = (const struct max77686_rtc_driver_data *)
 		id->driver_data;
 
-	info->regmap = max77686->regmap;
-	info->rtc_regmap = (info->drv_data->separate_i2c_addr) ?
-			    max77686->rtc_regmap : info->regmap;
+	ret = max77686_init_rtc_regmap(info);
+	if (ret < 0)
+		return ret;
 
 	platform_set_drvdata(pdev, info);
 
 	ret = max77686_rtc_init_reg(info);
-
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to initialize RTC reg:%d\n", ret);
 		goto err_rtc;
@@ -643,30 +735,44 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 		goto err_rtc;
 	}
 
-	if (!max77686->rtc_irq_data) {
-		ret = -EINVAL;
-		dev_err(&pdev->dev, "No RTC regmap IRQ chip\n");
-		goto err_rtc;
-	}
-
-	info->virq = regmap_irq_get_virq(max77686->rtc_irq_data,
+	info->virq = regmap_irq_get_virq(info->rtc_irq_data,
 					 MAX77686_RTCIRQ_RTCA1);
 	if (!info->virq) {
 		ret = -ENXIO;
 		goto err_rtc;
 	}
 
-	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-					max77686_rtc_alarm_irq, 0,
-					"rtc-alarm1", info);
-	if (ret < 0)
+	ret = request_threaded_irq(info->virq, NULL, max77686_rtc_alarm_irq, 0,
+				   "rtc-alarm1", info);
+	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
+		goto err_rtc;
+	}
+
+	return 0;
 
 err_rtc:
+	regmap_del_irq_chip(info->rtc_irq, info->rtc_irq_data);
+	if (info->rtc)
+		i2c_unregister_device(info->rtc);
+
 	return ret;
 }
 
+static int max77686_rtc_remove(struct platform_device *pdev)
+{
+	struct max77686_rtc_info *info = platform_get_drvdata(pdev);
+
+	free_irq(info->virq, info);
+	regmap_irq_put_virq(info->virq);
+	regmap_del_irq_chip(info->rtc_irq, info->rtc_irq_data);
+	if (info->rtc)
+		i2c_unregister_device(info->rtc);
+
+	return 0;
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int max77686_rtc_suspend(struct device *dev)
 {
@@ -707,6 +813,7 @@ static struct platform_driver max77686_rtc_driver = {
 		.pm	= &max77686_rtc_pm_ops,
 	},
 	.probe		= max77686_rtc_probe,
+	.remove		= max77686_rtc_remove,
 	.id_table	= rtc_id,
 };
 
diff --git a/include/linux/mfd/max77686-private.h b/include/linux/mfd/max77686-private.h
index f504349..643dae7 100644
--- a/include/linux/mfd/max77686-private.h
+++ b/include/linux/mfd/max77686-private.h
@@ -437,14 +437,11 @@ enum max77686_irq {
 struct max77686_dev {
 	struct device *dev;
 	struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */
-	struct i2c_client *rtc; /* slave addr 0x0c */
 
 	unsigned long type;
 
 	struct regmap *regmap;		/* regmap for mfd */
-	struct regmap *rtc_regmap;	/* regmap for rtc */
 	struct regmap_irq_chip_data *irq_data;
-	struct regmap_irq_chip_data *rtc_irq_data;
 
 	int irq;
 	struct mutex irqlock;
-- 
2.1.4

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH V4 6/6] rtc: max77686: move initialisation of rtc regmap, irq chip locally
  2016-02-06 14:37   ` [rtc-linux] " Laxman Dewangan
@ 2016-02-08 10:20     ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-08 10:20 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux


On Saturday 06 February 2016 08:07 PM, Laxman Dewangan wrote:
> -	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
> -					max77686_rtc_alarm_irq, 0,
> -					"rtc-alarm1", info);
> -	if (ret < 0)
> +	ret = request_threaded_irq(info->virq, NULL, max77686_rtc_alarm_irq, 0,
> +				   "rtc-alarm1", info);
> +	if (ret < 0) {
>   		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
>   			info->virq, ret);
> +		goto err_rtc;
> +	}
> +
> +	return 0;
>   
>   err_rtc:

Oops.. I wish I should have called regmap_irq_put_virq(info->virq); here.

Please let me know if I can respin this patch only instead of entire series.

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

* [rtc-linux] Re: [PATCH V4 6/6] rtc: max77686: move initialisation of rtc regmap, irq chip locally
@ 2016-02-08 10:20     ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-08 10:20 UTC (permalink / raw)
  To: lee.jones, alexandre.belloni, k.kozlowski, javier, broonie,
	gregkh, a.zummo
  Cc: cw00.choi, linux-kernel, rtc-linux


On Saturday 06 February 2016 08:07 PM, Laxman Dewangan wrote:
> -	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
> -					max77686_rtc_alarm_irq, 0,
> -					"rtc-alarm1", info);
> -	if (ret < 0)
> +	ret = request_threaded_irq(info->virq, NULL, max77686_rtc_alarm_irq, 0,
> +				   "rtc-alarm1", info);
> +	if (ret < 0) {
>   		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
>   			info->virq, ret);
> +		goto err_rtc;
> +	}
> +
> +	return 0;
>   
>   err_rtc:

Oops.. I wish I should have called regmap_irq_put_virq(info->virq); here.

Please let me know if I can respin this patch only instead of entire series.


-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH V4 6/6] rtc: max77686: move initialisation of rtc regmap, irq chip locally
  2016-02-08 10:20     ` [rtc-linux] " Laxman Dewangan
@ 2016-02-08 10:42       ` Alexandre Belloni
  -1 siblings, 0 replies; 36+ messages in thread
From: Alexandre Belloni @ 2016-02-08 10:42 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: lee.jones, k.kozlowski, javier, broonie, gregkh, a.zummo,
	cw00.choi, linux-kernel, rtc-linux

On 08/02/2016 at 15:50:06 +0530, Laxman Dewangan wrote :
> 
> On Saturday 06 February 2016 08:07 PM, Laxman Dewangan wrote:
> >-	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
> >-					max77686_rtc_alarm_irq, 0,
> >-					"rtc-alarm1", info);
> >-	if (ret < 0)
> >+	ret = request_threaded_irq(info->virq, NULL, max77686_rtc_alarm_irq, 0,
> >+				   "rtc-alarm1", info);
> >+	if (ret < 0) {
> >  		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
> >  			info->virq, ret);
> >+		goto err_rtc;
> >+	}
> >+
> >+	return 0;
> >  err_rtc:
> 
> Oops.. I wish I should have called regmap_irq_put_virq(info->virq); here.
> 
> Please let me know if I can respin this patch only instead of entire series.
> 

Sure, you can.

> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [rtc-linux] Re: [PATCH V4 6/6] rtc: max77686: move initialisation of rtc regmap, irq chip locally
@ 2016-02-08 10:42       ` Alexandre Belloni
  0 siblings, 0 replies; 36+ messages in thread
From: Alexandre Belloni @ 2016-02-08 10:42 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: lee.jones, k.kozlowski, javier, broonie, gregkh, a.zummo,
	cw00.choi, linux-kernel, rtc-linux

On 08/02/2016 at 15:50:06 +0530, Laxman Dewangan wrote :
> 
> On Saturday 06 February 2016 08:07 PM, Laxman Dewangan wrote:
> >-	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
> >-					max77686_rtc_alarm_irq, 0,
> >-					"rtc-alarm1", info);
> >-	if (ret < 0)
> >+	ret = request_threaded_irq(info->virq, NULL, max77686_rtc_alarm_irq, 0,
> >+				   "rtc-alarm1", info);
> >+	if (ret < 0) {
> >  		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
> >  			info->virq, ret);
> >+		goto err_rtc;
> >+	}
> >+
> >+	return 0;
> >  err_rtc:
> 
> Oops.. I wish I should have called regmap_irq_put_virq(info->virq); here.
> 
> Please let me know if I can respin this patch only instead of entire series.
> 

Sure, you can.

> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-06 14:37   ` [rtc-linux] " Laxman Dewangan
@ 2016-02-08 14:55     ` Mark Brown
  -1 siblings, 0 replies; 36+ messages in thread
From: Mark Brown @ 2016-02-08 14:55 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: lee.jones, alexandre.belloni, k.kozlowski, javier, gregkh,
	a.zummo, cw00.choi, linux-kernel, rtc-linux

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

On Sat, Feb 06, 2016 at 08:07:22PM +0530, Laxman Dewangan wrote:

> Before removing irq domains, it is require to unmap all
> mapped interrupt from that domain. Currently there is API
> to map the interrupt on chip as regmap_irq_get_virq() for
> creating mapping. Add equivalent API to dispose the mapped
> irq in irq domains.

This makes no sense to me.  Why would you ever want to unmap the
interrupts separately to destroying the domain and why would you ever
want to destroy the domain without unmapping the interrupts?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-08 14:55     ` Mark Brown
  0 siblings, 0 replies; 36+ messages in thread
From: Mark Brown @ 2016-02-08 14:55 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: lee.jones, alexandre.belloni, k.kozlowski, javier, gregkh,
	a.zummo, cw00.choi, linux-kernel, rtc-linux

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

On Sat, Feb 06, 2016 at 08:07:22PM +0530, Laxman Dewangan wrote:

> Before removing irq domains, it is require to unmap all
> mapped interrupt from that domain. Currently there is API
> to map the interrupt on chip as regmap_irq_get_virq() for
> creating mapping. Add equivalent API to dispose the mapped
> irq in irq domains.

This makes no sense to me.  Why would you ever want to unmap the
interrupts separately to destroying the domain and why would you ever
want to destroy the domain without unmapping the interrupts?

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-08 14:55     ` [rtc-linux] " Mark Brown
@ 2016-02-08 16:38       ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-08 16:38 UTC (permalink / raw)
  To: Mark Brown
  Cc: lee.jones, alexandre.belloni, k.kozlowski, javier, gregkh,
	a.zummo, cw00.choi, linux-kernel, rtc-linux


On Monday 08 February 2016 08:25 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Sat, Feb 06, 2016 at 08:07:22PM +0530, Laxman Dewangan wrote:
>
>> Before removing irq domains, it is require to unmap all
>> mapped interrupt from that domain. Currently there is API
>> to map the interrupt on chip as regmap_irq_get_virq() for
>> creating mapping. Add equivalent API to dispose the mapped
>> irq in irq domains.
> This makes no sense to me.  Why would you ever want to unmap the
> interrupts separately to destroying the domain

This is the requirement from irq_domain_remove(). This is what we have 
in irq_domain_remove():
kernel/irq/irqdomain.c

/*
  * This routine is used to remove an irq domain. The caller must ensure
  * that all mappings within the domain have been disposed of prior to
  * use, depending on the revmap type.
  */
void irq_domain_remove(struct irq_domain *domain)


I am adding the API equivalent to regmap_irq_get_virq() to unmap virtual 
irq here.



> and why would you ever
> want to destroy the domain without unmapping the interrupts?
>
That's exactlly we are trying to do, unmap interrupt in client level 
before destroying domain.

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-08 16:38       ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-08 16:38 UTC (permalink / raw)
  To: Mark Brown
  Cc: lee.jones, alexandre.belloni, k.kozlowski, javier, gregkh,
	a.zummo, cw00.choi, linux-kernel, rtc-linux


On Monday 08 February 2016 08:25 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Sat, Feb 06, 2016 at 08:07:22PM +0530, Laxman Dewangan wrote:
>
>> Before removing irq domains, it is require to unmap all
>> mapped interrupt from that domain. Currently there is API
>> to map the interrupt on chip as regmap_irq_get_virq() for
>> creating mapping. Add equivalent API to dispose the mapped
>> irq in irq domains.
> This makes no sense to me.  Why would you ever want to unmap the
> interrupts separately to destroying the domain

This is the requirement from irq_domain_remove(). This is what we have 
in irq_domain_remove():
kernel/irq/irqdomain.c

/*
  * This routine is used to remove an irq domain. The caller must ensure
  * that all mappings within the domain have been disposed of prior to
  * use, depending on the revmap type.
  */
void irq_domain_remove(struct irq_domain *domain)


I am adding the API equivalent to regmap_irq_get_virq() to unmap virtual 
irq here.



> and why would you ever
> want to destroy the domain without unmapping the interrupts?
>
That's exactlly we are trying to do, unmap interrupt in client level 
before destroying domain.





-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-08 16:59         ` [rtc-linux] " Mark Brown
@ 2016-02-08 16:56           ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-08 16:56 UTC (permalink / raw)
  To: Mark Brown, Thomas Gleixner
  Cc: lee.jones, alexandre.belloni, k.kozlowski, javier, gregkh,
	a.zummo, cw00.choi, linux-kernel, rtc-linux

Adding Thomas in the discussion.

On Monday 08 February 2016 10:29 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Mon, Feb 08, 2016 at 10:08:28PM +0530, Laxman Dewangan wrote:
>> On Monday 08 February 2016 08:25 PM, Mark Brown wrote:
>>> On Sat, Feb 06, 2016 at 08:07:22PM +0530, Laxman Dewangan wrote:
>>>> Before removing irq domains, it is require to unmap all
>>>> mapped interrupt from that domain. Currently there is API
>>>> to map the interrupt on chip as regmap_irq_get_virq() for
>>>> creating mapping. Add equivalent API to dispose the mapped
>>>> irq in irq domains.
>>> This makes no sense to me.  Why would you ever want to unmap the
>>> interrupts separately to destroying the domain
>> This is the requirement from irq_domain_remove(). This is what we have in
>> irq_domain_remove():
>> kernel/irq/irqdomain.c
>> I am adding the API equivalent to regmap_irq_get_virq() to unmap virtual irq
>> here.
> This does not explain why anyone would ever want to use this interface
> (which was my question), why would anyone ever want to do this as a
> separate step?

OK, so you want to say that irq_domain_remove() should take care of 
doing unmap also?

>
>>> and why would you ever
>>> want to destroy the domain without unmapping the interrupts?
>> That's exactlly we are trying to do, unmap interrupt in client level before
>> destroying domain.
> Again, why would any client ever want to skip this step?

If above is yes then we will not need for unmap virtual irq.
So fix need to go in the irq_domain_remove() to unamp before actually 
destroying the irq domain?

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-08 16:56           ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-08 16:56 UTC (permalink / raw)
  To: Mark Brown, Thomas Gleixner
  Cc: lee.jones, alexandre.belloni, k.kozlowski, javier, gregkh,
	a.zummo, cw00.choi, linux-kernel, rtc-linux

Adding Thomas in the discussion.

On Monday 08 February 2016 10:29 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Mon, Feb 08, 2016 at 10:08:28PM +0530, Laxman Dewangan wrote:
>> On Monday 08 February 2016 08:25 PM, Mark Brown wrote:
>>> On Sat, Feb 06, 2016 at 08:07:22PM +0530, Laxman Dewangan wrote:
>>>> Before removing irq domains, it is require to unmap all
>>>> mapped interrupt from that domain. Currently there is API
>>>> to map the interrupt on chip as regmap_irq_get_virq() for
>>>> creating mapping. Add equivalent API to dispose the mapped
>>>> irq in irq domains.
>>> This makes no sense to me.  Why would you ever want to unmap the
>>> interrupts separately to destroying the domain
>> This is the requirement from irq_domain_remove(). This is what we have in
>> irq_domain_remove():
>> kernel/irq/irqdomain.c
>> I am adding the API equivalent to regmap_irq_get_virq() to unmap virtual irq
>> here.
> This does not explain why anyone would ever want to use this interface
> (which was my question), why would anyone ever want to do this as a
> separate step?

OK, so you want to say that irq_domain_remove() should take care of 
doing unmap also?

>
>>> and why would you ever
>>> want to destroy the domain without unmapping the interrupts?
>> That's exactlly we are trying to do, unmap interrupt in client level before
>> destroying domain.
> Again, why would any client ever want to skip this step?

If above is yes then we will not need for unmap virtual irq.
So fix need to go in the irq_domain_remove() to unamp before actually 
destroying the irq domain?


-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-08 16:38       ` [rtc-linux] " Laxman Dewangan
@ 2016-02-08 16:59         ` Mark Brown
  -1 siblings, 0 replies; 36+ messages in thread
From: Mark Brown @ 2016-02-08 16:59 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: lee.jones, alexandre.belloni, k.kozlowski, javier, gregkh,
	a.zummo, cw00.choi, linux-kernel, rtc-linux

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

On Mon, Feb 08, 2016 at 10:08:28PM +0530, Laxman Dewangan wrote:
> On Monday 08 February 2016 08:25 PM, Mark Brown wrote:
> >On Sat, Feb 06, 2016 at 08:07:22PM +0530, Laxman Dewangan wrote:

> >>Before removing irq domains, it is require to unmap all
> >>mapped interrupt from that domain. Currently there is API
> >>to map the interrupt on chip as regmap_irq_get_virq() for
> >>creating mapping. Add equivalent API to dispose the mapped
> >>irq in irq domains.

> >This makes no sense to me.  Why would you ever want to unmap the
> >interrupts separately to destroying the domain

> This is the requirement from irq_domain_remove(). This is what we have in
> irq_domain_remove():
> kernel/irq/irqdomain.c

> I am adding the API equivalent to regmap_irq_get_virq() to unmap virtual irq
> here.

This does not explain why anyone would ever want to use this interface
(which was my question), why would anyone ever want to do this as a
separate step?

> >and why would you ever
> >want to destroy the domain without unmapping the interrupts?

> That's exactlly we are trying to do, unmap interrupt in client level before
> destroying domain.

Again, why would any client ever want to skip this step? 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-08 16:59         ` Mark Brown
  0 siblings, 0 replies; 36+ messages in thread
From: Mark Brown @ 2016-02-08 16:59 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: lee.jones, alexandre.belloni, k.kozlowski, javier, gregkh,
	a.zummo, cw00.choi, linux-kernel, rtc-linux

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

On Mon, Feb 08, 2016 at 10:08:28PM +0530, Laxman Dewangan wrote:
> On Monday 08 February 2016 08:25 PM, Mark Brown wrote:
> >On Sat, Feb 06, 2016 at 08:07:22PM +0530, Laxman Dewangan wrote:

> >>Before removing irq domains, it is require to unmap all
> >>mapped interrupt from that domain. Currently there is API
> >>to map the interrupt on chip as regmap_irq_get_virq() for
> >>creating mapping. Add equivalent API to dispose the mapped
> >>irq in irq domains.

> >This makes no sense to me.  Why would you ever want to unmap the
> >interrupts separately to destroying the domain

> This is the requirement from irq_domain_remove(). This is what we have in
> irq_domain_remove():
> kernel/irq/irqdomain.c

> I am adding the API equivalent to regmap_irq_get_virq() to unmap virtual irq
> here.

This does not explain why anyone would ever want to use this interface
(which was my question), why would anyone ever want to do this as a
separate step?

> >and why would you ever
> >want to destroy the domain without unmapping the interrupts?

> That's exactlly we are trying to do, unmap interrupt in client level before
> destroying domain.

Again, why would any client ever want to skip this step? 

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-08 16:56           ` [rtc-linux] " Laxman Dewangan
@ 2016-02-08 18:19             ` Mark Brown
  -1 siblings, 0 replies; 36+ messages in thread
From: Mark Brown @ 2016-02-08 18:19 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux

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

On Mon, Feb 08, 2016 at 10:26:20PM +0530, Laxman Dewangan wrote:
> Adding Thomas in the discussion.

> >This does not explain why anyone would ever want to use this interface
> >(which was my question), why would anyone ever want to do this as a
> >separate step?

> OK, so you want to say that irq_domain_remove() should take care of doing
> unmap also?

My main focus is on the regmap-irq interface you are trying to add - why
would a user of this interface want to do this as a separate step (which
would require changing all the existing users...)?  We're providing an
interface to get the virq mapped to a particular interrupt in the
device, it's not obvious that that is an allocation and it certainly
wasn't the intention (this code predates us using domains).

> So fix need to go in the irq_domain_remove() to unamp before actually
> destroying the irq domain?

That's one option, but you could also do this at the regmap-irq level.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-08 18:19             ` Mark Brown
  0 siblings, 0 replies; 36+ messages in thread
From: Mark Brown @ 2016-02-08 18:19 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux

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

On Mon, Feb 08, 2016 at 10:26:20PM +0530, Laxman Dewangan wrote:
> Adding Thomas in the discussion.

> >This does not explain why anyone would ever want to use this interface
> >(which was my question), why would anyone ever want to do this as a
> >separate step?

> OK, so you want to say that irq_domain_remove() should take care of doing
> unmap also?

My main focus is on the regmap-irq interface you are trying to add - why
would a user of this interface want to do this as a separate step (which
would require changing all the existing users...)?  We're providing an
interface to get the virq mapped to a particular interrupt in the
device, it's not obvious that that is an allocation and it certainly
wasn't the intention (this code predates us using domains).

> So fix need to go in the irq_domain_remove() to unamp before actually
> destroying the irq domain?

That's one option, but you could also do this at the regmap-irq level.

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-08 18:19             ` [rtc-linux] " Mark Brown
@ 2016-02-09  5:16               ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-09  5:16 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux


On Monday 08 February 2016 11:49 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Mon, Feb 08, 2016 at 10:26:20PM +0530, Laxman Dewangan wrote:
>
>> So fix need to go in the irq_domain_remove() to unamp before actually
>> destroying the irq domain?
> That's one option, but you could also do this at the regmap-irq level.
>

Do we need to dispose all virtual irq in regmap_del_irq_chip() before 
actually removing domain?
This means we need to store the created virq  in regmap_irq_chip_data 
for disposing it when removing the irq domain.

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-09  5:16               ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-09  5:16 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux


On Monday 08 February 2016 11:49 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Mon, Feb 08, 2016 at 10:26:20PM +0530, Laxman Dewangan wrote:
>
>> So fix need to go in the irq_domain_remove() to unamp before actually
>> destroying the irq domain?
> That's one option, but you could also do this at the regmap-irq level.
>

Do we need to dispose all virtual irq in regmap_del_irq_chip() before 
actually removing domain?
This means we need to store the created virq  in regmap_irq_chip_data 
for disposing it when removing the irq domain.

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-09  5:16               ` [rtc-linux] " Laxman Dewangan
@ 2016-02-09  9:08                 ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-09  9:08 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux


On Tuesday 09 February 2016 10:46 AM, Laxman Dewangan wrote:
>
> On Monday 08 February 2016 11:49 PM, Mark Brown wrote:
>> * PGP Signed by an unknown key
>>
>> On Mon, Feb 08, 2016 at 10:26:20PM +0530, Laxman Dewangan wrote:
>>
>>> So fix need to go in the irq_domain_remove() to unamp before actually
>>> destroying the irq domain?
>> That's one option, but you could also do this at the regmap-irq level.
>>
>
> Do we need to dispose all virtual irq in regmap_del_irq_chip() before 
> actually removing domain?
> This means we need to store the created virq  in regmap_irq_chip_data 
> for disposing it when removing the irq domain.

It is easy for me to communicate through code to avoid any confusion. So 
do you want to say as follows? In this case, there is no need of any new 
API.

  void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d)
  {
+       unsigned int virq;
+       int hwirq;
+
         if (!d)
                 return;

         free_irq(irq, d);
+
+       /* Unmap all virtual irq from this domain */
+       for (hwirq = 0; hwirq < d->chip->num_irqs; hwirq++) {
+               if (!d->chip->irqs[irq].mask)
+                       continue;
+
+               /* Get virtual irq of hwirq on chip if already mapped */
+               virq = irq_find_mapping(d->domain, hwirq);
+               if (virq)
+                       irq_dispose_mapping(virq);
+       }
+

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-09  9:08                 ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-09  9:08 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux


On Tuesday 09 February 2016 10:46 AM, Laxman Dewangan wrote:
>
> On Monday 08 February 2016 11:49 PM, Mark Brown wrote:
>> * PGP Signed by an unknown key
>>
>> On Mon, Feb 08, 2016 at 10:26:20PM +0530, Laxman Dewangan wrote:
>>
>>> So fix need to go in the irq_domain_remove() to unamp before actually
>>> destroying the irq domain?
>> That's one option, but you could also do this at the regmap-irq level.
>>
>
> Do we need to dispose all virtual irq in regmap_del_irq_chip() before 
> actually removing domain?
> This means we need to store the created virq  in regmap_irq_chip_data 
> for disposing it when removing the irq domain.

It is easy for me to communicate through code to avoid any confusion. So 
do you want to say as follows? In this case, there is no need of any new 
API.

  void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d)
  {
+       unsigned int virq;
+       int hwirq;
+
         if (!d)
                 return;

         free_irq(irq, d);
+
+       /* Unmap all virtual irq from this domain */
+       for (hwirq = 0; hwirq < d->chip->num_irqs; hwirq++) {
+               if (!d->chip->irqs[irq].mask)
+                       continue;
+
+               /* Get virtual irq of hwirq on chip if already mapped */
+               virq = irq_find_mapping(d->domain, hwirq);
+               if (virq)
+                       irq_dispose_mapping(virq);
+       }
+

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-09 11:27                   ` [rtc-linux] " Mark Brown
@ 2016-02-09 11:21                     ` Laxman Dewangan
  -1 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-09 11:21 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux


On Tuesday 09 February 2016 04:57 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Tue, Feb 09, 2016 at 02:38:28PM +0530, Laxman Dewangan wrote:
>> On Tuesday 09 February 2016 10:46 AM, Laxman Dewangan wrote:
>>> Do we need to dispose all virtual irq in regmap_del_irq_chip() before
>>> actually removing domain?
>>> This means we need to store the created virq  in regmap_irq_chip_data for
>>> disposing it when removing the irq domain.
>> It is easy for me to communicate through code to avoid any confusion. So do
>> you want to say as follows? In this case, there is no need of any new API.
> Something like that, yes.  Documentation/SubmittingPatches please...
Thanks for suggestion and review.

Sure, I will do this.

BTW, I like to add devm_ version of regmap_add_irq_chip() and 
regmap_del_irq_chip() so that error path and .remove callback is much 
cleaner. If you are fine then I can make part of this series so that rtc 
driver will look more simple on probe/remove callback.

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-09 11:21                     ` Laxman Dewangan
  0 siblings, 0 replies; 36+ messages in thread
From: Laxman Dewangan @ 2016-02-09 11:21 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux


On Tuesday 09 February 2016 04:57 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Tue, Feb 09, 2016 at 02:38:28PM +0530, Laxman Dewangan wrote:
>> On Tuesday 09 February 2016 10:46 AM, Laxman Dewangan wrote:
>>> Do we need to dispose all virtual irq in regmap_del_irq_chip() before
>>> actually removing domain?
>>> This means we need to store the created virq  in regmap_irq_chip_data for
>>> disposing it when removing the irq domain.
>> It is easy for me to communicate through code to avoid any confusion. So do
>> you want to say as follows? In this case, there is no need of any new API.
> Something like that, yes.  Documentation/SubmittingPatches please...
Thanks for suggestion and review.

Sure, I will do this.

BTW, I like to add devm_ version of regmap_add_irq_chip() and 
regmap_del_irq_chip() so that error path and .remove callback is much 
cleaner. If you are fine then I can make part of this series so that rtc 
driver will look more simple on probe/remove callback.


-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
  2016-02-09  9:08                 ` [rtc-linux] " Laxman Dewangan
@ 2016-02-09 11:27                   ` Mark Brown
  -1 siblings, 0 replies; 36+ messages in thread
From: Mark Brown @ 2016-02-09 11:27 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux

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

On Tue, Feb 09, 2016 at 02:38:28PM +0530, Laxman Dewangan wrote:
> On Tuesday 09 February 2016 10:46 AM, Laxman Dewangan wrote:

> >Do we need to dispose all virtual irq in regmap_del_irq_chip() before
> >actually removing domain?
> >This means we need to store the created virq  in regmap_irq_chip_data for
> >disposing it when removing the irq domain.

> It is easy for me to communicate through code to avoid any confusion. So do
> you want to say as follows? In this case, there is no need of any new API.

Something like that, yes.  Documentation/SubmittingPatches please...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* [rtc-linux] Re: [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq
@ 2016-02-09 11:27                   ` Mark Brown
  0 siblings, 0 replies; 36+ messages in thread
From: Mark Brown @ 2016-02-09 11:27 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: Thomas Gleixner, lee.jones, alexandre.belloni, k.kozlowski,
	javier, gregkh, a.zummo, cw00.choi, linux-kernel, rtc-linux

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

On Tue, Feb 09, 2016 at 02:38:28PM +0530, Laxman Dewangan wrote:
> On Tuesday 09 February 2016 10:46 AM, Laxman Dewangan wrote:

> >Do we need to dispose all virtual irq in regmap_del_irq_chip() before
> >actually removing domain?
> >This means we need to store the created virq  in regmap_irq_chip_data for
> >disposing it when removing the irq domain.

> It is easy for me to communicate through code to avoid any confusion. So do
> you want to say as follows? In this case, there is no need of any new API.

Something like that, yes.  Documentation/SubmittingPatches please...

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2016-02-09 11:33 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-06 14:37 [PATCH V4 0/6] rtc: max77686: make max77686 rtc driver as IP driver Laxman Dewangan
2016-02-06 14:37 ` [rtc-linux] " Laxman Dewangan
2016-02-06 14:37 ` [PATCH V4 1/6] regmap: irq: add apis to unmap the mapped irq Laxman Dewangan
2016-02-06 14:37   ` [rtc-linux] " Laxman Dewangan
2016-02-08 14:55   ` Mark Brown
2016-02-08 14:55     ` [rtc-linux] " Mark Brown
2016-02-08 16:38     ` Laxman Dewangan
2016-02-08 16:38       ` [rtc-linux] " Laxman Dewangan
2016-02-08 16:59       ` Mark Brown
2016-02-08 16:59         ` [rtc-linux] " Mark Brown
2016-02-08 16:56         ` Laxman Dewangan
2016-02-08 16:56           ` [rtc-linux] " Laxman Dewangan
2016-02-08 18:19           ` Mark Brown
2016-02-08 18:19             ` [rtc-linux] " Mark Brown
2016-02-09  5:16             ` Laxman Dewangan
2016-02-09  5:16               ` [rtc-linux] " Laxman Dewangan
2016-02-09  9:08               ` Laxman Dewangan
2016-02-09  9:08                 ` [rtc-linux] " Laxman Dewangan
2016-02-09 11:27                 ` Mark Brown
2016-02-09 11:27                   ` [rtc-linux] " Mark Brown
2016-02-09 11:21                   ` Laxman Dewangan
2016-02-09 11:21                     ` [rtc-linux] " Laxman Dewangan
2016-02-06 14:37 ` [PATCH V4 2/6] rtc: max77686: fix checkpatch error Laxman Dewangan
2016-02-06 14:37   ` [rtc-linux] " Laxman Dewangan
2016-02-06 14:37 ` [PATCH V4 3/6] rtc: max77686: use rtc regmap to access RTC registers Laxman Dewangan
2016-02-06 14:37   ` [rtc-linux] " Laxman Dewangan
2016-02-06 14:37 ` [PATCH V4 4/6] rtc: max77686: avoid reference of parent device info multiple places Laxman Dewangan
2016-02-06 14:37   ` [rtc-linux] " Laxman Dewangan
2016-02-06 14:37 ` [PATCH V4 5/6] mfd: max77686: do not set i2c client data for rtc i2c client Laxman Dewangan
2016-02-06 14:37   ` [rtc-linux] " Laxman Dewangan
2016-02-06 14:37 ` [PATCH V4 6/6] rtc: max77686: move initialisation of rtc regmap, irq chip locally Laxman Dewangan
2016-02-06 14:37   ` [rtc-linux] " Laxman Dewangan
2016-02-08 10:20   ` Laxman Dewangan
2016-02-08 10:20     ` [rtc-linux] " Laxman Dewangan
2016-02-08 10:42     ` Alexandre Belloni
2016-02-08 10:42       ` [rtc-linux] " Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.