History

Merge tag 'extcon-next-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next

Chanwoo writes: Update extcon next for v5.19 Detailed description for this pull request: 1. update extcon core driver - extcon_get_extcon_dev() has been almost used to get the extcon device on booting time. If extcon provider driver is probed at late time, the extcon consumer driver get the -EPROBE_DEFER return value. It requires the inefficient handling code of -EPROBE_DEFER. Instead, extcon_get_extcon_dev() will return -EPROBE_DEFER if the required extcon device is none. It makes the extcon consumer driver to be simplified when getting extcon device. - Register device after dev_set_drvdata because of accessing the sysfs attributes at timing of between drv_set_data and device_register. - Fix some kernel-doc comments of extcon functions. 2. update extcon provider driver - Update extcon-intel-int3496.c : Add support for controlling vbus power via regulator and support to the extcon-intel-int3496.c driver to bind to devices without an ACPi companion. And fix the minor clean-up. - Use struct_size() helper on extcon-usbc-cros-ec.c - Remove the disable irq operation in system sleep for using vbus/id gpio as the wakeup source on extcon-usb-gpio.c - Add support of SM5703 device by using existing extcon-sm5502.c and rename i2c_devic_id from sm5703 to sm5703-muic to reduce confusion between SM5703 MFD device and extcon device. - Add usb role class support and add queue work sync before driver release on extcon-ptn5150.c * tag 'extcon-next-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon: extcon: Modify extcon device to be created after driver data is set extcon: sm5502: Clarify SM5703's i2c device ID extcon: ptn5150: Add usb role class support extcon: ptn5150: Add queue work sync before driver release extcon: sm5502: Add support for SM5703 dt-bindings: extcon: bindings for SM5703 extcon: usb-gpio: Remove disable irq operation in system sleep extcon: Fix some kernel-doc comments extcon: usbc-cros-ec: Use struct_size() helper in kzalloc() extcon: int3496: Add support for controlling Vbus through a regulator extcon: int3496: Add support for binding to plain platform devices extcon: int3496: Request non-exclusive access to the ID GPIO extcon: int3496: Make the driver a bit less verbose extcon: Fix extcon_get_extcon_dev() error handling

Greg Kroah-Hartman committed 4 years ago

Commit e727efe2 parents fa5602c 5dcc2af16 files · +139 −70Browse files

Unified · Split

16 files
  1. Documentation/devicetree/bindings/extcon/siliconmitus,sm5502-muic.yaml +3 −2
  2. drivers/extcon/Kconfig +2 −1
  3. drivers/extcon/extcon-axp288.c +2 −2
  4. drivers/extcon/extcon-intel-int3496.c +46 −8
  5. drivers/extcon/extcon-ptn5150.c +36 −0
  6. drivers/extcon/extcon-sm5502.c +2 −0
  7. drivers/extcon/extcon-usb-gpio.c +0 −15
  8. drivers/extcon/extcon-usbc-cros-ec.c +1 −1
  9. drivers/extcon/extcon.c +24 −13
  10. drivers/power/supply/axp288_charger.c +10 −7
  11. drivers/power/supply/charger-manager.c +2 −5
  12. drivers/power/supply/max8997_charger.c +4 −4
  13. drivers/usb/dwc3/drd.c +2 −7
  14. drivers/usb/phy/phy-omap-otg.c +2 −2
  15. drivers/usb/typec/tcpm/fusb302.c +2 −2
  16. include/linux/extcon.h +1 −1
Documentation/devicetree/bindings/extcon/siliconmitus,sm5502-muic.yaml+3−2
@@ -20,11 +20,12 @@ properties: · 19 unmodified lines
20 enum:20 enum:
21 - siliconmitus,sm5502-muic21 - siliconmitus,sm5502-muic
22 - siliconmitus,sm5504-muic22 - siliconmitus,sm5504-muic
23 - siliconmitus,sm5703-muic
23 24
24 reg:25 reg:
25 maxItems: 126 maxItems: 1
26 description: I2C slave address of the device. Usually 0x25 for SM5502,27 description: I2C slave address of the device. Usually 0x25 for SM5502
27 0x14 for SM5504.28 and SM5703, 0x14 for SM5504.
28 29
29 interrupts:30 interrupts:
30 maxItems: 131 maxItems: 1
drivers/extcon/Kconfig+2−1
@@ -131,6 +131,7 @@ config EXTCON_PALMAS · 130 unmodified lines
131config EXTCON_PTN5150131config EXTCON_PTN5150
132 tristate "NXP PTN5150 CC LOGIC USB EXTCON support"132 tristate "NXP PTN5150 CC LOGIC USB EXTCON support"
133 depends on I2C && (GPIOLIB || COMPILE_TEST)133 depends on I2C && (GPIOLIB || COMPILE_TEST)
134 depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH
134 select REGMAP_I2C135 select REGMAP_I2C
135 help136 help
136 Say Y here to enable support for USB peripheral and USB host137 Say Y here to enable support for USB peripheral and USB host
@@ -156,7 +157,7 @@ config EXTCON_RT8973A · 19 unmodified lines
156 from abnormal high input voltage (up to 28V).157 from abnormal high input voltage (up to 28V).
157 158
158config EXTCON_SM5502159config EXTCON_SM5502
159 tristate "Silicon Mitus SM5502/SM5504 EXTCON support"160 tristate "Silicon Mitus SM5502/SM5504/SM5703 EXTCON support"
160 depends on I2C161 depends on I2C
161 select IRQ_DOMAIN162 select IRQ_DOMAIN
162 select REGMAP_I2C163 select REGMAP_I2C
drivers/extcon/extcon-axp288.c+2−2
@@ -394,8 +394,8 @@ static int axp288_extcon_probe(struct platform_device *pdev) · 393 unmodified lines
394 if (adev) {394 if (adev) {
395 info->id_extcon = extcon_get_extcon_dev(acpi_dev_name(adev));395 info->id_extcon = extcon_get_extcon_dev(acpi_dev_name(adev));
396 put_device(&adev->dev);396 put_device(&adev->dev);
397 if (!info->id_extcon)397 if (IS_ERR(info->id_extcon))
398 return -EPROBE_DEFER;398 return PTR_ERR(info->id_extcon);
399 399
400 dev_info(dev, "controlling USB role\n");400 dev_info(dev, "controlling USB role\n");
401 } else {401 } else {
drivers/extcon/extcon-intel-int3496.c+46−8
@@ -17,6 +17,7 @@ · 16 unmodified lines
17#include <linux/interrupt.h>17#include <linux/interrupt.h>
18#include <linux/module.h>18#include <linux/module.h>
19#include <linux/platform_device.h>19#include <linux/platform_device.h>
20#include <linux/regulator/consumer.h>
20 21
21#define INT3496_GPIO_USB_ID 022#define INT3496_GPIO_USB_ID 0
22#define INT3496_GPIO_VBUS_EN 123#define INT3496_GPIO_VBUS_EN 1
@@ -30,7 +31,9 @@ struct int3496_data { · 7 unmodified lines
30 struct gpio_desc *gpio_usb_id;31 struct gpio_desc *gpio_usb_id;
31 struct gpio_desc *gpio_vbus_en;32 struct gpio_desc *gpio_vbus_en;
32 struct gpio_desc *gpio_usb_mux;33 struct gpio_desc *gpio_usb_mux;
34 struct regulator *vbus_boost;
33 int usb_id_irq;35 int usb_id_irq;
36 bool vbus_boost_enabled;
34};37};
35 38
36static const unsigned int int3496_cable[] = {39static const unsigned int int3496_cable[] = {
@@ -53,6 +56,27 @@ static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = { · 16 unmodified lines
53 { },56 { },
54};57};
55 58
59static void int3496_set_vbus_boost(struct int3496_data *data, bool enable)
60{
61 int ret;
62
63 if (IS_ERR_OR_NULL(data->vbus_boost))
64 return;
65
66 if (data->vbus_boost_enabled == enable)
67 return;
68
69 if (enable)
70 ret = regulator_enable(data->vbus_boost);
71 else
72 ret = regulator_disable(data->vbus_boost);
73
74 if (ret == 0)
75 data->vbus_boost_enabled = enable;
76 else
77 dev_err(data->dev, "Error updating Vbus boost regulator: %d\n", ret);
78}
79
56static void int3496_do_usb_id(struct work_struct *work)80static void int3496_do_usb_id(struct work_struct *work)
57{81{
58 struct int3496_data *data =82 struct int3496_data *data =
@@ -71,6 +95,8 @@ static void int3496_do_usb_id(struct work_struct *work) · 12 unmodified lines
71 95
72 if (!IS_ERR(data->gpio_vbus_en))96 if (!IS_ERR(data->gpio_vbus_en))
73 gpiod_direction_output(data->gpio_vbus_en, !id);97 gpiod_direction_output(data->gpio_vbus_en, !id);
98 else
99 int3496_set_vbus_boost(data, !id);
74 100
75 extcon_set_state_sync(data->edev, EXTCON_USB_HOST, !id);101 extcon_set_state_sync(data->edev, EXTCON_USB_HOST, !id);
76}102}
@@ -91,10 +117,12 @@ static int int3496_probe(struct platform_device *pdev) · 14 unmodified lines
91 struct int3496_data *data;117 struct int3496_data *data;
92 int ret;118 int ret;
93 119
94 ret = devm_acpi_dev_add_driver_gpios(dev, acpi_int3496_default_gpios);120 if (has_acpi_companion(dev)) {
95 if (ret) {121 ret = devm_acpi_dev_add_driver_gpios(dev, acpi_int3496_default_gpios);
96 dev_err(dev, "can't add GPIO ACPI mapping\n");122 if (ret) {
97 return ret;123 dev_err(dev, "can't add GPIO ACPI mapping\n");
124 return ret;
125 }
98 }126 }
99 127
100 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);128 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
@@ -106,7 +134,8 @@ static int int3496_probe(struct platform_device *pdev) · 5 unmodified lines
106 if (ret)134 if (ret)
107 return ret;135 return ret;
108 136
109 data->gpio_usb_id = devm_gpiod_get(dev, "id", GPIOD_IN);137 data->gpio_usb_id =
138 devm_gpiod_get(dev, "id", GPIOD_IN | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
110 if (IS_ERR(data->gpio_usb_id)) {139 if (IS_ERR(data->gpio_usb_id)) {
111 ret = PTR_ERR(data->gpio_usb_id);140 ret = PTR_ERR(data->gpio_usb_id);
112 dev_err(dev, "can't request USB ID GPIO: %d\n", ret);141 dev_err(dev, "can't request USB ID GPIO: %d\n", ret);
@@ -120,12 +149,14 @@ static int int3496_probe(struct platform_device *pdev) · 7 unmodified lines
120 }149 }
121 150
122 data->gpio_vbus_en = devm_gpiod_get(dev, "vbus", GPIOD_ASIS);151 data->gpio_vbus_en = devm_gpiod_get(dev, "vbus", GPIOD_ASIS);
123 if (IS_ERR(data->gpio_vbus_en))152 if (IS_ERR(data->gpio_vbus_en)) {
124 dev_info(dev, "can't request VBUS EN GPIO\n");153 dev_dbg(dev, "can't request VBUS EN GPIO\n");
154 data->vbus_boost = devm_regulator_get_optional(dev, "vbus");
155 }
125 156
126 data->gpio_usb_mux = devm_gpiod_get(dev, "mux", GPIOD_ASIS);157 data->gpio_usb_mux = devm_gpiod_get(dev, "mux", GPIOD_ASIS);
127 if (IS_ERR(data->gpio_usb_mux))158 if (IS_ERR(data->gpio_usb_mux))
128 dev_info(dev, "can't request USB MUX GPIO\n");159 dev_dbg(dev, "can't request USB MUX GPIO\n");
129 160
130 /* register extcon device */161 /* register extcon device */
131 data->edev = devm_extcon_dev_allocate(dev, int3496_cable);162 data->edev = devm_extcon_dev_allocate(dev, int3496_cable);
@@ -164,12 +195,19 @@ static const struct acpi_device_id int3496_acpi_match[] = { · 32 unmodified lines
164};195};
165MODULE_DEVICE_TABLE(acpi, int3496_acpi_match);196MODULE_DEVICE_TABLE(acpi, int3496_acpi_match);
166 197
198static const struct platform_device_id int3496_ids[] = {
199 { .name = "intel-int3496" },
200 {},
201};
202MODULE_DEVICE_TABLE(platform, int3496_ids);
203
167static struct platform_driver int3496_driver = {204static struct platform_driver int3496_driver = {
168 .driver = {205 .driver = {
169 .name = "intel-int3496",206 .name = "intel-int3496",
170 .acpi_match_table = int3496_acpi_match,207 .acpi_match_table = int3496_acpi_match,
171 },208 },
172 .probe = int3496_probe,209 .probe = int3496_probe,
210 .id_table = int3496_ids,
173};211};
174 212
175module_platform_driver(int3496_driver);213module_platform_driver(int3496_driver);
drivers/extcon/extcon-ptn5150.c+36−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
17#include <linux/slab.h>17#include <linux/slab.h>
18#include <linux/extcon-provider.h>18#include <linux/extcon-provider.h>
19#include <linux/gpio/consumer.h>19#include <linux/gpio/consumer.h>
20#include <linux/usb/role.h>
20 21
21/* PTN5150 registers */22/* PTN5150 registers */
22#define PTN5150_REG_DEVICE_ID 0x0123#define PTN5150_REG_DEVICE_ID 0x01
@@ -52,6 +53,7 @@ struct ptn5150_info { · 29 unmodified lines
52 int irq;53 int irq;
53 struct work_struct irq_work;54 struct work_struct irq_work;
54 struct mutex mutex;55 struct mutex mutex;
56 struct usb_role_switch *role_sw;
55};57};
56 58
57/* List of detectable cables */59/* List of detectable cables */
@@ -70,6 +72,7 @@ static const struct regmap_config ptn5150_regmap_config = { · 12 unmodified lines
70static void ptn5150_check_state(struct ptn5150_info *info)72static void ptn5150_check_state(struct ptn5150_info *info)
71{73{
72 unsigned int port_status, reg_data, vbus;74 unsigned int port_status, reg_data, vbus;
75 enum usb_role usb_role = USB_ROLE_NONE;
73 int ret;76 int ret;
74 77
75 ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, &reg_data);78 ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, &reg_data);
@@ -85,6 +88,7 @@ static void ptn5150_check_state(struct ptn5150_info *info) · 9 unmodified lines
85 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, false);88 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, false);
86 gpiod_set_value_cansleep(info->vbus_gpiod, 0);89 gpiod_set_value_cansleep(info->vbus_gpiod, 0);
87 extcon_set_state_sync(info->edev, EXTCON_USB, true);90 extcon_set_state_sync(info->edev, EXTCON_USB, true);
91 usb_role = USB_ROLE_DEVICE;
88 break;92 break;
89 case PTN5150_UFP_ATTACHED:93 case PTN5150_UFP_ATTACHED:
90 extcon_set_state_sync(info->edev, EXTCON_USB, false);94 extcon_set_state_sync(info->edev, EXTCON_USB, false);
@@ -95,10 +99,18 @@ static void ptn5150_check_state(struct ptn5150_info *info) · 4 unmodified lines
95 gpiod_set_value_cansleep(info->vbus_gpiod, 1);99 gpiod_set_value_cansleep(info->vbus_gpiod, 1);
96 100
97 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true);101 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true);
102 usb_role = USB_ROLE_HOST;
98 break;103 break;
99 default:104 default:
100 break;105 break;
101 }106 }
107
108 if (usb_role) {
109 ret = usb_role_switch_set_role(info->role_sw, usb_role);
110 if (ret)
111 dev_err(info->dev, "failed to set %s role: %d\n",
112 usb_role_string(usb_role), ret);
113 }
102}114}
103 115
104static void ptn5150_irq_work(struct work_struct *work)116static void ptn5150_irq_work(struct work_struct *work)
@@ -133,6 +145,13 @@ static void ptn5150_irq_work(struct work_struct *work) · 28 unmodified lines
133 extcon_set_state_sync(info->edev,145 extcon_set_state_sync(info->edev,
134 EXTCON_USB, false);146 EXTCON_USB, false);
135 gpiod_set_value_cansleep(info->vbus_gpiod, 0);147 gpiod_set_value_cansleep(info->vbus_gpiod, 0);
148
149 ret = usb_role_switch_set_role(info->role_sw,
150 USB_ROLE_NONE);
151 if (ret)
152 dev_err(info->dev,
153 "failed to set none role: %d\n",
154 ret);
136 }155 }
137 }156 }
138 157
@@ -194,6 +213,14 @@ static int ptn5150_init_dev_type(struct ptn5150_info *info) · 55 unmodified lines
194 return 0;213 return 0;
195}214}
196 215
216static void ptn5150_work_sync_and_put(void *data)
217{
218 struct ptn5150_info *info = data;
219
220 cancel_work_sync(&info->irq_work);
221 usb_role_switch_put(info->role_sw);
222}
223
197static int ptn5150_i2c_probe(struct i2c_client *i2c)224static int ptn5150_i2c_probe(struct i2c_client *i2c)
198{225{
199 struct device *dev = &i2c->dev;226 struct device *dev = &i2c->dev;
@@ -284,6 +311,15 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c) · 84 unmodified lines
284 if (ret)311 if (ret)
285 return -EINVAL;312 return -EINVAL;
286 313
314 info->role_sw = usb_role_switch_get(info->dev);
315 if (IS_ERR(info->role_sw))
316 return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
317 "failed to get role switch\n");
318
319 ret = devm_add_action_or_reset(dev, ptn5150_work_sync_and_put, info);
320 if (ret)
321 return ret;
322
287 /*323 /*
288 * Update current extcon state if for example OTG connection was there324 * Update current extcon state if for example OTG connection was there
289 * before the probe325 * before the probe
drivers/extcon/extcon-sm5502.c+2−0
@@ -798,6 +798,7 @@ static const struct sm5502_type sm5504_data = { · 797 unmodified lines
798static const struct of_device_id sm5502_dt_match[] = {798static const struct of_device_id sm5502_dt_match[] = {
799 { .compatible = "siliconmitus,sm5502-muic", .data = &sm5502_data },799 { .compatible = "siliconmitus,sm5502-muic", .data = &sm5502_data },
800 { .compatible = "siliconmitus,sm5504-muic", .data = &sm5504_data },800 { .compatible = "siliconmitus,sm5504-muic", .data = &sm5504_data },
801 { .compatible = "siliconmitus,sm5703-muic", .data = &sm5502_data },
801 { },802 { },
802};803};
803MODULE_DEVICE_TABLE(of, sm5502_dt_match);804MODULE_DEVICE_TABLE(of, sm5502_dt_match);
@@ -830,6 +831,7 @@ static SIMPLE_DEV_PM_OPS(sm5502_muic_pm_ops, · 26 unmodified lines
830static const struct i2c_device_id sm5502_i2c_id[] = {831static const struct i2c_device_id sm5502_i2c_id[] = {
831 { "sm5502", (kernel_ulong_t)&sm5502_data },832 { "sm5502", (kernel_ulong_t)&sm5502_data },
832 { "sm5504", (kernel_ulong_t)&sm5504_data },833 { "sm5504", (kernel_ulong_t)&sm5504_data },
834 { "sm5703-muic", (kernel_ulong_t)&sm5502_data },
833 { }835 { }
834};836};
835MODULE_DEVICE_TABLE(i2c, sm5502_i2c_id);837MODULE_DEVICE_TABLE(i2c, sm5502_i2c_id);
drivers/extcon/extcon-usb-gpio.c+0−15
@@ -226,16 +226,6 @@ static int usb_extcon_suspend(struct device *dev) · 225 unmodified lines
226 }226 }
227 }227 }
228 228
229 /*
230 * We don't want to process any IRQs after this point
231 * as GPIOs used behind I2C subsystem might not be
232 * accessible until resume completes. So disable IRQ.
233 */
234 if (info->id_gpiod)
235 disable_irq(info->id_irq);
236 if (info->vbus_gpiod)
237 disable_irq(info->vbus_irq);
238
239 if (!device_may_wakeup(dev))229 if (!device_may_wakeup(dev))
240 pinctrl_pm_select_sleep_state(dev);230 pinctrl_pm_select_sleep_state(dev);
241 231
@@ -267,11 +257,6 @@ static int usb_extcon_resume(struct device *dev) · 25 unmodified lines
267 }257 }
268 }258 }
269 259
270 if (info->id_gpiod)
271 enable_irq(info->id_irq);
272 if (info->vbus_gpiod)
273 enable_irq(info->vbus_irq);
274
275 queue_delayed_work(system_power_efficient_wq,260 queue_delayed_work(system_power_efficient_wq,
276 &info->wq_detcable, 0);261 &info->wq_detcable, 0);
277 262
drivers/extcon/extcon-usbc-cros-ec.c+1−1
@@ -68,7 +68,7 @@ static int cros_ec_pd_command(struct cros_ec_extcon_info *info, · 67 unmodified lines
68 struct cros_ec_command *msg;68 struct cros_ec_command *msg;
69 int ret;69 int ret;
70 70
71 msg = kzalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL);71 msg = kzalloc(struct_size(msg, data, max(outsize, insize)), GFP_KERNEL);
72 if (!msg)72 if (!msg)
73 return -ENOMEM;73 return -ENOMEM;
74 74
drivers/extcon/extcon.c+24−13
@@ -399,6 +399,7 @@ static ssize_t cable_state_show(struct device *dev, · 398 unmodified lines
399/**399/**
400 * extcon_sync() - Synchronize the state for an external connector.400 * extcon_sync() - Synchronize the state for an external connector.
401 * @edev: the extcon device401 * @edev: the extcon device
402 * @id: the unique id indicating an external connector
402 *403 *
403 * Note that this function send a notification in order to synchronize404 * Note that this function send a notification in order to synchronize
404 * the state and property of an external connector.405 * the state and property of an external connector.
@@ -736,6 +737,9 @@ EXPORT_SYMBOL_GPL(extcon_set_property); · 331 unmodified lines
736 737
737/**738/**
738 * extcon_set_property_sync() - Set property of an external connector with sync.739 * extcon_set_property_sync() - Set property of an external connector with sync.
740 * @edev: the extcon device
741 * @id: the unique id indicating an external connector
742 * @prop: the property id indicating an extcon property
739 * @prop_val: the pointer including the new value of extcon property743 * @prop_val: the pointer including the new value of extcon property
740 *744 *
741 * Note that when setting the property value of external connector,745 * Note that when setting the property value of external connector,
@@ -851,6 +855,8 @@ EXPORT_SYMBOL_GPL(extcon_set_property_capability); · 109 unmodified lines
851 * @extcon_name: the extcon name provided with extcon_dev_register()855 * @extcon_name: the extcon name provided with extcon_dev_register()
852 *856 *
853 * Return the pointer of extcon device if success or ERR_PTR(err) if fail.857 * Return the pointer of extcon device if success or ERR_PTR(err) if fail.
858 * NOTE: This function returns -EPROBE_DEFER so it may only be called from
859 * probe() functions.
854 */860 */
855struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)861struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
856{862{
@@ -864,7 +870,7 @@ struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) · 7 unmodified lines
864 if (!strcmp(sd->name, extcon_name))870 if (!strcmp(sd->name, extcon_name))
865 goto out;871 goto out;
866 }872 }
867 sd = NULL;873 sd = ERR_PTR(-EPROBE_DEFER);
868out:874out:
869 mutex_unlock(&extcon_dev_list_lock);875 mutex_unlock(&extcon_dev_list_lock);
870 return sd;876 return sd;
@@ -1218,19 +1224,14 @@ int extcon_dev_register(struct extcon_dev *edev) · 347 unmodified lines
1218 edev->dev.type = &edev->extcon_dev_type;1224 edev->dev.type = &edev->extcon_dev_type;
1219 }1225 }
1220 1226
1221 ret = device_register(&edev->dev);
1222 if (ret) {
1223 put_device(&edev->dev);
1224 goto err_dev;
1225 }
1226
1227 spin_lock_init(&edev->lock);1227 spin_lock_init(&edev->lock);
1228 edev->nh = devm_kcalloc(&edev->dev, edev->max_supported,1228 if (edev->max_supported) {
1229 sizeof(*edev->nh), GFP_KERNEL);1229 edev->nh = kcalloc(edev->max_supported, sizeof(*edev->nh),
1230 if (!edev->nh) {1230 GFP_KERNEL);
1231 ret = -ENOMEM;1231 if (!edev->nh) {
1232 device_unregister(&edev->dev);1232 ret = -ENOMEM;
1233 goto err_dev;1233 goto err_alloc_nh;
1234 }
1234 }1235 }
1235 1236
1236 for (index = 0; index < edev->max_supported; index++)1237 for (index = 0; index < edev->max_supported; index++)
@@ -1241,6 +1242,12 @@ int extcon_dev_register(struct extcon_dev *edev) · 4 unmodified lines
1241 dev_set_drvdata(&edev->dev, edev);1242 dev_set_drvdata(&edev->dev, edev);
1242 edev->state = 0;1243 edev->state = 0;
1243 1244
1245 ret = device_register(&edev->dev);
1246 if (ret) {
1247 put_device(&edev->dev);
1248 goto err_dev;
1249 }
1250
1244 mutex_lock(&extcon_dev_list_lock);1251 mutex_lock(&extcon_dev_list_lock);
1245 list_add(&edev->entry, &extcon_dev_list);1252 list_add(&edev->entry, &extcon_dev_list);
1246 mutex_unlock(&extcon_dev_list_lock);1253 mutex_unlock(&extcon_dev_list_lock);
@@ -1248,6 +1255,9 @@ int extcon_dev_register(struct extcon_dev *edev) · 1 unmodified line
1248 return 0;1255 return 0;
1249 1256
1250err_dev:1257err_dev:
1258 if (edev->max_supported)
1259 kfree(edev->nh);
1260err_alloc_nh:
1251 if (edev->max_supported)1261 if (edev->max_supported)
1252 kfree(edev->extcon_dev_type.groups);1262 kfree(edev->extcon_dev_type.groups);
1253err_alloc_groups:1263err_alloc_groups:
@@ -1308,6 +1318,7 @@ void extcon_dev_unregister(struct extcon_dev *edev) · 54 unmodified lines
1308 if (edev->max_supported) {1318 if (edev->max_supported) {
1309 kfree(edev->extcon_dev_type.groups);1319 kfree(edev->extcon_dev_type.groups);
1310 kfree(edev->cables);1320 kfree(edev->cables);
1321 kfree(edev->nh);
1311 }1322 }
1312 1323
1313 put_device(&edev->dev);1324 put_device(&edev->dev);
drivers/power/supply/axp288_charger.c+10−7
@@ -865,17 +865,20 @@ static int axp288_charger_probe(struct platform_device *pdev) · 864 unmodified lines
865 info->regmap_irqc = axp20x->regmap_irqc;865 info->regmap_irqc = axp20x->regmap_irqc;
866 866
867 info->cable.edev = extcon_get_extcon_dev(AXP288_EXTCON_DEV_NAME);867 info->cable.edev = extcon_get_extcon_dev(AXP288_EXTCON_DEV_NAME);
868 if (info->cable.edev == NULL) {868 if (IS_ERR(info->cable.edev)) {
869 dev_dbg(dev, "%s is not ready, probe deferred\n",869 dev_err_probe(dev, PTR_ERR(info->cable.edev),
870 AXP288_EXTCON_DEV_NAME);870 "extcon_get_extcon_dev(%s) failed\n",
871 return -EPROBE_DEFER;871 AXP288_EXTCON_DEV_NAME);
872 return PTR_ERR(info->cable.edev);
872 }873 }
873 874
874 if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1)) {875 if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1)) {
875 info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_NAME);876 info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_NAME);
876 if (info->otg.cable == NULL) {877 if (IS_ERR(info->otg.cable)) {
877 dev_dbg(dev, "EXTCON_USB_HOST is not ready, probe deferred\n");878 dev_err_probe(dev, PTR_ERR(info->otg.cable),
878 return -EPROBE_DEFER;879 "extcon_get_extcon_dev(%s) failed\n",
880 USB_HOST_EXTCON_NAME);
881 return PTR_ERR(info->otg.cable);
879 }882 }
880 dev_info(dev, "Using " USB_HOST_EXTCON_HID " extcon for usb-id\n");883 dev_info(dev, "Using " USB_HOST_EXTCON_HID " extcon for usb-id\n");
881 }884 }
drivers/power/supply/charger-manager.c+2−5
@@ -985,13 +985,10 @@ static int charger_extcon_init(struct charger_manager *cm, · 984 unmodified lines
985 cable->nb.notifier_call = charger_extcon_notifier;985 cable->nb.notifier_call = charger_extcon_notifier;
986 986
987 cable->extcon_dev = extcon_get_extcon_dev(cable->extcon_name);987 cable->extcon_dev = extcon_get_extcon_dev(cable->extcon_name);
988 if (IS_ERR_OR_NULL(cable->extcon_dev)) {988 if (IS_ERR(cable->extcon_dev)) {
989 pr_err("Cannot find extcon_dev for %s (cable: %s)\n",989 pr_err("Cannot find extcon_dev for %s (cable: %s)\n",
990 cable->extcon_name, cable->name);990 cable->extcon_name, cable->name);
991 if (cable->extcon_dev == NULL)991 return PTR_ERR(cable->extcon_dev);
992 return -EPROBE_DEFER;
993 else
994 return PTR_ERR(cable->extcon_dev);
995 }992 }
996 993
997 for (i = 0; i < ARRAY_SIZE(extcon_mapping); i++) {994 for (i = 0; i < ARRAY_SIZE(extcon_mapping); i++) {
drivers/power/supply/max8997_charger.c+4−4
@@ -242,10 +242,10 @@ static int max8997_battery_probe(struct platform_device *pdev) · 241 unmodified lines
242 dev_info(&pdev->dev, "couldn't get charger regulator\n");242 dev_info(&pdev->dev, "couldn't get charger regulator\n");
243 }243 }
244 charger->edev = extcon_get_extcon_dev("max8997-muic");244 charger->edev = extcon_get_extcon_dev("max8997-muic");
245 if (IS_ERR_OR_NULL(charger->edev)) {245 if (IS_ERR(charger->edev)) {
246 if (!charger->edev)246 dev_err_probe(charger->dev, PTR_ERR(charger->edev),
247 return -EPROBE_DEFER;247 "couldn't get extcon device: max8997-muic\n");
248 dev_info(charger->dev, "couldn't get extcon device\n");248 return PTR_ERR(charger->edev);
249 }249 }
250 250
251 if (!IS_ERR(charger->reg) && !IS_ERR_OR_NULL(charger->edev)) {251 if (!IS_ERR(charger->reg) && !IS_ERR_OR_NULL(charger->edev)) {
drivers/usb/dwc3/drd.c+2−7
@@ -455,13 +455,8 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) · 454 unmodified lines
455 * This device property is for kernel internal use only and455 * This device property is for kernel internal use only and
456 * is expected to be set by the glue code.456 * is expected to be set by the glue code.
457 */457 */
458 if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) {458 if (device_property_read_string(dev, "linux,extcon-name", &name) == 0)
459 edev = extcon_get_extcon_dev(name);459 return extcon_get_extcon_dev(name);
460 if (!edev)
461 return ERR_PTR(-EPROBE_DEFER);
462
463 return edev;
464 }
465 460
466 /*461 /*
467 * Try to get an extcon device from the USB PHY controller's "port"462 * Try to get an extcon device from the USB PHY controller's "port"
drivers/usb/phy/phy-omap-otg.c+2−2
@@ -95,8 +95,8 @@ static int omap_otg_probe(struct platform_device *pdev) · 94 unmodified lines
95 return -ENODEV;95 return -ENODEV;
96 96
97 extcon = extcon_get_extcon_dev(config->extcon);97 extcon = extcon_get_extcon_dev(config->extcon);
98 if (!extcon)98 if (IS_ERR(extcon))
99 return -EPROBE_DEFER;99 return PTR_ERR(extcon);
100 100
101 otg_dev = devm_kzalloc(&pdev->dev, sizeof(*otg_dev), GFP_KERNEL);101 otg_dev = devm_kzalloc(&pdev->dev, sizeof(*otg_dev), GFP_KERNEL);
102 if (!otg_dev)102 if (!otg_dev)
drivers/usb/typec/tcpm/fusb302.c+2−2
@@ -1708,8 +1708,8 @@ static int fusb302_probe(struct i2c_client *client, · 1707 unmodified lines
1708 */1708 */
1709 if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) {1709 if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) {
1710 chip->extcon = extcon_get_extcon_dev(name);1710 chip->extcon = extcon_get_extcon_dev(name);
1711 if (!chip->extcon)1711 if (IS_ERR(chip->extcon))
1712 return -EPROBE_DEFER;1712 return PTR_ERR(chip->extcon);
1713 }1713 }
1714 1714
1715 chip->vbus = devm_regulator_get(chip->dev, "vbus");1715 chip->vbus = devm_regulator_get(chip->dev, "vbus");
include/linux/extcon.h+1−1
@@ -296,7 +296,7 @@ static inline void devm_extcon_unregister_notifier_all(struct device *dev, · 295 unmodified lines
296 296
297static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)297static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
298{298{
299 return ERR_PTR(-ENODEV);299 return NULL;
300}300}
301 301
302static inline struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)302static inline struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t