[PATCH v3 09/22] firmware: ti_sci: Fetch info struct from handle inside ti_sci_do_xfer()
Sebin Francis
sebin.francis at ti.com
Wed Dec 2 05:26:30 PST 2026
Hi Beleswar,
On 29/10/26 23:41, Beleswar Padhi wrote:
> From: Andrew Davis <afd at ti.com>
>
> As the only use for the handle is to fetch the info struct, which is only
> used by the ti_sci_do_xfer() function, move the info struct retrieval
> into that function. This also allows us to move the handle validity check
> inside also, saving us from needing to do this at each message function.
>
> Signed-off-by: Andrew Davis <afd at ti.com>
> Co-developed-by: Beleswar Padhi <b-padhi at ti.com>
> Signed-off-by: Beleswar Padhi <b-padhi at ti.com>
> ---
> v3: Changelog:
> 1. None to this patch.
>
> Link to v2:
> https://lore.kernel.org/all/20260930160607.2674980-10-b-padhi@ti.com/
>
> v2: Changelog:
> 1. None to this patch.
>
> Link to v1:
> https://lore.kernel.org/all/20260929201746.4078803-10-b-padhi@ti.com/
>
> drivers/firmware/ti_sci.c | 306 ++++++++------------------------------
> 1 file changed, 60 insertions(+), 246 deletions(-)
>
> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
> index 6d0ecb77d731e..dbe192142bf17 100644
> --- a/drivers/firmware/ti_sci.c
> +++ b/drivers/firmware/ti_sci.c
> @@ -435,7 +435,7 @@ static inline bool ti_sci_is_response_ack(void *r)
>
> /**
> * ti_sci_do_xfer() - Do one transfer
> - * @info: Pointer to SCI entity information
> + * @handle: Pointer to TI SCI handle
> * @msg_type: Message type
> * @msg_flags: Flag to set for the message
> * @tx_message: transmit message storage location
> @@ -443,23 +443,26 @@ static inline bool ti_sci_is_response_ack(void *r)
> * @rx_message: receive message storage location
> * @rx_message_size: receive message size
> *
> - * Return: -ETIMEDOUT in case of no response, or
> + * Return: -EINVAL if @handle is NULL, or
> + * PTR_ERR(@handle) if @handle is an error pointer, or
> + * -ETIMEDOUT in case of no response, or
> * -ENODEV in case of a NACK response, or
> * corresponding error if xfer allocation fails, or
> * corresponding error if transmit fails, or
> * return 0, if all goes well.
> */
> -static inline int ti_sci_do_xfer(struct ti_sci_info *info,
> +static inline int ti_sci_do_xfer(const struct ti_sci_handle *handle,
> u16 msg_type, u32 msg_flags,
> void *tx_message, size_t tx_message_size,
> void *rx_message, size_t rx_message_size)
> {
> + struct ti_sci_info *info;
> struct ti_sci_xfer *xfer;
> bool response_expected = !!(msg_flags & (TI_SCI_FLAG_REQ_ACK_ON_PROCESSED |
> TI_SCI_FLAG_REQ_ACK_ON_RECEIVED));
> int ret;
> int timeout;
> - struct device *dev = info->dev;
> + struct device *dev;
> bool done_state = true;
> void *caller;
>
> @@ -470,6 +473,14 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
> */
> caller = (void *)_RET_IP_;
>
> + if (IS_ERR(handle))
> + return PTR_ERR(handle);
> + if (!handle)
> + return -EINVAL;
> +
> + info = handle_to_ti_sci_info(handle);
> + dev = info->dev;
> +
> xfer = ti_sci_get_one_xfer(info, msg_type, msg_flags,
> tx_message, tx_message_size,
> rx_message, rx_message_size, caller);
> @@ -551,7 +562,7 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info)
> struct ti_sci_msg_resp_version resp;
> int ret;
>
> - ret = ti_sci_do_xfer(info, TI_SCI_MSG_VERSION,
> + ret = ti_sci_do_xfer(handle, TI_SCI_MSG_VERSION,
> TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
> &req, sizeof(req),
> &resp, sizeof(resp));
> @@ -579,22 +590,14 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info)
> static int ti_sci_set_device_state(const struct ti_sci_handle *handle,
> u32 id, u32 flags, u8 state)
> {
> - struct ti_sci_info *info;
> struct ti_sci_msg_req_set_device_state req;
> struct ti_sci_msg_hdr resp;
> int ret = 0;
>
> - if (IS_ERR(handle))
> - return PTR_ERR(handle);
> - if (!handle)
> - return -EINVAL;
> -
> - info = handle_to_ti_sci_info(handle);
> -
Minor
As we are removing the if checkes, there is a simple if that can be
removed in most of the functions, but if this is kept for consistency,
then we can keep it
```
if (ret)
return ret;
return 0;
```
Sebin
---
More information about the linux-arm-kernel
mailing list