Re: [PATCH] synclink_gt add compat_ioctl

From: Arnd Bergmann
Date: Sat May 05 2007 - 20:28:00 EST


On Saturday 05 May 2007, Paul Fulghum wrote:

> That declaration will need to be duplicated in each driver that
> uses it (4 drivers in my case). In that sense (a structure declaration
> used by multiple code modules) it does seem like an interface definition.
>
> If that is what is needed, I will do it.

Now that you mention the duplication, this sounds wrong as well. The easiest
solution is probably to just put the definition of your data structure
inside of #ifdef CONFIG_COMPAT in the header file.

Or you could go really fancy and write a new file that does the synclink
compat_ioctl handling in a generic way end in the end just calls the
fops->{unlocked_,}ioctl() function.

Which reminds me that I have been meaning to do a patch that creates
a new generic_compat_ioctl() [1] function for some time, and convert
drivers to this if their handlers are all compatible.

Arnd <><

[1]
/*
* Can be used as the ->compat_ioctl method in the file_operations
* for any driver that does not need any conversion in its ioctl
* handler
*/
long generic_file_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int ret;
arg = (unsigned long)compat_ptr(arg);

if (file->f_ops->unlocked_ioctl)
ret = file->f_ops->unlocked_ioctl(file, cmd, arg);
else {
lock_kernel();
ret = file->f_ops->ioctl(file, cmd, arg);
unlock_kernel();
} else
ret = -ENOIOCTLCMD;

return ret;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/