From: Andi Kleen <andi@firstfloor.org>
To: Avi Kivity <avi@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
viro@ZenIV.linux.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] ioctl: generic ioctl dispatcher
Date: Mon, 29 Sep 2008 19:16:35 +0200 [thread overview]
Message-ID: <87od26q3d8.fsf@basil.nowhere.org> (raw)
In-Reply-To: <1222530242-1272-2-git-send-email-avi@redhat.com> (Avi Kivity's message of "Sat, 27 Sep 2008 18:44:00 +0300")
Avi Kivity <avi@redhat.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
next prev parent reply other threads:[~2008-09-29 17:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-27 15:43 [PATCH 0/3][RFC] ioctl dispatcher Avi Kivity
2008-09-27 15:44 ` [PATCH 1/3] ioctl: generic " Avi Kivity
2008-09-29 17:16 ` Andi Kleen [this message]
2008-09-30 9:08 ` Avi Kivity
2008-09-27 15:44 ` [PATCH 2/3] ioctl: extensible ioctl dispatch Avi Kivity
2008-09-27 15:44 ` [PATCH 3/3] KVM: Convert x86 vcpu ioctls to use dispatch_ioctl_extensible() Avi Kivity
2008-09-27 16:13 ` [PATCH 0/3][RFC] ioctl dispatcher Arjan van de Ven
2008-09-27 17:40 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87od26q3d8.fsf@basil.nowhere.org \
--to=andi@firstfloor.org \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox