Re: [PATCH] virtio-mmio: Devices parameter parsing
From: Rusty Russell
Date: Tue Nov 15 2011 - 21:34:28 EST
On Tue, 15 Nov 2011 13:53:05 +0000, Pawel Moll <pawel.moll@xxxxxxx> 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, ¶m_ops_virtio_mmio, NULL, 0400);
Initialization and error handling is now done for you...
Cheers,
Rusty.
--
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/