History log of /openbmc/linux/drivers/extcon/extcon.c (Results 1 – 25 of 156)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: v6.6.25, v6.6.24, v6.6.23, v6.6.16, v6.6.15, v6.6.14, v6.6.13, v6.6.12, v6.6.11, v6.6.10, v6.6.9, v6.6.8, v6.6.7, v6.6.6, v6.6.5, v6.6.4, v6.6.3
# 8b755fc7 23-Nov-2023 Yaxiong Tian <tianyaxiong@kylinos.cn>

extcon: fix possible name leak in extcon_dev_register()

[ Upstream commit e66523c72c9aae0ff0dae6859eb77b04de1e8e5f ]

In the error path after calling dev_set_name(), the device
name is leaked. To fi

extcon: fix possible name leak in extcon_dev_register()

[ Upstream commit e66523c72c9aae0ff0dae6859eb77b04de1e8e5f ]

In the error path after calling dev_set_name(), the device
name is leaked. To fix this, moving dev_set_name() after the
error path and before device_register.

Link: https://lore.kernel.org/lkml/TYZPR01MB4784ADCD3E951E0863F3DB72D5B8A@TYZPR01MB4784.apcprd01.prod.exchangelabs.com/
Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

show more ...


Revision tags: v6.6.2, v6.5.11, v6.6.1, v6.5.10, v6.6, v6.5.9, v6.5.8, v6.5.7, v6.5.6, v6.5.5, v6.5.4, v6.5.3, v6.5.2, v6.1.51, v6.5.1, v6.1.50, v6.5, v6.1.49, v6.1.48, v6.1.46, v6.1.45, v6.1.44, v6.1.43, v6.1.42, v6.1.41, v6.1.40, v6.1.39, v6.1.38, v6.1.37, v6.1.36, v6.4, v6.1.35, v6.1.34, v6.1.33, v6.1.32, v6.1.31, v6.1.30, v6.1.29, v6.1.28, v6.1.27, v6.1.26, v6.3, v6.1.25, v6.1.24
# 93e60cd5 11-Apr-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Drop unneeded assignments

In one case the assignment is duplicative, in the other,
it's better to move it into the loop — the user of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@l

extcon: Drop unneeded assignments

In one case the assignment is duplicative, in the other,
it's better to move it into the loop — the user of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# ef753fb4 11-Apr-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Use sizeof(*pointer) instead of sizeof(type)

It is preferred to use sizeof(*pointer) instead of sizeof(type).
The type of the variable can change and one needs not change
the former (unlike

extcon: Use sizeof(*pointer) instead of sizeof(type)

It is preferred to use sizeof(*pointer) instead of sizeof(type).
The type of the variable can change and one needs not change
the former (unlike the latter). No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 7bba9e81 11-Apr-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Use unique number for the extcon device ID

The use of atomic variable is still racy when we do not control which
device has been unregistered and there is a (theoretical) possibility
of the

extcon: Use unique number for the extcon device ID

The use of atomic variable is still racy when we do not control which
device has been unregistered and there is a (theoretical) possibility
of the overflow that may cause a duplicate extcon device ID number
to be allocated next time a device is registered.

Replace above mentioned approach by using IDA framework.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


Revision tags: v6.1.23, v6.1.22
# 566825a3 22-Mar-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Remove dup device name in the message and unneeded error check

The device name is already printed with dev_err(), no need to repeat.
The device pointer itself is not supposed to be an error

extcon: Remove dup device name in the message and unneeded error check

The device name is already printed with dev_err(), no need to repeat.
The device pointer itself is not supposed to be an error point, drop
that check.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 9b4aea51 22-Mar-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Use dev_of_node(dev) instead of dev->of_node

The dev_of_node function should be preferred.
In the result we may drop unneeded NULL check
of the pointer to the device object.

Signed-off-by:

extcon: Use dev_of_node(dev) instead of dev->of_node

The dev_of_node function should be preferred.
In the result we may drop unneeded NULL check
of the pointer to the device object.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 0146f56b 22-Mar-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Use device_match_of_node() helper

Instead of open coding, use device_match_of_node() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <

extcon: Use device_match_of_node() helper

Instead of open coding, use device_match_of_node() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 6ee0a22e 22-Mar-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Use sysfs_emit() to instead of sprintf()

Follow the advice of the Documentation/filesystems/sysfs.rst that
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to

extcon: Use sysfs_emit() to instead of sprintf()

Follow the advice of the Documentation/filesystems/sysfs.rst that
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 6e4e8670 22-Mar-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Use DECLARE_BITMAP() to declare bit arrays

Bit arrays has a specific type helper for the declaration.
Use it instead of homegronw equivalent.

Signed-off-by: Andy Shevchenko <andriy.shevchen

extcon: Use DECLARE_BITMAP() to declare bit arrays

Bit arrays has a specific type helper for the declaration.
Use it instead of homegronw equivalent.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 73346b99 22-Mar-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Fix kernel doc of property capability fields to avoid warnings

Kernel documentation has to be synchronized with a code, otherwise
the validator is not happy:

Function parameter or memb

extcon: Fix kernel doc of property capability fields to avoid warnings

Kernel documentation has to be synchronized with a code, otherwise
the validator is not happy:

Function parameter or member 'usb_bits' not described in 'extcon_cable'
Function parameter or member 'chg_bits' not described in 'extcon_cable'
Function parameter or member 'jack_bits' not described in 'extcon_cable'
Function parameter or member 'disp_bits' not described in 'extcon_cable'

Describe the fields added in the past.

Fixes: ceaa98f442cf ("extcon: Add the support for the capability of each property")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 7e77e0b7 22-Mar-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: Fix kernel doc of property fields to avoid warnings

Kernel documentation has to be synchronized with a code, otherwise
the validator is not happy:

Function parameter or member 'usb_pro

extcon: Fix kernel doc of property fields to avoid warnings

Kernel documentation has to be synchronized with a code, otherwise
the validator is not happy:

Function parameter or member 'usb_propval' not described in 'extcon_cable'
Function parameter or member 'chg_propval' not described in 'extcon_cable'
Function parameter or member 'jack_propval' not described in 'extcon_cable'
Function parameter or member 'disp_propval' not described in 'extcon_cable'

Describe the fields added in the past.

Fixes: 067c1652e7a7 ("extcon: Add the support for extcon property according to extcon type")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


Revision tags: v6.1.21
# 04151575 19-Mar-2023 Bumwoo Lee <bw365.lee@samsung.com>

extcon: Add extcon_alloc_groups to simplify extcon register function

The alloc groups is functionalized from extcon_dev_register.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
Acked-by: MyungJo

extcon: Add extcon_alloc_groups to simplify extcon register function

The alloc groups is functionalized from extcon_dev_register.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 3e70a014 19-Mar-2023 Bumwoo Lee <bw365.lee@samsung.com>

extcon: Add extcon_alloc_muex to simplify extcon register function

The mutual exclusive part is functionalized from extcon_dev_register.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
Acked-by:

extcon: Add extcon_alloc_muex to simplify extcon register function

The mutual exclusive part is functionalized from extcon_dev_register.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 3d9138e5 19-Mar-2023 Bumwoo Lee <bw365.lee@samsung.com>

extcon: Add extcon_alloc_cables to simplify extcon register function

The cable allocation part is functionalized from extcon_dev_register.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
Acked-by

extcon: Add extcon_alloc_cables to simplify extcon register function

The cable allocation part is functionalized from extcon_dev_register.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


Revision tags: v6.1.20, v6.1.19, v6.1.18, v6.1.17, v6.1.16, v6.1.15
# 7f4c9bc2 02-Mar-2023 Bumwoo Lee <bw365.lee@samsung.com>

extcon: Remove redundant null checking for class

create_extcon_class() is already Null checking.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com
S

extcon: Remove redundant null checking for class

create_extcon_class() is already Null checking.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 1aaba11d 13-Mar-2023 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

driver core: class: remove module * from class_create()

The module pointer in class_create() never actually did anything, and it
shouldn't have been requred to be set as a parameter even if it did
s

driver core: class: remove module * from class_create()

The module pointer in class_create() never actually did anything, and it
shouldn't have been requred to be set as a parameter even if it did
something. So just remove it and fix up all callers of the function in
the kernel tree at the same time.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20230313181843.1207845-4-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...


Revision tags: v6.1.14, v6.1.13, v6.2, v6.1.12, v6.1.11, v6.1.10, v6.1.9, v6.1.8, v6.1.7, v6.1.6, v6.1.5, v6.0.19, v6.0.18, v6.1.4, v6.1.3, v6.0.17, v6.1.2, v6.0.16, v6.1.1, v6.0.15, v6.0.14, v6.0.13, v6.1, v6.0.12, v6.0.11, v6.0.10, v5.15.80, v6.0.9, v5.15.79, v6.0.8, v5.15.78, v6.0.7, v5.15.77, v5.15.76, v6.0.6, v6.0.5, v5.15.75, v6.0.4, v6.0.3, v6.0.2, v5.15.74, v5.15.73, v6.0.1, v5.15.72, v6.0, v5.15.71, v5.15.70, v5.15.69, v5.15.68, v5.15.67, v5.15.66, v5.15.65, v5.15.64, v5.15.63, v5.15.62, v5.15.61, v5.15.60, v5.15.59, v5.19, v5.15.58, v5.15.57, v5.15.56, v5.15.55, v5.15.54
# 3a06ed80 08-Jul-2022 Michael Wu <michael@allwinnertech.com>

extcon: Add EXTCON_DISP_CVBS and EXTCON_DISP_EDP

Add EXTCON_DISP_CVBS for Composite Video Broadcast Signal.
Add EXTCON_DISP_EDP for Embedded Display Port

[1] https://en.wikipedia.org/wiki/Composite

extcon: Add EXTCON_DISP_CVBS and EXTCON_DISP_EDP

Add EXTCON_DISP_CVBS for Composite Video Broadcast Signal.
Add EXTCON_DISP_EDP for Embedded Display Port

[1] https://en.wikipedia.org/wiki/Composite_video
[2] https://en.wikipedia.org/wiki/DisplayPort#eDP

Signed-off-by: Michael Wu <michael@allwinnertech.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


Revision tags: v5.15.53, v5.15.52, v5.15.51, v5.15.50, v5.15.49
# 97e1bb93 21-Jun-2022 Jiang Jian <jiangjian@cdjrlc.com>

extcon: Drop unexpected word "the" in the comments

there is an unexpected word "the" in the comments that need to be dropped

file: ./drivers/extcon/extcon.c
line: 250

/* Find the the index of extc

extcon: Drop unexpected word "the" in the comments

there is an unexpected word "the" in the comments that need to be dropped

file: ./drivers/extcon/extcon.c
line: 250

/* Find the the index of extcon cable in edev->supported_cable */
changed to
/* Find the index of extcon cable in edev->supported_cable */

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


Revision tags: v5.15.48, v5.15.47, v5.15.46, v5.15.45, v5.15.44, v5.15.43, v5.15.42, v5.18, v5.15.41, v5.15.40, v5.15.39, v5.15.38, v5.15.37, v5.15.36
# 5dcc2afe 26-Apr-2022 bumwoo lee <bw365.lee@samsung.com>

extcon: Modify extcon device to be created after driver data is set

Currently, someone can invoke the sysfs such as state_show()
intermittently before dev_set_drvdata() is done.
And it can be a caus

extcon: Modify extcon device to be created after driver data is set

Currently, someone can invoke the sysfs such as state_show()
intermittently before dev_set_drvdata() is done.
And it can be a cause of kernel Oops because of edev is Null at that time.
So modified the driver registration to after setting drviver data.

- Oops's backtrace.

Backtrace:
[<c067865c>] (state_show) from [<c05222e8>] (dev_attr_show)
[<c05222c0>] (dev_attr_show) from [<c02c66e0>] (sysfs_kf_seq_show)
[<c02c6648>] (sysfs_kf_seq_show) from [<c02c496c>] (kernfs_seq_show)
[<c02c4938>] (kernfs_seq_show) from [<c025e2a0>] (seq_read)
[<c025e11c>] (seq_read) from [<c02c50a0>] (kernfs_fop_read)
[<c02c5064>] (kernfs_fop_read) from [<c0231cac>] (__vfs_read)
[<c0231c5c>] (__vfs_read) from [<c0231ee0>] (vfs_read)
[<c0231e34>] (vfs_read) from [<c0232464>] (ksys_read)
[<c02323f0>] (ksys_read) from [<c02324fc>] (sys_read)
[<c02324e4>] (sys_read) from [<c00091d0>] (__sys_trace_return)

Signed-off-by: bumwoo lee <bw365.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


Revision tags: v5.15.35, v5.15.34, v5.15.33, v5.15.32, v5.15.31, v5.17, v5.15.30, v5.15.29, v5.15.28, v5.15.27, v5.15.26, v5.15.25, v5.15.24, v5.15.23, v5.15.22, v5.15.21, v5.15.20, v5.15.19, v5.15.18, v5.15.17, v5.4.173, v5.15.16, v5.15.15, v5.16
# 6506f6a0 04-Jan-2022 Yang Li <yang.lee@linux.alibaba.com>

extcon: Fix some kernel-doc comments

Add the description of @id in extcon_sync() kernel-doc comment
and @edev, @id, @prop in extcon_set_property_sync() kernel-doc
comment to remove warnings found by

extcon: Fix some kernel-doc comments

Add the description of @id in extcon_sync() kernel-doc comment
and @edev, @id, @prop in extcon_set_property_sync() kernel-doc
comment to remove warnings found by running scripts/kernel-doc,
which is caused by using 'make W=1'.
drivers/extcon/extcon.c:409: warning: Function parameter or
member 'id' not described in 'extcon_sync'
drivers/extcon/extcon.c:750: warning: Function parameter or
member 'edev' not described in 'extcon_set_property_sync'
drivers/extcon/extcon.c:750: warning: Function parameter or
member 'id' not described in 'extcon_set_property_sync'
drivers/extcon/extcon.c:750: warning: Function parameter or
member 'prop' not described in 'extcon_set_property_sync'

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


Revision tags: v5.15.10
# 58e4a2d2 17-Dec-2021 Dan Carpenter <dan.carpenter@oracle.com>

extcon: Fix extcon_get_extcon_dev() error handling

The extcon_get_extcon_dev() function returns error pointers on error,
NULL when it's a -EPROBE_DEFER defer situation, and ERR_PTR(-ENODEV)
when the

extcon: Fix extcon_get_extcon_dev() error handling

The extcon_get_extcon_dev() function returns error pointers on error,
NULL when it's a -EPROBE_DEFER defer situation, and ERR_PTR(-ENODEV)
when the CONFIG_EXTCON option is disabled. This is very complicated for
the callers to handle and a number of them had bugs that would lead to
an Oops.

In real life, there are two things which prevented crashes. First,
error pointers would only be returned if there was bug in the caller
where they passed a NULL "extcon_name" and none of them do that.
Second, only two out of the eight drivers will build when CONFIG_EXTCON
is disabled.

The normal way to write this would be to return -EPROBE_DEFER directly
when appropriate and return NULL when CONFIG_EXTCON is disabled. Then
the error handling is simple and just looks like:

dev->edev = extcon_get_extcon_dev(acpi_dev_name(adev));
if (IS_ERR(dev->edev))
return PTR_ERR(dev->edev);

For the two drivers which can build with CONFIG_EXTCON disabled, then
extcon_get_extcon_dev() will now return NULL which is not treated as an
error and the probe will continue successfully. Those two drivers are
"typec_fusb302" and "max8997-battery". In the original code, the
typec_fusb302 driver had an 800ms hang in tcpm_get_current_limit() but
now that function is a no-op. For the max8997-battery driver everything
should continue working as is.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


Revision tags: v5.15.9, v5.15.8, v5.15.7, v5.15.6, v5.15.5
# 2da3db7f 23-Nov-2021 Alexander Stein <alexander.stein@ew.tq-group.com>

extcon: Deduplicate code in extcon_set_state_sync()

Finding the cable index and checking for changed status is also done
in extcon_set_state(). So calling extcon_set_state_sync() will do these
check

extcon: Deduplicate code in extcon_set_state_sync()

Finding the cable index and checking for changed status is also done
in extcon_set_state(). So calling extcon_set_state_sync() will do these
checks twice. Remove them and use these checks from extcon_set_state().

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

show more ...


# 368e68ad 26-Apr-2022 bumwoo lee <bw365.lee@samsung.com>

extcon: Modify extcon device to be created after driver data is set

[ Upstream commit 5dcc2afe716d69f5112ce035cb14f007461ff189 ]

Currently, someone can invoke the sysfs such as state_show()
intermi

extcon: Modify extcon device to be created after driver data is set

[ Upstream commit 5dcc2afe716d69f5112ce035cb14f007461ff189 ]

Currently, someone can invoke the sysfs such as state_show()
intermittently before dev_set_drvdata() is done.
And it can be a cause of kernel Oops because of edev is Null at that time.
So modified the driver registration to after setting drviver data.

- Oops's backtrace.

Backtrace:
[<c067865c>] (state_show) from [<c05222e8>] (dev_attr_show)
[<c05222c0>] (dev_attr_show) from [<c02c66e0>] (sysfs_kf_seq_show)
[<c02c6648>] (sysfs_kf_seq_show) from [<c02c496c>] (kernfs_seq_show)
[<c02c4938>] (kernfs_seq_show) from [<c025e2a0>] (seq_read)
[<c025e11c>] (seq_read) from [<c02c50a0>] (kernfs_fop_read)
[<c02c5064>] (kernfs_fop_read) from [<c0231cac>] (__vfs_read)
[<c0231c5c>] (__vfs_read) from [<c0231ee0>] (vfs_read)
[<c0231e34>] (vfs_read) from [<c0232464>] (ksys_read)
[<c02323f0>] (ksys_read) from [<c02324fc>] (sys_read)
[<c02324e4>] (sys_read) from [<c00091d0>] (__sys_trace_return)

Signed-off-by: bumwoo lee <bw365.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

show more ...


# 4785574f 17-Dec-2021 Dan Carpenter <dan.carpenter@oracle.com>

extcon: Fix extcon_get_extcon_dev() error handling

[ Upstream commit 58e4a2d27d3255e4e8c507fdc13734dccc9fc4c7 ]

The extcon_get_extcon_dev() function returns error pointers on error,
NULL when it's

extcon: Fix extcon_get_extcon_dev() error handling

[ Upstream commit 58e4a2d27d3255e4e8c507fdc13734dccc9fc4c7 ]

The extcon_get_extcon_dev() function returns error pointers on error,
NULL when it's a -EPROBE_DEFER defer situation, and ERR_PTR(-ENODEV)
when the CONFIG_EXTCON option is disabled. This is very complicated for
the callers to handle and a number of them had bugs that would lead to
an Oops.

In real life, there are two things which prevented crashes. First,
error pointers would only be returned if there was bug in the caller
where they passed a NULL "extcon_name" and none of them do that.
Second, only two out of the eight drivers will build when CONFIG_EXTCON
is disabled.

The normal way to write this would be to return -EPROBE_DEFER directly
when appropriate and return NULL when CONFIG_EXTCON is disabled. Then
the error handling is simple and just looks like:

dev->edev = extcon_get_extcon_dev(acpi_dev_name(adev));
if (IS_ERR(dev->edev))
return PTR_ERR(dev->edev);

For the two drivers which can build with CONFIG_EXTCON disabled, then
extcon_get_extcon_dev() will now return NULL which is not treated as an
error and the probe will continue successfully. Those two drivers are
"typec_fusb302" and "max8997-battery". In the original code, the
typec_fusb302 driver had an 800ms hang in tcpm_get_current_limit() but
now that function is a no-op. For the max8997-battery driver everything
should continue working as is.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

show more ...


# 368e68ad 26-Apr-2022 bumwoo lee <bw365.lee@samsung.com>

extcon: Modify extcon device to be created after driver data is set

[ Upstream commit 5dcc2afe716d69f5112ce035cb14f007461ff189 ]

Currently, someone can invoke the sysfs such as state_show()
intermi

extcon: Modify extcon device to be created after driver data is set

[ Upstream commit 5dcc2afe716d69f5112ce035cb14f007461ff189 ]

Currently, someone can invoke the sysfs such as state_show()
intermittently before dev_set_drvdata() is done.
And it can be a cause of kernel Oops because of edev is Null at that time.
So modified the driver registration to after setting drviver data.

- Oops's backtrace.

Backtrace:
[<c067865c>] (state_show) from [<c05222e8>] (dev_attr_show)
[<c05222c0>] (dev_attr_show) from [<c02c66e0>] (sysfs_kf_seq_show)
[<c02c6648>] (sysfs_kf_seq_show) from [<c02c496c>] (kernfs_seq_show)
[<c02c4938>] (kernfs_seq_show) from [<c025e2a0>] (seq_read)
[<c025e11c>] (seq_read) from [<c02c50a0>] (kernfs_fop_read)
[<c02c5064>] (kernfs_fop_read) from [<c0231cac>] (__vfs_read)
[<c0231c5c>] (__vfs_read) from [<c0231ee0>] (vfs_read)
[<c0231e34>] (vfs_read) from [<c0232464>] (ksys_read)
[<c02323f0>] (ksys_read) from [<c02324fc>] (sys_read)
[<c02324e4>] (sys_read) from [<c00091d0>] (__sys_trace_return)

Signed-off-by: bumwoo lee <bw365.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

show more ...


1234567