[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87od26q3d8.fsf@basil.nowhere.org>
Date: Mon, 29 Sep 2008 19:16:35 +0200
From: Andi Kleen <andi@...stfloor.org>
To: Avi Kivity <avi@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, viro@...IV.linux.org.uk,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] ioctl: generic ioctl dispatcher
Avi Kivity <avi@...hat.com> writes:
> +/**
> + * dispatch_ioctl - dispatch to an ioctl handler based on ioctl number
> + * @inode: inode to invoke ioctl method on
> + * @filp: open file to invoke ioctl method on
> + * @cmd: ioctl command to execute
> + * @arg: command-specific argument for ioctl
> + * @handlers: list of potential handlers for @cmd; null terminated;
> + * place frequently used cmds first
> + * @fallback: optional function to call if @cmd not found in @handlers
> + *
> + * Locates and calls ioctl handler in @handlers; if none exist, calls
> + * @fallback; if that does not exist, return -ENOTTY.
> + */
> +long dispatch_ioctl(struct inode *inode, struct file *filp,
> + unsigned cmd, unsigned long arg,
> + const struct ioctl_handler *handlers,
> + long (*fallback)(const struct ioctl_arg *arg))
The basic idea is good, but i don't like the proliferation of callbacks,
which tends to make complicated code and is ugly for simple code
(which a lot of ioctls are)
How about you make it return an number that can index a switch() instead?
Then everything could be still kept in the same function.
-Andi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists