2022-02-09 10:08:23

by Prashant Malani

[permalink] [raw]
Subject: [PATCH v2 0/4] platform/chrome: cros_ec_typec: Reorganize mux configuration

This is a short series that reorganizes when mux configuration occurs
during Type C port updates. The first 2 patches are minor refactors
which move some of the mux update logic to within
cros_typec_configure_mux(). The third patch moves
cros_typec_configure_mux() itself to be earlier in
cros_typec_port_update().

The final patch updates the stashed mux flag when a partner removal has
occured.

v1:
https://lore.kernel.org/chrome-platform/[email protected]/

Changes in v2:
- Addressed minor comments (unrelated variable initialization. variable
name change, return value can be 0).

Prashant Malani (4):
platform/chrome: cros_ec_typec: Move mux flag checks
platform/chrome: cros_ec_typec: Get mux state inside configure_mux
platform/chrome: cros_ec_typec: Configure muxes at start of port
update
platform/chrome: cros_ec_typec: Update mux flags during partner
removal

drivers/platform/chrome/cros_ec_typec.c | 76 +++++++++++--------------
1 file changed, 34 insertions(+), 42 deletions(-)

--
2.35.0.263.gb82422642f-goog



2022-02-09 10:18:46

by Prashant Malani

[permalink] [raw]
Subject: [PATCH v2 1/4] platform/chrome: cros_ec_typec: Move mux flag checks

Move mux and role flag checks inside of cros_typec_configure_mux(),
which is a more logical location for them.

Signed-off-by: Prashant Malani <[email protected]>
---

Changes in v2:
- Removed unrelated "ret" variable initialization.

drivers/platform/chrome/cros_ec_typec.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index c6f17e3ef72d..58d08dd02f65 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -521,6 +521,13 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
enum typec_orientation orientation;
int ret;

+ /* No change needs to be made, let's exit early. */
+ if (port->mux_flags == mux_flags && port->role == pd_ctrl->role)
+ return 0;
+
+ port->mux_flags = mux_flags;
+ port->role = pd_ctrl->role;
+
if (mux_flags == USB_PD_MUX_NONE) {
ret = cros_typec_usb_disconnect_state(port);
goto mux_ack;
@@ -983,13 +990,6 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
return 0;
}

- /* No change needs to be made, let's exit early. */
- if (typec->ports[port_num]->mux_flags == mux_resp.flags &&
- typec->ports[port_num]->role == resp.role)
- return 0;
-
- typec->ports[port_num]->mux_flags = mux_resp.flags;
- typec->ports[port_num]->role = resp.role;
ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp);
if (ret)
dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret);
--
2.35.0.263.gb82422642f-goog


2022-02-09 11:32:45

by Prashant Malani

[permalink] [raw]
Subject: [PATCH v2 4/4] platform/chrome: cros_ec_typec: Update mux flags during partner removal

In cros_typec_remove_partner(), we call
cros_typec_usb_disconnect_state() which sets the switches/muxes to be in
a disconnected state. This also happens in cros_typec_configure_mux().
However, unlike there, here the mux_flags variable hasn't been updated
to reflect that a disconnection has occurred. Update the flag here
accordingly.

Signed-off-by: Prashant Malani <[email protected]>
---

Changes in v2:
- No changes.

drivers/platform/chrome/cros_ec_typec.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 3019e29f200d..4bd2752c0823 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -228,6 +228,7 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec,
cros_typec_unregister_altmodes(typec, port_num, true);

cros_typec_usb_disconnect_state(port);
+ port->mux_flags = USB_PD_MUX_NONE;

typec_unregister_partner(port->partner);
port->partner = NULL;
--
2.35.0.263.gb82422642f-goog


2022-02-09 12:11:02

by Tzung-Bi Shih

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] platform/chrome: cros_ec_typec: Move mux flag checks

On Tue, Feb 08, 2022 at 06:47:18PM +0000, Prashant Malani wrote:
> Move mux and role flag checks inside of cros_typec_configure_mux(),
> which is a more logical location for them.
>
> Signed-off-by: Prashant Malani <[email protected]>

Reviewed-by: Tzung-Bi Shih <[email protected]>

Subject: Re: [PATCH v2 0/4] platform/chrome: cros_ec_typec: Reorganize mux configuration

Hello:

This series was applied to chrome-platform/linux.git (for-kernelci)
by Prashant Malani <[email protected]>:

On Tue, 8 Feb 2022 18:47:16 +0000 you wrote:
> This is a short series that reorganizes when mux configuration occurs
> during Type C port updates. The first 2 patches are minor refactors
> which move some of the mux update logic to within
> cros_typec_configure_mux(). The third patch moves
> cros_typec_configure_mux() itself to be earlier in
> cros_typec_port_update().
>
> [...]

Here is the summary with links:
- [v2,1/4] platform/chrome: cros_ec_typec: Move mux flag checks
https://git.kernel.org/chrome-platform/c/53a0023c6450
- [v2,2/4] platform/chrome: cros_ec_typec: Get mux state inside configure_mux
https://git.kernel.org/chrome-platform/c/0d8495dc0321
- [v2,3/4] platform/chrome: cros_ec_typec: Configure muxes at start of port update
https://git.kernel.org/chrome-platform/c/af34f115b3b7
- [v2,4/4] platform/chrome: cros_ec_typec: Update mux flags during partner removal
https://git.kernel.org/chrome-platform/c/b579f139e470

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


Subject: Re: [PATCH v2 0/4] platform/chrome: cros_ec_typec: Reorganize mux configuration

Hello:

This series was applied to chrome-platform/linux.git (for-next)
by Prashant Malani <[email protected]>:

On Tue, 8 Feb 2022 18:47:16 +0000 you wrote:
> This is a short series that reorganizes when mux configuration occurs
> during Type C port updates. The first 2 patches are minor refactors
> which move some of the mux update logic to within
> cros_typec_configure_mux(). The third patch moves
> cros_typec_configure_mux() itself to be earlier in
> cros_typec_port_update().
>
> [...]

Here is the summary with links:
- [v2,1/4] platform/chrome: cros_ec_typec: Move mux flag checks
https://git.kernel.org/chrome-platform/c/53a0023c6450
- [v2,2/4] platform/chrome: cros_ec_typec: Get mux state inside configure_mux
https://git.kernel.org/chrome-platform/c/0d8495dc0321
- [v2,3/4] platform/chrome: cros_ec_typec: Configure muxes at start of port update
https://git.kernel.org/chrome-platform/c/af34f115b3b7
- [v2,4/4] platform/chrome: cros_ec_typec: Update mux flags during partner removal
https://git.kernel.org/chrome-platform/c/b579f139e470

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html