From patchwork Tue Nov 22 22:05:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 24602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2462673wrr; Tue, 22 Nov 2022 14:11:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf7S3R12LvbihbjeGqOli1XDKb42c4fgBt/Ez79jBZoYWdNRCBb89oRyY1BKyo/Wk1eg2erc X-Received: by 2002:a17:90b:198e:b0:20d:23ee:c041 with SMTP id mv14-20020a17090b198e00b0020d23eec041mr27085618pjb.140.1669155059769; Tue, 22 Nov 2022 14:10:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669155059; cv=none; d=google.com; s=arc-20160816; b=jH3+RtF8T7PMBEh2eAPBaSOEiTthrZgmpV/QbG8Czyt+YdhbFG4K8LWP4E2Gm2fH15 fnvwliPWWMrrek5oEXXdbo29AIQ3LAvYlY49v0X1k+rfRAvw511cxaxikH9ePNFPWgKK UhXSIEUGMIgKpIr3t83w31mrF6RZ+Ra+k4NeyKdUlh9KiOhhlANI2X5fBIu2FFw72HQR +9Mvg02n87bEBT/cqQH30N8kalGX8SHsD2zuFJEbGD+wi9HjSW4fzqD8/POfVDH6CHBA 0nO4ca92KXPTOMCLv/OuX5UpX3tqRlz4Py1vFztjmIT+tOo98cp9XKukp+cnpJtmWL9z lc6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MTwasftcYWGoOTE8NtdjlLPhFZo1K5FqzfQnri8pWqI=; b=D0qU+IY///fu992vyhcMUaADmr2n3PbSSJy6gwB6SGfhJIws6h5rqt0g06GN6IGRBC Bo8mBN0ukhBNmq7hELjwQWl+5BUpNV1dmxGRu3/rRgAJ2m66bGgMpY5C38O+0lRH0A/u hMSklXV0832bQJlIfJ749y8H5HRFvVC3v0B4DNWBctuSjDUefk6P3DrFRzdHIC/9jiKk Lj6dnbtu5YpVwqCQLnSS6ZksvNOGkksTCC56KMGUZXc9OfeSzW1Ebg9PDhynO93AwHtg LTGB8A/SAakSeZuyeQrcW4rkEblHFoiKpepV00Zu0zmMnzFNx9Lb9l7Ebouak9dUIN7h vgmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MsUJ2I6a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d10-20020a056a00244a00b0056ca7c10cf2si16337448pfj.251.2022.11.22.14.10.46; Tue, 22 Nov 2022 14:10:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MsUJ2I6a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235182AbiKVWGW (ORCPT + 99 others); Tue, 22 Nov 2022 17:06:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232783AbiKVWGO (ORCPT ); Tue, 22 Nov 2022 17:06:14 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D173C7220 for ; Tue, 22 Nov 2022 14:06:11 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id d192so15670532pfd.0 for ; Tue, 22 Nov 2022 14:06:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MTwasftcYWGoOTE8NtdjlLPhFZo1K5FqzfQnri8pWqI=; b=MsUJ2I6a4ufk8VL80LUg7X5dz5P321MFBR9qAYp30CBw34Zi5yXn1JbMB8zoTZH/gF /vsTmHEWlIPIv7UADILPslwaI1eenMfK56llyah7PRD2FOw3ucNeO+1NeLGaElmW1ykU JgzwzMMkr+ZM/kFNBtARIq6ALHXvreLLjKKUU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MTwasftcYWGoOTE8NtdjlLPhFZo1K5FqzfQnri8pWqI=; b=OaW/dy3yBVFD6BSjFk5DeV2I2duwFuO/lyjjd4BcW7KZMuSqZyId3gYfe1TinhSuPc zlDJuoIIT9Nzch4TKMCSezfH+jo8POxuccgRtPrI66n/3wbed6zWaP4y85psUFXFcWv5 BCa5BPN1OlK7yde2wBIu1QHyJKREfA/OwJow5gzP0och+Nys38AV9cwm8Wb0fV+eYLXj M8tfLtxDIdfFnpR+Mssxvzmb7BonyPARzDSepiEBO92PHIwmTSGdJdN67yateuGX080D H8d1v06NaoNUjUFAXW4S31gC9Z0D9gViZ6gjekwfrmErFSZchqkt6DNh/V3DycBLeo6m Ltbw== X-Gm-Message-State: ANoB5pn+WZek3ck5rM6hOQBVokEm3vnrLCeNpAUzK8Or7TXSsYQAu7K1 X3DzzqM3OJyuux7Ici61t6YYjEXEGom12w== X-Received: by 2002:aa7:9159:0:b0:572:24c7:34da with SMTP id 25-20020aa79159000000b0057224c734damr5946459pfi.73.1669154770592; Tue, 22 Nov 2022 14:06:10 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id i24-20020a63e458000000b0042988a04bfdsm9640497pgk.9.2022.11.22.14.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 14:06:10 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Cc: Prashant Malani , Heikki Krogerus , Benson Leung , Greg Kroah-Hartman , Guenter Roeck Subject: [PATCH v2 1/2] usb: typec: Add partner PD object wrapper Date: Tue, 22 Nov 2022 22:05:36 +0000 Message-Id: <20221122220538.2991775-2-pmalani@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221122220538.2991775-1-pmalani@chromium.org> References: <20221122220538.2991775-1-pmalani@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750235936306198283?= X-GMAIL-MSGID: =?utf-8?q?1750235936306198283?= Some port drivers may want to set a Type-C partner as a parent for a USB Power Delivery object, but the Type-C partner struct isn't exposed outside of the Type-C class driver. Add a wrapper to usb_power_delivery_register() which sets the provided Type-C partner as a parent to the USB PD object. This helps to avoid exposing the Type-C partner's device struct unnecessarily. Suggested-by: Heikki Krogerus Cc: Benson Leung Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- Changes since v1: - Patch first introduced in v2. drivers/usb/typec/class.c | 19 +++++++++++++++++++ include/linux/usb/typec.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index bd5e5dd70431..5897905cb4f0 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -821,6 +821,25 @@ void typec_partner_set_svdm_version(struct typec_partner *partner, } EXPORT_SYMBOL_GPL(typec_partner_set_svdm_version); +/** + * typec_partner_usb_power_delivery_register - Register Type-C partner USB Power Delivery Support + * @partner: Type-C partner device. + * @desc: Description of the USB PD contract. + * + * This routine is a wrapper around usb_power_delivery_register(). It registers + * USB Power Delivery Capabilities for a Type-C partner device. Specifically, + * it sets the Type-C partner device as a parent for the resulting USB Power Delivery object. + * + * Returns handle to struct usb_power_delivery or ERR_PTR. + */ +struct usb_power_delivery * +typec_partner_usb_power_delivery_register(struct typec_partner *partner, + struct usb_power_delivery_desc *desc) +{ + return usb_power_delivery_register(&partner->dev, desc); +} +EXPORT_SYMBOL_GPL(typec_partner_usb_power_delivery_register); + /** * typec_register_partner - Register a USB Type-C Partner * @port: The USB Type-C Port the partner is connected to diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 7751bedcae5d..8fa781207970 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -23,6 +23,7 @@ struct fwnode_handle; struct device; struct usb_power_delivery; +struct usb_power_delivery_desc; enum typec_port_type { TYPEC_PORT_SRC, @@ -327,6 +328,9 @@ void typec_partner_set_svdm_version(struct typec_partner *partner, enum usb_pd_svdm_ver svdm_version); int typec_get_negotiated_svdm_version(struct typec_port *port); +struct usb_power_delivery *typec_partner_usb_power_delivery_register(struct typec_partner *partner, + struct usb_power_delivery_desc *desc); + int typec_port_set_usb_power_delivery(struct typec_port *port, struct usb_power_delivery *pd); int typec_partner_set_usb_power_delivery(struct typec_partner *partner, struct usb_power_delivery *pd);