[PATCH 2/9] VC04_SERVICES: Add top level compat ioctl handler

Dan Carpenter dan.carpenter at oracle.com
Wed Jan 18 23:01:58 UTC 2017


On Wed, Jan 18, 2017 at 07:04:46AM -0800, Michael Zoran wrote:
> Add the top level compat ioctl handler as a placeholder
> for adding additional handlers.
> 
> The ioctls are first filtered and forwarded to the
> regular ioctl handler if the ioctl does not require
> any extra compatibility processing.
> 
> Signed-off-by: Michael Zoran <mzoran at crowfest.net>
> ---
>  .../vc04_services/interface/vchiq_arm/vchiq_arm.c  | 73 ++++++++++++++++++++++
>  1 file changed, 73 insertions(+)
> 
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> index 0525211bcd65..9ade2f63606b 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -1206,6 +1206,76 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  	return ret;
>  }
>  
> +#if defined(CONFIG_COMPAT)
> +
> +static long
> +vchiq_ioctl_compat_internal(
> +	struct file *file,
> +	unsigned int cmd,
> +	unsigned long arg)

Align these with the open parenthesis.

> +{
> +	VCHIQ_INSTANCE_T instance = file->private_data;
> +	VCHIQ_STATUS_T status = VCHIQ_SUCCESS;
> +	VCHIQ_SERVICE_T *service = NULL;
> +	long ret = 0;
> +
> +	DEBUG_INITIALISE(g_state.local)

What a horrible little macro...

> +
> +	vchiq_log_trace(vchiq_arm_log_level,
> +			"vchiq_ioctl_compat - instance %pK, cmd %s, arg %lx",
> +			instance,
> +			((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) &&
> +			(_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ?
> +			ioctl_names[_IOC_NR(cmd)] : "<invalid>", arg);
> +
> +	switch (cmd) {
> +	default:
> +		ret = -ENOTTY;
> +		break;
> +	}

Ugh...

> +
> +	if (service)
> +		unlock_service(service);


More ugh...

> +
> +	if (ret == 0) {

What the heck???  I feel you're trying to gaslight me now.

It's unfortunate that this is right at the start of the series because
I've already met my quota of nonsense code and I won't be reviewing the
rest until v2 comes out.

regards,
dan carpenter



More information about the devel mailing list