From patchwork Fri Nov 25 09:09:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 84072 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp27554obn; Fri, 25 Nov 2016 01:14:10 -0800 (PST) X-Received: by 10.84.218.136 with SMTP id r8mr15198675pli.23.1480065250339; Fri, 25 Nov 2016 01:14:10 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id z26si43769397pfk.57.2016.11.25.01.14.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 01:14:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cACZ0-0003Fy-5j; Fri, 25 Nov 2016 09:12:58 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cACW7-0007lM-Ik for linux-arm-kernel@lists.infradead.org; Fri, 25 Nov 2016 09:10:07 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 959AD20C7A; Fri, 25 Nov 2016 10:09:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from qschulz.home (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 4182F206A9; Fri, 25 Nov 2016 10:09:37 +0100 (CET) From: Quentin Schulz To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, linux@armlinux.org.uk, maxime.ripard@free-electrons.com, lee.jones@linaro.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 Message-Id: <20161125090921.23138-2-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161125090921.23138-1-quentin.schulz@free-electrons.com> References: <20161125090921.23138-1-quentin.schulz@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161125_011000_492703_894A9602 X-CRM114-Status: GOOD ( 16.33 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 FSL_HELO_HOME No description available. -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Quentin Schulz , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 --- drivers/power/supply/axp20x_usb_power.c | 39 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) -- 2.9.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 #include #include +#include #include #include #include @@ -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 = {