Skip to content

Commit c800c51

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: fusb302: reorganizing the probe function a little
The debugfs needs to be initialized as the last step in probe in this case. The struct dentry *rootdir can't be pointing to anything unless driver probe really finishes successfully. It is also not necessary to clear the i2c clientdata if the probe fails, so removing the extra label used for that. Acked-by: Hans de Goede <[email protected]> Tested-by: Hans de Goede <[email protected]> Signed-off-by: Heikki Krogerus <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 148b0aa commit c800c51

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

drivers/usb/typec/fusb302/fusb302.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,6 @@ static int fusb302_probe(struct i2c_client *client,
17191719
return -ENOMEM;
17201720

17211721
chip->i2c_client = client;
1722-
i2c_set_clientdata(client, chip);
17231722
chip->dev = &client->dev;
17241723
chip->tcpc_config = fusb302_tcpc_config;
17251724
chip->tcpc_dev.config = &chip->tcpc_config;
@@ -1748,22 +1747,17 @@ static int fusb302_probe(struct i2c_client *client,
17481747
return -EPROBE_DEFER;
17491748
}
17501749

1751-
fusb302_debugfs_init(chip);
1750+
chip->vbus = devm_regulator_get(chip->dev, "vbus");
1751+
if (IS_ERR(chip->vbus))
1752+
return PTR_ERR(chip->vbus);
17521753

17531754
chip->wq = create_singlethread_workqueue(dev_name(chip->dev));
1754-
if (!chip->wq) {
1755-
ret = -ENOMEM;
1756-
goto clear_client_data;
1757-
}
1755+
if (!chip->wq)
1756+
return -ENOMEM;
1757+
17581758
INIT_DELAYED_WORK(&chip->bc_lvl_handler, fusb302_bc_lvl_handler_work);
17591759
init_tcpc_dev(&chip->tcpc_dev);
17601760

1761-
chip->vbus = devm_regulator_get(chip->dev, "vbus");
1762-
if (IS_ERR(chip->vbus)) {
1763-
ret = PTR_ERR(chip->vbus);
1764-
goto destroy_workqueue;
1765-
}
1766-
17671761
if (client->irq) {
17681762
chip->gpio_int_n_irq = client->irq;
17691763
} else {
@@ -1789,15 +1783,15 @@ static int fusb302_probe(struct i2c_client *client,
17891783
goto tcpm_unregister_port;
17901784
}
17911785
enable_irq_wake(chip->gpio_int_n_irq);
1786+
fusb302_debugfs_init(chip);
1787+
i2c_set_clientdata(client, chip);
1788+
17921789
return ret;
17931790

17941791
tcpm_unregister_port:
17951792
tcpm_unregister_port(chip->tcpm_port);
17961793
destroy_workqueue:
17971794
destroy_workqueue(chip->wq);
1798-
clear_client_data:
1799-
i2c_set_clientdata(client, NULL);
1800-
fusb302_debugfs_exit(chip);
18011795

18021796
return ret;
18031797
}
@@ -1808,7 +1802,6 @@ static int fusb302_remove(struct i2c_client *client)
18081802

18091803
tcpm_unregister_port(chip->tcpm_port);
18101804
destroy_workqueue(chip->wq);
1811-
i2c_set_clientdata(client, NULL);
18121805
fusb302_debugfs_exit(chip);
18131806

18141807
return 0;

0 commit comments

Comments
 (0)