Commit a7382a23 authored by Alessandro Rubini's avatar Alessandro Rubini

bugfix: kernel: move initializations

This commit changes the initialization order, so that the trigger type
is registered at module init, and not at device probe.

This allows the driver to properly work with more than one card, as
expected.  Thanks to Laura Delaporte for a good bug report on this.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 6570a61c
......@@ -105,13 +105,22 @@ static int fa_init(void)
int ret;
pr_debug("%s\n",__func__);
ret = fmc_driver_register(&fa_dev_drv);
/* First trigger and zio driver */
ret = fa_trig_init();
if (ret)
return ret;
ret = fa_zio_register();
if (ret) {
fa_trig_exit();
return ret;
}
/* Finally the fmc driver, whose probe instantiates zio devices */
ret = fmc_driver_register(&fa_dev_drv);
if (ret) {
fmc_driver_unregister(&fa_dev_drv);
fa_zio_unregister();
return ret;
}
return 0;
......@@ -119,8 +128,9 @@ static int fa_init(void)
static void fa_exit(void)
{
fa_zio_unregister();
fmc_driver_unregister(&fa_dev_drv);
fa_zio_unregister();
fa_trig_exit();
}
module_init(fa_init);
......
......@@ -1186,14 +1186,6 @@ int fa_zio_init(struct fa_dev *fa)
return -ENODEV;
}
/* Register our trigger hardware */
err = zio_register_trig(&zfat_type, "adc-100m14b");
if (err) {
dev_err(hwdev, "Cannot register ZIO trigger type"
" \"adc-100m14b\"\n");
goto out_trg;
}
/* Allocate the hardware zio_device for registration */
fa->hwzdev = zio_allocate_device();
if (IS_ERR(fa->hwzdev)) {
......@@ -1218,8 +1210,6 @@ int fa_zio_init(struct fa_dev *fa)
out_dev:
zio_free_device(fa->hwzdev);
out_allocate:
zio_unregister_trig(&zfat_type);
out_trg:
return err;
}
......@@ -1233,5 +1223,4 @@ void fa_zio_exit(struct fa_dev *fa)
{
zio_unregister_device(fa->hwzdev);
zio_free_device(fa->hwzdev);
zio_unregister_trig(&zfat_type);
}
......@@ -374,7 +374,7 @@ static const struct zio_trigger_operations zfat_ops = {
.push_block = zfat_push,
};
/* Definition of the trigger type */
/* Definition of the trigger type -- can't be static */
struct zio_trigger_type zfat_type = {
.owner = THIS_MODULE,
.zattr_set = {
......@@ -386,3 +386,18 @@ struct zio_trigger_type zfat_type = {
.t_op = &zfat_ops,
};
int fa_trig_init(void)
{
int err;
err = zio_register_trig(&zfat_type, "adc-100m14b");
if (err)
pr_err("%s: Cannot register ZIO trigger type"
" \"adc-100m14b\" (error %i)\n", KBUILD_MODNAME, err);
return err;
}
void fa_trig_exit(void)
{
zio_unregister_trig(&zfat_type);
}
......@@ -379,12 +379,16 @@ static inline void zfa_hardware_read(struct fa_dev *fa,
}
/* Functions exported by fa-zio.c */
/* Functions exported by fa-zio-drv.c */
extern int fa_zio_register(void);
extern void fa_zio_unregister(void);
extern int fa_zio_init(struct fa_dev *fa);
extern void fa_zio_exit(struct fa_dev *fa);
/* Functions exported by fa-zio-trg.c */
extern int fa_trig_init(void);
extern void fa_trig_exit(void);
/* Functions exported by fa-spec.c */
extern int fa_spec_init(void);
extern void fa_spec_exit(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment