From patchwork Sun Sep 3 21:41:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13373377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A07B8CA0FFF for ; Sun, 3 Sep 2023 21:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234657AbjICVmU (ORCPT ); Sun, 3 Sep 2023 17:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349070AbjICVmE (ORCPT ); Sun, 3 Sep 2023 17:42:04 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8096115 for ; Sun, 3 Sep 2023 14:41:58 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-500b0f06136so1542360e87.0 for ; Sun, 03 Sep 2023 14:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693777317; x=1694382117; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SWHSZWaKhvE1MjysmoYq2syAfT9CG/PqkkscIEqVNT4=; b=OFGjRw15uVSbGAp4yu9zzgtzGPg8+T2glIgwMKBNEypXFfvXXOMCnXcBGmXfmdDOzO 846sonlFk704L2Ont7y+SWa0ldpFMcmfi1KaqGgBo9Ys5Sb0WiaOqIM+x+DpTMldQ47Q XX1CO0+/O3bNgKf7pOJv//hNpwgjyxsV0k69x+awp/1KtBj+SBhnl1l7LoUGoab88l4L XsOuZkzMTTWzgLk0fgjlPPC66W9V7bQi1pM2e8nwJKYSeFf+tDEveGjtCDi94zRlcFBw OfPz+/YXry+rIC48tGl97KlcSfbSrzjxOuszKPovZvpEr1vzMtnNAicxd1dCPj7jTYM7 y9wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693777317; x=1694382117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SWHSZWaKhvE1MjysmoYq2syAfT9CG/PqkkscIEqVNT4=; b=EM+je7lwZ2XrNrxwgDxHH3oOxZ9qBnH2BFwmAw987mWr9RzKOx25d92X4SHzx0TyMA 0gL1JLkG6UIs3CFiU5OlVrwlDohDIjZLFw3fxNOAzsorEr6QW52R6CbUvbB0XCEl+sni K2xhvzpw++WdUtz3gRfZ/R3KHp11Fy079HKQ4OVSBIorFZGwHN0s3gE3qDuoDM3TzBzv 2m9XodVeKK35r01D0IVf/UWs/oxtnXdUgfNCUHC2IophFgMf5K8wUeD/vd/wfXE3k6U5 VKaNdRaaN76Itft3RO+miY0xhIKVrLwCLCfAxVGJE/8Fp0dXCpXs6vwGQwx8CLQokZTL c2eQ== X-Gm-Message-State: AOJu0Yzxblo5etSLXInRCfgXVouqwpk1roFSSqqHVGJuKQz/sA6SYp0l 1AXFIYAQ/vZThXRKckLJXTYeWg== X-Google-Smtp-Source: AGHT+IHdP+cCSWTvD+87l9JrZmPVTmSpURuy7YzU/9ihGfD9uR1Aa2DcxlQZlNBD7Tvco0iNQQ5Pmw== X-Received: by 2002:a05:6512:2247:b0:500:7dcc:621 with SMTP id i7-20020a056512224700b005007dcc0621mr6544464lfu.31.1693777317228; Sun, 03 Sep 2023 14:41:57 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id x17-20020ac25dd1000000b004f8555f7aa1sm1422506lfq.52.2023.09.03.14.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Sep 2023 14:41:56 -0700 (PDT) From: Dmitry Baryshkov To: David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , "Bryan O'Donoghue" , Guenter Roeck , Heikki Krogerus , Janne Grunau , Simon Ser , Andy Gross , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [RFC PATCH v1 08/12] usb: typec: support generating Type-C port names for userspace Date: Mon, 4 Sep 2023 00:41:46 +0300 Message-Id: <20230903214150.2877023-9-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230903214150.2877023-1-dmitry.baryshkov@linaro.org> References: <20230903214150.2877023-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org We need a way to generate and return the Type-C port device names. For example, it is going to be used by the DRM to provide PATH property for DisplayPort connectors. Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/class.c | 14 ++++++++++++++ include/linux/usb/typec.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 9c1dbf3c00e0..7394a2ecef6f 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -2327,6 +2327,20 @@ void typec_unregister_port(struct typec_port *port) } EXPORT_SYMBOL_GPL(typec_unregister_port); +/** + * typec_port_get_name - Get USB Type-C Port name + * @port: The port to describe + * + * Returns a name of the passed USB Type-C port on success or NULL when the + * port has not been enumerated yet. The resulting string should be freed by + * the caller. + */ +char *typec_port_get_name(struct typec_port *port) +{ + return kasprintf(GFP_KERNEL, "typec:%s", dev_name(&port->dev)); +} +EXPORT_SYMBOL_GPL(typec_port_get_name); + static int __init typec_init(void) { int ret; diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 8fa781207970..4aa9c9378383 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -303,6 +303,8 @@ struct typec_plug *typec_register_plug(struct typec_cable *cable, struct typec_plug_desc *desc); void typec_unregister_plug(struct typec_plug *plug); +char *typec_port_get_name(struct typec_port *port); + void typec_set_data_role(struct typec_port *port, enum typec_data_role role); void typec_set_pwr_role(struct typec_port *port, enum typec_role role); void typec_set_vconn_role(struct typec_port *port, enum typec_role role);