lkml.org 
[lkml]   [2008]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 1/3] ioctl: generic ioctl dispatcher
    From
    Date
    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


    \
     
     \ /
      Last update: 2008-09-29 19:19    [W:0.023 / U:29.352 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site