From patchwork Fri Aug 16 13:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 13766345 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 131CA1B8E92 for ; Fri, 16 Aug 2024 13:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816747; cv=none; b=Ua2GlqjK2eITBmALZcAyyLst725gN27E4n6QFUcbI/tyHndB/iwO3egfjW7YZZ7T2orOOB3D86bIkNey6MOiXPWA0FYiNH4wk+NhPT4DAsJ6+v2TGX+IJ1FfWV/rf3SVMDCWGHMgTBunQ+iiHiw8uLCK6YUxDZzKB/faTCivSIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816747; c=relaxed/simple; bh=EjArrNWVZAsibljlpj4C3taslIyLaRX4F290EmCjBfs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mUtJweoJgKNgUB2ecj6PyHV3jne1pXV3OEHsSbwhmsJMQtWkQ3QLEL/kvM6kojltabH2qyjlB2VxpDsvmWb5FjVlKV9eG7l6Kuooqkng9VrZbyDUizPuL8Ms9P9oSEk7m+p4Y7vUM2AK2K3+KsgDg+0LK9d4k5QAbMnCnJ6bPLU= 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=nhJpKq2x; arc=none smtp.client-ip=192.198.163.18 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nhJpKq2x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723816746; x=1755352746; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EjArrNWVZAsibljlpj4C3taslIyLaRX4F290EmCjBfs=; b=nhJpKq2x7dIh6fsftPEWq0zehkkRYZ/SWt8Kta5FGhyo0R8Es/E8LBZ5 5tPwGbD/pHP5UOhZmSb5NpqT/Z4pqm113V75hYq2g8SGJ7AwgMXwor3t8 GVTMj6OsJJXwmbnkTsMFEJiabjj62gty48ISimRHwQNW4NWENzpQaoZdI szmYk8ZT4y6LzgMWBRwtwAG8QO02PPT3t57iHe1MciVWDs7Aut2/5umOq Ghwd1fJVhXPpefWxLHaCz6XtNsFHntPI/YkxEapG3Rp3HOmuv2gzK4hsr PwtLso9BBHOwY0pdihZymp3RVOcW6ayZ7XWS+3yfrGMgxjeugThORnBrO A==; X-CSE-ConnectionGUID: EI7AcdphTfWnwE9Y+VQwIw== X-CSE-MsgGUID: a2N9f8vSQ86GAtxV4o6CSw== X-IronPort-AV: E=McAfee;i="6700,10204,11166"; a="21660066" X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="21660066" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2024 06:59:06 -0700 X-CSE-ConnectionGUID: qryt0gEPSmWeJVyKhF94nA== X-CSE-MsgGUID: 58yXjVgrS2OmfikSyx4llA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="97192388" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 16 Aug 2024 06:59:03 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Jameson Thies , Benson Leung , Prashant Malani , Dmitry Baryshkov , linux-usb@vger.kernel.org, "Pilla, Siva sai kumar" , Abhishek Pandit-Subedi , Bartosz Szpila Subject: [PATCH v2 1/6] usb: typec: ucsi: Remove unused fields from struct ucsi_connector_status Date: Fri, 16 Aug 2024 16:58:54 +0300 Message-ID: <20240816135859.3499351-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> References: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The new fields are valid only with the new UCSI versions. They are at offsets that go beyond the MAX_DATA_LENGTH (16 bytes) with the older UCSI versions. That has not caused any problems before because nothing uses those new fields yet. Because they are not used yet, dropping them for now. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/ucsi/ucsi.h | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 57129f3c0814..7bc132b59027 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -344,35 +344,12 @@ struct ucsi_connector_status { #define UCSI_CONSTAT_PARTNER_TYPE_AUDIO 6 u32 request_data_obj; - u8 pwr_status[3]; -#define UCSI_CONSTAT_BC_STATUS(_p_) ((_p_[0]) & GENMASK(1, 0)) + u8 pwr_status; +#define UCSI_CONSTAT_BC_STATUS(_p_) ((_p_) & GENMASK(1, 0)) #define UCSI_CONSTAT_BC_NOT_CHARGING 0 #define UCSI_CONSTAT_BC_NOMINAL_CHARGING 1 #define UCSI_CONSTAT_BC_SLOW_CHARGING 2 #define UCSI_CONSTAT_BC_TRICKLE_CHARGING 3 -#define UCSI_CONSTAT_PROVIDER_CAP_LIMIT(_p_) (((_p_[0]) & GENMASK(5, 2)) >> 2) -#define UCSI_CONSTAT_CAP_PWR_LOWERED 0 -#define UCSI_CONSTAT_CAP_PWR_BUDGET_LIMIT 1 -#define UCSI_CONSTAT_PROVIDER_PD_VERSION_OPER_MODE(_p_) \ - ((get_unaligned_le32(_p_) & GENMASK(21, 6)) >> 6) -#define UCSI_CONSTAT_ORIENTATION(_p_) (((_p_[2]) & GENMASK(6, 6)) >> 6) -#define UCSI_CONSTAT_ORIENTATION_DIRECT 0 -#define UCSI_CONSTAT_ORIENTATION_FLIPPED 1 -#define UCSI_CONSTAT_SINK_PATH_STATUS(_p_) (((_p_[2]) & GENMASK(7, 7)) >> 7) -#define UCSI_CONSTAT_SINK_PATH_DISABLED 0 -#define UCSI_CONSTAT_SINK_PATH_ENABLED 1 - u8 pwr_readings[9]; -#define UCSI_CONSTAT_REV_CURR_PROT_STATUS(_p_) ((_p_[0]) & 0x1) -#define UCSI_CONSTAT_PWR_READING_VALID(_p_) (((_p_[0]) & GENMASK(1, 1)) >> 1) -#define UCSI_CONSTAT_CURRENT_SCALE(_p_) (((_p_[0]) & GENMASK(4, 2)) >> 2) -#define UCSI_CONSTAT_PEAK_CURRENT(_p_) \ - ((get_unaligned_le32(_p_) & GENMASK(20, 5)) >> 5) -#define UCSI_CONSTAT_AVG_CURRENT(_p_) \ - ((get_unaligned_le32(&(_p_)[2]) & GENMASK(20, 5)) >> 5) -#define UCSI_CONSTAT_VOLTAGE_SCALE(_p_) \ - ((get_unaligned_le16(&(_p_)[4]) & GENMASK(8, 5)) >> 5) -#define UCSI_CONSTAT_VOLTAGE_READING(_p_) \ - ((get_unaligned_le32(&(_p_)[5]) & GENMASK(16, 1)) >> 1) } __packed; /* From patchwork Fri Aug 16 13:58:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 13766346 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 02CE41B8E92 for ; Fri, 16 Aug 2024 13:59:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816750; cv=none; b=MPjstymH+bTbshpWYWDFXPPPq+63Sj8iIHNi8TPZxQTPxWjdvm4IiGV2fYzbNYBkNpv61CpMqn0dV8FEV7Wm+COlp/E/yT+EailbNGCK8dGH8LWrfZKBZOx/GCGJh9qtDVq2j9XAGUGQgWrc8dnFvb+zJ5Hd1vW1gpnGz23PMl0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816750; c=relaxed/simple; bh=9HP4kFHNBYXFjEvVrW2ypfLb5RsuJXENwWBXAo1/6m8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uM0I1FbAnDRf5c+S+YWmD24NdDic6ySHF4IcoWlriUWHijSsumC//lHDS5CyCcuu4YMAizDpHjygMVAxGAhyZEVC8U3yAzddxu+hmqMLhXayUs4oKwES06IMnBlGkntnlR29YN/k9F9y9wHwOTPO7VdCg9vYJldExnlAWK8exFI= 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=WlmYYLR9; arc=none smtp.client-ip=192.198.163.18 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WlmYYLR9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723816749; x=1755352749; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9HP4kFHNBYXFjEvVrW2ypfLb5RsuJXENwWBXAo1/6m8=; b=WlmYYLR9ffY1NtUKa65mhrYMsA9oGW1VJb+JjizcDiLRgYWR8/FkBql1 CUX5saj705sl0YmLF555b2+BPVhVtxz5RNJZZvYgYtwmMcOnwOtoEfVrd DWegpHqiyk2jEB7HsN81V7tyZ5NbF7b7PeXFJKV2RDUTqnT9YTPUZOmRv NXuPs0IqD8wfyx0dU8czQuWnX+hLlOsxollLWp3YszNxL7+I33mvpNDx5 LPFoku1nn3kubJvviG6cfmTarq4CEkxY1/005DnjyV9EbZQxHrgf3ZFP9 u7JkjAOfbf3g9ijtU9f6BZ1ZDy2gsouHp8Wtp+o3ynWfIyWDuBsH8q4S2 w==; X-CSE-ConnectionGUID: 7nb35vBATmu7Pdg0qtK6AA== X-CSE-MsgGUID: 9JIJ4wXzRUuISe+gQf+3cQ== X-IronPort-AV: E=McAfee;i="6700,10204,11166"; a="21660075" X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="21660075" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2024 06:59:09 -0700 X-CSE-ConnectionGUID: 6NUvuKhBSAC8O8NCwa9K1Q== X-CSE-MsgGUID: bLxQW1FsSnu6XbUj2Dkyzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="97192397" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 16 Aug 2024 06:59:06 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Jameson Thies , Benson Leung , Prashant Malani , Dmitry Baryshkov , linux-usb@vger.kernel.org, "Pilla, Siva sai kumar" , Abhishek Pandit-Subedi , Bartosz Szpila Subject: [PATCH v2 2/6] usb: typec: ucsi: Don't truncate the reads Date: Fri, 16 Aug 2024 16:58:55 +0300 Message-ID: <20240816135859.3499351-3-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> References: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 That may silently corrupt the data. Instead, failing attempts to read more than the interface can handle. Signed-off-by: Heikki Krogerus Reviewed-by: Abhishek Pandit-Subedi --- drivers/usb/typec/ucsi/ucsi.c | 8 ++------ drivers/usb/typec/ucsi/ucsi.h | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 4039851551c1..96ef099a6f84 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -99,12 +99,8 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci, *cci = 0; - /* - * Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the - * reads here. - */ - if (ucsi->version <= UCSI_VERSION_1_2) - size = clamp(size, 0, 16); + if (size > UCSI_MAX_DATA_LENGTH(ucsi)) + return -EINVAL; ret = ucsi->ops->sync_control(ucsi, command); if (ret) diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 7bc132b59027..5e3c6cb822c8 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -412,6 +412,8 @@ struct ucsi { #define UCSI_DELAY_DEVICE_PDOS BIT(1) /* Reading PDOs fails until the parter is in PD mode */ }; +#define UCSI_MAX_DATA_LENGTH(u) (((u)->version < UCSI_VERSION_2_0) ? 0x10 : 0xff) + #define UCSI_MAX_SVID 5 #define UCSI_MAX_ALTMODES (UCSI_MAX_SVID * 6) From patchwork Fri Aug 16 13:58:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 13766347 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 E91CA1B8E92 for ; Fri, 16 Aug 2024 13:59:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816753; cv=none; b=dx0EOmPFusLbRsKM3AzgKsiRtdv2ASkS3fV+mZNd4b+rqDk/Du+QUwSXGWBqCGnxOF+qi3YsV29+v0zSEnZnaee+qWrf1PI+0z92sBsOjmz+etgE1p9Gjk03BuDG71k0V7cdQm0EM4uyRjLqe6ioWhGEm4QDxg4aqr4J87LXCMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816753; c=relaxed/simple; bh=TE7c8VVSjm4laoQSHm/9MpjOwYlJekw9z/Vh/WVESBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=obnaCdeOedBlhqn3ww2IlvwZ7KkLV9DGvZZMPxBJJsvxdYyLyoGKyAf1JksoWQeKmPArjHfIvbJNVMSLhMwKXQ9HZ9JpAWh/FezUWveQjX8U/he5jtkShC9NPMs0MPcgEo9mjR3n8pxMaPi4TXurIhdqkHuAav73Gnq9qA7Sbic= 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=lM1NE7BR; arc=none smtp.client-ip=192.198.163.18 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lM1NE7BR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723816752; x=1755352752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TE7c8VVSjm4laoQSHm/9MpjOwYlJekw9z/Vh/WVESBA=; b=lM1NE7BRkXa5iQCVhxV3PDmdK8VOjHeiGpUEmEECQQR52648ZHAF/OG/ BxJRsDbpIlaQG8qOTHu6cXtekRAJJIOj3Y30yiad5zlv+JSLYVgJcT9W9 mq+NbkRynEdlBqc/o+MD4fXZcwIXDtfYnUWN59dywvcd7V5BuhJ7sDVh0 nlfZ6BDiQfiq+FpOxFkGwXiyUvaSACR7tysf3pOOlGsWzhwAInIWfsBTl ySESdnJxL6G1RQnlvxMNKPrmj6nuTBxvmUNvlkK9ifXK+bBju9bosISYp Ajn4DYpJd+RzxIBMCpBKdDqFZJjQzThzBMwnmdUUdikDnTru2DDMZ1Rve A==; X-CSE-ConnectionGUID: rlfl3CtNTryWrQDQLUO7yA== X-CSE-MsgGUID: m06/0oQxRViAv/6PYtn0/g== X-IronPort-AV: E=McAfee;i="6700,10204,11166"; a="21660081" X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="21660081" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2024 06:59:12 -0700 X-CSE-ConnectionGUID: Yf5QVPxpTm28ty8j5yLSQw== X-CSE-MsgGUID: zbDcAnJCRcWcvHzdh1oWHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="97192408" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 16 Aug 2024 06:59:09 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Jameson Thies , Benson Leung , Prashant Malani , Dmitry Baryshkov , linux-usb@vger.kernel.org, "Pilla, Siva sai kumar" , Abhishek Pandit-Subedi , Bartosz Szpila Subject: [PATCH v2 3/6] usb: typec: ucsi: Only assign the identity structure if the PPM supports it Date: Fri, 16 Aug 2024 16:58:56 +0300 Message-ID: <20240816135859.3499351-4-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> References: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This will make sure that the identity sysfs attribute files are kept hidden if the UCSI interface doesn't support reading the USB Power Delivery messages. Signed-off-by: Heikki Krogerus Reviewed-by: Abhishek Pandit-Subedi --- drivers/usb/typec/ucsi/ucsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 96ef099a6f84..1f6e3f0d25c1 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -979,7 +979,8 @@ static int ucsi_register_cable(struct ucsi_connector *con) break; } - desc.identity = &con->cable_identity; + if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE) + desc.identity = &con->cable_identity; desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE & con->cable_prop.flags); desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD( @@ -1058,7 +1059,8 @@ static int ucsi_register_partner(struct ucsi_connector *con) if (pwr_opmode == UCSI_CONSTAT_PWR_OPMODE_PD) ucsi_register_device_pdos(con); - desc.identity = &con->partner_identity; + if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE) + desc.identity = &con->partner_identity; desc.usb_pd = pwr_opmode == UCSI_CONSTAT_PWR_OPMODE_PD; desc.pd_revision = UCSI_CONCAP_FLAG_PARTNER_PD_MAJOR_REV_AS_BCD(con->cap.flags); From patchwork Fri Aug 16 13:58:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 13766348 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 E53241B8E92 for ; Fri, 16 Aug 2024 13:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816756; cv=none; b=R4Dg7yZwIQEJcw+UZgcTTnWV6YOPLPzFr3Nxvg9vwEyJhTt2FTfzdP2hYH/k4KcT8d3KhPrcJCaFM5AGZIe5aRLO5h0WG1MWnmtUJCV7HFOECXIWar2CyQm+4fyH0GyCb+qW7c1yrQlpnqvdorWMsfDWhvR6r7cBZT0BIPla0h4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816756; c=relaxed/simple; bh=qSfcfmHFtu7sDRNkOEXrsuJWELUORsyxr9IPc8iJcSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b3tkOQPGHr2dLw8FAP22F/MovyAImh+cTwAoIuFI6bGzfqkb0yz+y61ur2aWjdlUev3rzvtP2XbpAiJitUOAJ5x4siuDNFpYWWwA5uI8YX8jAfxxVpEZIdFc7CA6V4JFaJnfT9lFKYzRpSaPkMKQLXHKHEzlwkYbJkwCWHHXOt4= 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=OkJKf5so; arc=none smtp.client-ip=192.198.163.18 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OkJKf5so" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723816755; x=1755352755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qSfcfmHFtu7sDRNkOEXrsuJWELUORsyxr9IPc8iJcSU=; b=OkJKf5somJn6/ENOxZbwO2tRKjlaYQtOZ+zmFm5HCYJ7V7feeGKea8qM Zf3dj3DcA2S+uAQ2/J7tpeVGevNGHe2etjvSL7/PdzzvWRb0WNMDJ4Ksm bKnZE1q6B5uM+4dnwuQ/04K+weS806ZfNvmEEgc9Nv25vgOPLol/KHJuB VX/1U8g1DW7rMqMnqOy3w9zSAeOebfy7A3kd8Ox/t77RJeHWTVcn1qgCR DJP75Nsp6afd841Eo8xffd8EPSdHz/vq09ba7qNciOw0DaoF3HnNMmpr+ tilKPqO2akxNf+RN+E1AMei7ViNxteER5VjpE2VqBAbWDIb5L2+75xUp9 w==; X-CSE-ConnectionGUID: h1F1kMnqQiaX5VUrCqk7HQ== X-CSE-MsgGUID: OJjxujQ9SsC8Eyj9p7uoKw== X-IronPort-AV: E=McAfee;i="6700,10204,11166"; a="21660088" X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="21660088" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2024 06:59:15 -0700 X-CSE-ConnectionGUID: rDbz6wrCREKLidMYgj7MzA== X-CSE-MsgGUID: Hq7UU75iQAm5vB55IXAlNg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="97192418" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 16 Aug 2024 06:59:12 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Jameson Thies , Benson Leung , Prashant Malani , Dmitry Baryshkov , linux-usb@vger.kernel.org, "Pilla, Siva sai kumar" , Abhishek Pandit-Subedi , Bartosz Szpila Subject: [PATCH v2 4/6] usb: typec: ucsi: Common function for the GET_PD_MESSAGE command Date: Fri, 16 Aug 2024 16:58:57 +0300 Message-ID: <20240816135859.3499351-5-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> References: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 So far that command was only used to read the response to the Discover Identity Request, but it is handled with two separate functions, which is not really necessary. Squashing the command execution into a single function. That function can now also be used to read other messages on top of the Request Identity response. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/ucsi/ucsi.c | 92 ++++++++++------------------------- drivers/usb/typec/ucsi/ucsi.h | 12 ----- 2 files changed, 27 insertions(+), 77 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 1f6e3f0d25c1..470c9532b4f2 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -748,104 +748,66 @@ static struct usb_power_delivery_capabilities *ucsi_get_pd_caps(struct ucsi_conn &pd_caps); } -static int ucsi_read_identity(struct ucsi_connector *con, u8 recipient, - u8 offset, u8 bytes, void *resp) +static int ucsi_get_pd_message(struct ucsi_connector *con, u8 recipient, + size_t bytes, void *data, u8 type) { - struct ucsi *ucsi = con->ucsi; + size_t len = min(bytes, UCSI_MAX_DATA_LENGTH(con->ucsi)); u64 command; + u8 offset; int ret; - command = UCSI_COMMAND(UCSI_GET_PD_MESSAGE) | - UCSI_CONNECTOR_NUMBER(con->num); - command |= UCSI_GET_PD_MESSAGE_RECIPIENT(recipient); - command |= UCSI_GET_PD_MESSAGE_OFFSET(offset); - command |= UCSI_GET_PD_MESSAGE_BYTES(bytes); - command |= UCSI_GET_PD_MESSAGE_TYPE(UCSI_GET_PD_MESSAGE_TYPE_IDENTITY); - - ret = ucsi_send_command(ucsi, command, resp, bytes); - if (ret < 0) - dev_err(ucsi->dev, "UCSI_GET_PD_MESSAGE failed (%d)\n", ret); - - return ret; -} - -static int ucsi_get_identity(struct ucsi_connector *con, u8 recipient, - struct usb_pd_identity *id) -{ - struct ucsi *ucsi = con->ucsi; - struct ucsi_pd_message_disc_id resp = {}; - int ret; - - if (ucsi->version < UCSI_VERSION_2_0) { - /* - * Before UCSI v2.0, MESSAGE_IN is 16 bytes which cannot fit - * the 28 byte identity response including the VDM header. - * First request the VDM header, ID Header VDO, Cert Stat VDO - * and Product VDO. - */ - ret = ucsi_read_identity(con, recipient, 0, 0x10, &resp); - if (ret < 0) - return ret; + for (offset = 0; offset < bytes; offset += len) { + len = min(len, bytes - offset); + command = UCSI_COMMAND(UCSI_GET_PD_MESSAGE) | UCSI_CONNECTOR_NUMBER(con->num); + command |= UCSI_GET_PD_MESSAGE_RECIPIENT(recipient); + command |= UCSI_GET_PD_MESSAGE_OFFSET(offset); + command |= UCSI_GET_PD_MESSAGE_BYTES(len); + command |= UCSI_GET_PD_MESSAGE_TYPE(type); - /* Then request Product Type VDO1 through Product Type VDO3. */ - ret = ucsi_read_identity(con, recipient, 0x10, 0xc, - &resp.vdo[0]); - if (ret < 0) - return ret; - - } else { - /* - * In UCSI v2.0 and after, MESSAGE_IN is large enough to request - * the large enough to request the full Discover Identity - * response at once. - */ - ret = ucsi_read_identity(con, recipient, 0x0, 0x1c, &resp); + ret = ucsi_send_command(con->ucsi, command, data + offset, len); if (ret < 0) return ret; } - id->id_header = resp.id_header; - id->cert_stat = resp.cert_stat; - id->product = resp.product; - id->vdo[0] = resp.vdo[0]; - id->vdo[1] = resp.vdo[1]; - id->vdo[2] = resp.vdo[2]; return 0; } static int ucsi_get_partner_identity(struct ucsi_connector *con) { + u32 vdo[7] = {}; int ret; - ret = ucsi_get_identity(con, UCSI_RECIPIENT_SOP, - &con->partner_identity); + ret = ucsi_get_pd_message(con, UCSI_RECIPIENT_SOP, sizeof(vdo), vdo, + UCSI_GET_PD_MESSAGE_TYPE_IDENTITY); if (ret < 0) return ret; + /* VDM Header is not part of struct usb_pd_identity, so dropping it. */ + con->partner_identity = *(struct usb_pd_identity *)&vdo[1]; + ret = typec_partner_set_identity(con->partner); - if (ret < 0) { - dev_err(con->ucsi->dev, "Failed to set partner identity (%d)\n", - ret); - } + if (ret < 0) + dev_err(con->ucsi->dev, "Failed to set partner identity (%d)\n", ret); return ret; } static int ucsi_get_cable_identity(struct ucsi_connector *con) { + u32 vdo[7] = {}; int ret; - ret = ucsi_get_identity(con, UCSI_RECIPIENT_SOP_P, - &con->cable_identity); + ret = ucsi_get_pd_message(con, UCSI_RECIPIENT_SOP_P, sizeof(vdo), vdo, + UCSI_GET_PD_MESSAGE_TYPE_IDENTITY); if (ret < 0) return ret; + con->cable_identity = *(struct usb_pd_identity *)&vdo[1]; + ret = typec_cable_set_identity(con->cable); - if (ret < 0) { - dev_err(con->ucsi->dev, "Failed to set cable identity (%d)\n", - ret); - } + if (ret < 0) + dev_err(con->ucsi->dev, "Failed to set cable identity (%d)\n", ret); return ret; } diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 5e3c6cb822c8..c8c87377909d 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -352,18 +352,6 @@ struct ucsi_connector_status { #define UCSI_CONSTAT_BC_TRICKLE_CHARGING 3 } __packed; -/* - * Data structure filled by PPM in response to GET_PD_MESSAGE command with the - * Response Message Type set to Discover Identity Response. - */ -struct ucsi_pd_message_disc_id { - u32 vdm_header; - u32 id_header; - u32 cert_stat; - u32 product; - u32 vdo[3]; -} __packed; - /* -------------------------------------------------------------------------- */ struct ucsi_debugfs_entry { From patchwork Fri Aug 16 13:58:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 13766349 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 DB1971BC9E7 for ; Fri, 16 Aug 2024 13:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816759; cv=none; b=lfJr4X+uNdThEsOPjbdNz3QQCm8osDw5r3FwhjsMVMP+bSCCX8LeJ4yK8nSRYBRMmCjClJTZ1PQj7mni8V9xDFqI1plNpo0lG4RAlvpL6tbHuuEEQL+uZibskNMnE/W5hWgHGNx+ZwPaVgysr9LWctP83z/y/flJLJVlT0fi8tA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816759; c=relaxed/simple; bh=3R2pm5Kuk4wEYjoyM3jFKb/ppgX0RodA/DTz5vhow0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rw6mR3MRRm8E2PfCUOx0O6ZgO+slodeC/cqQsymGRgAWROYOYIiIHRVO15+byoYlX3A+3RAezOiINKAAFOnR3O9+V6fkpXSIsLX9eWENgfLBv2OX3X6L0F/hMnXuK74n5DJwl1ShzvU78xslXhXQBMy6jBrcm9mpqOlyz3LLKrQ= 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=eTebGpIy; arc=none smtp.client-ip=192.198.163.18 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eTebGpIy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723816758; x=1755352758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3R2pm5Kuk4wEYjoyM3jFKb/ppgX0RodA/DTz5vhow0A=; b=eTebGpIyw4l/22gdZFNssp7oP3Paqv/bT5o3Wk6u/sWFbwXOhYZ7y2NL RC1QSUjvuKFHJveMh3XvgY/t2PapiSaBltkTqJUnD4NKanGm5ZQJX5FEG mSAd6ODSM+7FBa3bveOu0cRxirTVdQTzbVL4LqcSArE05MN3hETVPfxEL pZHxzu92M9HbI2VJoKhqMgMpH5kxhz8S6NLbpPGCD2icUaa6A3g3KHgvv JCHG3dT9dIa9cmp+Zln2kOhYWPmfFL6jFLSyQyKjukq6RSRgttXD7GlZj I7fjEDiKMKALL1SXwHDShRuVo/G7Qv3Vzoxue94Lq+XWsvFWbQNT+kJsF Q==; X-CSE-ConnectionGUID: sTcRM6/hRSSKaJ8yKbWxGQ== X-CSE-MsgGUID: Pef7i8DUQe6+voHCCv0V6A== X-IronPort-AV: E=McAfee;i="6700,10204,11166"; a="21660095" X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="21660095" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2024 06:59:18 -0700 X-CSE-ConnectionGUID: 8JkX4/GVT0yW2ne8ZcHTjA== X-CSE-MsgGUID: bjVewc46RwGZP7Kp+tSJEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="97192425" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 16 Aug 2024 06:59:15 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Jameson Thies , Benson Leung , Prashant Malani , Dmitry Baryshkov , linux-usb@vger.kernel.org, "Pilla, Siva sai kumar" , Abhishek Pandit-Subedi , Bartosz Szpila Subject: [PATCH v2 5/6] usb: typec: ucsi: Call CANCEL from single location Date: Fri, 16 Aug 2024 16:58:58 +0300 Message-ID: <20240816135859.3499351-6-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> References: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The command cancellation can be done right after detecting that the PPM is busy. There is no need to do it separately in ucsi_read_error() and ucsi_send_command_common(). Signed-off-by: Heikki Krogerus --- drivers/usb/typec/ucsi/ucsi.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 470c9532b4f2..64fe59e05b4f 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -111,7 +111,7 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci, return ret; if (*cci & UCSI_CCI_BUSY) - return -EBUSY; + return ucsi_run_command(ucsi, UCSI_CANCEL, cci, NULL, 0, false) ?: -EBUSY; if (!(*cci & UCSI_CCI_COMMAND_COMPLETE)) return -EIO; @@ -144,15 +144,7 @@ static int ucsi_read_error(struct ucsi *ucsi, u8 connector_num) int ret; command = UCSI_GET_ERROR_STATUS | UCSI_CONNECTOR_NUMBER(connector_num); - ret = ucsi_run_command(ucsi, command, &cci, - &error, sizeof(error), false); - - if (cci & UCSI_CCI_BUSY) { - ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false); - - return ret ? ret : -EBUSY; - } - + ret = ucsi_run_command(ucsi, command, &cci, &error, sizeof(error), false); if (ret < 0) return ret; @@ -234,9 +226,8 @@ static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd, mutex_lock(&ucsi->ppm_lock); ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack); - if (cci & UCSI_CCI_BUSY) - ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false) ?: -EBUSY; - else if (cci & UCSI_CCI_ERROR) + + if (cci & UCSI_CCI_ERROR) ret = ucsi_read_error(ucsi, connector_num); mutex_unlock(&ucsi->ppm_lock); From patchwork Fri Aug 16 13:58:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 13766350 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 CDB951BB68D for ; Fri, 16 Aug 2024 13:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816762; cv=none; b=D8WkVaiJL+w6gtiVaYbbenZ688+hxPJEGv3GeM9hn6InRWMc7cOa2sKQJ3EJC+M8MKi/9Pq5Z44L86DddL22u72jut08Sv4RbCUC1e7ID7Lpl0nntAabzWKKytShtidCLRSZT0gHPQ6XEsQpig43gWE81V17jSJuckYJggSzbXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723816762; c=relaxed/simple; bh=G2lurmo+k3UCRLAgigooeszpiMhc7Uh1WD01LPPpFNA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pR84tgczQA9VyP+sMRIOWUIEN6tgLyOfKWzFnQX5Y12yqhaf7gUaDiuOfby0CTlXSv6xivxYkoiGXEMzbAasD9n8ii46bYG+7hebfin3UcIC+CJc3xujvOC47EmFf6Sy3BAxSvCqnXXUHnro4p+xFmHSWcdw4prIygdFbxMKSlE= 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=hFlVWdpA; arc=none smtp.client-ip=192.198.163.18 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hFlVWdpA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723816761; x=1755352761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G2lurmo+k3UCRLAgigooeszpiMhc7Uh1WD01LPPpFNA=; b=hFlVWdpANUn2F+s2IY/GIvc/pUmofDLSXy8CCDvuzKumrRVuMpKvX46S eHgLgiXHjEYFiVjmz1uQUUADwqO1mKHJxVtnNv8SaKEi965xZsEf8T9gj SmkInXz+jEvd227bcXGyG0rFtYnBRhmwqdoov40SFghZzMf0HF6q+Bw54 np/+2nKb+7dcXB+cUNtOVtSUM/MGdYIxRxoA0cdmzV/HPl3IMMXvwchR8 ejsOruKcNj/luLB9QBAOVhF3DPcwHNvY/1Z1+F4xn/DvdbEwBsAl6Wfr8 6mqWWdtoD0CEStYrJn0jruf/gAF6VRBD0L9DmkwglDgVmPtONzEghLc7q g==; X-CSE-ConnectionGUID: TDL9yu1FR9WH9OcbT0afjQ== X-CSE-MsgGUID: gU43l660REOVaaNNCDElVg== X-IronPort-AV: E=McAfee;i="6700,10204,11166"; a="21660102" X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="21660102" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2024 06:59:21 -0700 X-CSE-ConnectionGUID: HOP5lSC+QmS72wG2K4Gr1Q== X-CSE-MsgGUID: mX9ij3XlRFurNUoVVVtk8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="97192432" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 16 Aug 2024 06:59:18 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Jameson Thies , Benson Leung , Prashant Malani , Dmitry Baryshkov , linux-usb@vger.kernel.org, "Pilla, Siva sai kumar" , Abhishek Pandit-Subedi , Bartosz Szpila Subject: [PATCH v2 6/6] usb: typec: ucsi: Remove useless error check from ucsi_read_error() Date: Fri, 16 Aug 2024 16:58:59 +0300 Message-ID: <20240816135859.3499351-7-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> References: <20240816135859.3499351-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If the GET_ERROR_STATUS command fails, ucsi_read_error() can not reach the condition where the CCI error bit is checked, because ucsi_run_command() has already checked that bit and returned an error. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/ucsi/ucsi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 64fe59e05b4f..927007230cb8 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -148,9 +148,6 @@ static int ucsi_read_error(struct ucsi *ucsi, u8 connector_num) if (ret < 0) return ret; - if (cci & UCSI_CCI_ERROR) - return -EIO; - switch (error) { case UCSI_ERROR_INCOMPATIBLE_PARTNER: return -EOPNOTSUPP;