lkml.org 
[lkml]   [2011]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH] virtio-mmio: Devices parameter parsing
    Date
    On Tue, 15 Nov 2011 13:53:05 +0000, Pawel Moll <pawel.moll@arm.com> wrote:
    > +static char *virtio_mmio_cmdline_devices;
    > +module_param_named(devices, virtio_mmio_cmdline_devices, charp, 0);

    This is the wrong way to do this.

    Don't put things in a charp and process it later. It's lazy. You
    should write parsers for it and call it straight from module_param.

    And if you do it that way, multiple devices are simply multiple
    arguments.

    Like so:

    static int virtio_mmio_set(const char *val, const struct kernel_param *kp)
    {
    if (!virtio_mmio_cmdline_parent_initialized) {
    err = device_register(&virtio_mmio_cmdline_parent);
    if (err)
    return err;
    virtio_mmio_cmdline_parent_initialized = true;
    }

    ... parse here, return -errno on fail, 0 on success.
    }

    static struct kernel_param_ops param_ops_virtio_mmio = {
    .set = virtio_mmio_set,
    .get = virtio_mmio_get,
    };

    module_param_cb(device, &param_ops_virtio_mmio, NULL, 0400);

    Initialization and error handling is now done for you...

    Cheers,
    Rusty.


    \
     
     \ /
      Last update: 2011-11-16 03:37    [W:2.941 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site