Skip to content

Commit

Permalink
staging: comedi: refactor pcmad driver to remove forward declarations
Browse files Browse the repository at this point in the history
Move the module_init/module_exit routines and the associated
struct comedi_driver and other variables to the end of the source.
This is more typical of how other drivers are written and removes
the need for the forward declarations.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Apr 30, 2012
1 parent f3ebaf4 commit 3496cb9
Showing 1 changed file with 31 additions and 36 deletions.
67 changes: 31 additions & 36 deletions drivers/staging/comedi/drivers/pcmad.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,51 +57,15 @@ struct pcmad_board_struct {
const char *name;
int n_ai_bits;
};
static const struct pcmad_board_struct pcmad_boards[] = {
{
.name = "pcmad12",
.n_ai_bits = 12,
},
{
.name = "pcmad16",
.n_ai_bits = 16,
},
};

#define this_board ((const struct pcmad_board_struct *)(dev->board_ptr))
#define n_pcmad_boards ARRAY_SIZE(pcmad_boards)

struct pcmad_priv_struct {
int differential;
int twos_comp;
};
#define devpriv ((struct pcmad_priv_struct *)dev->private)

static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it);
static int pcmad_detach(struct comedi_device *dev);
static struct comedi_driver driver_pcmad = {
.driver_name = "pcmad",
.module = THIS_MODULE,
.attach = pcmad_attach,
.detach = pcmad_detach,
.board_name = &pcmad_boards[0].name,
.num_names = n_pcmad_boards,
.offset = sizeof(pcmad_boards[0]),
};

static int __init driver_pcmad_init_module(void)
{
return comedi_driver_register(&driver_pcmad);
}

static void __exit driver_pcmad_cleanup_module(void)
{
comedi_driver_unregister(&driver_pcmad);
}

module_init(driver_pcmad_init_module);
module_exit(driver_pcmad_cleanup_module);

#define TIMEOUT 100

static int pcmad_ai_insn_read(struct comedi_device *dev,
Expand Down Expand Up @@ -188,6 +152,37 @@ static int pcmad_detach(struct comedi_device *dev)
return 0;
}

static const struct pcmad_board_struct pcmad_boards[] = {
{
.name = "pcmad12",
.n_ai_bits = 12,
}, {
.name = "pcmad16",
.n_ai_bits = 16,
},
};
static struct comedi_driver driver_pcmad = {
.driver_name = "pcmad",
.module = THIS_MODULE,
.attach = pcmad_attach,
.detach = pcmad_detach,
.board_name = &pcmad_boards[0].name,
.num_names = ARRAY_SIZE(pcmad_boards),
.offset = sizeof(pcmad_boards[0]),
};

static int __init driver_pcmad_init_module(void)
{
return comedi_driver_register(&driver_pcmad);
}
module_init(driver_pcmad_init_module);

static void __exit driver_pcmad_cleanup_module(void)
{
comedi_driver_unregister(&driver_pcmad);
}
module_exit(driver_pcmad_cleanup_module);

MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");

0 comments on commit 3496cb9

Please sign in to comment.