From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Javier Carrasco <javier.carrasco@wolfvision.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
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
Date: Tue, 19 Dec 2023 13:51:58 +0200 [thread overview]
Message-ID: <ZYGD3h1/il9hmdL0@kuha.fi.intel.com> (raw)
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 <javier.carrasco@wolfvision.net>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> 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
next prev parent reply other threads:[~2023-12-19 11:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 16:29 [PATCH v2 0/4] usb: typec: tipd: add patch update support for tps6598x Javier Carrasco
2023-12-14 16:29 ` [PATCH v2 1/4] usb: typec: tipd: add init and reset functions to tipd_data Javier Carrasco
2023-12-19 11:46 ` Heikki Krogerus
2024-01-04 16:14 ` Roger Quadros
2024-01-04 16:39 ` Javier Carrasco
2023-12-14 16:29 ` [PATCH v2 2/4] usb: typec: tipd: add function to request firmware Javier Carrasco
2023-12-19 11:50 ` Heikki Krogerus
2023-12-14 16:29 ` [PATCH v2 3/4] usb: typec: tipd: declare in_data in as const in exec_cmd functions Javier Carrasco
2023-12-19 11:51 ` Heikki Krogerus [this message]
2023-12-14 16:29 ` [PATCH v2 4/4] usb: typec: tipd: add patch update support for tps6598x Javier Carrasco
2023-12-19 13:24 ` Heikki Krogerus
2024-01-04 14:20 ` [PATCH v2 0/4] " Jai Luthra
2024-01-04 15:47 ` Jai Luthra
2024-01-04 16:15 ` Roger Quadros
2024-01-04 16:36 ` Javier Carrasco
2024-01-04 17:08 ` Roger Quadros
2024-01-04 17:15 ` Javier Carrasco
2024-01-04 18:52 ` Dhruva Gole
2024-01-04 20:15 ` Javier Carrasco
2024-01-05 7:57 ` Roger Quadros
2024-01-04 16:25 ` Javier Carrasco
2024-01-05 8:12 ` Jai Luthra
2024-01-05 9:49 ` Javier Carrasco
2024-01-05 10:10 ` Jai Luthra
2024-01-05 16:40 ` Abdel Alkuor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZYGD3h1/il9hmdL0@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=javier.carrasco@wolfvision.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox