Re: [PATCH 9/9] firmware: arm_ffa: Setup in-kernel users of FFA partitions

Jonathan Cameron
2020-09-01T16:41:01Z

On Sat, 29 Aug 2020 18:09:23 +0100
Sudeep Holla <sudeep.holla@arm.com> wrote:

> In order to also enable in-kernel users of FFA interface along with
> the access to user-space applications, let us add simple set of operations
> for such devices.
>
> The in-kernel users are registered without the character device interface.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 119 ++++++++++++++++++++++++++----
> include/linux/arm_ffa.h | 12 +++
> 2 files changed, 117 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index 96113e594db6..811558ef2a1d 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -372,6 +372,97 @@ static void ffa_device_put(struct ffa_device *ffa_dev)
> mutex_unlock(&ffa_dev->mutex);
> }

...

> +
> +static long
> +ffa_dev_ioctl(struct ffa_device *ffa_dev, unsigned int ioctl, void *arg)
> +{
> + long r = -EINVAL;
> +
> + switch (ioctl) {
> + case FFA_GET_API_VERSION:
> + r = drv_info->version;

Early returns would make this a tiny bit shorter and more readable.

return drv_info->version;
etc

> + break;
> + case FFA_GET_PARTITION_ID:
> + r = ffa_dev->vm_id;
> + break;
> + case FFA_GET_PARTITION_INFO: {
> + struct ffa_part_info *pinfo = arg;
> +
> + if (ffa_partition_probe(pinfo->uuid_str, &pinfo->info) != 1)
> + r = -E2BIG;
> + break;
> + }
> + case FFA_SEND_RECEIVE_SYNC: {
> + struct ffa_send_recv_sync *kdata = arg;
> +
> + r = ffa_msg_send_direct_req(ffa_dev->vm_id, kdata->endpoint_id,
> + &kdata->data);
> + break;
> + }
> + case FFA_SEND_RECEIVE_ASYNC: {
> + struct ffa_send_recv_async *kdata = arg;
> +
> + if (kdata->length < 0 || kdata->length > RXTX_BUFFER_SIZE) {
> + r = -EINVAL;
> + break;
> + }
> +
> + r = ffa_msg_send(ffa_dev->vm_id, kdata->endpoint_id,
> + kdata->buffer, kdata->length);
> + break;
> + }
> + default:
> + r = -EINVAL;
> + }
> +
> + return r;
> +}
> +

...

Thanks,

Jonathan