Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp441142rdh; Tue, 19 Dec 2023 03:52:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEdLBW9E93RJdvgWklWBi0B2hhu2pvCcXMD9kw3WyXcfLv8D03VtN0bRtzAqpH3TQemIUY X-Received: by 2002:a05:620a:28c2:b0:77e:fba4:3a21 with SMTP id l2-20020a05620a28c200b0077efba43a21mr23901300qkp.119.1702986732841; Tue, 19 Dec 2023 03:52:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702986732; cv=none; d=google.com; s=arc-20160816; b=tDXsfPXWmfE3tkxGilIfH23jSnI5HjivPjsuMkjUAFMezI3UjTSunWGpZ1ypH9XhLB k3TKcwuwgisfu8nuMgvfJACDzAZkKeZo+IML7Wf7yWJdkCreCBLeQtvyG3C7tOWuH98W kwYhqalLvwPLccaSWiPFaZBxWgiGYK/HwcNMDcUuBee5qyoJKuqnokoN/3addT+DrfMf IKz6wXvv8AxZYODtZj7nsZTSbGJZwYFtYi83nfSNd4sePejmGBAYPjNWEfcICRmXx/R0 TTTl5KJ9KpoQRUs0vEaqUzgl31vCEjkuBIAQHggrAy2kuckis/Mszk4po+4O2QOVWRVj uS8Q== ARC-Message-Signature: i=1; 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=VX6nDw6CmLw5GCzmoAD7wGb5FeDJeC1rMJZLqEoFb9M=; fh=W2pHPIJPqCP8HsXFXoA7ZzEbMb5czJzPDgB2sMvpzSo=; b=bVeozvi1yO7CNrezokNOslBEFWZh3hlLuOc8LQtz276uZrsYxL4cNHYSn4KRnw2Mqk E3+ywHtszTK3xyXpH4IFbbTpkalYyrO08h8haJyuNN7WXkFad/ALsr9vTtrigLZpGVuH qYfG7sMUSR1yMBO49qSESGEFRl6VFfnwHEyuCPXQHj8ZfLmy18HWfADq4qbpWKebIfwz C6M48LSzmZVE+1egyIkooS+L1Ttq2+I0yqhTVoxU+1AlP7VcNhun/+Oe8KVS3q6zsFFr tR6SbkVeJ4BMUE9iNDifcsu7uaH7cNJDWfRNVD69db1Yp98jjmUks2PimDTYlx+Zv1kg 0n/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kfLaMZjk; spf=pass (google.com: domain of linux-kernel+bounces-5112-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5112-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h4-20020a05620a284400b0077bfe536f45si26599843qkp.121.2023.12.19.03.52.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 03:52:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5112-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kfLaMZjk; spf=pass (google.com: domain of linux-kernel+bounces-5112-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5112-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 92C5C1C23EF4 for ; Tue, 19 Dec 2023 11:52:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 293FB16407; Tue, 19 Dec 2023 11:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kfLaMZjk" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) (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 D487A18629; Tue, 19 Dec 2023 11:52:01 +0000 (UTC) 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=1702986721; x=1734522721; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=M2pLPbJFA0BRzGzcj7zUHtvY6vO14MPKUj+G4zRU83Y=; b=kfLaMZjkcidGLiAmrhyJzD43UyfY7obUWJ0+Grx2LxFsyjRJAahoZnUq Yf94SNKDtzEwRdNMIq42S8DPxZZYMeNKiAP4PLbo+lZQuwQTx2aNm/VxC EA1NPqjGuyAW4aL6ed6J8EC2dHLQM215hHbXDH5V44aHP57gh3CAFX2wS H6aUl5b2OIpiuqEfxnNHRD4/EIbr1ArzTZ02GFvoupzJxSE1l0ssx3rlO aQnCr4DZBgph7497SIsbYAE6S5qHX84JrLOaXZBnS7zPawOPTYg1GZOZN 3eP8X55Vig3Jy9Lvoz9qYSlZNp7yDrHop197cEUTKDRhVp35ynE4JhiTS Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="459988851" X-IronPort-AV: E=Sophos;i="6.04,288,1695711600"; d="scan'208";a="459988851" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 03:52:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="894264381" X-IronPort-AV: E=Sophos;i="6.04,288,1695711600"; d="scan'208";a="894264381" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga002.fm.intel.com with SMTP; 19 Dec 2023 03:51:58 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 19 Dec 2023 13:51:58 +0200 Date: Tue, 19 Dec 2023 13:51:58 +0200 From: Heikki Krogerus To: Javier Carrasco Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] usb: typec: tipd: declare in_data in as const in exec_cmd functions Message-ID: References: <20231207-tps6598x_update-v2-0-f3cfcde6d890@wolfvision.net> <20231207-tps6598x_update-v2-3-f3cfcde6d890@wolfvision.net> 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: <20231207-tps6598x_update-v2-3-f3cfcde6d890@wolfvision.net> On Thu, Dec 14, 2023 at 05:29:11PM +0100, Javier Carrasco wrote: > The input data passed to execute commands with tps6598x_exec_cmd() > is not supposed to be modified by the function. Moreover, this data is > passed to tps6598x_exec_cmd_tmo() and finally to tps6598x_block_write(), > which expects a const pointer. > > The current implementation does not produce any bugs, but it discards > const qualifiers from the pointers passed as arguments. This leads to > compile issues if 'discarded-qualifiers' is active and a const pointer > is passed to the function, which is the case if data from a firmware > structure is passed to execute update commands. Adding the const > modifier to in_data prevents such issues and provides code consistency. > > Signed-off-by: Javier Carrasco Reviewed-by: Heikki Krogerus > --- > drivers/usb/typec/tipd/core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 83e5eeecdf5c..7f4bbc0629b0 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -330,7 +330,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) > } > > static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, > - size_t in_len, u8 *in_data, > + size_t in_len, const u8 *in_data, > size_t out_len, u8 *out_data, > u32 cmd_timeout_ms, u32 res_delay_ms) > { > @@ -396,7 +396,7 @@ static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, > } > > static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, > - size_t in_len, u8 *in_data, > + size_t in_len, const u8 *in_data, > size_t out_len, u8 *out_data) > { > return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data, > > -- > 2.39.2 -- heikki