aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2018-09-20 07:23:46 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-20 07:37:29 -0400
commitc800c51f586b3c3dda59f5f08d3df9bd1ae09e3d (patch)
tree1407171a899d8eb8ae28df01f95655afdc28b9cd
parent148b0aa78e4e1077e38f928124bbc9c2d2d24006 (diff)
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 <hdegoede@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/typec/fusb302/fusb302.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
index 1cb0cd2a4e63..6e9370a813f7 100644
--- a/drivers/usb/typec/fusb302/fusb302.c
+++ b/drivers/usb/typec/fusb302/fusb302.c
@@ -1719,7 +1719,6 @@ static int fusb302_probe(struct i2c_client *client,
1719 return -ENOMEM; 1719 return -ENOMEM;
1720 1720
1721 chip->i2c_client = client; 1721 chip->i2c_client = client;
1722 i2c_set_clientdata(client, chip);
1723 chip->dev = &client->dev; 1722 chip->dev = &client->dev;
1724 chip->tcpc_config = fusb302_tcpc_config; 1723 chip->tcpc_config = fusb302_tcpc_config;
1725 chip->tcpc_dev.config = &chip->tcpc_config; 1724 chip->tcpc_dev.config = &chip->tcpc_config;
@@ -1748,22 +1747,17 @@ static int fusb302_probe(struct i2c_client *client,
1748 return -EPROBE_DEFER; 1747 return -EPROBE_DEFER;
1749 } 1748 }
1750 1749
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);
1752 1753
1753 chip->wq = create_singlethread_workqueue(dev_name(chip->dev)); 1754 chip->wq = create_singlethread_workqueue(dev_name(chip->dev));
1754 if (!chip->wq) { 1755 if (!chip->wq)
1755 ret = -ENOMEM; 1756 return -ENOMEM;
1756 goto clear_client_data; 1757
1757 }
1758 INIT_DELAYED_WORK(&chip->bc_lvl_handler, fusb302_bc_lvl_handler_work); 1758 INIT_DELAYED_WORK(&chip->bc_lvl_handler, fusb302_bc_lvl_handler_work);
1759 init_tcpc_dev(&chip->tcpc_dev); 1759 init_tcpc_dev(&chip->tcpc_dev);
1760 1760
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
1767 if (client->irq) { 1761 if (client->irq) {
1768 chip->gpio_int_n_irq = client->irq; 1762 chip->gpio_int_n_irq = client->irq;
1769 } else { 1763 } else {
@@ -1789,15 +1783,15 @@ static int fusb302_probe(struct i2c_client *client,
1789 goto tcpm_unregister_port; 1783 goto tcpm_unregister_port;
1790 } 1784 }
1791 enable_irq_wake(chip->gpio_int_n_irq); 1785 enable_irq_wake(chip->gpio_int_n_irq);
1786 fusb302_debugfs_init(chip);
1787 i2c_set_clientdata(client, chip);
1788
1792 return ret; 1789 return ret;
1793 1790
1794tcpm_unregister_port: 1791tcpm_unregister_port:
1795 tcpm_unregister_port(chip->tcpm_port); 1792 tcpm_unregister_port(chip->tcpm_port);
1796destroy_workqueue: 1793destroy_workqueue:
1797 destroy_workqueue(chip->wq); 1794 destroy_workqueue(chip->wq);
1798clear_client_data:
1799 i2c_set_clientdata(client, NULL);
1800 fusb302_debugfs_exit(chip);
1801 1795
1802 return ret; 1796 return ret;
1803} 1797}
@@ -1808,7 +1802,6 @@ static int fusb302_remove(struct i2c_client *client)
1808 1802
1809 tcpm_unregister_port(chip->tcpm_port); 1803 tcpm_unregister_port(chip->tcpm_port);
1810 destroy_workqueue(chip->wq); 1804 destroy_workqueue(chip->wq);
1811 i2c_set_clientdata(client, NULL);
1812 fusb302_debugfs_exit(chip); 1805 fusb302_debugfs_exit(chip);
1813 1806
1814 return 0; 1807 return 0;