[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1397475984-28001-5-git-send-email-r.baldyga@samsung.com>
Date: Mon, 14 Apr 2014 13:46:15 +0200
From: Robert Baldyga <r.baldyga@...sung.com>
To: unlisted-recipients:; (no To-header on input)
Cc: robh+dt@...nel.org, pawel.moll@....com, mark.rutland@....com,
ijc+devicetree@...lion.org.uk, galak@...eaurora.org,
rob@...dley.net, myungjoo.ham@...sung.com, cw00.choi@...sung.com,
dbaryshkov@...il.com, dwmw2@...radead.org, balbi@...com,
gregkh@...uxfoundation.org, grant.likely@...aro.org,
ldewangan@...dia.com, kishon@...com, gg@...mlogic.co.uk,
anton@...msg.org, jonghwa3.lee@...sung.com, rongjun.ying@....com,
linux@...ck-us.net, devicetree@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
patches@...nsource.wolfsonmicro.com, linux-usb@...r.kernel.org,
linux-omap@...r.kernel.org, aaro.koskinen@....fi,
m.szyprowski@...sung.com, t.figa@...sung.com,
Robert Baldyga <r.baldyga@...sung.com>
Subject: [PATCH v2 04/13] extcon: extcon-class: match extcon device by
devicetree node
This patch modifies extcon_get_edev_by_phandle() function, to match
extcon device by devicetree node. This modification needed to add
field 'node' in extcon_dev structure, and fill it in probe function
of each extcon provider driver.
This patch adds function of_extcon_get_extcon_dev(),
returning extcon device which contains given devicetree node.
Signed-off-by: Robert Baldyga <r.baldyga@...sung.com>
---
drivers/extcon/extcon-adc-jack.c | 1 +
drivers/extcon/extcon-arizona.c | 1 +
drivers/extcon/extcon-class.c | 21 ++++++++++++++++++++-
drivers/extcon/extcon-gpio.c | 1 +
drivers/extcon/extcon-max14577.c | 2 ++
drivers/extcon/extcon-max77693.c | 1 +
drivers/extcon/extcon-max8997.c | 1 +
drivers/extcon/extcon-palmas.c | 1 +
include/linux/extcon.h | 2 ++
9 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index e23f1c2..d65915e 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -111,6 +111,7 @@ static int adc_jack_probe(struct platform_device *pdev)
}
data->edev.dev.parent = &pdev->dev;
+ data->edev.node = pdev->dev.of_node;
data->edev.supported_cable = pdata->cable_names;
/* Check the length of array and set num_cables */
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 98a14f6..fc69cca 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1153,6 +1153,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
info->edev.name = "Headset Jack";
info->edev.dev.parent = arizona->dev;
+ info->edev.node = pdev->dev.of_node;
info->edev.supported_cable = arizona_cable;
ret = extcon_dev_register(&info->edev);
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 1b98c4e..b0d9c90 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -377,6 +377,25 @@ out:
}
EXPORT_SYMBOL_GPL(extcon_get_extcon_dev);
+/**
+ * of_extcon_get_extcon_dev() - Get the extcon device instance from the name
+ * @np: The node of extcon device
+ */
+struct extcon_dev *of_extcon_get_extcon_dev(const struct device_node *np)
+{
+ struct extcon_dev *edev;
+
+ mutex_lock(&extcon_dev_list_lock);
+ list_for_each_entry(edev, &extcon_dev_list, entry) {
+ if (edev->node == np)
+ goto out;
+ }
+ edev = NULL;
+out:
+ mutex_unlock(&extcon_dev_list_lock);
+ return edev;
+}
+
static int _call_per_cable(struct notifier_block *nb, unsigned long val,
void *ptr)
{
@@ -827,7 +846,7 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
return ERR_PTR(-ENODEV);
}
- edev = extcon_get_extcon_dev(node->name);
+ edev = of_extcon_get_extcon_dev(node);
if (!edev) {
dev_err(dev, "unable to get extcon device : %s\n", node->name);
return ERR_PTR(-ENODEV);
diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 13d5222..fc90b7a 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -100,6 +100,7 @@ static int gpio_extcon_probe(struct platform_device *pdev)
extcon_data->edev.name = pdata->name;
extcon_data->edev.dev.parent = &pdev->dev;
+ extcon_data->edev.node = pdev->dev.of_node;
extcon_data->gpio = pdata->gpio;
extcon_data->gpio_active_low = pdata->gpio_active_low;
extcon_data->state_on = pdata->state_on;
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 7a947d3..b017a0d 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -676,6 +676,8 @@ static int max14577_muic_probe(struct platform_device *pdev)
return -ENOMEM;
}
info->edev->name = DEV_NAME;
+ info->edev->dev.parent = &pdev->dev;
+ info->edev->node = pdev->dev.of_node;
info->edev->supported_cable = max14577_extcon_cable;
ret = extcon_dev_register(info->edev);
if (ret) {
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 7a014cd..2cd8892 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1200,6 +1200,7 @@ static int max77693_muic_probe(struct platform_device *pdev)
}
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
+ info->edev->node = pdev->dev.of_node;
info->edev->supported_cable = max77693_extcon_cable;
ret = extcon_dev_register(info->edev);
if (ret) {
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index a3df70d..c071588 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -718,6 +718,7 @@ static int max8997_muic_probe(struct platform_device *pdev)
}
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
+ info->edev->node = pdev->dev.of_node;
info->edev->supported_cable = max8997_extcon_cable;
ret = extcon_dev_register(info->edev);
if (ret) {
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 26c0619..153a40e 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -199,6 +199,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->edev.supported_cable = palmas_extcon_cable;
palmas_usb->edev.dev.parent = palmas_usb->dev;
+ palmas_usb->edev.node = pdev->dev.of_node;
palmas_usb->edev.mutually_exclusive = mutually_exclusive;
status = extcon_dev_register(&palmas_usb->edev);
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index ed4a47b..573dd1f 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -77,6 +77,7 @@ struct extcon_cable;
/**
* struct extcon_dev - An extcon device represents one external connector.
* @name: The name of this extcon device. Parent device name is
+ * @node: Devicetree node of parent device.
* used if NULL.
* @supported_cable: Array of supported cable names ending with NULL.
* If supported_cable is NULL, cable name related APIs
@@ -113,6 +114,7 @@ struct extcon_cable;
struct extcon_dev {
/* Optional user initializing data */
const char *name;
+ const struct device_node *node;
const char **supported_cable;
const u32 *mutually_exclusive;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists