2023-05-26 13:23:43

by Heikki Krogerus

[permalink] [raw]
Subject: [PATCH v2 0/2] usb: typec: mux: Remove the "svid" device property checks

Hi,

The comment in the first patch is now fixed as requested by Bjorn. No
other changes compared to v1.

Original message:

The background for this change:
https://lore.kernel.org/lkml/[email protected]/

The idea with that device property was that it would allow us to
support separate mode specific switches behind a single port if
necessary.

Although, I guess it is still possible that we could have that kind of
separate mode switches, especially now that the mode switch represents
a kind of virtual aggregate device that can be build from multiple
physical muxes (so the modes could need different "combos" of the
muxes), but now no such systems exist.

We can look at how to handle that kind of switches when/if we actually
have them, but for now, keeping the functions as simple as possible.

thanks,

Heikki Krogerus (2):
usb: typec: mux: Clean up mux_fwnode_match()
usb: typec: mux: Remove alt mode parameters from the API

drivers/platform/chrome/cros_ec_typec.c | 2 +-
drivers/soc/qcom/pmic_glink_altmode.c | 5 +-
drivers/usb/typec/class.c | 4 +-
drivers/usb/typec/mux.c | 61 ++++---------------------
include/linux/usb/typec_mux.h | 11 ++---
5 files changed, 17 insertions(+), 66 deletions(-)

--
2.39.2



2023-05-26 13:24:52

by Heikki Krogerus

[permalink] [raw]
Subject: [PATCH v2 1/2] usb: typec: mux: Clean up mux_fwnode_match()

Removing the "svid" and "accessory" device property checks.
Those properties are not supported on any platform.

Signed-off-by: Heikki Krogerus <[email protected]>
Link: https://lore.kernel.org/lkml/20230522215348.uoyboow26n2o3tel@ripper/
Reviewed-by: Bjorn Andersson <[email protected]>
Tested-by: Bjorn Andersson <[email protected]>
---
v2: Fixed the comment as requested by Bjorn.

drivers/usb/typec/mux.c | 55 ++++++-----------------------------------
1 file changed, 7 insertions(+), 48 deletions(-)

diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index d9eaf9a0b0bfd..f2eee6322815d 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -265,60 +265,19 @@ static int mux_fwnode_match(struct device *dev, const void *fwnode)
static void *typec_mux_match(const struct fwnode_handle *fwnode,
const char *id, void *data)
{
- const struct typec_altmode_desc *desc = data;
struct device *dev;
- bool match;
- int nval;
- u16 *val;
- int ret;
- int i;

/*
- * Check has the identifier already been "consumed". If it
- * has, no need to do any extra connection identification.
+ * Device graph (OF graph) does not give any means to identify the
+ * device type or the device class of the remote port parent that @fwnode
+ * represents, so in order to identify the type or the class of @fwnode
+ * an additional device property is needed. With typec muxes the
+ * property is named "mode-switch" (@id). The value of the device
+ * property is ignored.
*/
- match = !id;
- if (match)
- goto find_mux;
-
- if (!desc) {
- /*
- * Accessory Mode muxes & muxes which explicitly specify
- * the required identifier can avoid SVID matching.
- */
- match = fwnode_property_present(fwnode, "accessory") ||
- fwnode_property_present(fwnode, id);
- if (match)
- goto find_mux;
- return NULL;
- }
-
- /* Alternate Mode muxes */
- nval = fwnode_property_count_u16(fwnode, "svid");
- if (nval <= 0)
+ if (id && !fwnode_property_present(fwnode, id))
return NULL;

- val = kcalloc(nval, sizeof(*val), GFP_KERNEL);
- if (!val)
- return ERR_PTR(-ENOMEM);
-
- ret = fwnode_property_read_u16_array(fwnode, "svid", val, nval);
- if (ret < 0) {
- kfree(val);
- return ERR_PTR(ret);
- }
-
- for (i = 0; i < nval; i++) {
- match = val[i] == desc->svid;
- if (match) {
- kfree(val);
- goto find_mux;
- }
- }
- kfree(val);
- return NULL;
-
-find_mux:
dev = class_find_device(&typec_mux_class, NULL, fwnode,
mux_fwnode_match);

--
2.39.2


Subject: Re: [PATCH v2 0/2] usb: typec: mux: Remove the "svid" device property checks

Hello:

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

On Fri, 26 May 2023 16:14:32 +0300 you wrote:
> Hi,
>
> The comment in the first patch is now fixed as requested by Bjorn. No
> other changes compared to v1.
>
> Original message:
>
> [...]

Here is the summary with links:
- [v2,1/2] usb: typec: mux: Clean up mux_fwnode_match()
https://git.kernel.org/chrome-platform/c/4aebc4f89f00
- [v2,2/2] usb: typec: mux: Remove alt mode parameters from the API
https://git.kernel.org/chrome-platform/c/3524fe31538c

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/2] usb: typec: mux: Remove the "svid" device property checks

Hello:

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

On Fri, 26 May 2023 16:14:32 +0300 you wrote:
> Hi,
>
> The comment in the first patch is now fixed as requested by Bjorn. No
> other changes compared to v1.
>
> Original message:
>
> [...]

Here is the summary with links:
- [v2,1/2] usb: typec: mux: Clean up mux_fwnode_match()
https://git.kernel.org/chrome-platform/c/4aebc4f89f00
- [v2,2/2] usb: typec: mux: Remove alt mode parameters from the API
https://git.kernel.org/chrome-platform/c/3524fe31538c

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