Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1855706lqe; Tue, 9 Apr 2024 02:24:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLuYeLnn6Ph3EtRyxPFCsPHaiCxlhIK4eyMNC8PQZMkWMCvqazWVWGeTLgKC5dYGWKV7L9iK1daBBqyjJIMFlee7UfGrOWbU5nZCB/+Q== X-Google-Smtp-Source: AGHT+IGtOYPhs47JEx5ged2zQJFQg9Wm35uI80rXQAHi9ztG3q59HLkVKBkcgxu9w9/W5FapSeOD X-Received: by 2002:a9d:6849:0:b0:6ea:10a3:346a with SMTP id c9-20020a9d6849000000b006ea10a3346amr7046302oto.27.1712654655493; Tue, 09 Apr 2024 02:24:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712654655; cv=pass; d=google.com; s=arc-20160816; b=v/f2B3QoTkSoiqKAep7IgC/1zBf5/oIZN2fC+tEdD7xzqxh4NB0HgWKuR3aBfvOOqK dMOrbKiIdaSX2CG5BN1RlH0C4hJaRpu6a4YUtQjyucZRvnPAa022w7kcQcls8tiHXcv0 8sgB3Vrj8nV8U86eEz9+auaN+qdnimEzTka6AaDvMf3WS8d2zZVPtUVkWvaFpOgOXXDU JwvEkosJ4Qsl9lR5ZpqmDe0hy4DwRSbJ278BFqxRqemkLyu5wDzH+ZrGRgIdnfaayYcV 0WmSOGzAwPWBDeV4OJV6sJjQXtDDhEcw7QSOpEgF+r4Ln1zsiOjeTsgkix/RSWmMT0tr Sxdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eFSq2C3hRSECjixpZK8GWFpyyom9TZAX8KJgABFns3w=; fh=UXUL8cFUpQi3eVy+A3GfoNkLC2OoKPIrJofCuFo0FDw=; b=Q+qPAJYFPBSQyrbP6+eCkH9HZnRcALQLQHP4VWQcgMnvCwSEfLNm1nQ8IwGghvPiY5 ntKsrv3oipZIDm5WDOkzM5QJGSIrzNmHO6H76ISSxAXw2Wx1WJCH0rIk4xVip2irOvZ8 /0k5Q0CDI1ynaaCsyzPr0ed5kNu5qt37YWlGiQPvAQenck3D2alZdQhsA39uraoBrxCS uAVCmmxoXb0iQ5i6SfEttypLwaSJyaAP7+YY0tc0H37Vo69aPLeIZ1afWELUcJrnJHBL A630hYjoM/CP4wkWU4yUi+shOQmdMCvenk2bf27nWFJDcXBJtpmUzx6HF+O+FVRAOPTd iCEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MDyIUb7f; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-136331-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136331-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s2-20020a63e802000000b005dc49c4dfc7si7856810pgh.471.2024.04.09.02.24.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136331-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MDyIUb7f; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-136331-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136331-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 47EC62847E6 for ; Tue, 9 Apr 2024 06:58:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 276D778286; Tue, 9 Apr 2024 06:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MDyIUb7f" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DDD542046; Tue, 9 Apr 2024 06:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712645916; cv=none; b=ed9QeQHfuNDqEaZ46fIgic9Ku2bXiDvOkErUK+bAnGjasGh7XzVo/LpcATJp1opFEfcxW5vyMMGwuZ5dLLgZmgRK6HRWluGjqgPjf1MjLbrUKmC2EqqbvEu/r44JfUqt0+8mrY0+sBIrSoNtqEobotqkCIZwCmN/RpKBbWnW+nk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712645916; c=relaxed/simple; bh=RNDQ/WAShIYxQ56ytQsVbdot0whnV2CuqsOaiBNW8ws=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sgVnRRzdAIORv0a1YjwHu2h5R2/Pn8PnZ6/lmuAs4r6ZHPkcZVEYGhKht+fr1wW70S/42eC+eBIfoO8sfmxKAKO+imsXfkmEzwVFVONIZYJqTWhTSadXSPERzUBr6yaELf1n9eZz6EJe9kJDwb4VeIqUaUmbohgp37AmexJ49zI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MDyIUb7f; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712645915; x=1744181915; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=RNDQ/WAShIYxQ56ytQsVbdot0whnV2CuqsOaiBNW8ws=; b=MDyIUb7foURLaC/W5B/KUhZkIKmm6JZzqY+a+cfTx4nda32Qkd8QZyZx XP4t4SmTZcRH2p1P776ODn1LOWQUx1z6yQMyH4flzmI5DGkXvcVuZA4fr QiDAI3NRiajRGZ3BurQOEqzXCn59FLVZAGPMjYAesBHaw9VpgoPJWgQXc +RdZAXDWXk39MiKOMjmxNOg5P9ccsiW1v+ztoUPRIQaIaoxTF/7RPvU5+ K1mrvKm9RY5D4djM7PxI1pqWOoh5MS1Tu+Nk1wEUbskh9ZB/z19czod+n CVA0NMgtnmO4NCFufIO2XCm+f/nSLNFPz9sapqtb+V1Hg5TciYf5Efma1 g==; X-CSE-ConnectionGUID: Yz0MeUhDTVqWFykSLjh5vA== X-CSE-MsgGUID: IDYoI1rdSHCHaN/E2mChrQ== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="8071295" X-IronPort-AV: E=Sophos;i="6.07,188,1708416000"; d="scan'208";a="8071295" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 23:58:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="937093086" X-IronPort-AV: E=Sophos;i="6.07,188,1708416000"; d="scan'208";a="937093086" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 08 Apr 2024 23:58:31 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 09 Apr 2024 09:58:30 +0300 Date: Tue, 9 Apr 2024 09:58:30 +0300 From: Heikki Krogerus To: Dmitry Baryshkov Cc: Greg Kroah-Hartman , Neil Armstrong , linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] usb: typec: ucsi: add callback for connector status updates Message-ID: References: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> <20240408-ucsi-orient-aware-v1-1-95a74a163a10@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240408-ucsi-orient-aware-v1-1-95a74a163a10@linaro.org> On Mon, Apr 08, 2024 at 07:30:49AM +0300, Dmitry Baryshkov wrote: > Allow UCSI glue driver to perform addtional work to update connector > status. For example, it might check the cable orientation. This call is > performed after reading new connector statatus, so the platform driver > can peek at new connection status bits. > > The callback is called both when registering the port and when the > connector change event is being handled. > > Signed-off-by: Dmitry Baryshkov > --- > drivers/usb/typec/ucsi/ucsi.c | 6 ++++++ > drivers/usb/typec/ucsi/ucsi.h | 3 +++ > 2 files changed, 9 insertions(+) > > diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c > index 3106e69050cd..7ad544c968e4 100644 > --- a/drivers/usb/typec/ucsi/ucsi.c > +++ b/drivers/usb/typec/ucsi/ucsi.c > @@ -1199,6 +1199,9 @@ static void ucsi_handle_connector_change(struct work_struct *work) > > trace_ucsi_connector_change(con->num, &con->status); > > + if (ucsi->ops->connector_status) > + ucsi->ops->connector_status(con); > + > role = !!(con->status.flags & UCSI_CONSTAT_PWR_DIR); > > if (con->status.change & UCSI_CONSTAT_POWER_DIR_CHANGE) { > @@ -1588,6 +1591,9 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con) > } > ret = 0; /* ucsi_send_command() returns length on success */ > > + if (ucsi->ops->connector_status) > + ucsi->ops->connector_status(con); > + > switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) { > case UCSI_CONSTAT_PARTNER_TYPE_UFP: > case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP: > diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h > index 2caf2969668c..6599fbd09bee 100644 > --- a/drivers/usb/typec/ucsi/ucsi.h > +++ b/drivers/usb/typec/ucsi/ucsi.h > @@ -53,12 +53,14 @@ struct dentry; > #define UCSI_CCI_ERROR BIT(30) > #define UCSI_CCI_COMMAND_COMPLETE BIT(31) > > +struct ucsi_connector; Let's keep the forward declarations in one place. Please move that to the beginning of the file where the other forward declarations are. thanks, > /** > * struct ucsi_operations - UCSI I/O operations > * @read: Read operation > * @sync_write: Blocking write operation > * @async_write: Non-blocking write operation > * @update_altmodes: Squashes duplicate DP altmodes > + * @connector_status: Updates connector status, called holding connector lock > * > * Read and write routines for UCSI interface. @sync_write must wait for the > * Command Completion Event from the PPM before returning, and @async_write must > @@ -73,6 +75,7 @@ struct ucsi_operations { > const void *val, size_t val_len); > bool (*update_altmodes)(struct ucsi *ucsi, struct ucsi_altmode *orig, > struct ucsi_altmode *updated); > + void (*connector_status)(struct ucsi_connector *con); > }; > > struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops); -- heikki