diff mbox series

[V1] media: mc-device.c: change media_device_request_alloc to match media_ioctl_info

Message ID 20200806072952.11709-2-frederic.chen@mediatek.com (mailing list archive)
State New, archived
Headers show
Series media: change media_device_request_alloc to match media_ioctl_info | expand

Commit Message

Frederic Chen Aug. 6, 2020, 7:29 a.m. UTC
From: Frederic Chen <frederic.chen@mediatek.com>

We modified the type of media_device_request_alloc()'s second
parameter from int* to void* so that it can match the interface
defined in struct media_ioctl_info.

Signed-off-by: Frederic Chen <frederic.chen@mediatek.com>
---
 drivers/media/mc/mc-device.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Hans Verkuil Aug. 6, 2020, 7:42 a.m. UTC | #1
On 06/08/2020 09:29, frederic.chen@mediatek.com wrote:
> From: Frederic Chen <frederic.chen@mediatek.com>
> 
> We modified the type of media_device_request_alloc()'s second
> parameter from int* to void* so that it can match the interface
> defined in struct media_ioctl_info.
> 
> Signed-off-by: Frederic Chen <frederic.chen@mediatek.com>
> ---
>  drivers/media/mc/mc-device.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
> index da8088351135..bc5b5ecb6581 100644
> --- a/drivers/media/mc/mc-device.c
> +++ b/drivers/media/mc/mc-device.c
> @@ -370,9 +370,10 @@ static long media_device_get_topology(struct media_device *mdev, void *arg)
>  	return ret;
>  }
>  
> -static long media_device_request_alloc(struct media_device *mdev,
> -				       int *alloc_fd)
> +static long media_device_request_alloc(struct media_device *mdev, void *arg)
>  {
> +	int *alloc_fd = arg;
> +
>  #ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API
>  	if (!mdev->ops || !mdev->ops->req_validate || !mdev->ops->req_queue)
>  		return -ENOTTY;
> 

This change is fine, but the reason this wasn't noticed before is the cast in
the MEDIA_IOC_ARG define:

#define MEDIA_IOC_ARG(__cmd, func, fl, from_user, to_user)              \
        [_IOC_NR(MEDIA_IOC_##__cmd)] = {                                \
                .cmd = MEDIA_IOC_##__cmd,                               \
                .fn = (long (*)(struct media_device *, void *))func,    \
                .flags = fl,                                            \
                .arg_from_user = from_user,                             \
                .arg_to_user = to_user,                                 \
        }

When assigning to .fn the func is cast to a specific function prototype.
Without that cast the compiler would have warned about the mismatch.

I see no reason for that cast, so drop that cast as well.

Regards,

	Hans
Frederic Chen Aug. 6, 2020, 3:27 p.m. UTC | #2
Dear Hans,

On Thu, 2020-08-06 at 09:42 +0200, Hans Verkuil wrote:
> On 06/08/2020 09:29, frederic.chen@mediatek.com wrote:
> > From: Frederic Chen <frederic.chen@mediatek.com>
> > 
> > We modified the type of media_device_request_alloc()'s second
> > parameter from int* to void* so that it can match the interface
> > defined in struct media_ioctl_info.
> > 
> > Signed-off-by: Frederic Chen <frederic.chen@mediatek.com>
> > ---
> >  drivers/media/mc/mc-device.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
> > index da8088351135..bc5b5ecb6581 100644
> > --- a/drivers/media/mc/mc-device.c
> > +++ b/drivers/media/mc/mc-device.c
> > @@ -370,9 +370,10 @@ static long media_device_get_topology(struct media_device *mdev, void *arg)
> >  	return ret;
> >  }
> >  
> > -static long media_device_request_alloc(struct media_device *mdev,
> > -				       int *alloc_fd)
> > +static long media_device_request_alloc(struct media_device *mdev, void *arg)
> >  {
> > +	int *alloc_fd = arg;
> > +
> >  #ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API
> >  	if (!mdev->ops || !mdev->ops->req_validate || !mdev->ops->req_queue)
> >  		return -ENOTTY;
> > 
> 
> This change is fine, but the reason this wasn't noticed before is the cast in
> the MEDIA_IOC_ARG define:
> 
> #define MEDIA_IOC_ARG(__cmd, func, fl, from_user, to_user)              \
>         [_IOC_NR(MEDIA_IOC_##__cmd)] = {                                \
>                 .cmd = MEDIA_IOC_##__cmd,                               \
>                 .fn = (long (*)(struct media_device *, void *))func,    \
>                 .flags = fl,                                            \
>                 .arg_from_user = from_user,                             \
>                 .arg_to_user = to_user,                                 \
>         }
> 
> When assigning to .fn the func is cast to a specific function prototype.
> Without that cast the compiler would have warned about the mismatch.
> 
> I see no reason for that cast, so drop that cast as well.

I got it. I will remove the cast in the next patch.

> 
> Regards,
> 
> 	Hans


Sincerely,

Frederic Chen
diff mbox series

Patch

diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
index da8088351135..bc5b5ecb6581 100644
--- a/drivers/media/mc/mc-device.c
+++ b/drivers/media/mc/mc-device.c
@@ -370,9 +370,10 @@  static long media_device_get_topology(struct media_device *mdev, void *arg)
 	return ret;
 }
 
-static long media_device_request_alloc(struct media_device *mdev,
-				       int *alloc_fd)
+static long media_device_request_alloc(struct media_device *mdev, void *arg)
 {
+	int *alloc_fd = arg;
+
 #ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API
 	if (!mdev->ops || !mdev->ops->req_validate || !mdev->ops->req_queue)
 		return -ENOTTY;