[PATCH 2/4] leds: cpcap: make leds-cpcap an independent platform device to allow varying led setups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Previously led-cpcap devices where defined statically in mfd_cell
of the parent mdf device. This causes issues for devices like
xt875 that have less and different leds than xt894. Splitting the
device like this is posssible, as in reality the cpcap led ip block
is totaly independent from the mdf device and cpcap core.

Signed-off-by: Carl Philipp Klemm <philipp@xxxxxxxx>
---
 drivers/leds/leds-cpcap.c    | 19 +++++++++++++++++--
 drivers/mfd/motorola-cpcap.c | 24 ------------------------
 2 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/drivers/leds/leds-cpcap.c b/drivers/leds/leds-cpcap.c
index 11a9b857d8ea..7a1dd050fdf0 100644
--- a/drivers/leds/leds-cpcap.c
+++ b/drivers/leds/leds-cpcap.c
@@ -11,6 +11,7 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
+#include <linux/spi/spi.h>
 
 #define CPCAP_LED_NO_CURRENT 0x0001
 
@@ -170,6 +171,18 @@ static int cpcap_led_probe(struct platform_device *pdev)
 {
 	struct cpcap_led *led;
 	int err;
+	struct device_node *mfd_node;
+	struct device *cpcap_dev;
+
+	mfd_node = of_parse_phandle(pdev->dev.of_node, "cpcap-phandle", 0);
+	if (!mfd_node) {
+		dev_err(&pdev->dev, "cpcap-phandle is missing in device tree\n");
+		return -ENODEV;
+	}
+
+	cpcap_dev = bus_find_device_by_of_node(&spi_bus_type, mfd_node);
+	if (IS_ERR_OR_NULL(cpcap_dev))
+		return -EAGAIN;
 
 	led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
 	if (!led)
@@ -188,9 +201,11 @@ static int cpcap_led_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	led->regmap = dev_get_regmap(pdev->dev.parent, NULL);
-	if (!led->regmap)
+	led->regmap = dev_get_regmap(cpcap_dev, NULL);
+	if (!led->regmap) {
+		dev_err(led->dev, "Couldn't get regmap from cpcap mdf device");
 		return -ENODEV;
+	}
 
 	led->vdd = devm_regulator_get(&pdev->dev, "vdd");
 	if (IS_ERR(led->vdd)) {
diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
index 57b3378a8829..e1ae14e0e651 100644
--- a/drivers/mfd/motorola-cpcap.c
+++ b/drivers/mfd/motorola-cpcap.c
@@ -265,30 +265,6 @@ static const struct mfd_cell cpcap_mfd_devices[] = {
 	}, {
 		.name          = "cpcap-usb-phy",
 		.of_compatible = "motorola,mapphone-cpcap-usb-phy",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 0,
-		.of_compatible = "motorola,cpcap-led-red",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 1,
-		.of_compatible = "motorola,cpcap-led-green",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 2,
-		.of_compatible = "motorola,cpcap-led-blue",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 3,
-		.of_compatible = "motorola,cpcap-led-adl",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 4,
-		.of_compatible = "motorola,cpcap-led-cp",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 5,
-		.of_compatible = "motorola,cpcap-led-kl",
 	}, {
 		.name          = "cpcap-codec",
 	}
-- 
2.38.1





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux