linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification
@ 2025-11-20 14:38 André Draszik
  2025-11-20 14:38 ` [PATCH v2 1/3] mfd: sec: add rtc alarm IRQ as platform device resource André Draszik
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: André Draszik @ 2025-11-20 14:38 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Alexandre Belloni
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, Juan Yescas,
	Douglas Anderson, kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc, André Draszik

Hi,

With the attached patches the Samsung s5m RTC driver is simplified a
little bit with regards to alarm IRQ acquisition.

The end result is that instead of having a list of IRQ numbers for each
variant (and a BUILD_BUG_ON() to ensure consistency), the RTC driver
queries the 'alarm' platform resource from the parent (mfd cell).

Additionally, we can drop a now-useless field from runtime data,
reducing memory consumption slightly.

The attached patches must be applied in-order as patch 2 without 1 will
fail at runtime, and patch 3 without 2 will fail at build time. I would
expect them all to go via the MFD tree. Alternatively, they could be
applied individually to the respective kernel trees during multiple
kernel release cycles, but that seems a needless complication and
delay.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
Changes in v2:
- rebase on top of https://lore.kernel.org/r/20251114-s2mpg10-chained-irq-v1-1-34ddfa49c4cd@linaro.org
- return struct regmap_irq_chip_data * in sec_irq_init() (Lee)
- collect tags
- Link to v1: https://lore.kernel.org/r/20251114-s5m-alarm-v1-0-c9b3bebae65f@linaro.org

---
André Draszik (3):
      mfd: sec: add rtc alarm IRQ as platform device resource
      rtc: s5m: query platform device IRQ resource for alarm IRQ
      mfd: sec: drop now unused struct sec_pmic_dev::irq_data

 drivers/mfd/sec-common.c         | 45 ++++++++++++++++++++--------
 drivers/mfd/sec-core.h           |  2 +-
 drivers/mfd/sec-irq.c            | 63 ++++++++++++++++++----------------------
 drivers/rtc/rtc-s5m.c            | 21 +++++---------
 include/linux/mfd/samsung/core.h |  1 -
 5 files changed, 71 insertions(+), 61 deletions(-)
---
base-commit: 9ad5de6d54f306b2bbf7ceb27e67a60c58a71224
change-id: 20251114-s5m-alarm-3de705ea53ce

Best regards,
-- 
André Draszik <andre.draszik@linaro.org>


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

* [PATCH v2 1/3] mfd: sec: add rtc alarm IRQ as platform device resource
  2025-11-20 14:38 [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
@ 2025-11-20 14:38 ` André Draszik
  2025-11-20 14:38 ` [PATCH v2 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ André Draszik
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: André Draszik @ 2025-11-20 14:38 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Alexandre Belloni
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, Juan Yescas,
	Douglas Anderson, kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc, André Draszik

By adding the RTC alarm IRQ to the MFD cell as a resource, the child
driver (rtc) can simply query that IRQ, instead of having a lookup
table itself.

This change therefore allows the child driver to be simplified with
regards to determining the alarm IRQ.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/mfd/sec-common.c | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
index 42d55e70e34c8d7cd68cddaecc88017e259365b4..77370db52a7ba81234136b29f85892f4b197f429 100644
--- a/drivers/mfd/sec-common.c
+++ b/drivers/mfd/sec-common.c
@@ -23,9 +23,13 @@
 #include <linux/regmap.h>
 #include "sec-core.h"
 
+static const struct resource s5m8767_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S5M8767_IRQ_RTCA1, "alarm"),
+};
+
 static const struct mfd_cell s5m8767_devs[] = {
 	MFD_CELL_NAME("s5m8767-pmic"),
-	MFD_CELL_NAME("s5m-rtc"),
+	MFD_CELL_RES("s5m-rtc", s5m8767_rtc_resources),
 	MFD_CELL_OF("s5m8767-clk", NULL, NULL, 0, 0, "samsung,s5m8767-clk"),
 };
 
@@ -33,50 +37,66 @@ static const struct mfd_cell s2dos05_devs[] = {
 	MFD_CELL_NAME("s2dos05-regulator"),
 };
 
+static const struct resource s2mpg10_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S2MPG10_IRQ_RTCA0, "alarm"),
+};
+
 static const struct mfd_cell s2mpg10_devs[] = {
 	MFD_CELL_NAME("s2mpg10-meter"),
 	MFD_CELL_NAME("s2mpg10-regulator"),
-	MFD_CELL_NAME("s2mpg10-rtc"),
+	MFD_CELL_RES("s2mpg10-rtc", s2mpg10_rtc_resources),
 	MFD_CELL_OF("s2mpg10-clk", NULL, NULL, 0, 0, "samsung,s2mpg10-clk"),
 	MFD_CELL_OF("s2mpg10-gpio", NULL, NULL, 0, 0, "samsung,s2mpg10-gpio"),
 };
 
+static const struct resource s2mps11_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S2MPS11_IRQ_RTCA0, "alarm"),
+};
+
 static const struct mfd_cell s2mps11_devs[] = {
 	MFD_CELL_NAME("s2mps11-regulator"),
-	MFD_CELL_NAME("s2mps14-rtc"),
+	MFD_CELL_RES("s2mps14-rtc", s2mps11_rtc_resources),
 	MFD_CELL_OF("s2mps11-clk", NULL, NULL, 0, 0, "samsung,s2mps11-clk"),
 };
 
+static const struct resource s2mps14_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S2MPS14_IRQ_RTCA0, "alarm"),
+};
+
 static const struct mfd_cell s2mps13_devs[] = {
 	MFD_CELL_NAME("s2mps13-regulator"),
-	MFD_CELL_NAME("s2mps13-rtc"),
+	MFD_CELL_RES("s2mps13-rtc", s2mps14_rtc_resources),
 	MFD_CELL_OF("s2mps13-clk", NULL, NULL, 0, 0, "samsung,s2mps13-clk"),
 };
 
 static const struct mfd_cell s2mps14_devs[] = {
 	MFD_CELL_NAME("s2mps14-regulator"),
-	MFD_CELL_NAME("s2mps14-rtc"),
+	MFD_CELL_RES("s2mps14-rtc", s2mps14_rtc_resources),
 	MFD_CELL_OF("s2mps14-clk", NULL, NULL, 0, 0, "samsung,s2mps14-clk"),
 };
 
 static const struct mfd_cell s2mps15_devs[] = {
 	MFD_CELL_NAME("s2mps15-regulator"),
-	MFD_CELL_NAME("s2mps15-rtc"),
+	MFD_CELL_RES("s2mps15-rtc", s2mps14_rtc_resources),
 	MFD_CELL_OF("s2mps13-clk", NULL, NULL, 0, 0, "samsung,s2mps13-clk"),
 };
 
 static const struct mfd_cell s2mpa01_devs[] = {
 	MFD_CELL_NAME("s2mpa01-pmic"),
-	MFD_CELL_NAME("s2mps14-rtc"),
+	MFD_CELL_RES("s2mps14-rtc", s2mps14_rtc_resources),
 };
 
 static const struct mfd_cell s2mpu02_devs[] = {
 	MFD_CELL_NAME("s2mpu02-regulator"),
 };
 
+static const struct resource s2mpu05_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S2MPU05_IRQ_RTCA0, "alarm"),
+};
+
 static const struct mfd_cell s2mpu05_devs[] = {
 	MFD_CELL_NAME("s2mpu05-regulator"),
-	MFD_CELL_NAME("s2mps15-rtc"),
+	MFD_CELL_RES("s2mps15-rtc", s2mpu05_rtc_resources),
 };
 
 static void sec_pmic_dump_rev(struct sec_pmic_dev *sec_pmic)
@@ -220,7 +240,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 				     sec_pmic->device_type);
 	}
 	ret = devm_mfd_add_devices(sec_pmic->dev, -1, sec_devs, num_sec_devs,
-				   NULL, 0, NULL);
+				   NULL, 0, regmap_irq_get_domain(sec_pmic->irq_data));
 	if (ret)
 		return ret;
 

-- 
2.52.0.rc1.455.g30608eb744-goog


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

* [PATCH v2 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ
  2025-11-20 14:38 [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
  2025-11-20 14:38 ` [PATCH v2 1/3] mfd: sec: add rtc alarm IRQ as platform device resource André Draszik
@ 2025-11-20 14:38 ` André Draszik
  2025-11-20 14:38 ` [PATCH v2 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data André Draszik
  2025-11-26 11:29 ` [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
  3 siblings, 0 replies; 8+ messages in thread
From: André Draszik @ 2025-11-20 14:38 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Alexandre Belloni
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, Juan Yescas,
	Douglas Anderson, kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc, André Draszik

The core driver now exposes the alarm IRQ as a resource, so we can drop
the lookup from here to simplify the code and make adding support for
additional variants easier in this driver.

Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/rtc/rtc-s5m.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
index a7220b4d0e8dd35786b060e2a4106e2a39fe743f..c6ed5a4ca8a0e4554b1c88c879b01fc384735007 100644
--- a/drivers/rtc/rtc-s5m.c
+++ b/drivers/rtc/rtc-s5m.c
@@ -15,7 +15,6 @@
 #include <linux/rtc.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/samsung/core.h>
-#include <linux/mfd/samsung/irq.h>
 #include <linux/mfd/samsung/rtc.h>
 #include <linux/mfd/samsung/s2mps14.h>
 
@@ -683,22 +682,18 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 		case S2MPS15X:
 			regmap_cfg = &s2mps14_rtc_regmap_config;
 			info->regs = &s2mps15_rtc_regs;
-			alarm_irq = S2MPS14_IRQ_RTCA0;
 			break;
 		case S2MPS14X:
 			regmap_cfg = &s2mps14_rtc_regmap_config;
 			info->regs = &s2mps14_rtc_regs;
-			alarm_irq = S2MPS14_IRQ_RTCA0;
 			break;
 		case S2MPS13X:
 			regmap_cfg = &s2mps14_rtc_regmap_config;
 			info->regs = &s2mps13_rtc_regs;
-			alarm_irq = S2MPS14_IRQ_RTCA0;
 			break;
 		case S5M8767X:
 			regmap_cfg = &s5m_rtc_regmap_config;
 			info->regs = &s5m_rtc_regs;
-			alarm_irq = S5M8767_IRQ_RTCA1;
 			break;
 		default:
 			return dev_err_probe(&pdev->dev, -ENODEV,
@@ -719,7 +714,6 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 					     "Failed to allocate regmap\n");
 	} else if (device_type == S2MPG10) {
 		info->regs = &s2mpg10_rtc_regs;
-		alarm_irq = S2MPG10_IRQ_RTCA0;
 	} else {
 		return dev_err_probe(&pdev->dev, -ENODEV,
 				     "Unsupported device type %d\n",
@@ -730,13 +724,14 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 	info->s5m87xx = s5m87xx;
 	info->device_type = device_type;
 
-	if (s5m87xx->irq_data) {
-		info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
-		if (info->irq <= 0)
-			return dev_err_probe(&pdev->dev, -EINVAL,
-					     "Failed to get virtual IRQ %d\n",
-					     alarm_irq);
-	}
+	alarm_irq = platform_get_irq_byname_optional(pdev, "alarm");
+	if (alarm_irq > 0)
+		info->irq = alarm_irq;
+	else if (alarm_irq == -ENXIO)
+		info->irq = 0;
+	else
+		return dev_err_probe(&pdev->dev, alarm_irq ? : -EINVAL,
+				     "IRQ 'alarm' not found\n");
 
 	platform_set_drvdata(pdev, info);
 

-- 
2.52.0.rc1.455.g30608eb744-goog


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

* [PATCH v2 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data
  2025-11-20 14:38 [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
  2025-11-20 14:38 ` [PATCH v2 1/3] mfd: sec: add rtc alarm IRQ as platform device resource André Draszik
  2025-11-20 14:38 ` [PATCH v2 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ André Draszik
@ 2025-11-20 14:38 ` André Draszik
  2025-11-26 11:29 ` [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
  3 siblings, 0 replies; 8+ messages in thread
From: André Draszik @ 2025-11-20 14:38 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Alexandre Belloni
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, Juan Yescas,
	Douglas Anderson, kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc, André Draszik

This was used only to allow the s5m RTC driver to deal with the alarm
IRQ. That driver now uses a different approach to acquire that IRQ, and
::irq_data doesn't need to be kept around anymore.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/mfd/sec-common.c         |  9 +++---
 drivers/mfd/sec-core.h           |  2 +-
 drivers/mfd/sec-irq.c            | 63 ++++++++++++++++++----------------------
 include/linux/mfd/samsung/core.h |  1 -
 4 files changed, 35 insertions(+), 40 deletions(-)

diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
index 77370db52a7ba81234136b29f85892f4b197f429..0021f9ae8484fd0afc2e47c813a953c91fa38546 100644
--- a/drivers/mfd/sec-common.c
+++ b/drivers/mfd/sec-common.c
@@ -163,6 +163,7 @@ sec_pmic_parse_dt_pdata(struct device *dev)
 int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 		   struct regmap *regmap, struct i2c_client *client)
 {
+	struct regmap_irq_chip_data *irq_data;
 	struct sec_platform_data *pdata;
 	const struct mfd_cell *sec_devs;
 	struct sec_pmic_dev *sec_pmic;
@@ -187,9 +188,9 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 
 	sec_pmic->pdata = pdata;
 
-	ret = sec_irq_init(sec_pmic);
-	if (ret)
-		return ret;
+	irq_data = sec_irq_init(sec_pmic);
+	if (IS_ERR(irq_data))
+		return PTR_ERR(irq_data);
 
 	pm_runtime_set_active(sec_pmic->dev);
 
@@ -240,7 +241,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 				     sec_pmic->device_type);
 	}
 	ret = devm_mfd_add_devices(sec_pmic->dev, -1, sec_devs, num_sec_devs,
-				   NULL, 0, regmap_irq_get_domain(sec_pmic->irq_data));
+				   NULL, 0, regmap_irq_get_domain(irq_data));
 	if (ret)
 		return ret;
 
diff --git a/drivers/mfd/sec-core.h b/drivers/mfd/sec-core.h
index 92c7558ab8b0de44a52e028eeb7998e38358cb4c..8d85c70c232612d1f7e5fb61b2acd25bf03a62e0 100644
--- a/drivers/mfd/sec-core.h
+++ b/drivers/mfd/sec-core.h
@@ -18,6 +18,6 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 		   struct regmap *regmap, struct i2c_client *client);
 void sec_pmic_shutdown(struct device *dev);
 
-int sec_irq_init(struct sec_pmic_dev *sec_pmic);
+struct regmap_irq_chip_data *sec_irq_init(struct sec_pmic_dev *sec_pmic);
 
 #endif /* __SEC_CORE_INT_H */
diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
index d992e41e716dcdc060421e1db8475523842a12be..96f53c3617da4cb54f650f9b98c0b934b823ceda 100644
--- a/drivers/mfd/sec-irq.c
+++ b/drivers/mfd/sec-irq.c
@@ -268,26 +268,28 @@ static const struct regmap_irq_chip s5m8767_irq_chip = {
 	.ack_base = S5M8767_REG_INT1,
 };
 
-static int s2mpg1x_add_chained_irq_chip(struct device *dev, struct regmap *regmap, int pirq,
-					struct regmap_irq_chip_data *parent,
-					const struct regmap_irq_chip *chip,
-					struct regmap_irq_chip_data **data)
+static struct regmap_irq_chip_data *
+s2mpg1x_add_chained_irq_chip(struct device *dev, struct regmap *regmap, int pirq,
+			     struct regmap_irq_chip_data *parent,
+			     const struct regmap_irq_chip *chip)
 {
+	struct regmap_irq_chip_data *data;
 	int irq, ret;
 
 	irq = regmap_irq_get_virq(parent, pirq);
 	if (irq < 0)
-		return dev_err_probe(dev, irq, "Failed to get parent vIRQ(%d) for chip %s\n", pirq,
-				     chip->name);
+		return dev_err_ptr_probe(dev, irq, "Failed to get parent vIRQ(%d) for chip %s\n",
+					 pirq, chip->name);
 
-	ret = devm_regmap_add_irq_chip(dev, regmap, irq, IRQF_ONESHOT | IRQF_SHARED, 0, chip, data);
+	ret = devm_regmap_add_irq_chip(dev, regmap, irq, IRQF_ONESHOT | IRQF_SHARED, 0, chip,
+				       &data);
 	if (ret)
-		return dev_err_probe(dev, ret, "Failed to add %s IRQ chip\n", chip->name);
+		return dev_err_ptr_probe(dev, ret, "Failed to add %s IRQ chip\n", chip->name);
 
-	return 0;
+	return data;
 }
 
-static int sec_irq_init_s2mpg1x(struct sec_pmic_dev *sec_pmic)
+static struct regmap_irq_chip_data *sec_irq_init_s2mpg1x(struct sec_pmic_dev *sec_pmic)
 {
 	const struct regmap_irq_chip *irq_chip, *chained_irq_chip;
 	struct regmap_irq_chip_data *irq_data;
@@ -302,27 +304,28 @@ static int sec_irq_init_s2mpg1x(struct sec_pmic_dev *sec_pmic)
 		chained_pirq = S2MPG10_COMMON_IRQ_PMIC;
 		break;
 	default:
-		return dev_err_probe(sec_pmic->dev, -EINVAL, "Unsupported device type %d\n",
-				     sec_pmic->device_type);
+		return dev_err_ptr_probe(sec_pmic->dev, -EINVAL, "Unsupported device type %d\n",
+					 sec_pmic->device_type);
 	};
 
 	regmap_common = dev_get_regmap(sec_pmic->dev, "common");
 	if (!regmap_common)
-		return dev_err_probe(sec_pmic->dev, -EINVAL, "No 'common' regmap %d\n",
-				     sec_pmic->device_type);
+		return dev_err_ptr_probe(sec_pmic->dev, -EINVAL, "No 'common' regmap %d\n",
+					 sec_pmic->device_type);
 
 	ret = devm_regmap_add_irq_chip(sec_pmic->dev, regmap_common, sec_pmic->irq, IRQF_ONESHOT, 0,
 				       irq_chip, &irq_data);
 	if (ret)
-		return dev_err_probe(sec_pmic->dev, ret, "Failed to add %s IRQ chip\n",
-				     irq_chip->name);
+		return dev_err_ptr_probe(sec_pmic->dev, ret, "Failed to add %s IRQ chip\n",
+					 irq_chip->name);
 
 	return s2mpg1x_add_chained_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic, chained_pirq,
-					    irq_data, chained_irq_chip, &sec_pmic->irq_data);
+					    irq_data, chained_irq_chip);
 }
 
-int sec_irq_init(struct sec_pmic_dev *sec_pmic)
+struct regmap_irq_chip_data *sec_irq_init(struct sec_pmic_dev *sec_pmic)
 {
+	struct regmap_irq_chip_data *sec_irq_chip_data;
 	const struct regmap_irq_chip *sec_irq_chip;
 	int ret;
 
@@ -331,7 +334,7 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic)
 		sec_irq_chip = &s5m8767_irq_chip;
 		break;
 	case S2DOS05:
-		return 0;
+		return NULL;
 	case S2MPA01:
 		sec_irq_chip = &s2mps14_irq_chip;
 		break;
@@ -356,30 +359,22 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic)
 		sec_irq_chip = &s2mpu05_irq_chip;
 		break;
 	default:
-		return dev_err_probe(sec_pmic->dev, -EINVAL,
-				     "Unsupported device type %d\n",
-				     sec_pmic->device_type);
+		return dev_err_ptr_probe(sec_pmic->dev, -EINVAL, "Unsupported device type %d\n",
+					 sec_pmic->device_type);
 	}
 
 	if (!sec_pmic->irq) {
 		dev_warn(sec_pmic->dev,
 			 "No interrupt specified, no interrupts\n");
-		return 0;
+		return NULL;
 	}
 
 	ret = devm_regmap_add_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic,
 				       sec_pmic->irq, IRQF_ONESHOT,
-				       0, sec_irq_chip, &sec_pmic->irq_data);
+				       0, sec_irq_chip, &sec_irq_chip_data);
 	if (ret)
-		return dev_err_probe(sec_pmic->dev, ret,
-				     "Failed to add %s IRQ chip\n",
-				     sec_irq_chip->name);
+		return dev_err_ptr_probe(sec_pmic->dev, ret, "Failed to add %s IRQ chip\n",
+					 sec_irq_chip->name);
 
-	/*
-	 * The rtc-s5m driver requests S2MPS14_IRQ_RTCA0 also for S2MPS11
-	 * so the interrupt number must be consistent.
-	 */
-	BUILD_BUG_ON(((enum s2mps14_irq)S2MPS11_IRQ_RTCA0) != S2MPS14_IRQ_RTCA0);
-
-	return 0;
+	return sec_irq_chip_data;
 }
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index d785e101fe795a5d8f9cccf4ccc4232437e89416..c7c3c8cd8d5f99ef0cc3188e1c3b49031f4750f2 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -69,7 +69,6 @@ struct sec_pmic_dev {
 
 	int device_type;
 	int irq;
-	struct regmap_irq_chip_data *irq_data;
 };
 
 struct sec_platform_data {

-- 
2.52.0.rc1.455.g30608eb744-goog


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

* Re: [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification
  2025-11-20 14:38 [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
                   ` (2 preceding siblings ...)
  2025-11-20 14:38 ` [PATCH v2 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data André Draszik
@ 2025-11-26 11:29 ` Lee Jones
  2025-11-26 12:30   ` André Draszik
  2025-11-26 14:04   ` Lee Jones
  3 siblings, 2 replies; 8+ messages in thread
From: Lee Jones @ 2025-11-26 11:29 UTC (permalink / raw)
  To: André Draszik
  Cc: Krzysztof Kozlowski, Alexandre Belloni, Peter Griffin,
	Tudor Ambarus, Will McVicker, Juan Yescas, Douglas Anderson,
	kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc

On Thu, 20 Nov 2025, André Draszik wrote:

> Hi,
> 
> With the attached patches the Samsung s5m RTC driver is simplified a
> little bit with regards to alarm IRQ acquisition.
> 
> The end result is that instead of having a list of IRQ numbers for each
> variant (and a BUILD_BUG_ON() to ensure consistency), the RTC driver
> queries the 'alarm' platform resource from the parent (mfd cell).
> 
> Additionally, we can drop a now-useless field from runtime data,
> reducing memory consumption slightly.
> 
> The attached patches must be applied in-order as patch 2 without 1 will
> fail at runtime, and patch 3 without 2 will fail at build time. I would
> expect them all to go via the MFD tree. Alternatively, they could be
> applied individually to the respective kernel trees during multiple
> kernel release cycles, but that seems a needless complication and
> delay.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
> Changes in v2:
> - rebase on top of https://lore.kernel.org/r/20251114-s2mpg10-chained-irq-v1-1-34ddfa49c4cd@linaro.org
> - return struct regmap_irq_chip_data * in sec_irq_init() (Lee)
> - collect tags
> - Link to v1: https://lore.kernel.org/r/20251114-s5m-alarm-v1-0-c9b3bebae65f@linaro.org
> 
> ---
> André Draszik (3):
>       mfd: sec: add rtc alarm IRQ as platform device resource
>       rtc: s5m: query platform device IRQ resource for alarm IRQ
>       mfd: sec: drop now unused struct sec_pmic_dev::irq_data
> 
>  drivers/mfd/sec-common.c         | 45 ++++++++++++++++++++--------
>  drivers/mfd/sec-core.h           |  2 +-
>  drivers/mfd/sec-irq.c            | 63 ++++++++++++++++++----------------------
>  drivers/rtc/rtc-s5m.c            | 21 +++++---------
>  include/linux/mfd/samsung/core.h |  1 -
>  5 files changed, 71 insertions(+), 61 deletions(-)

The MFD parts look okay to me.

Once we have the RTC Ack, I'll merge this and send out a PR.

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification
  2025-11-26 11:29 ` [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
@ 2025-11-26 12:30   ` André Draszik
  2025-11-26 14:04   ` Lee Jones
  1 sibling, 0 replies; 8+ messages in thread
From: André Draszik @ 2025-11-26 12:30 UTC (permalink / raw)
  To: Lee Jones
  Cc: Krzysztof Kozlowski, Alexandre Belloni, Peter Griffin,
	Tudor Ambarus, Will McVicker, Juan Yescas, Douglas Anderson,
	kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc

Hi Lee,

On Wed, 2025-11-26 at 11:29 +0000, Lee Jones wrote:
> On Thu, 20 Nov 2025, André Draszik wrote:
> 
> > Hi,
> > 
> > With the attached patches the Samsung s5m RTC driver is simplified a
> > little bit with regards to alarm IRQ acquisition.
> > 
> > The end result is that instead of having a list of IRQ numbers for each
> > variant (and a BUILD_BUG_ON() to ensure consistency), the RTC driver
> > queries the 'alarm' platform resource from the parent (mfd cell).
> > 
> > Additionally, we can drop a now-useless field from runtime data,
> > reducing memory consumption slightly.
> > 
> > The attached patches must be applied in-order as patch 2 without 1 will
> > fail at runtime, and patch 3 without 2 will fail at build time. I would
> > expect them all to go via the MFD tree. Alternatively, they could be
> > applied individually to the respective kernel trees during multiple
> > kernel release cycles, but that seems a needless complication and
> > delay.
> > 
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> > Changes in v2:
> > - rebase on top of https://lore.kernel.org/r/20251114-s2mpg10-chained-irq-v1-1-34ddfa49c4cd@linaro.org
> > - return struct regmap_irq_chip_data * in sec_irq_init() (Lee)
> > - collect tags
> > - Link to v1: https://lore.kernel.org/r/20251114-s5m-alarm-v1-0-c9b3bebae65f@linaro.org
> > 
> > ---
> > André Draszik (3):
> >       mfd: sec: add rtc alarm IRQ as platform device resource
> >       rtc: s5m: query platform device IRQ resource for alarm IRQ
> >       mfd: sec: drop now unused struct sec_pmic_dev::irq_data
> > 
> >  drivers/mfd/sec-common.c         | 45 ++++++++++++++++++++--------
> >  drivers/mfd/sec-core.h           |  2 +-
> >  drivers/mfd/sec-irq.c            | 63 ++++++++++++++++++----------------------
> >  drivers/rtc/rtc-s5m.c            | 21 +++++---------
> >  include/linux/mfd/samsung/core.h |  1 -
> >  5 files changed, 71 insertions(+), 61 deletions(-)
> 
> The MFD parts look okay to me.
> 
> Once we have the RTC Ack, I'll merge this and send out a PR.

Thanks Lee. Alexandre kindly acked v1 in
https://lore.kernel.org/all/2025111415582194c6ee16@mail.local/
and there was no change to the RTC part in v2 hence I collected it
already.

So should be good to go?

Cheers,
Andre'


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

* Re: [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification
  2025-11-26 11:29 ` [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
  2025-11-26 12:30   ` André Draszik
@ 2025-11-26 14:04   ` Lee Jones
  2025-12-16 16:20     ` Lee Jones
  1 sibling, 1 reply; 8+ messages in thread
From: Lee Jones @ 2025-11-26 14:04 UTC (permalink / raw)
  To: André Draszik
  Cc: Krzysztof Kozlowski, Alexandre Belloni, Peter Griffin,
	Tudor Ambarus, Will McVicker, Juan Yescas, Douglas Anderson,
	kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc

On Wed, 26 Nov 2025, Lee Jones wrote:

> On Thu, 20 Nov 2025, André Draszik wrote:
> 
> > Hi,
> > 
> > With the attached patches the Samsung s5m RTC driver is simplified a
> > little bit with regards to alarm IRQ acquisition.
> > 
> > The end result is that instead of having a list of IRQ numbers for each
> > variant (and a BUILD_BUG_ON() to ensure consistency), the RTC driver
> > queries the 'alarm' platform resource from the parent (mfd cell).
> > 
> > Additionally, we can drop a now-useless field from runtime data,
> > reducing memory consumption slightly.
> > 
> > The attached patches must be applied in-order as patch 2 without 1 will
> > fail at runtime, and patch 3 without 2 will fail at build time. I would
> > expect them all to go via the MFD tree. Alternatively, they could be
> > applied individually to the respective kernel trees during multiple
> > kernel release cycles, but that seems a needless complication and
> > delay.
> > 
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> > Changes in v2:
> > - rebase on top of https://lore.kernel.org/r/20251114-s2mpg10-chained-irq-v1-1-34ddfa49c4cd@linaro.org
> > - return struct regmap_irq_chip_data * in sec_irq_init() (Lee)
> > - collect tags
> > - Link to v1: https://lore.kernel.org/r/20251114-s5m-alarm-v1-0-c9b3bebae65f@linaro.org
> > 
> > ---
> > André Draszik (3):
> >       mfd: sec: add rtc alarm IRQ as platform device resource
> >       rtc: s5m: query platform device IRQ resource for alarm IRQ
> >       mfd: sec: drop now unused struct sec_pmic_dev::irq_data
> > 
> >  drivers/mfd/sec-common.c         | 45 ++++++++++++++++++++--------
> >  drivers/mfd/sec-core.h           |  2 +-
> >  drivers/mfd/sec-irq.c            | 63 ++++++++++++++++++----------------------
> >  drivers/rtc/rtc-s5m.c            | 21 +++++---------
> >  include/linux/mfd/samsung/core.h |  1 -
> >  5 files changed, 71 insertions(+), 61 deletions(-)
> 
> The MFD parts look okay to me.
> 
> Once we have the RTC Ack, I'll merge this and send out a PR.

Ah, I see it.  Apologies.

It's too late in the cycle to take this now anyway.

It's on my radar for when -rc1 is released.

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification
  2025-11-26 14:04   ` Lee Jones
@ 2025-12-16 16:20     ` Lee Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2025-12-16 16:20 UTC (permalink / raw)
  To: André Draszik
  Cc: Krzysztof Kozlowski, Alexandre Belloni, Peter Griffin,
	Tudor Ambarus, Will McVicker, Juan Yescas, Douglas Anderson,
	kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc

On Wed, 26 Nov 2025, Lee Jones wrote:

> On Wed, 26 Nov 2025, Lee Jones wrote:
> 
> > On Thu, 20 Nov 2025, André Draszik wrote:
> > 
> > > Hi,
> > > 
> > > With the attached patches the Samsung s5m RTC driver is simplified a
> > > little bit with regards to alarm IRQ acquisition.
> > > 
> > > The end result is that instead of having a list of IRQ numbers for each
> > > variant (and a BUILD_BUG_ON() to ensure consistency), the RTC driver
> > > queries the 'alarm' platform resource from the parent (mfd cell).
> > > 
> > > Additionally, we can drop a now-useless field from runtime data,
> > > reducing memory consumption slightly.
> > > 
> > > The attached patches must be applied in-order as patch 2 without 1 will
> > > fail at runtime, and patch 3 without 2 will fail at build time. I would
> > > expect them all to go via the MFD tree. Alternatively, they could be
> > > applied individually to the respective kernel trees during multiple
> > > kernel release cycles, but that seems a needless complication and
> > > delay.
> > > 
> > > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > > ---
> > > Changes in v2:
> > > - rebase on top of https://lore.kernel.org/r/20251114-s2mpg10-chained-irq-v1-1-34ddfa49c4cd@linaro.org
> > > - return struct regmap_irq_chip_data * in sec_irq_init() (Lee)
> > > - collect tags
> > > - Link to v1: https://lore.kernel.org/r/20251114-s5m-alarm-v1-0-c9b3bebae65f@linaro.org
> > > 
> > > ---
> > > André Draszik (3):
> > >       mfd: sec: add rtc alarm IRQ as platform device resource
> > >       rtc: s5m: query platform device IRQ resource for alarm IRQ
> > >       mfd: sec: drop now unused struct sec_pmic_dev::irq_data
> > > 
> > >  drivers/mfd/sec-common.c         | 45 ++++++++++++++++++++--------
> > >  drivers/mfd/sec-core.h           |  2 +-
> > >  drivers/mfd/sec-irq.c            | 63 ++++++++++++++++++----------------------
> > >  drivers/rtc/rtc-s5m.c            | 21 +++++---------
> > >  include/linux/mfd/samsung/core.h |  1 -
> > >  5 files changed, 71 insertions(+), 61 deletions(-)
> > 
> > The MFD parts look okay to me.
> > 
> > Once we have the RTC Ack, I'll merge this and send out a PR.
> 
> Ah, I see it.  Apologies.
> 
> It's too late in the cycle to take this now anyway.
> 
> It's on my radar for when -rc1 is released.

This does not seem to apply well on v6.19-rc1.

Please rebase and send as a [RESEND].

-----

% cat drivers/mfd/sec-irq.c.rej
diff a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c	(rejected hunks)
@@ -302,27 +304,28 @@ static int sec_irq_init_s2mpg1x(struct sec_pmic_dev *sec_pmic)
 		chained_pirq = S2MPG10_COMMON_IRQ_PMIC;
 		break;
 	default:
-		return dev_err_probe(sec_pmic->dev, -EINVAL, "Unsupported device type %d\n",
-				    sec_pmic->device_type);
+		return dev_err_ptr_probe(sec_pmic->dev, -EINVAL, "Unsupported device type %d\n",
+					sec_pmic->device_type);
 	};
 
 	regmap_common = dev_get_regmap(sec_pmic->dev, "common");
 	if (!regmap_common)
-		return dev_err_probe(sec_pmic->dev, -EINVAL, "No 'common' regmap %d\n",
-				    sec_pmic->device_type);
+		return dev_err_ptr_probe(sec_pmic->dev, -EINVAL, "No 'common' regmap %d\n",
+					sec_pmic->device_type);
 
 	ret = devm_regmap_add_irq_chip(sec_pmic->dev, regmap_common, sec_pmic->irq, IRQF_ONESHOT, 0,
 				      irq_chip, &irq_data);
 	if (ret)
-		return dev_err_probe(sec_pmic->dev, ret, "Failed to add %s IRQ chip\n",
-				    irq_chip->name);
+		return dev_err_ptr_probe(sec_pmic->dev, ret, "Failed to add %s IRQ chip\n",
+					irq_chip->name);
 
 	return s2mpg1x_add_chained_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic, chained_pirq,
-					   irq_data, chained_irq_chip, &sec_pmic->irq_data);
+					   irq_data, chained_irq_chip);
 }
 
-int sec_irq_init(struct sec_pmic_dev *sec_pmic)
+struct regmap_irq_chip_data *sec_irq_init(struct sec_pmic_dev *sec_pmic)
 {
+	struct regmap_irq_chip_data *sec_irq_chip_data;
 	const struct regmap_irq_chip *sec_irq_chip;
 	int ret;

-- 
Lee Jones [李琼斯]

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

end of thread, other threads:[~2025-12-16 16:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 14:38 [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
2025-11-20 14:38 ` [PATCH v2 1/3] mfd: sec: add rtc alarm IRQ as platform device resource André Draszik
2025-11-20 14:38 ` [PATCH v2 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ André Draszik
2025-11-20 14:38 ` [PATCH v2 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data André Draszik
2025-11-26 11:29 ` [PATCH v2 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
2025-11-26 12:30   ` André Draszik
2025-11-26 14:04   ` Lee Jones
2025-12-16 16:20     ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).