public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Andrei Kuchynski <akuchynski@chromium.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
	Benson Leung <bleung@chromium.org>,
	Jameson Thies <jthies@google.com>,
	Tzung-Bi Shih <tzungbi@kernel.org>,
	linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev,
	Guenter Roeck <groeck@chromium.org>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	"Christian A. Ehrhardt" <lk@c--e.de>,
	Venkat Jayaraman <venkat.jayaraman@intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 5/5] usb: typec: Expose alternate mode priority via sysfs
Date: Wed, 10 Sep 2025 15:27:57 +0200	[thread overview]
Message-ID: <2025091028-darkish-washcloth-3d02@gregkh> (raw)
In-Reply-To: <20250905142206.4105351-6-akuchynski@chromium.org>

On Fri, Sep 05, 2025 at 02:22:06PM +0000, Andrei Kuchynski wrote:
> This patch introduces a priority sysfs attribute to the USB Type-C
> alternate mode port interface. This new attribute allows user-space to
> configure the numeric priority of alternate modes managing their preferred
> order of operation.
> 
> Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  Documentation/ABI/testing/sysfs-class-typec | 11 +++++++
>  drivers/usb/typec/class.c                   | 32 ++++++++++++++++++++-
>  2 files changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec
> index 38e101c17a00..dab3e4e727b6 100644
> --- a/Documentation/ABI/testing/sysfs-class-typec
> +++ b/Documentation/ABI/testing/sysfs-class-typec
> @@ -162,6 +162,17 @@ Description:	Lists the supported USB Modes. The default USB mode that is used
>  		- usb3 (USB 3.2)
>  		- usb4 (USB4)
>  
> +		What:		/sys/class/typec/<port>/<alt-mode>/priority
> +Date:		July 2025
> +Contact:	Andrei Kuchynski <akuchynski@chromium.org>
> +Description:
> +		Displays and allows setting the priority for a specific alt-mode.
> +		When read, it shows the current integer priority value. Lower numerical
> +		values indicate higher priority (0 is the highest priority).
> +		If the new value is already in use by another mode, the priority of the
> +		conflicting mode and any subsequent modes will be incremented until they
> +		are all unique.

What is the units here?  0 is highest, what is the lowest?  What is the
range here?  I can't determine this from the text, sorry.

> +
>  USB Type-C partner devices (eg. /sys/class/typec/port0-partner/)
>  
>  What:		/sys/class/typec/<port>-partner/accessory_mode
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 9f86605ce125..aaab2e1e98b4 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -19,6 +19,7 @@
>  #include "bus.h"
>  #include "class.h"
>  #include "pd.h"
> +#include "mode_selection.h"
>  
>  static DEFINE_IDA(typec_index_ida);
>  
> @@ -445,11 +446,34 @@ svid_show(struct device *dev, struct device_attribute *attr, char *buf)
>  }
>  static DEVICE_ATTR_RO(svid);
>  
> +static ssize_t priority_store(struct device *dev,
> +			       struct device_attribute *attr,
> +			       const char *buf, size_t size)
> +{
> +	unsigned int val;
> +	int err = kstrtouint(buf, 10, &val);
> +
> +	if (!err) {
> +		typec_mode_set_priority(to_typec_altmode(dev), val);
> +		return size;
> +	}
> +
> +	return err;
> +}
> +
> +static ssize_t priority_show(struct device *dev,
> +			      struct device_attribute *attr, char *buf)
> +{
> +	return sprintf(buf, "%u\n", to_typec_altmode(dev)->priority);

For new sysfs files, please use sysfs_emit(), otherwise someone will
come along with a janitorial patch to fix it up after it lands in the
tree :)

thanks,

greg k-h

  reply	other threads:[~2025-09-10 13:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 14:22 [PATCH v3 0/5] USB Type-C alternate mode priorities Andrei Kuchynski
2025-09-05 14:22 ` [PATCH v3 1/5] usb: typec: Add mode_control field to port property Andrei Kuchynski
2025-09-09  8:47   ` Heikki Krogerus
2025-09-10 13:30   ` Greg Kroah-Hartman
2025-09-10 19:34     ` Andrei Kuchynski
2025-09-05 14:22 ` [PATCH v3 2/5] platform/chrome: cros_ec_typec: Set no_mode_control flag Andrei Kuchynski
2025-09-08  3:57   ` Tzung-Bi Shih
2025-09-05 14:22 ` [PATCH v3 3/5] usb: typec: ucsi: " Andrei Kuchynski
2025-09-09  9:07   ` Heikki Krogerus
2025-09-09  9:22     ` Andrei Kuchynski
2025-09-10 19:36       ` Andrei Kuchynski
2025-09-05 14:22 ` [PATCH v3 4/5] usb: typec: Implement alternate mode priority handling Andrei Kuchynski
2025-09-09  8:50   ` Heikki Krogerus
2025-09-10 13:31   ` Greg Kroah-Hartman
2025-09-10 19:35     ` Andrei Kuchynski
2025-09-11  5:07       ` Greg Kroah-Hartman
2025-09-11  8:46         ` Andrei Kuchynski
2025-09-11 10:41           ` Greg Kroah-Hartman
2025-09-11 13:11             ` Andrei Kuchynski
2025-09-05 14:22 ` [PATCH v3 5/5] usb: typec: Expose alternate mode priority via sysfs Andrei Kuchynski
2025-09-10 13:27   ` Greg Kroah-Hartman [this message]
2025-09-10 19:34     ` Andrei Kuchynski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2025091028-darkish-washcloth-3d02@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=abhishekpandit@chromium.org \
    --cc=akuchynski@chromium.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=groeck@chromium.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jthies@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lk@c--e.de \
    --cc=tzungbi@kernel.org \
    --cc=venkat.jayaraman@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox