Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp284655pxb; Wed, 3 Feb 2021 05:41:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/aMBTiWSULfBAx7wnjYh8FRXESmkPpOnbW6daHYavNpFwgMj+aL/0kEcdzWGu7ut54dbm X-Received: by 2002:a17:906:3b04:: with SMTP id g4mr2067318ejf.369.1612359682506; Wed, 03 Feb 2021 05:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612359682; cv=none; d=google.com; s=arc-20160816; b=C+Be8z4SYnt7ui5TQtWbgpjyrTlgZ3W+OLiP+l6J/fcyqJNpZFwlDYkXcjAm/fgEaR 0I53FTALXkT8MPo9AS7PDSAm2f8or9Q/V/hvm98umL7f1cGfy8rtKKTp6dd2JCSsM3do IwCX0T34RDimJsxVwTrcf1NnRN4weCmJWA5Br2qcvFpyfT8C/a/hdw+qSz1XnRcg8c/V pBKta/ySLi9S/Vnr/yHWxoPorn2obxSRqDK8Bq+IaIkXDmVavXtRSU8KfKVzmq/bZ0iK D4RR6dCHs2T31+H3pwoQzeGhcjMsLwVTHAXKzT3dp0F1lyGKqPWIsZEPG9oR4V+Kp/EC HA1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=3wAaH33qKPQH3p3cQmLI4ggbf/gx+j35R8hjCenNrVw=; b=YqGOfur1qoPX8n1C1uwRI/6T6V+iXcsZJof6cz5gT1z1zFWM0wznGUIYdjQPiKqhW3 4pRA2gsf/cLa4MKfLMJxnUz3fiIGYNpxe0ajp+DjXm56HO4bi9csJxpwB3f7q+uMK1aB 8jQNgWq33npMLUkInqJvRvIdEtmZXykxQ+dvSBkfWUzqqgel8WkF6kdAp4NIokklZCdP Cxr19ZgH2GXyFSBOQqrNZfSe3HyAIZf7LKFzJlWX+VT7x7ZwxIApXvUASXjRw26sGGP2 0q1VoOHRW5XKcSO4NGn8zg2GVWFFSpbwRTr8HZFaqrbgo0G1tlghpjKASwI5q0t6Knz4 nU2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i3si1375328ejz.79.2021.02.03.05.40.57; Wed, 03 Feb 2021 05:41:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232014AbhBCNhe (ORCPT + 99 others); Wed, 3 Feb 2021 08:37:34 -0500 Received: from mga12.intel.com ([192.55.52.136]:53857 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232078AbhBCNgH (ORCPT ); Wed, 3 Feb 2021 08:36:07 -0500 IronPort-SDR: m+0DYk33G3PA7AxzQNJtvKjsWkYheUFWDbgunej4W4zIKNBup27SVVg9OhsJFc7cSIjMRO/5RW VTYeU2k7U28g== X-IronPort-AV: E=McAfee;i="6000,8403,9883"; a="160205448" X-IronPort-AV: E=Sophos;i="5.79,398,1602572400"; d="diff'?scan'208";a="160205448" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2021 05:34:12 -0800 IronPort-SDR: ebZ4EKkbByu9zyt371NkzmzjxNMJcy6cR2nDbKa+Oj1ilrgll0Rn9FR5xeBc7xilx74s60AuYW WilY1Q93q46w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,398,1602572400"; d="diff'?scan'208";a="480351688" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 03 Feb 2021 05:34:09 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Wed, 03 Feb 2021 15:34:08 +0200 Date: Wed, 3 Feb 2021 15:34:08 +0200 From: Heikki Krogerus To: Kyle Tso Cc: linux@roeck-us.net, gregkh@linuxfoundation.org, hdegoede@redhat.com, robh+dt@kernel.org, badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v5 1/8] usb: typec: Manage SVDM version Message-ID: <20210203133408.GF1687065@kuha.fi.intel.com> References: <20210202161733.932215-1-kyletso@google.com> <20210202161733.932215-2-kyletso@google.com> <20210203124724.GD1687065@kuha.fi.intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="CE+1k2dSO48ffgeK" Content-Disposition: inline In-Reply-To: <20210203124724.GD1687065@kuha.fi.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Kyle, On Wed, Feb 03, 2021 at 02:47:28PM +0200, Heikki Krogerus wrote: > You need to document those exported functions! You need to do that in > any case, but in this case it's very important, because the purpose of > these functions is not clear from the ctx. > > I'm sorry for noticing that so late. Since you do need to fix that, > please see if you can also store that detail in the partner device > object instead of the port object. I'm attaching here my (quite crude) proposal how to do this. It should give you an idea what I'm after here. Br, -- heikki --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="svdm_version_proposal.diff" diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 8f77669f9cf4f..04238b0a5d47f 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -36,6 +36,8 @@ struct typec_partner { enum typec_accessory accessory; struct ida mode_ids; int num_altmodes; + + enum usb_pd_svdm_ver svdm_version; }; struct typec_port { @@ -792,6 +794,18 @@ typec_partner_register_altmode(struct typec_partner *partner, } EXPORT_SYMBOL_GPL(typec_partner_register_altmode); +/** + * typec_partner_set_svdm_version - Set negotiated SVDM version + * @partner: The partner. + * ... + */ +void typec_partner_set_svdm_version(struct typec_partner *partner, + enum usb_pd_svdm_ver svdm_version) +{ + partner->svdm_version = svdm_version; +} +EXPORT_SYMBOL_GPL(typec_partner_set_svdm_version); + /** * typec_register_partner - Register a USB Type-C Partner * @port: The USB Type-C Port the partner is connected to @@ -1847,6 +1861,27 @@ EXPORT_SYMBOL_GPL(typec_set_mode); /* --------------------------------------- */ +/** + * typec_get_negotiated_svdm_version - Get negotiated SVDM version + * @port: The port. + * ... + */ +int typec_get_negotiated_svdm_version(struct typec_port *port) +{ + enum usb_pd_svdm_ver svdm_version; + struct device *partner_dev; + + partner_dev = device_find_child(&port->dev, NULL, partner_match); + if (!partner_dev) + return -ENODEV; + + svdm_version = to_typec_partner(partner_dev)->svdm_version; + put_device(partner_dev); + + return svdm_version +} +EXPORT_SYMBOL_GPL(typec_partner_set_svdm_version); + /** * typec_get_drvdata - Return private driver data pointer * @port: USB Type-C port diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h index 5e0a7b7647c3b..91e119e37ba70 100644 --- a/include/linux/usb/typec_altmode.h +++ b/include/linux/usb/typec_altmode.h @@ -132,6 +132,16 @@ typec_altmode_get_orientation(struct typec_altmode *altmode) return typec_get_orientation(typec_altmode2port(altmode)); } +/** + * typec_get_negotiated_svdm_version - Get negotiated SVDM version + * ... + */ +static inline int +typec_altmode_get_svdm_version(struct typec_altmode *altmode) +{ + return typec_get_negotiated_svdm_version(typec_altmode2port(altmode)); +} + /** * struct typec_altmode_driver - USB Type-C alternate mode device driver * @id_table: Null terminated array of SVIDs --CE+1k2dSO48ffgeK--