diff mbox series

firmware: arm_scmi: Avoid multiple initialisations of hdr->protocol_id

Message ID 20210608140140.2042257-1-sudeep.holla@arm.com (mailing list archive)
State New, archived
Headers show
Series firmware: arm_scmi: Avoid multiple initialisations of hdr->protocol_id | expand

Commit Message

Sudeep Holla June 8, 2021, 2:01 p.m. UTC
Since the hdr->protocol_id is set from the scmi_protocol_instance handle
just before the transfer, there is no need to initialise the same in
scmi_xfer_get_init. Remove the unnecessary initialisations.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/firmware/arm_scmi/driver.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Cristian Marussi June 8, 2021, 2:56 p.m. UTC | #1
Hi,

On Tue, Jun 08, 2021 at 03:01:40PM +0100, Sudeep Holla wrote:
> Since the hdr->protocol_id is set from the scmi_protocol_instance handle
> just before the transfer, there is no need to initialise the same in
> scmi_xfer_get_init. Remove the unnecessary initialisations.
> 
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  drivers/firmware/arm_scmi/driver.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 80010d3f5975..1b446d076b12 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -432,9 +432,9 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
>  	struct scmi_chan_info *cinfo;
>  
>  	/*
> -	 * Re-instate protocol id here from protocol handle so that cannot be
> +	 * Initialise protocol id now from protocol handle to avoid it being
>  	 * overridden by mistake (or malice) by the protocol code mangling with
> -	 * the scmi_xfer structure.
> +	 * the scmi_xfer structure prior to this.
>  	 */
>  	xfer->hdr.protocol_id = pi->proto->id;
>  	reinit_completion(&xfer->done);
> @@ -512,8 +512,6 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph,
>  	const struct scmi_protocol_instance *pi = ph_to_pi(ph);

This stale unused pi now causing a Warning.

>  	DECLARE_COMPLETION_ONSTACK(async_response);
>  
> -	xfer->hdr.protocol_id = pi->proto->id;
> -
>  	xfer->async_done = &async_response;
>  
>  	ret = do_xfer(ph, xfer);
> @@ -569,7 +567,6 @@ static int xfer_get_init(const struct scmi_protocol_handle *ph,
>  	xfer->tx.len = tx_size;
>  	xfer->rx.len = rx_size ? : info->desc->max_msg_size;
>  	xfer->hdr.id = msg_id;
> -	xfer->hdr.protocol_id = pi->proto->id;
>  	xfer->hdr.poll_completion = false;
>  
>  	*p = xfer;

LGTM, other that the warning above, and tested fine too.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Tested-by: Cristian Marussi <cristian.marussi@arm.com>

Thanks,
Cristian

> -- 
> 2.25.1
>
Sudeep Holla June 9, 2021, 8:47 p.m. UTC | #2
On Tue, 8 Jun 2021 15:01:40 +0100, Sudeep Holla wrote:
> Since the hdr->protocol_id is set from the scmi_protocol_instance handle
> just before the transfer, there is no need to initialise the same in
> scmi_xfer_get_init. Remove the unnecessary initialisations.

Applied to sudeep.holla/linux (master), thanks!

[1/1] firmware: arm_scmi: Avoid multiple initialisations of hdr->protocol_id
      https://git.kernel.org/sudeep.holla/c/61832b35b4

--
Regards,
Sudeep
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 80010d3f5975..1b446d076b12 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -432,9 +432,9 @@  static int do_xfer(const struct scmi_protocol_handle *ph,
 	struct scmi_chan_info *cinfo;
 
 	/*
-	 * Re-instate protocol id here from protocol handle so that cannot be
+	 * Initialise protocol id now from protocol handle to avoid it being
 	 * overridden by mistake (or malice) by the protocol code mangling with
-	 * the scmi_xfer structure.
+	 * the scmi_xfer structure prior to this.
 	 */
 	xfer->hdr.protocol_id = pi->proto->id;
 	reinit_completion(&xfer->done);
@@ -512,8 +512,6 @@  static int do_xfer_with_response(const struct scmi_protocol_handle *ph,
 	const struct scmi_protocol_instance *pi = ph_to_pi(ph);
 	DECLARE_COMPLETION_ONSTACK(async_response);
 
-	xfer->hdr.protocol_id = pi->proto->id;
-
 	xfer->async_done = &async_response;
 
 	ret = do_xfer(ph, xfer);
@@ -569,7 +567,6 @@  static int xfer_get_init(const struct scmi_protocol_handle *ph,
 	xfer->tx.len = tx_size;
 	xfer->rx.len = rx_size ? : info->desc->max_msg_size;
 	xfer->hdr.id = msg_id;
-	xfer->hdr.protocol_id = pi->proto->id;
 	xfer->hdr.poll_completion = false;
 
 	*p = xfer;