From patchwork Thu Jun 6 09:03:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13688098 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2137.outbound.protection.outlook.com [40.107.22.137]) (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 B2EDD13F43C; Thu, 6 Jun 2024 09:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.137 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717664653; cv=fail; b=Tndul5aV2BH8Q5ln3Qs3k71dhNiztYgxmNwbSbW/6eQQGxRkCa4DvBtrMCwzVWaLErpGhPY6CBRLSFdhn0KMLQ3SjKHsxsY5acV+y8FisM1/LO80aD9KpgDEJBb9QaGS1H4cqxAspr8GBNaPsndcYJYL+nQE4Zs4yolJsYSOLS4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717664653; c=relaxed/simple; bh=/bvpjmuTI73t9Y50sKoIVGe6v8d3c15b5jQEKsWXO6g=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=J3U8To1embw1OO6Nl/dqdSPV6qxBS+f0CTCyomPgNTQ5QNWwh+Q7MqDK5KCZXCxVQBJfvJ5XTPOOstOMiWqhjvUyvUc9T2e0FOyK77Bvi+K2fFw7HuIQg+WcUaiyfTjr9KKc7xLlB7dNp49exIBeCx3yr/8vMe2E7ADQPYmEXCQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net; spf=pass smtp.mailfrom=wolfvision.net; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b=Mfe8kNA8; arc=fail smtp.client-ip=40.107.22.137 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="Mfe8kNA8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D0EafCGd4TYE7ps86p31XWdT1gkhqR0oxOFguEHrHUBjOSb6WBkcitdRiJL/dbaAJv0Kw3SEUcy8TXarSUWOf2iRWkb9GtWzB7DBJe7W6ydaOeOkkxMS7WOHQxC8iuVhnph/ITJoj2v0aikOPU0nWAe1NWGF93N6SSJVm7kr80kmYDN+jkDHl15fE/RYlo7rY9NUxQCZ1dT36sRIH3OYXGHvgvQ8VMDvluo0edY/KRjoKQUKDYAVHMyS2cpmzvnNA6tLeZmnDg+yRgBjOo6IdBHdtMR1PTFHn4IqJT+6fQwPT8HKYG821ecLtTa52ci57A8+gzfv0WC+KdxIQCfqLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=/0sPv/kgzthBYwBq9wWhLcgJfqattFC5Ri363g8RG+s=; b=bbqHXrGym1JJIdRhMEaJN2PTM1xqVL51r8XWFNA85VHUwZyYwqj7ZrL//FEbQTgiMO4lrW3kTHs1B3BVk45TRCT3I9q8kIiIDjxe0l8tdBCsw06/0uwp3a6io0TZCgnE6Z7HUf4WPXAzCVdd6SxbdrRBqMLJFS7wmkh9zJJpCXRWOPGfY4B8QIN3TsQSf4C09VHbFB754Zde9aXEqYrA+pWVuLncDZZAXpIbPk/fhaJyfPMicrQRWv5en8X0JMJ6GMYpH6ANXwU/IIxtM6wE3A6en2YKif+Tint1lxTqYbcdRHcPfU4Iu8zG10rAj9CtrxnLgE/Ae9TWgASU/v46/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/0sPv/kgzthBYwBq9wWhLcgJfqattFC5Ri363g8RG+s=; b=Mfe8kNA8MnhORslnyJW2ba+tsUavRNxPtrQZjcT0BTbkaZLR+OeWdvXujiRZBn3ObdzZ3nlAQCV0oyh5gSZldVm509sBBUMF3LaJ8KAGzsVPDrtzRtILFy7fNIvPI0kc4Lxmxc5Xn7imhgbhmbroQrasqjDPZSDbiuFRUxadnFE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by DB9PR08MB9513.eurprd08.prod.outlook.com (2603:10a6:10:459::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31; Thu, 6 Jun 2024 09:04:04 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1%4]) with mapi id 15.20.7633.033; Thu, 6 Jun 2024 09:04:04 +0000 From: Javier Carrasco Date: Thu, 06 Jun 2024 11:03:57 +0200 Subject: [PATCH 3/3] usb: typec: tipd: use min() to set tps6598x firmware packet size Message-Id: <20240606-tps6598x_fw_update_log-v1-3-2b5b8369a0ba@wolfvision.net> References: <20240606-tps6598x_fw_update_log-v1-0-2b5b8369a0ba@wolfvision.net> In-Reply-To: <20240606-tps6598x_fw_update_log-v1-0-2b5b8369a0ba@wolfvision.net> To: Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco , Julia Lawall X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717664643; l=1069; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=/bvpjmuTI73t9Y50sKoIVGe6v8d3c15b5jQEKsWXO6g=; b=rItKa9iubWFufBYxSWm3roOl9DhE7SOTQxKGq428uU59ImBcxOIMUFYbYzbZ3wxucnyPyl1bK B0Q+qwA7qAXDBnqhPYkS/59J6l17DKOK/7cEYVanpJDeEEG/rDwd0s0 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR07CA0310.eurprd07.prod.outlook.com (2603:10a6:800:130::38) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DB9PR08MB9513:EE_ X-MS-Office365-Filtering-Correlation-Id: e8150fcc-12e0-4735-f2c3-08dc86079d54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015|52116005|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?IJPekG6vrbwybYGsmzLF02bLzhLeW/2?= =?utf-8?q?aosuPNUdvbEkdCx3iYGye3Kb8AWZKfXk0SUhup0Zhhw3FEPQ8bJkOKMz3X5vXKg8D?= =?utf-8?q?uXv5F95Nw6d9AgfwgfgAmh7Pv9QjnACN5t0kMDiYDiV768q4wJdupoUA8BOj0wmmA?= =?utf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PaF?= =?utf-8?q?+S9ZAAcFrMwl1hRCcjMtOuTqCgblhqZikpqm0TT/XJQhv7DqsZr3e6B4eMtdaBX2M?= =?utf-8?q?MMmbmL/XfjurIbqj3vz52dKexZBeb1DlB16hu2BZ5M6AvPSYWCsbsbgeG8qyvlidt?= =?utf-8?q?S43gOb6BpxPhQGmLD8XeRMrVHWYZQn5dpPQdpmuSt8rbA1GKQGbkvmH0s7vf5CNgF?= =?utf-8?q?qU/BzJkr8I/sIlCxLvXkQa5VkxtD0iNj0L0hP6GjDG51OkiJs/sYYIs9M7GZldvSm?= =?utf-8?q?iakhm63EZ8beWKHEdM7StM0blWGQBtAFbsRXHWV2Y0229K4DmHOWIYjQ=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR08MB4974.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(52116005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mUMsYzgQMGCh2oV1C1HRtOPdmG8T?= =?utf-8?q?xqqo0M7YpfxqvFsrUdtJwLV7HF91d+Ij2tdEEI/yeorcb2Cz6aWs+PXcweA4n19Nw?= =?utf-8?q?s8LLYJXRLtBs8NJr6/FqAn4PBt/Ec31i5Hr7ngtbe1DFjaq/ST7q79T3yTp3ffP3j?= =?utf-8?q?3/6tQJSRWVLsJ1uLz8WMbf/MejfOJM3WdVwJqzwM/OwQ1TQKw9gJi47mLSjeNfoj3?= =?utf-8?q?Ddwoys3yGOK4yet4DggzVkhcbw9w1SrFRCYqIEOiAENHtavlyzHzA+XLnE17BH8xS?= =?utf-8?q?M+Rll4zWz08bwqUqsgjudzi3QuHd2uS+PH7gqPy5+lbG5La566ir+ABuLQ+zJ3f56?= =?utf-8?q?hVBZJVQ6NtZpyt8MaP8PWHT1b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4GzDyI/RKa3Qryg2LrVg+xBh3d?= =?utf-8?q?SapvLfgH5AJYuCa+PQvbMXKK2ZHbWwJFxPwvuqj1saWUFoA9ONsc4CEdUTHCI/DvT?= =?utf-8?q?OC/hg9kG23OKlmID56mb4/FZGQvjEiFo5lI/oVMg8/yBqDISQ3/UD0IHDq07WW0D+?= =?utf-8?q?n1g1ZAmAjAQdJSn4BFyLLH8jgasWxD+OlcoYMlIDyU+gshKEH4dprKNTUOTH8TbHf?= =?utf-8?q?5hxXqdrZ1daQ5S4bYuZua0xSe9H+jqBBMEsf1BSZjPcFrlkw5lGGZTcCOtxC612pd?= =?utf-8?q?GSDcix5eI7kbTj106bZopysDxMARyD1I36O4Gn4D6sbKVne2AyAuXPQ=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: e8150fcc-12e0-4735-f2c3-08dc86079d54 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 09:04:04.3202 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YPjXAs4gDcCNtis9VgPMVGVEGwrPsujzqIDg5WbjO9QEnlF+PS1bns7A9gEJU8zkoDv/9Iaidtx/4G/tYdgo9t/a6GPuJ2gvGeSYV7GzSAQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB9513 Simplify the current firmware packet size check in the tps6598x implementation by means of a single call to min(), which is what the current code does in a more verbose, less elegant way. This patch fixes a cocci warning ("WARNING opportunity for min()"). Suggested-by: Julia Lawall Signed-off-by: Javier Carrasco Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 58f6eeffd070..ea768b19a7f1 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1165,10 +1165,7 @@ static int tps6598x_apply_patch(struct tps6598x *tps) bytes_left = fw->size; while (bytes_left) { - if (bytes_left < TPS_MAX_LEN) - in_len = bytes_left; - else - in_len = TPS_MAX_LEN; + in_len = min(bytes_left, TPS_MAX_LEN); ret = tps6598x_exec_cmd(tps, "PTCd", in_len, fw->data + copied_bytes, TPS_PTCD_OUT_BYTES, out);