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: <20220226184147.769964-8-pgwipeout@gmail.com>
Date:   Sat, 26 Feb 2022 13:41:43 -0500
From:   Peter Geis <pgwipeout@...il.com>
To:     Felipe Balbi <balbi@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-rockchip@...ts.infradead.org, heiko@...ech.de,
        michael.riesch@...fvision.net, Peter Geis <pgwipeout@...il.com>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2 07/11] usb: dwc3: convert dwc3-of-simple to use match-data

The upcoming support for rk3568 will reuse data from rk3399.
Instead of adding a bunch of of_device_is_compatible as we add support
for new devices, lets get ahead of the problem and use of_match_data
instead.

Signed-off-by: Peter Geis <pgwipeout@...il.com>
---
 drivers/usb/dwc3/dwc3-of-simple.c | 39 ++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index 9dc6295df6b1..57ba9427ad74 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -30,12 +30,16 @@ struct dwc3_of_simple {
 	bool			need_reset;
 };
 
+struct dwc3_of_simple_data {
+	bool			need_reset;
+};
+
 static int dwc3_of_simple_probe(struct platform_device *pdev)
 {
 	struct dwc3_of_simple	*simple;
 	struct device		*dev = &pdev->dev;
 	struct device_node	*np = dev->of_node;
-
+	const struct dwc3_of_simple_data *data = of_device_get_match_data(dev);
 	int			ret;
 
 	simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
@@ -49,8 +53,8 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
 	 * Some controllers need to toggle the usb3-otg reset before trying to
 	 * initialize the PHY, otherwise the PHY times out.
 	 */
-	if (of_device_is_compatible(np, "rockchip,rk3399-dwc3"))
-		simple->need_reset = true;
+	if (data->need_reset)
+		simple->need_reset = data->need_reset;
 
 	simple->resets = of_reset_control_array_get(np, false, true,
 						    true);
@@ -170,13 +174,30 @@ static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = {
 			dwc3_of_simple_runtime_resume, NULL)
 };
 
+static const struct dwc3_of_simple_data dwc3_of_simple_data_rk3399 = {
+	.need_reset = true,
+};
+
 static const struct of_device_id of_dwc3_simple_match[] = {
-	{ .compatible = "allwinner,sun50i-h6-dwc3" },
-	{ .compatible = "cavium,octeon-7130-usb-uctl" },
-	{ .compatible = "hisilicon,hi3670-dwc3" },
-	{ .compatible = "intel,keembay-dwc3" },
-	{ .compatible = "rockchip,rk3399-dwc3" },
-	{ .compatible = "sprd,sc9860-dwc3" },
+	{
+		.compatible = "allwinner,sun50i-h6-dwc3",
+	},
+	{
+		.compatible = "cavium,octeon-7130-usb-uctl",
+	},
+	{
+		.compatible = "hisilicon,hi3670-dwc3",
+	},
+	{
+		.compatible = "intel,keembay-dwc3",
+	},
+	{
+		.compatible = "rockchip,rk3399-dwc3",
+		.data = &dwc3_of_simple_data_rk3399,
+	},
+	{
+		.compatible = "sprd,sc9860-dwc3",
+	},
 	{ /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, of_dwc3_simple_match);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ