Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp93981imj; Thu, 14 Feb 2019 16:05:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IYLWV4tLtbU67zS+qmTnzLXUbEBO/jCdJp1amg4o9k9fxDJ4HsLW8dt7v7g9MsZ38369o/5 X-Received: by 2002:a62:d10b:: with SMTP id z11mr6862920pfg.84.1550189126709; Thu, 14 Feb 2019 16:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550189126; cv=none; d=google.com; s=arc-20160816; b=UFP7KlSglDFfZpPIYEQYOR+OEA5pXDiYcGDJkAsALiCh9Q1nVpye3wCXNFxblKor0F beEfXrkzWw351cVivLl0H3L0AVwQNnEaV20gz41MqrT9AJPDBydPUbcvYKDJHqO2nIvO VM1dOxupQuYucrrWBK/ODEM6b6bKOogeMrufJQmFEtz4o6kxWtQMAQ3L5hWogpUAtH3e L1gkKRqrOZH++VCvILSQNxAG7/UWCLpcT24ltf/8oRwb6FkZ0F87RGdRlZPI7RTxQnPp unqLrbQOSkGwpgJXlRRSZCPj7tbH9E5DHFtPTcXkIRlczYN4B8cH/h4KDFXbMXcwJ4xq +HtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=I8Ik0YH4DDrW+a6thIGf2C23HRpkqbBiYZr2uZywPpY=; b=uSYxci+E23qxMSuyegy5BcMxfMcvcaJQDdwWCK3oR/l7lAgROQq6wA9e+s4P7KSYIc 8Hp81+Yt0sVBen79Ou/cn+TqyYBzQZD+1EoAhz7A2PVX6qTpwYz0qW7gnPrMvKfXYYJX TXf58bQrIrkYhdcEOUP7IR/65LqDBZXzyOlBgr3/LnoRQWmwJIPkxwDZ4hQZ84bK1AX4 IZ2hYtjR8KvUfL2RrPN8K6Oey4kyvrEObycWslgWxQkpvX5kAhu5Y8aiShpOpFKPW7oj uQPSTFZIXnai9X0mbnJRU1qJX3isHOY0b/O6RRvaBgRoBrlbUfFQ4HaHdilZVMUwVR5+ 1vRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Y5tDvRLh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g34si671802pld.15.2019.02.14.16.05.10; Thu, 14 Feb 2019 16:05:26 -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=fail header.i=@gmail.com header.s=20161025 header.b=Y5tDvRLh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439219AbfBNObX (ORCPT + 99 others); Thu, 14 Feb 2019 09:31:23 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44269 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439209AbfBNObW (ORCPT ); Thu, 14 Feb 2019 09:31:22 -0500 Received: by mail-pf1-f195.google.com with SMTP id u6so3177868pfh.11; Thu, 14 Feb 2019 06:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=I8Ik0YH4DDrW+a6thIGf2C23HRpkqbBiYZr2uZywPpY=; b=Y5tDvRLhZ6rQkbiRs7d3HKRyS24zoQClPpfWDl+Spr3VuYuamhZ3mVJ6qy/QAy/1jT DpSKz6D6ewQNhVTJnsD0jJRXPLUW+DiaQKH5FF0aMSTR+7oDEZvV6CcNNdrbGlIHEMSm iT/BBp8995nTs48DszxC7diELMR1+KiVJ7HVOwmv6/zNPi/Nid/C3eOxAwyHS9kRxhn2 2tZKpK0q5TBOF/Op21RumrnG9Oqr0iVeIRH/K5pNlkqQ5mD8gwLmWANa+OFqrlmGFO10 ozqyUOpjqt6zgoVCMktaK1jOBuVZQsVRGbjoTGNuDFkEyb4skbP6OHqr7IvlXx0tSguZ apCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=I8Ik0YH4DDrW+a6thIGf2C23HRpkqbBiYZr2uZywPpY=; b=Hd3dXcilaj1r8FZqLlqQaODTVS3B0eM4Gy/7QVU/6dXNVhC5KOjWNBSNv1ITKvw4km NNFN51+FIxoO+XX+/9vQe8tuj8BrMFhB906/7jV/JJOHHZqhKsAg9A/IVu194MBEN6pS 8gIWE7Ec9jHsN6K6lpon7kM4BDX1OJqkixyrfe7q7CmpiPV/3txKQLQl1ZLeFGCpUvqB cBRAzYE8q3lIF/Tfp4hkh1N3Pdlp8GRaBv8sHGxp0///AQBIBQEHFqHWgu27POE+aL9L P3togMG2kvR79jZ0/YowN56hy6M8x7UXn43/yje0t2q6bpUH6gfuk77a6qnolZnAZDRA Buyw== X-Gm-Message-State: AHQUAuZ5FnkHJQv6AMUfvUDzxujE0CZZrpPOwlKB3Q6CaEuB1tVKwIt+ yqZTStQ9rXV9aAFT6Mj7eZD0ns+X X-Received: by 2002:a63:2bc6:: with SMTP id r189mr177603pgr.201.1550154680939; Thu, 14 Feb 2019 06:31:20 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e24sm3618055pfi.153.2019.02.14.06.31.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:31:19 -0800 (PST) Subject: Re: [PATCH] usb: typec: tcpm: Export partner Source Capabilities To: Adam Thomson , Greg KH , Kyle Tso Cc: Heikki Krogerus , Badhri Jagan Sridharan , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20190131035411.53576-1-kyletso@google.com> <20190131070238.GA4500@kroah.com> <20190212105421.GA23271@kroah.com> From: Guenter Roeck Message-ID: <85ea1e87-eaaa-1540-f693-5601bcafddf6@roeck-us.net> Date: Thu, 14 Feb 2019 06:31:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/14/19 6:17 AM, Adam Thomson wrote: > On 12 February 2019 16:20, Guenter Roeck wrote: > >> On 2/12/19 2:54 AM, Greg KH wrote: >>> On Tue, Feb 12, 2019 at 06:29:39PM +0800, Kyle Tso wrote: >>>> 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. >>> >>> And where is that code? >>> >> >> Agreed - that code should be sent upstream as well to let us see the entire >> context. >> >>>> 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. >>> >>> Great, let's go delete them now, we should not have apis that no one >>> uses. This isn't a new thing... >>> >> >> I sent a patch to do just that. Quite frankly I don't recal why I thought those >> functions might be needed. > > As a mind jog - https://lkml.org/lkml/2017/11/27/1256 :) > Nice find. However, since the code using it was never implemented, I think it is prudent at this point to remove the code. It can be reintroduced if/when needed, and at that point be tested properly. Thanks, Guenter