From: quentin.schulz@free-electrons.com (Quentin Schulz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/10] power: supply: axp20x_usb_power: use of_device_id data field instead of device_is_compatible
Date: Fri, 25 Nov 2016 10:09:12 +0100 [thread overview]
Message-ID: <20161125090921.23138-2-quentin.schulz@free-electrons.com> (raw)
In-Reply-To: <20161125090921.23138-1-quentin.schulz@free-electrons.com>
This replaces calls to of_device_is_compatible to check data field of
of_device_id matched when probing the driver.
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
drivers/power/supply/axp20x_usb_power.c | 39 ++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c
index 6af6feb..b19754e 100644
--- a/drivers/power/supply/axp20x_usb_power.c
+++ b/drivers/power/supply/axp20x_usb_power.c
@@ -17,6 +17,7 @@
#include <linux/mfd/axp20x.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/regmap.h>
@@ -45,6 +46,7 @@ struct axp20x_usb_power {
struct device_node *np;
struct regmap *regmap;
struct power_supply *supply;
+ int axp20x_id;
};
static irqreturn_t axp20x_usb_power_irq(int irq, void *devid)
@@ -86,8 +88,7 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
switch (v & AXP20X_VBUS_CLIMIT_MASK) {
case AXP20X_VBUC_CLIMIT_100mA:
- if (of_device_is_compatible(power->np,
- "x-powers,axp202-usb-power-supply")) {
+ if (power->axp20x_id == AXP202_ID) {
val->intval = 100000;
} else {
val->intval = -1; /* No 100mA limit */
@@ -130,8 +131,7 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
val->intval = POWER_SUPPLY_HEALTH_GOOD;
- if (of_device_is_compatible(power->np,
- "x-powers,axp202-usb-power-supply")) {
+ if (power->axp20x_id == AXP202_ID) {
ret = regmap_read(power->regmap,
AXP20X_USB_OTG_STATUS, &v);
if (ret)
@@ -189,6 +189,17 @@ static const struct power_supply_desc axp22x_usb_power_desc = {
.get_property = axp20x_usb_power_get_property,
};
+static const struct of_device_id axp20x_usb_power_match[] = {
+ {
+ .compatible = "x-powers,axp202-usb-power-supply",
+ .data = (void *)AXP202_ID,
+ }, {
+ .compatible = "x-powers,axp221-usb-power-supply",
+ .data = (void *)AXP221_ID,
+ }, { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, axp20x_usb_power_match);
+
static int axp20x_usb_power_probe(struct platform_device *pdev)
{
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
@@ -200,11 +211,16 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
"VBUS_PLUGIN", "VBUS_REMOVAL", NULL };
static const char * const *irq_names;
const struct power_supply_desc *usb_power_desc;
+ const struct of_device_id *of_id;
int i, irq, ret;
if (!of_device_is_available(pdev->dev.of_node))
return -ENODEV;
+ of_id = of_match_device(axp20x_usb_power_match, &pdev->dev);
+ if (!of_id)
+ return -ENODEV;
+
if (!axp20x) {
dev_err(&pdev->dev, "Parent drvdata not set\n");
return -EINVAL;
@@ -214,11 +230,12 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
if (!power)
return -ENOMEM;
+ power->axp20x_id = (int)of_id->data;
+
power->np = pdev->dev.of_node;
power->regmap = axp20x->regmap;
- if (of_device_is_compatible(power->np,
- "x-powers,axp202-usb-power-supply")) {
+ if (power->axp20x_id == AXP202_ID) {
/* Enable vbus valid checking */
ret = regmap_update_bits(power->regmap, AXP20X_VBUS_MON,
AXP20X_VBUS_MON_VBUS_VALID,
@@ -235,8 +252,7 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
usb_power_desc = &axp20x_usb_power_desc;
irq_names = axp20x_irq_names;
- } else if (of_device_is_compatible(power->np,
- "x-powers,axp221-usb-power-supply")) {
+ } else if (power->axp20x_id == AXP221_ID) {
usb_power_desc = &axp22x_usb_power_desc;
irq_names = axp22x_irq_names;
} else {
@@ -272,13 +288,6 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
return 0;
}
-static const struct of_device_id axp20x_usb_power_match[] = {
- { .compatible = "x-powers,axp202-usb-power-supply" },
- { .compatible = "x-powers,axp221-usb-power-supply" },
- { }
-};
-MODULE_DEVICE_TABLE(of, axp20x_usb_power_match);
-
static struct platform_driver axp20x_usb_power_driver = {
.probe = axp20x_usb_power_probe,
.driver = {
--
2.9.3
next prev parent reply other threads:[~2016-11-25 9:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-25 9:09 [PATCH 00/10] add support for VBUS max current and min voltage limits AXP20X and AXP22X PMICs Quentin Schulz
2016-11-25 9:09 ` Quentin Schulz [this message]
2016-11-25 9:23 ` [PATCH 01/10] power: supply: axp20x_usb_power: use of_device_id data field instead of device_is_compatible Chen-Yu Tsai
2016-11-25 10:52 ` kbuild test robot
2016-11-25 9:09 ` [PATCH 02/10] power: supply: axp20x_usb_power: set min voltage and max current from sysfs Quentin Schulz
2016-11-25 9:42 ` Chen-Yu Tsai
2016-11-25 9:48 ` Thomas Petazzoni
2016-11-25 9:09 ` [PATCH 03/10] Documentation: DT: binding: axp20x_usb_power: add axp223 compatible Quentin Schulz
2016-11-25 9:25 ` Chen-Yu Tsai
2016-11-25 9:09 ` [PATCH 04/10] power: supply: axp20x_usb_power: add 100mA max current limit for AXP223 Quentin Schulz
2016-11-25 9:56 ` Chen-Yu Tsai
2016-11-25 9:09 ` [PATCH 05/10] mfd: axp20x: add separate MFD cell " Quentin Schulz
2016-11-25 10:03 ` Chen-Yu Tsai
2016-11-25 9:09 ` [PATCH 06/10] ARM: dtsi: add DTSI " Quentin Schulz
2016-11-25 10:04 ` Chen-Yu Tsai
2016-11-25 9:09 ` [PATCH 07/10] ARM: dts: sun8i-a33-olinuxino: use AXP223 DTSI Quentin Schulz
2016-11-25 10:05 ` Chen-Yu Tsai
2016-11-25 9:09 ` [PATCH 08/10] ARM: dts: sun8i-a33-sinlinx-sina33: " Quentin Schulz
2016-11-25 10:05 ` Chen-Yu Tsai
2016-11-25 9:09 ` [PATCH 09/10] ARM: dts: sun8i-r16-parrot: " Quentin Schulz
2016-11-25 10:05 ` Chen-Yu Tsai
2016-11-25 9:09 ` [PATCH 10/10] ARM: dtsi: sun8i-reference-design-tablet: " Quentin Schulz
2016-11-25 10:06 ` Chen-Yu Tsai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161125090921.23138-2-quentin.schulz@free-electrons.com \
--to=quentin.schulz@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox