Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3895734pxb; Mon, 1 Feb 2021 07:24:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGv0KeQ/kCv5OEy/QbP3c986Y5UVlWg+tg5tAJcOaLIsska7qDZ1KsGDb1OpnMfFkYLit5 X-Received: by 2002:a17:907:3e06:: with SMTP id hp6mr18178361ejc.254.1612193040855; Mon, 01 Feb 2021 07:24:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612193040; cv=none; d=google.com; s=arc-20160816; b=zLsETCFIH1M4azfHPCYI4Fnail2r3E90kzJEJ7JL7l29z+LS0mFU99bRtTiHVGzV41 bbfJStthi5XiwBcwMJamtLEOkJR5bL/EjcF1tK/Abf9uQFuMzyRDl/vxfcrrHCU0GBB6 3Ax4MabkuDMlvaaxS1xxZs8tJ1WpCEMZ87t5AYBl4pXU+4v7TQw9iKNKkaRqdHC1KBvn riqyeyT6dhPiwr1RHRIvgFY7/GP8W7Y0ze7p0UqjJLD2v45XUNkFBj2+Sw7lYIQQtlFg SMQqQBNUNnPDv9vlVtr6eP8Eq2Yi+dE8WIIR5+EZvrCIq8o8w2jaD1QK48zkh8XU8iCt kpFA== 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:dkim-signature; bh=5WnzSfFFImuwNvmP12YXzR7y8lX2uOQWp8+hFII+Jj4=; b=qAP7zRnLm21+3YmHqo8NZMvH6n4oNyzncr8J54KTzB8LPca5VmV6IY1idLgfaTSDxN SOeNAwca9g0oJ9CaN6dgIO7MLZAyPwbiH5xISn69l5OMrL8h7s+iAS3t9uaJNp6Bx+9i +aJq/8Na6E8+e5FRLQxhh26lrCR/9YsjJB2wnnYceKB+8hMxCBAiEhBxSy0uiJoktKip zNArvNxDs1fSxye8AQ3UQeI7UhRVQ8mwx0cDGMXvYrs7I3/W3jvQkQGT8g/5F1EoOAzG rf19i7OxLnhuHt4t8GdmFFMnpIE15S1ccOOZhm8aAVbJL5sK373faQbauZMlYZLK5/6u wFtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=unE6nqO4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si3246344ejw.435.2021.02.01.07.23.35; Mon, 01 Feb 2021 07:24:00 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=unE6nqO4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbhBAPW5 (ORCPT + 99 others); Mon, 1 Feb 2021 10:22:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:40102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231622AbhBAPUW (ORCPT ); Mon, 1 Feb 2021 10:20:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 26F6264E97; Mon, 1 Feb 2021 15:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612192781; bh=i0meEWipPp+80/IfSWPNUxndhg1IB7DJhkCycLLyrwA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=unE6nqO4297ses6x3WfO+gaqmvqx/V8iXaqO5p+vQKiO+1QqKHZU4Q5qn/GUydb6b iQsY2Wje3zdK6l2L07y1GtYMCFRbr6F/EU7yuhazbQFiRBg89CEsJ3DNJ7fpFZ11n5 LBmQ6U9MoUuItTzesfYCrEHnD4SeSMiqKOd2PGcE= Date: Mon, 1 Feb 2021 16:19:38 +0100 From: Greg Kroah-Hartman To: Heikki Krogerus Cc: Badhri Jagan Sridharan , Guenter Roeck , Kyle Tso , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/3] usb: typec: tcpm: Add Callback to Usb Communication capable partner Message-ID: References: <20210201095309.39486-1-badhri@google.com> <20210201151253.GG2465@kuha.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210201151253.GG2465@kuha.fi.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 01, 2021 at 05:12:53PM +0200, Heikki Krogerus wrote: > On Mon, Feb 01, 2021 at 01:53:07AM -0800, Badhri Jagan Sridharan wrote: > > The USB Communications Capable bit indicates if port > > partner is capable of communication over the USB data lines > > (e.g. D+/- or SS Tx/Rx). Notify the status of the bit to low > > level drivers to perform chip specific operation. > > For instance, low level driver enables USB switches on D+/D- > > lines to set up data path when the bit is set. > > > > Refactored from patch initially authored by > > Kyle Tso > > > > Signed-off-by: Badhri Jagan Sridharan > > --- > > drivers/usb/typec/tcpm/tcpm.c | 16 ++++++++++++++++ > > include/linux/usb/tcpm.h | 5 +++++ > > 2 files changed, 21 insertions(+) > > ... > > > diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h > > index 3af99f85e8b9..42fcfbe10590 100644 > > --- a/include/linux/usb/tcpm.h > > +++ b/include/linux/usb/tcpm.h > > @@ -108,6 +108,10 @@ enum tcpm_transmit_type { > > * is supported by TCPC, set this callback for TCPM to query > > * whether vbus is at VSAFE0V when needed. > > * Returns true when vbus is at VSAFE0V, false otherwise. > > + * @set_partner_usb_comm_capable: > > + * Optional; The USB Communications Capable bit indicates if port > > + * partner is capable of communication over the USB data lines > > + * (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. > > */ > > struct tcpc_dev { > > struct fwnode_handle *fwnode; > > @@ -139,6 +143,7 @@ struct tcpc_dev { > > int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev, enum typec_pwr_opmode mode, > > bool pps_active, u32 requested_vbus_voltage); > > bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev); > > + void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable); > > }; > > > > struct tcpm_port; > > There start to be a lot of callback there, separate for each function. > And I guess flags too... Would it be possible to have a single > notification callback instead, that would take the type of the > notification as a parameter (we could have an enum for those), and > then the specific object(s) for each type as another paramter (RDO I > guess in this case)? > > It would then be up to the TCPC driver to extract the detail it needs > from that object. That would somehow feel more cleaner to me, but what > do you guys think? It's pretty much the same thing, a "mux" function vs. individual function calls. Personally, individual callbacks are much more explicit, and I think make it easier to determine what is really going on in each driver. But it all does the same thing, if there's going to be loads of callbacks needed, then a single one makes it easier to maintain over time. So it's up to the maintainer what they want to see :) thanks, greg k-h