From patchwork Thu Jul 7 22:20:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12910308 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 806BA2F2B for ; Thu, 7 Jul 2022 22:22:05 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id b9so5953678pfp.10 for ; Thu, 07 Jul 2022 15:22:05 -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=1d8oUSgHflYddbSglWNBA8zQUNolQOQTA7TIi861ndw=; b=n/XYJko9I2Vab10eSfGNHdTlWxcrLl2NLM/pY9JnXgKT8cJccpbSlK4P9XXGRIxhib UWAU5BhKT099hQo8qZgPL2hvfirXJTyydcYp48nwQMSRMTSEyNUwA4gs7+Bu5LMCY6bo S4x94Lj5FHH7rx9tDBxHDjeYTVeaHckI68jKw= 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=1d8oUSgHflYddbSglWNBA8zQUNolQOQTA7TIi861ndw=; b=hh6bIyPZ8uOCnXlkfZ79qVgOL7yyj0pqMg9fonxRMqZZlFC6DXkftbHIeoiCDPDgxZ dmzts1afVCvWjwbv0/aS/yPvlLKDL+F4VRYxrDty5vVqzC3LFGxC34yLYG1iUWiZAiYd VxXWo5PFoBPjejz5ZybYrjY+3Rzqi8dlygcj1ef0zZw5TGFmgqm8ZUbGlrel4SVHqX6V auv/z8ePqjm63urwAjjaW/8AjRXzl1HZVdCQm5obJVqxkQ4Ny4wu2dVgbxbpr7eG41Aj 8JswNk19aA1rBJ6z22UWVdLg18GFNuB+w4bqQSziJBjKc9IA04OhGVYl9IiK2vlaItiK vRUQ== X-Gm-Message-State: AJIora9UA/P2YX3jECAIuoOsXL2Z8xsVcBycRQIfbNEstffEnjzyHHTn YPvC1kFr+Wu+eIMKj1FOCBuqig== X-Google-Smtp-Source: AGRyM1v3yQqQ+TNU43wur8Fhdh2vNt66qOELbhK2Z68f5Lwz32YRSI71HzG5/nHKgT3OD9oQ4ktf3g== X-Received: by 2002:a63:ea05:0:b0:411:f94f:b80f with SMTP id c5-20020a63ea05000000b00411f94fb80fmr275064pgi.189.1657232525017; Thu, 07 Jul 2022 15:22:05 -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 66-20020a620445000000b005289bfcee91sm5545657pfe.59.2022.07.07.15.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 15:22:04 -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 v3 2/9] usb: typec: Add retimer handle to port Date: Thu, 7 Jul 2022 22:20:09 +0000 Message-Id: <20220707222045.1415417-3-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220707222045.1415417-1-pmalani@chromium.org> References: <20220707222045.1415417-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 v2: - No changes. 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;