From patchwork Wed Jul 6 17:15:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 588073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F59CC433EF for ; Wed, 6 Jul 2022 17:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbiGFRSo (ORCPT ); Wed, 6 Jul 2022 13:18:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbiGFRSm (ORCPT ); Wed, 6 Jul 2022 13:18:42 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA05F1838E for ; Wed, 6 Jul 2022 10:18:41 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id i190so1910211pge.7 for ; Wed, 06 Jul 2022 10:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sB4D1atBiaqKiCp+/oP8s6xiYE5LCpCI5LwUJJ8ZAKk=; b=fCY8LiJ7Lx7jGPLpVOBG/PzTDFDgBR2+M9TVaoeErF0JqtEPIe1ynbxpUZPBHrzehU fxqDJQ24s4M0Vrwsjd0Z3qhlY1nTgElpZtgdQpBMhvGAjXGZD4UQMz5+2nZ+Qm4LW2CH JfJQflXLL8BzEkNAshx3aFvu4kPdU/a+6Apeg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sB4D1atBiaqKiCp+/oP8s6xiYE5LCpCI5LwUJJ8ZAKk=; b=Ept3qe8fXhNyT//gZp/nZeho15tsGmsstnIfVoFszElfrbDlUGVgjthK2HT6d4eDP3 ONwzwBj7biJ6WxJ8r9XTj3pWsvlTUvSVyz6hIYNI8v13B7VYgJxZNls3oo352jOYpypm xQqsaOAAfTRg3Qw2eFW8JCbdfk/Ejht4SEf9iqfyXmjqWFf8xZWw5r9+Wl13J/IDWOlH f2dNknN6ldBO+YaVdOJ1Pe97Sl01Y1dYJSxmH80YFPoqjsgw1+s6AhMTGMqI4VnqIgf7 pb5T8QdAIaD6lxoYQPUg7xcBJX6n4MR4p+FNt4UfOsYhHWAFyL9w5BkmehvO8XXLFe0k El0A== X-Gm-Message-State: AJIora9TeJIDhARLOlK6lLJePVpqdBdv3A31jrBxb4YpHiFPu3FN1KGv q3f+zhIYOgqDiEUckQtoujB3uQ== X-Google-Smtp-Source: AGRyM1vAFvh2Hyslk30+D+mp3QJUfmdlP6BYbMGe3W7KBUXLVDYIwgTZ55rfzR/lLX3w0CIIur+/Lw== X-Received: by 2002:a65:4b82:0:b0:412:4346:f594 with SMTP id t2-20020a654b82000000b004124346f594mr15815383pgq.593.1657127921401; Wed, 06 Jul 2022 10:18:41 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id h14-20020a170902f7ce00b0016be0d5483asm7514953plw.252.2022.07.06.10.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 10:18:41 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Cc: bleung@chromium.org, heikki.krogerus@linux.intel.com, Prashant Malani , Daisuke Nojiri , "Dustin L. Howett" , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Kees Cook , Sebastian Reichel , Tzung-Bi Shih Subject: [PATCH v2 2/9] usb: typec: Add retimer handle to port Date: Wed, 6 Jul 2022 17:15:06 +0000 Message-Id: <20220706171601.807042-3-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220706171601.807042-1-pmalani@chromium.org> References: <20220706171601.807042-1-pmalani@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Similar to mux and orientation switch, add a handle for registered retimer to the port, so that it has handles to the various switches connected to it. Signed-off-by: Prashant Malani --- Changes since v1: - Relinquish retimer reference during typec_release. drivers/usb/typec/class.c | 9 +++++++++ drivers/usb/typec/class.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 9062836bb638..f08e32d552b4 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "bus.h" #include "class.h" @@ -1736,6 +1737,7 @@ static void typec_release(struct device *dev) ida_destroy(&port->mode_ids); typec_switch_put(port->sw); typec_mux_put(port->mux); + typec_retimer_put(port->retimer); kfree(port->cap); kfree(port); } @@ -2249,6 +2251,13 @@ struct typec_port *typec_register_port(struct device *parent, return ERR_PTR(ret); } + port->retimer = typec_retimer_get(&port->dev); + if (IS_ERR(port->retimer)) { + ret = PTR_ERR(port->retimer); + put_device(&port->dev); + return ERR_PTR(ret); + } + ret = device_add(&port->dev); if (ret) { dev_err(parent, "failed to register port (%d)\n", ret); diff --git a/drivers/usb/typec/class.h b/drivers/usb/typec/class.h index 43fcf9e37a8c..673b2952b074 100644 --- a/drivers/usb/typec/class.h +++ b/drivers/usb/typec/class.h @@ -55,6 +55,7 @@ struct typec_port { enum typec_orientation orientation; struct typec_switch *sw; struct typec_mux *mux; + struct typec_retimer *retimer; const struct typec_capability *cap; const struct typec_operations *ops;