From patchwork Wed Oct 30 02:27:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rex Nie X-Patchwork-Id: 839626 Received: from HK3PR03CU002.outbound.protection.outlook.com (mail-eastasiaazon11021131.outbound.protection.outlook.com [52.101.129.131]) (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 91E5919BA6; Wed, 30 Oct 2024 02:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.129.131 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730255370; cv=fail; b=javQY+dReIff0HXagRhnjLf6U6g6R7kI+I7yEwnc6oSRsewhoTaiYNyQnUHNUHh+PbYMRsqoMGmSyp092jGO8pZOksKaf2u7GEvyzVhQOO5KkSDWBVSk1VUSE7g6rscD4mr6FZFYedhm5fKUm3MugtFVafUomPlPIfPxTh/rRUg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730255370; c=relaxed/simple; bh=9bNryjsieft3BISU91EPjJjOIfOL/w3oZKz9ek5dsYE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qrcNPUo3HP4OQTet4gUE1zVoJ0bWHeGsvFtKkibiqVpUCGZh6UJJ47Tu+Q8HaVf4RZxo+NjZQXAdJWlEOKTtRMckShRcLm46d1GSostLnh6EEj28fDXvvL+w5lBqXWchd+p1ID/uHHy9cnJ27NEFy178rkoZTG4t72ogcL1al58= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jaguarmicro.com; spf=pass smtp.mailfrom=jaguarmicro.com; dkim=pass (2048-bit key) header.d=jaguarmicro.com header.i=@jaguarmicro.com header.b=izJGoUd9; arc=fail smtp.client-ip=52.101.129.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jaguarmicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jaguarmicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jaguarmicro.com header.i=@jaguarmicro.com header.b="izJGoUd9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E6qGTq/U+bt9fIVjxogFhTPtgdL+BCMI1iNULqZIjduHqtq2yNUTQqFxcOMCnpqlgxQWnJ8hlkLnwiD6/bDMh18fnSL/ccS1/qX5PT7GnHXeLI10x7DWJEk2QC1GBeGeMKzTVlHj2dpBdiEjqZ4+QJVksCLH/TVlOaCNIW6V3QON8Z9vFrx52g2Hw9wGkj5cLfUYKGsZP9Vy/at/d2bbrBRObrjwCzXl2YZ+aiatx8X7ka/et5Qjo7a4+RyM8YEO6zN2UwPsg4BPxK4D0WzHAbEzDpZa3cpvY3yP/bxqHcvBsWjMNnlTNjn9HLEq6JYzzYFKKcG7h87/uAv/80CHuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UbwSAks+3dx4pJDANxaQQtP07h3HmRJtgOz22VN3eQU=; b=MGHo/zCix9BJZgJuJek9YpoOM8mVS5aXcotTwcosDhsB6tX2XYk5iFIVguZ01XfHaaLtdi7wXDY2cRTSoI02y8JkG1pok9tKaZvCAS2EmnQvh3t/hlikzRF+HQlJ6vxmeFaUVp656Cw8PNmpiBlQKzr78xFzMn/hC5JLlawon77ajI0ujetiQdTBMACyZweE5bVjmddHOoIUNBHQgZ8V5oTPwX87yBL6q1W94RSa0PfLT3U8qy23GryVWo3ugYkCTZtM6bAAvGN9V5yTnZNXsIeFkmTZj8W46Jp9RjKqIuQnNxgo9y+tjpA0owx94GjyVMKQAO0Qvv0fqVxiWjkNzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=jaguarmicro.com; dmarc=pass action=none header.from=jaguarmicro.com; dkim=pass header.d=jaguarmicro.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jaguarmicro.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UbwSAks+3dx4pJDANxaQQtP07h3HmRJtgOz22VN3eQU=; b=izJGoUd9MaerBVfmQWqZSkllBYw4w0Gj3iBDrlKjokoUbcrpmGJ57MaUUWALHMYlveqTVpHAibdCdMGA0njat1Xmcr0km3OHUKjtS3GBsyb4qRjK2r8yH8M/ZyyVOJkKj0zyCFPbF/tRMvkfUFkwaOYmqMlO9m8lPvbd/pN++HMaukbWB8PdDtWHEp8hZYfGro7CNUGXI16edIzx4YHYmUaHKq3myr8cxUBlTHG/nnKTDCe9RHkk/G6TyDfhj8TmYAeJZIkIVCmwXgiKsnVWhyoPRCr4f3vFn63OE19YCy+3iwoV+VG9efZqVlB9V3JuXkkiZ0ckbK0uBugYavI9RA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=jaguarmicro.com; Received: from KL1PR0601MB5773.apcprd06.prod.outlook.com (2603:1096:820:b1::13) by SEYPR06MB5696.apcprd06.prod.outlook.com (2603:1096:101:bb::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Wed, 30 Oct 2024 02:29:19 +0000 Received: from KL1PR0601MB5773.apcprd06.prod.outlook.com ([fe80::b56a:3ef:aa9d:c82]) by KL1PR0601MB5773.apcprd06.prod.outlook.com ([fe80::b56a:3ef:aa9d:c82%4]) with mapi id 15.20.8114.015; Wed, 30 Oct 2024 02:29:18 +0000 From: Rex Nie To: bryan.odonoghue@linaro.org, heikki.krogerus@linux.intel.com Cc: gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, angus.chen@jaguarmicro.com, Rex Nie Subject: [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier Date: Wed, 30 Oct 2024 10:27:54 +0800 Message-Id: <20241030022753.2045-1-rex.nie@jaguarmicro.com> X-Mailer: git-send-email 2.39.0.windows.2 In-Reply-To: <20241029021823.1978-1-rex.nie@jaguarmicro.com> References: <20241029021823.1978-1-rex.nie@jaguarmicro.com> X-ClientProxiedBy: SG2PR01CA0144.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::24) To KL1PR0601MB5773.apcprd06.prod.outlook.com (2603:1096:820:b1::13) Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR0601MB5773:EE_|SEYPR06MB5696:EE_ X-MS-Office365-Filtering-Correlation-Id: f28f8696-0002-48c0-20e3-08dcf88aa788 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: m78cd12Je6o0U7Q9KJuvUclEsvohOSsp9CfsFyyuOlXQGCFvJyzuWsMdsbpLQK4kVlDTankA+ml9Ns8zh1M/RVT6mjm98Im0pKxSwQULXREvePaQ3zslAgxs1tEwTpUDaBwh57OolvocQRFD0qklVaPTSvl2yhNW9SZ1JeBwoLeZMvLQuyfH2KRJE0d2FQH89OLHNUXnK8Iw2o6x/WWFOhAfWltWYTWf6kILs5tNecEAkqicQ9OO9/BCM6Z+447hHJL4XfMVQ/xRMNRDRBZ88um8SOchT6Aeef53QrcmEWVr84vJizHl0Ymm1pgSkyHQlt9TKzqWpX5y2FI+gF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CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:KL1PR0601MB5773.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(52116014)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x/SvWP55hA0RC0+CrseiMXwzPl8b1vC2ymSSgqPMUiIVFjF88hroBNPvN/2dWYM4xw8gVy6UJtWSIqN1/8LdiqWxxN9PpGImOs/2wrJ10LOD/opfEnCjTVPGP+VgFFu9KjImZB6LxeUYv1Gomm4l8wL/Hw/78RImMr9O2uKfk8bSyLjSrRIugXMq9+CecLOscH1BaMpkNI73RquM2uHY0JbWY6LeF0uTG2wf6vTuVdt8o5QOyRPEZ9VM45kWFbsJ0qDmiKmt+GlKz/I9JTgKzUXEY5ZTKN7Ze49cPBzX+f8FRN4hT/6M8FxIOtgAyrkr9DqNdAOdxYME3z/y8wwr5jFptiixv3dSK84E1jXuJQAjZ8TPBl14PQwkVq7tB+PKE4iRSP2lwiPIrgxwk//+qQjV6cYEey/h2wFYISqy5xc1WjYMDoK8+4O6bIEa76FFYMxPjMKnfLfM5RbuIAlfWfCV9CQS4ZKrgw+jfzptsKma+knl59mXKVEFd/8Mwp3inFlzzSnYDQg+TEUX5wkGNz28PZlY3PeepZLZkjbZ7fDs59vreQS1ldAv1+xtbdFWxLimX6U50ICei8BtautsIeFpofI+PpFHmJ1MYEw5PaA02kwr4KG9Jt/ulBY8okqJ4jzlztlVNlhfaHQjnLIfTDFDlrqQI2n70wlQSXTLNhWT75P/wEZksg4OEHHS8kNHuAYWVpa//BW9IS4iay7u6DBm6hA+6Q3zcX/9wcCwQRxcARXYeawyvixFcu+LgZgJ3fctoW3cfwuL3w0JUr/U8vaIEhhR0ypjw20Q7EWJe9RAh/+rqBd+Xke15oJNEj1TSKRiDup+MfcD+p0AwBPV/1pleN6/mDKFeuDXelQOXIutHYfvxV22RZxxHgsuSyPksGDxhQhlWoeeUcBl1puqM4C1sE7FU0ZQohQZP924iK1FRZX3njV5138qfZnFBb2bhlw9QsDNjl2wi54Av5VK5dFL299asxlTezUMS/JzeOEVNbNu/SObbpsW/J71TkVQoteacccFSDbf5oNJZJ+8Y1LD6SIxy7WJf7Vq6rqf8PAv+dQiptKQnTZ1UdLexY61cmSCu5onyb2ZzLvjvN4PNzvfG9hSvlzI89uCUntD8kPKWpdxaCzqFQhQbyg1VJtIwpUbDc12WRzZw6jLf3su1fofJd4kYWB+NsVmznBitotBqTjtZO8pfyDvpzCZlOhFuvMJIKbzUFfgQ78bYnGYT5EFB5vXtaQ6pJ4bAeoQVUE1FB0mPhEqMhgNKqJrCFRofjlE77fe1bxy3Go4BzCJWVfHdGk9RzwI/enojtISezUW14PwUEm6XdLTrqsOLnuKR9NEPnKf9Y2xbB+LUCVANPNBle2Qw/Ez/jyyYq7FoMySe3sBQnvf60DR4O86inCkvnwdEkBx8VGWeiswvfquk0GsZ3Y+JuY4dNQ1iZXMWgS5B57sy1pEXInGp46bCmNpDv4+GKZlflezmxahKjMo8jb/ziBBH1DBDXdYkV6zwtu2Xnir81P/HpDRIwNSIEs6WI2oWHmx7wLmCS9cisXKNoRcspjjneyPS0/60lOfY9WddE3Noxa/G48J3S/vr9NrpzIPIOjzM1BjKyUvXLjJ4g== X-OriginatorOrg: jaguarmicro.com X-MS-Exchange-CrossTenant-Network-Message-Id: f28f8696-0002-48c0-20e3-08dcf88aa788 X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB5773.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 02:29:18.1807 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 1e45a5c2-d3e1-46b3-a0e6-c5ebf6d8ba7b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3Pqh27syFgnsMw7fFq5oZJV9IAVO2gK9H5G/ZeMgYjpwcPz0uAbKZk4IOqkzuCFEm6apMQYFmV/x7FyjhHMEhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5696 If the read of USB_PDPHY_RX_ACKNOWLEDGE_REG failed, then hdr_len and txbuf_len are uninitialized. This commit stops to print uninitialized value and misleading/false data. Signed-off-by: Rex Nie --- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c index 5b7f52b74a40..726423684bae 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c @@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd spin_lock_irqsave(&pmic_typec_pdphy->lock, flags); + hdr_len = sizeof(msg->header); + txbuf_len = pd_header_cnt_le(msg->header) * 4; + txsize_len = hdr_len + txbuf_len - 1; + ret = regmap_read(pmic_typec_pdphy->regmap, pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG, &val); @@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd if (ret) goto done; - hdr_len = sizeof(msg->header); - txbuf_len = pd_header_cnt_le(msg->header) * 4; - txsize_len = hdr_len + txbuf_len - 1; - /* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */ ret = regmap_bulk_write(pmic_typec_pdphy->regmap, pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,