Skip to contentSkip to conversation

usb: typec: stusb160x: Make use of i2c_get_match_data()

PATCH In review Andy Shevchenko 2 participants 2 messages Sep 26, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: typec: stusb160x: Make use of i2c_get_match_data()

Get matching data in one step by switching to use i2c_get_match_data(). As a positive side effect the matching data is qualified as a constant.

---
v2: fixed rebase issue which led to the compilation error (LKP)

 drivers/usb/typec/stusb160x.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/typec/stusb160x.c +3 -4
index f3140fc04c12..6d85b25b40bc 100644
@@ -633,9 +633,8 @@ MODULE_DEVICE_TABLE(of, stusb160x_of_match);
 
 static int stusb160x_probe(struct i2c_client *client)
 {
+	const struct regmap_config *regmap_config;
 	struct stusb160x *chip;
-	const struct of_device_id *match;
-	struct regmap_config *regmap_config;
 	struct fwnode_handle *fwnode;
 	int ret;
 
@@ -645,8 +644,8 @@ static int stusb160x_probe(struct i2c_client *client)
 
 	i2c_set_clientdata(client, chip);
 
-	match = i2c_of_match_device(stusb160x_of_match, client);
-	regmap_config = (struct regmap_config *)match->data;
+	regmap_config = i2c_get_match_data(client);
+
 	chip->regmap = devm_regmap_init_i2c(client, regmap_config);
 	if (IS_ERR(chip->regmap)) {
 		ret = PTR_ERR(chip->regmap);
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines · Andy Shevchenko

Get matching data in one step by switching to use i2c_get_match_data(). As a positive side effect the matching data is qualified as a constant.

Quoted 33 lines

---
v2: fixed rebase issue which led to the compilation error (LKP)

 drivers/usb/typec/stusb160x.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/typec/stusb160x.c +3 -4
index f3140fc04c12..6d85b25b40bc 100644
@@ -633,9 +633,8 @@ MODULE_DEVICE_TABLE(of, stusb160x_of_match);
 
 static int stusb160x_probe(struct i2c_client *client)
 {
+	const struct regmap_config *regmap_config;
 	struct stusb160x *chip;
-	const struct of_device_id *match;
-	struct regmap_config *regmap_config;
 	struct fwnode_handle *fwnode;
 	int ret;
 
@@ -645,8 +644,8 @@ static int stusb160x_probe(struct i2c_client *client)
 
 	i2c_set_clientdata(client, chip);
 
-	match = i2c_of_match_device(stusb160x_of_match, client);
-	regmap_config = (struct regmap_config *)match->data;
+	regmap_config = i2c_get_match_data(client);
+
 	chip->regmap = devm_regmap_init_i2c(client, regmap_config);
 	if (IS_ERR(chip->regmap)) {
 		ret = PTR_ERR(chip->regmap);
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Signature · 1 line
heikki