aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2019-05-31 10:15:42 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-06-03 04:55:38 -0400
commitd84af483033d56d466d67c1a76a0028e3be6300d (patch)
tree1b200bcd813403df1d7a878cdb2ced6c93405b0d
parent3370db35193b241ba5836a66df6ec1a559108389 (diff)
platform/x86: intel_cht_int33fe: Register max17047 in its own function
To make the probe function a bit more nicer looking, moving the registration of max17047 to its own function. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/platform/x86/intel_cht_int33fe.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
index 657b8d61554c..3f532b5a5133 100644
--- a/drivers/platform/x86/intel_cht_int33fe.c
+++ b/drivers/platform/x86/intel_cht_int33fe.c
@@ -63,14 +63,6 @@ static int cht_int33fe_check_for_max17047(struct device *dev, void *data)
63 return 1; 63 return 1;
64} 64}
65 65
66static struct i2c_client *cht_int33fe_find_max17047(void)
67{
68 struct i2c_client *max17047 = NULL;
69
70 i2c_for_each_dev(&max17047, cht_int33fe_check_for_max17047);
71 return max17047;
72}
73
74static const char * const max17047_suppliers[] = { "bq24190-charger" }; 66static const char * const max17047_suppliers[] = { "bq24190-charger" };
75 67
76static const struct property_entry max17047_props[] = { 68static const struct property_entry max17047_props[] = {
@@ -86,12 +78,40 @@ static const struct property_entry fusb302_props[] = {
86 { } 78 { }
87}; 79};
88 80
81static int
82cht_int33fe_register_max17047(struct device *dev, struct cht_int33fe_data *data)
83{
84 struct i2c_client *max17047 = NULL;
85 struct i2c_board_info board_info;
86 int ret;
87
88 i2c_for_each_dev(&max17047, cht_int33fe_check_for_max17047);
89 if (max17047) {
90 /* Pre-existing i2c-client for the max17047, add device-props */
91 ret = device_add_properties(&max17047->dev, max17047_props);
92 if (ret)
93 return ret;
94 /* And re-probe to get the new device-props applied. */
95 ret = device_reprobe(&max17047->dev);
96 if (ret)
97 dev_warn(dev, "Reprobing max17047 error: %d\n", ret);
98 return 0;
99 }
100
101 memset(&board_info, 0, sizeof(board_info));
102 strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
103 board_info.dev_name = "max17047";
104 board_info.properties = max17047_props;
105 data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
106
107 return PTR_ERR_OR_ZERO(data->max17047);
108}
109
89static int cht_int33fe_probe(struct platform_device *pdev) 110static int cht_int33fe_probe(struct platform_device *pdev)
90{ 111{
91 struct device *dev = &pdev->dev; 112 struct device *dev = &pdev->dev;
92 struct i2c_board_info board_info; 113 struct i2c_board_info board_info;
93 struct cht_int33fe_data *data; 114 struct cht_int33fe_data *data;
94 struct i2c_client *max17047;
95 struct regulator *regulator; 115 struct regulator *regulator;
96 unsigned long long ptyp; 116 unsigned long long ptyp;
97 acpi_status status; 117 acpi_status status;
@@ -151,26 +171,10 @@ static int cht_int33fe_probe(struct platform_device *pdev)
151 if (!data) 171 if (!data)
152 return -ENOMEM; 172 return -ENOMEM;
153 173
154 /* Work around BIOS bug, see comment on cht_int33fe_find_max17047 */ 174 /* Work around BIOS bug, see comment on cht_int33fe_check_for_max17047 */
155 max17047 = cht_int33fe_find_max17047(); 175 ret = cht_int33fe_register_max17047(dev, data);
156 if (max17047) { 176 if (ret)
157 /* Pre-existing i2c-client for the max17047, add device-props */ 177 return ret;
158 ret = device_add_properties(&max17047->dev, max17047_props);
159 if (ret)
160 return ret;
161 /* And re-probe to get the new device-props applied. */
162 ret = device_reprobe(&max17047->dev);
163 if (ret)
164 dev_warn(dev, "Reprobing max17047 error: %d\n", ret);
165 } else {
166 memset(&board_info, 0, sizeof(board_info));
167 strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
168 board_info.dev_name = "max17047";
169 board_info.properties = max17047_props;
170 data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
171 if (IS_ERR(data->max17047))
172 return PTR_ERR(data->max17047);
173 }
174 178
175 data->connections[0].endpoint[0] = "port0"; 179 data->connections[0].endpoint[0] = "port0";
176 data->connections[0].endpoint[1] = "i2c-pi3usb30532-switch"; 180 data->connections[0].endpoint[1] = "i2c-pi3usb30532-switch";