Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3828712pxb; Tue, 17 Nov 2020 04:49:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxcq7rbHp4MZW09UX1KeEvDNNxL/LqjvmyHHJGAwRargr3DKxKIgr2qHtIHu+tpHZB9OZW X-Received: by 2002:a17:906:489a:: with SMTP id v26mr3655280ejq.422.1605617383192; Tue, 17 Nov 2020 04:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605617383; cv=none; d=google.com; s=arc-20160816; b=td976H+51JGjiLFZAu3vdDrF/vfWGdV7bLBmhsOtBNPIs57JjG1n9c32iNU4qSWkvs KpZv0Ne99s1/aqWPZ/C+Ftr3TL69d+qFrlbQxBiFNGcTIz5qeQ9FhdAN6S64DvyTbK5i wsfyVKlrVlpWj1QUb9Ap4gURO93LPZOkfqA+JYsjbZOxD/WVL6vk3jNO3FxVcw5ft0MH Q65QoUK4xNmfENZ1G6MAHrKL3P/67ZTideJiyA6M/SnXJu/c8ugaoPcGl8H9dOYM87rh SfEONDHFBRzOu8Ib8yN61w7N6io7esD+KZXbuA3iZI3hOAc2TlLUoLFavyr70s/ihwwG 5zdw== 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=UlSMKb4wlIg/zmu95B79KWwwt63CMuPkleh54Ky+wOY=; b=NiNO1o1HUcmJHlsCEEKp3adZ/n8PDKBwR1gJNJw7O4lXuxe6AHQeZvJt61eidOsjeh 8Ntbuu88+UgRzMe6cVWf6/sHlwh6lAwhNjoVbyfDiJH3z7nji3SHE7p/sAwrWoqFlM7n A7a+tpSSlTdaYz/tL4WFf3X89dfMsKcX8JDxLtYFxD8euNTLp6eWOC9HyMDFaEIM7Yhx Bo2i5XlSfzbsuvM2EQ3/8El8UghT05VJL3ZOXAdTUFjRbQYFLCYFGUgKXaGzgF4tfrJM xh4kpeFHh6p3x//2Dbc7A0dP8NK5hn73p0hTMIAsTrH3DYkHeG5cCr5jQJ6zLdTXlDEV CxGA== 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 u12si52560edp.98.2020.11.17.04.49.19; Tue, 17 Nov 2020 04:49:43 -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 S1728013AbgKQMpR (ORCPT + 99 others); Tue, 17 Nov 2020 07:45:17 -0500 Received: from mga18.intel.com ([134.134.136.126]:1159 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725355AbgKQMpP (ORCPT ); Tue, 17 Nov 2020 07:45:15 -0500 IronPort-SDR: 4+2BqcwkUBwZer24G03E/XY1D8mu6UHbMSPqdTdEhV3DSqt5iFtf+Yo0w9TVvNQ3KJqn/Ksjux 016Jr/8Z7DOg== X-IronPort-AV: E=McAfee;i="6000,8403,9807"; a="158690181" X-IronPort-AV: E=Sophos;i="5.77,485,1596524400"; d="scan'208";a="158690181" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2020 04:45:14 -0800 IronPort-SDR: CWh7jgNj/QKRbB51DDHqaVhuH+1ZYb4GB01V6RyBrdqVqoA3CnDT2wBgRF84toMHKkdiv2gBDw uyEftAor/Sjw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,485,1596524400"; d="scan'208";a="430468045" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 17 Nov 2020 04:45:11 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 17 Nov 2020 14:45:10 +0200 Date: Tue, 17 Nov 2020 14:45:10 +0200 From: Heikki Krogerus To: Prashant Malani Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, enric.balletbo@collabora.com, Benson Leung , Guenter Roeck Subject: Re: [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug Message-ID: <20201117124510.GJ3437448@kuha.fi.intel.com> References: <20201116201150.2919178-1-pmalani@chromium.org> <20201116201150.2919178-11-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201116201150.2919178-11-pmalani@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 16, 2020 at 12:11:56PM -0800, Prashant Malani wrote: > In order to register cable alternate modes, we need to first register a > plug object. Use the Type C connector class framework to register a SOP' > plug for this purpose. > > Since a cable and plug go hand in hand, we can handle the registration > and removal together. > > Signed-off-by: Prashant Malani FWIW: Reviewed-by: Heikki Krogerus > --- > > Changes in v3: > - Re-arranged patch order and combined it with related series of > patches. > > No version v2. > > drivers/platform/chrome/cros_ec_typec.c | 35 ++++++++++++++++++------- > 1 file changed, 26 insertions(+), 9 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > index ad5e37bfd45d..d2e154ae2362 100644 > --- a/drivers/platform/chrome/cros_ec_typec.c > +++ b/drivers/platform/chrome/cros_ec_typec.c > @@ -45,6 +45,8 @@ struct cros_typec_port { > struct typec_capability caps; > struct typec_partner *partner; > struct typec_cable *cable; > + /* SOP' plug. */ > + struct typec_plug *plug; > /* Port partner PD identity info. */ > struct usb_pd_identity p_identity; > /* Port cable PD identity info. */ > @@ -222,6 +224,8 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec, > { > struct cros_typec_port *port = typec->ports[port_num]; > > + typec_unregister_plug(port->plug); > + port->plug = NULL; > typec_unregister_cable(port->cable); > port->cable = NULL; > memset(&port->c_identity, 0, sizeof(port->c_identity)); > @@ -712,7 +716,8 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p > { > struct cros_typec_port *port = typec->ports[port_num]; > struct ec_response_typec_discovery *disc = port->disc_data; > - struct typec_cable_desc desc = {}; > + struct typec_cable_desc c_desc = {}; > + struct typec_plug_desc p_desc; > struct ec_params_typec_discovery req = { > .port = port_num, > .partner_type = TYPEC_PARTNER_SOP_PRIME, > @@ -735,32 +740,44 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p > cable_plug_type = VDO_TYPEC_CABLE_TYPE(port->c_identity.vdo[0]); > switch (cable_plug_type) { > case CABLE_ATYPE: > - desc.type = USB_PLUG_TYPE_A; > + c_desc.type = USB_PLUG_TYPE_A; > break; > case CABLE_BTYPE: > - desc.type = USB_PLUG_TYPE_B; > + c_desc.type = USB_PLUG_TYPE_B; > break; > case CABLE_CTYPE: > - desc.type = USB_PLUG_TYPE_C; > + c_desc.type = USB_PLUG_TYPE_C; > break; > case CABLE_CAPTIVE: > - desc.type = USB_PLUG_CAPTIVE; > + c_desc.type = USB_PLUG_CAPTIVE; > break; > default: > - desc.type = USB_PLUG_NONE; > + c_desc.type = USB_PLUG_NONE; > } > - desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE; > + c_desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE; > } > > - desc.identity = &port->c_identity; > + c_desc.identity = &port->c_identity; > > - port->cable = typec_register_cable(port->port, &desc); > + port->cable = typec_register_cable(port->port, &c_desc); > if (IS_ERR(port->cable)) { > ret = PTR_ERR(port->cable); > port->cable = NULL; > + goto sop_prime_disc_exit; > + } > + > + p_desc.index = TYPEC_PLUG_SOP_P; > + port->plug = typec_register_plug(port->cable, &p_desc); > + if (IS_ERR(port->plug)) { > + ret = PTR_ERR(port->plug); > + port->plug = NULL; > + goto sop_prime_disc_exit; > } > > + return 0; > + > sop_prime_disc_exit: > + cros_typec_remove_cable(typec, port_num); > return ret; > } > > -- > 2.29.2.299.gdc1121823c-goog -- heikki