lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aKb_rwVqqzipHHqf@kuha.fi.intel.com>
Date: Thu, 21 Aug 2025 14:14:55 +0300
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Andrei Kuchynski <akuchynski@...omium.org>
Cc: Abhishek Pandit-Subedi <abhishekpandit@...omium.org>,
	Benson Leung <bleung@...omium.org>,
	Jameson Thies <jthies@...gle.com>,
	Tzung-Bi Shih <tzungbi@...nel.org>, linux-usb@...r.kernel.org,
	chrome-platform@...ts.linux.dev,
	Guenter Roeck <groeck@...omium.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>,
	"Christian A. Ehrhardt" <lk@...e.de>,
	Venkat Jayaraman <venkat.jayaraman@...el.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 4/5] usb: typec: Implement alternate mode priority
 handling

Hi again,

On Thu, Aug 21, 2025 at 01:09:57PM +0300, Heikki Krogerus wrote:
> > diff --git a/drivers/usb/typec/mode_selection.c b/drivers/usb/typec/mode_selection.c
> > new file mode 100644
> > index 000000000000..8a54639b86bf
> > --- /dev/null
> > +++ b/drivers/usb/typec/mode_selection.c
> > @@ -0,0 +1,127 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright 2025 Google LLC.
> > + */
> > +
> > +#include <linux/usb/typec_altmode.h>
> > +#include <linux/slab.h>
> > +#include <linux/list.h>
> > +#include "mode_selection.h"
> > +#include "class.h"
> > +
> > +static const char * const mode_names[TYPEC_ALTMODE_MAX] = {
> > +	[TYPEC_ALTMODE_DP] = "DisplayPort",
> > +	[TYPEC_ALTMODE_TBT] = "Thunderbolt3",
> > +	[TYPEC_ALTMODE_USB4] = "USB4",
> > +};
> 
> You only need string for USB4. The altmode names come from the drivers.

Sorry, that won't work with port altmode. But you can still do the
lookup with just the sid.

<snip>

> > +/* -------------------------------------------------------------------------- */
> > +/* port 'mode_priorities' attribute */
> > +
> > +int typec_mode_set_priority(struct typec_altmode *adev, const int priority)
> > +{
> > +	struct typec_port *port = to_typec_port(adev->dev.parent);
> > +	const enum typec_mode_type mode = typec_svid_to_altmode(adev->svid);
> > +	struct mode_selection_state *ms_target = NULL;
> > +	struct mode_selection_state *ms, *tmp;
> > +
> > +	if (mode >= TYPEC_ALTMODE_MAX || !mode_names[mode])
> > +		return -EOPNOTSUPP;
> 
> Just support every altmode bind to a driver and USB4. USB4 you
> identify with a specific usb4 device type.

No driver so you would need to use the mode_names, but instead of
doing that, just don't limit this at all.

If there is no name for the mode, use the svid.

thanks,

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ