Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3662400imj; Tue, 12 Feb 2019 02:33:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IZmJyTTu2LYut1ca/Y6E3yd9z4cVrF/bG9i8vBo5GTUeWwxS6uiY9zLyJY+dutgVYQuIveu X-Received: by 2002:a62:109b:: with SMTP id 27mr3198054pfq.227.1549967613440; Tue, 12 Feb 2019 02:33:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549967613; cv=none; d=google.com; s=arc-20160816; b=xrR0uY/FC9v3MBnDyQMRmuCUVSNxgjx4HPH1yERjcpZLNF8EJiLblJ1XxTuutsbOzL OPDxQLQRY9s8FEa4DyuGqxXF4ttxe/BBWwU/C8NI9/YYmit09R2/JEabtTp4eZ98rygY PT4nwT73pz181ULNeArG+34Cer0x2Ud+V8mXLpHkFx1SSmV5FQ9sjtFePSfhK4eenj7X m62nAlytT8XJGjx4+G0aMMP0h6TUTepKa5zFIWcb/K7V/xniG9ZGOtgDYIHD1XO4Z4CM OMnYjOflZyuv9Ji8pK2zQTI5eT8gN1y3g60+vEF0LP5CtTBxQfOOPg89t72++7zhk88g B/Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8hP3bD0/FecycY6KWyvMuhSejR3aZm0LxXnJZpTyPxg=; b=LLsjLfKJYOKRky1VerrkkvMdZ3ioTeE0V/V4cqbMur8bO5JD7BGcd+NbNRTRDxaAD5 CkxwKoqGCDE52cv64kmfVKF7JtLk3f9LxUfLXzGz228AaRemFmTljGdobD7jXzY2QE9s zrMEWFPBQ7PqGJeOmTRp5rGPliELDYew8jymqZGZvn0cZTWVvZzerv9rc8Kp6xJxVN+L 9NPJYED1HHb7v1rmPqBBTw//MtI1w3mIwr4z/0OKni1P460IitveQ3cenqNMvtZ33gOm naHP0ZtLEDjTMVy62OvUk6otvXdLWni+oIw3tYt+qcx/hpth+EotS9SV0Gw3YBvCCj8j rslw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HLwtflPd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z17si9779195pgf.267.2019.02.12.02.33.16; Tue, 12 Feb 2019 02:33:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HLwtflPd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728800AbfBLKch (ORCPT + 99 others); Tue, 12 Feb 2019 05:32:37 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:33711 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726003AbfBLKcg (ORCPT ); Tue, 12 Feb 2019 05:32:36 -0500 Received: by mail-qt1-f196.google.com with SMTP id z39so2333273qtz.0 for ; Tue, 12 Feb 2019 02:32:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8hP3bD0/FecycY6KWyvMuhSejR3aZm0LxXnJZpTyPxg=; b=HLwtflPdhldC+kVUvK7Wgv52dxtzVHAlSD70fox3I32UX+f4RgM+5RqLaNC6e2c68e 2izWcdfPhr+jvNkLwrVVBesHYDRqrYoO8Ex8lVScFvqQWslGo2IzbhQqsDTnHHs/zJNw aIkdLZnAuboh7fOW+GA1N23ofEnvvPy21+I59zqn7T4FrJKth5gdecW1T/JMtvFYrbCL QfPrOHK06J1mNtU2iTf28ji3j65ldMKDO5c3aJSAqMSrF6UEUONxHVeHwt9SyFov/MMz VInDwX22Sas0Z95tAjqvi4dbueS6Cnk97arQLbRZj/9lxI6cz2p3GTDFgvaQLgDq4iHO Aiew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8hP3bD0/FecycY6KWyvMuhSejR3aZm0LxXnJZpTyPxg=; b=odhX3xLQzN7U829v2oXBVqC7HJAyh6kQG1g5zRbAUN9qpzqBjcinjTBQ2gdV+Dmo4Y f+sj9BNKj7z9Bu2bfojrvhMnGVgqjvvF1qNRfNg8WEHIExhGTeBv6f+ue+u2eRvd/wc4 Ml8ztYy2ORYWV+t8dSPWBBSMblrdVIcFZaPz/Di86tJuoB3ov9z5/kh7dXZOHYlrVQzP mSFC7MBGnZ1yWTb8pOPn5aOl3u787TM2oEaM1SYrcy0IOfAAE/CaK6SWbzayFpo7KKRU YW+9C/C/Y530uxFsor7ESvD89/Oa6R2xYe9m8KdKqm1KD2EF6BcZWj/0xtaq4CM5xz89 gs+w== X-Gm-Message-State: AHQUAua4KpCNpZ0+qMqG1mD+lLjhVEP4NID7PmbmNXBuFSlqGcXWULD4 CBnHzvX7qMfwk181No2D3DDPudcmGz3Y7vhWIEP0vw== X-Received: by 2002:a0c:ade7:: with SMTP id x36mr2023514qvc.66.1549967555218; Tue, 12 Feb 2019 02:32:35 -0800 (PST) MIME-Version: 1.0 References: <20190131035411.53576-1-kyletso@google.com> <20190131070238.GA4500@kroah.com> In-Reply-To: <20190131070238.GA4500@kroah.com> From: Kyle Tso Date: Tue, 12 Feb 2019 18:32:24 +0800 Message-ID: Subject: Re: [PATCH] usb: typec: tcpm: Export partner Source Capabilities To: Greg KH Cc: Guenter Roeck , Heikki Krogerus , Badhri Jagan Sridharan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 31, 2019 at 3:02 PM Greg KH wrote: > > On Thu, Jan 31, 2019 at 11:54:11AM +0800, Kyle Tso wrote: > > Provide a function to get the partner Source Capabilities. > > > > Signed-off-by: Kyle Tso > > --- > > drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ > > include/linux/usb/tcpm.h | 1 + > > 2 files changed, 24 insertions(+) > > > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > > index f1d3e54210df..29cd84ba9960 100644 > > --- a/drivers/usb/typec/tcpm/tcpm.c > > +++ b/drivers/usb/typec/tcpm/tcpm.c > > @@ -4494,6 +4494,29 @@ int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, > > } > > EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities); > > > > +/* > > + * Don't call this function in interrupt context. Caller needs to free the > > + * memory itself. > > + */ > > +int tcpm_get_partner_src_caps(struct tcpm_port *port, u32 **src_pdo) > > +{ > > + unsigned int nr_pdo; > > + > > + if (port->nr_source_caps == 0) > > + return -ENODATA; > > + > > + *src_pdo = kcalloc(port->nr_source_caps, sizeof(u32), GFP_KERNEL); > > + if (!src_pdo) > > + return -ENOMEM; > > + > > + mutex_lock(&port->lock); > > + nr_pdo = tcpm_copy_pdos(*src_pdo, port->source_caps, > > + port->nr_source_caps); > > + mutex_unlock(&port->lock); > > + return nr_pdo; > > +} > > +EXPORT_SYMBOL_GPL(tcpm_get_partner_src_caps); > > We don't add new functions that no one uses :( > This function is useful if the PD Device Policy Manager is implemented outside of TCPM. In this situation, Device Policy Manager needs to know the partner capabilities to optimize the charging process. Take existing functions in TCPM for example: Function "tcpm_update_sink_capabilities" and "tcpm_update_source_capabilities" are exposed as well. And no one uses them now.