lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1440753128-3288-5-git-send-email-milo.kim@ti.com>
Date:	Fri, 28 Aug 2015 18:12:08 +0900
From:	Milo Kim <milo.kim@...com>
To:	<grant.likely@...aro.org>, <devicetree@...r.kernel.org>
CC:	Milo Kim <milo.kim@...com>,
	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Felipe Balbi <balbi@...com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Lee Jones <lee.jones@...aro.org>,
	Rob Herring <robh+dt@...nel.org>,
	Samuel Ortiz <sameo@...ux.intel.com>,
	Tony Lindgren <tony@...mide.com>,
	<linux-kernel@...r.kernel.org>
Subject: [RFC 4/4] usb: musb: use of_dev_get_platdata()

'of_dev_get_platdata()' makes if-statements simple.

Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: Felipe Balbi <balbi@...com>
Cc: Grant Likely <grant.likely@...aro.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Lee Jones <lee.jones@...aro.org>
Cc: Rob Herring <robh+dt@...nel.org>
Cc: Samuel Ortiz <sameo@...ux.intel.com>
Cc: Tony Lindgren <tony@...mide.com>
Cc: devicetree@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Milo Kim <milo.kim@...com>
---
 drivers/usb/musb/ux500.c | 40 ++++++++++++++++------------------------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 39168fe..851cf4a 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -25,6 +25,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/usb/musb-ux500.h>
 
@@ -200,21 +201,16 @@ static const struct musb_platform_ops ux500_ops = {
 	.set_vbus	= ux500_musb_set_vbus,
 };
 
-static struct musb_hdrc_platform_data *
-ux500_of_probe(struct platform_device *pdev, struct device_node *np)
+static int ux500_of_probe(struct device *dev, void *data, void *priv)
 {
-	struct musb_hdrc_platform_data *pdata;
+	struct musb_hdrc_platform_data *pdata = data;
 	const char *mode;
 	int strlen;
 
-	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata)
-		return NULL;
-
-	mode = of_get_property(np, "dr_mode", &strlen);
+	mode = of_get_property(dev->of_node, "dr_mode", &strlen);
 	if (!mode) {
-		dev_err(&pdev->dev, "No 'dr_mode' property found\n");
-		return NULL;
+		dev_err(dev, "No 'dr_mode' property found\n");
+		return -EINVAL;
 	}
 
 	if (strlen > 0) {
@@ -226,31 +222,27 @@ ux500_of_probe(struct platform_device *pdev, struct device_node *np)
 			pdata->mode = MUSB_PERIPHERAL;
 	}
 
-	return pdata;
+	return 0;
 }
 
 static int ux500_probe(struct platform_device *pdev)
 {
 	struct resource musb_resources[2];
-	struct musb_hdrc_platform_data	*pdata = dev_get_platdata(&pdev->dev);
-	struct device_node		*np = pdev->dev.of_node;
+	struct musb_hdrc_platform_data	*pdata;
 	struct platform_device		*musb;
 	struct ux500_glue		*glue;
 	struct clk			*clk;
 	int				ret = -ENOMEM;
 
-	if (!pdata) {
-		if (np) {
-			pdata = ux500_of_probe(pdev, np);
-			if (!pdata)
-				goto err0;
+	pdata = of_dev_get_platdata(&pdev->dev, sizeof(*pdata),
+				    ux500_of_probe, NULL);
+	if (IS_ERR(pdata))
+		return PTR_ERR(pdata);
 
-			pdev->dev.platform_data = pdata;
-		} else {
-			dev_err(&pdev->dev, "no pdata or device tree found\n");
-			goto err0;
-		}
-	}
+	if (!pdata)
+		goto err0;
+
+	pdev->dev.platform_data = pdata;
 
 	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue)
-- 
1.9.1

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ