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: <20210918120934.28252-3-sven@svenpeter.dev>
Date:   Sat, 18 Sep 2021 14:09:27 +0200
From:   Sven Peter <sven@...npeter.dev>
To:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc:     Sven Peter <sven@...npeter.dev>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Guido Günther <agx@...xcpu.org>,
        "Bryan O'Donoghue" <bryan.odonoghue@...aro.org>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        Hector Martin <marcan@...can.st>,
        Mohamed Mediouni <mohamed.mediouni@...amail.com>,
        Stan Skowronek <stan@...ellium.com>,
        Mark Kettenis <mark.kettenis@...all.nl>,
        Alexander Graf <graf@...zon.com>,
        Alyssa Rosenzweig <alyssa@...enzweig.io>
Subject: [RFT PATCH 2/9] usb: typec: tipd: Prepare supporting different variants

Apple M1 machines come with a variant of the TI TPS6598x and will need
some changes to the current logic. Let's prepare for that by setting up
the infrastructure required to support different variants of this chip
identified by the DT compatible.

Signed-off-by: Sven Peter <sven@...npeter.dev>
---
 drivers/usb/typec/tipd/core.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 21b3ae25c76d..656020e7f533 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -9,6 +9,7 @@
 #include <linux/i2c.h>
 #include <linux/acpi.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/power_supply.h>
 #include <linux/regmap.h>
 #include <linux/interrupt.h>
@@ -76,6 +77,10 @@ static const char *const modes[] = {
 /* Unrecognized commands will be replaced with "!CMD" */
 #define INVALID_CMD(_cmd_)		(_cmd_ == 0x444d4321)
 
+struct tps6598x_hw {
+};
+static const struct tps6598x_hw ti_tps6598x_data;
+
 struct tps6598x {
 	struct device *dev;
 	struct regmap *regmap;
@@ -91,6 +96,8 @@ struct tps6598x {
 	struct power_supply *psy;
 	struct power_supply_desc psy_desc;
 	enum power_supply_usb_type usb_type;
+
+	const struct tps6598x_hw *hw;
 };
 
 static enum power_supply_property tps6598x_psy_props[] = {
@@ -590,6 +597,13 @@ static int tps6598x_probe(struct i2c_client *client)
 	if (!tps)
 		return -ENOMEM;
 
+	if (client->dev.of_node)
+		tps->hw = of_device_get_match_data(&client->dev);
+	else
+		tps->hw = &ti_tps6598x_data;
+	if (!tps->hw)
+		return -EINVAL;
+
 	mutex_init(&tps->lock);
 	tps->dev = &client->dev;
 
@@ -729,8 +743,11 @@ static int tps6598x_remove(struct i2c_client *client)
 	return 0;
 }
 
+static const struct tps6598x_hw ti_tps6598x_data = {
+};
+
 static const struct of_device_id tps6598x_of_match[] = {
-	{ .compatible = "ti,tps6598x", },
+	{ .compatible = "ti,tps6598x", .data = &ti_tps6598x_data },
 	{}
 };
 MODULE_DEVICE_TABLE(of, tps6598x_of_match);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ