staging: comedi: amplc_pc236: Remove most #if lines
Remove most of the #if IS_ENABLED(xxx) lines, but add extra if (IS_ENABLED(xxx)) tests so the compiler can remove unreachable code. The pci_driver stuff and device table is still conditionally compiled. Also made pc236_find_pci() static as it was accidentally made non-static by an earlier patch, so the compiler wouldn't remove it when it was unreachable. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
18e41de083
commit
a46e759fc0
1 changed files with 39 additions and 77 deletions
|
@ -98,9 +98,7 @@ enum pc236_model { pc36at_model, pci236_model, anypci_model };
|
||||||
|
|
||||||
struct pc236_board {
|
struct pc236_board {
|
||||||
const char *name;
|
const char *name;
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
|
||||||
unsigned short devid;
|
unsigned short devid;
|
||||||
#endif
|
|
||||||
enum pc236_bustype bustype;
|
enum pc236_bustype bustype;
|
||||||
enum pc236_model model;
|
enum pc236_model model;
|
||||||
};
|
};
|
||||||
|
@ -133,18 +131,15 @@ static const struct pc236_board pc236_boards[] = {
|
||||||
feel free to suggest moving the variable to the struct comedi_device struct.
|
feel free to suggest moving the variable to the struct comedi_device struct.
|
||||||
*/
|
*/
|
||||||
struct pc236_private {
|
struct pc236_private {
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
|
||||||
/* PCI device */
|
/* PCI device */
|
||||||
struct pci_dev *pci_dev;
|
struct pci_dev *pci_dev;
|
||||||
unsigned long lcr_iobase; /* PLX PCI9052 config registers in PCIBAR1 */
|
unsigned long lcr_iobase; /* PLX PCI9052 config registers in PCIBAR1 */
|
||||||
#endif
|
|
||||||
int enable_irq;
|
int enable_irq;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function looks for a board matching the supplied PCI device.
|
* This function looks for a board matching the supplied PCI device.
|
||||||
*/
|
*/
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
|
||||||
static const struct pc236_board *pc236_find_pci_board(struct pci_dev *pci_dev)
|
static const struct pc236_board *pc236_find_pci_board(struct pci_dev *pci_dev)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -155,14 +150,12 @@ static const struct pc236_board *pc236_find_pci_board(struct pci_dev *pci_dev)
|
||||||
return &pc236_boards[i];
|
return &pc236_boards[i];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function looks for a PCI device matching the requested board name,
|
* This function looks for a PCI device matching the requested board name,
|
||||||
* bus and slot.
|
* bus and slot.
|
||||||
*/
|
*/
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
static struct pci_dev *
|
||||||
struct pci_dev *
|
|
||||||
pc236_find_pci(struct comedi_device *dev, int bus, int slot)
|
pc236_find_pci(struct comedi_device *dev, int bus, int slot)
|
||||||
{
|
{
|
||||||
const struct pc236_board *thisboard = comedi_board(dev);
|
const struct pc236_board *thisboard = comedi_board(dev);
|
||||||
|
@ -207,13 +200,11 @@ pc236_find_pci(struct comedi_device *dev, int bus, int slot)
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function checks and requests an I/O region, reporting an error
|
* This function checks and requests an I/O region, reporting an error
|
||||||
* if there is a conflict.
|
* if there is a conflict.
|
||||||
*/
|
*/
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)
|
|
||||||
static int pc236_request_region(struct comedi_device *dev, unsigned long from,
|
static int pc236_request_region(struct comedi_device *dev, unsigned long from,
|
||||||
unsigned long extent)
|
unsigned long extent)
|
||||||
{
|
{
|
||||||
|
@ -224,7 +215,6 @@ static int pc236_request_region(struct comedi_device *dev, unsigned long from,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is called to mark the interrupt as disabled (no command
|
* This function is called to mark the interrupt as disabled (no command
|
||||||
|
@ -238,10 +228,8 @@ static void pc236_intr_disable(struct comedi_device *dev)
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->spinlock, flags);
|
spin_lock_irqsave(&dev->spinlock, flags);
|
||||||
devpriv->enable_irq = 0;
|
devpriv->enable_irq = 0;
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && devpriv->lcr_iobase)
|
||||||
if (devpriv->lcr_iobase)
|
|
||||||
outl(PCI236_INTR_DISABLE, devpriv->lcr_iobase + PLX9052_INTCSR);
|
outl(PCI236_INTR_DISABLE, devpriv->lcr_iobase + PLX9052_INTCSR);
|
||||||
#endif
|
|
||||||
spin_unlock_irqrestore(&dev->spinlock, flags);
|
spin_unlock_irqrestore(&dev->spinlock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,10 +245,8 @@ static void pc236_intr_enable(struct comedi_device *dev)
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->spinlock, flags);
|
spin_lock_irqsave(&dev->spinlock, flags);
|
||||||
devpriv->enable_irq = 1;
|
devpriv->enable_irq = 1;
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && devpriv->lcr_iobase)
|
||||||
if (devpriv->lcr_iobase)
|
|
||||||
outl(PCI236_INTR_ENABLE, devpriv->lcr_iobase + PLX9052_INTCSR);
|
outl(PCI236_INTR_ENABLE, devpriv->lcr_iobase + PLX9052_INTCSR);
|
||||||
#endif
|
|
||||||
spin_unlock_irqrestore(&dev->spinlock, flags);
|
spin_unlock_irqrestore(&dev->spinlock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,8 +266,8 @@ static int pc236_intr_check(struct comedi_device *dev)
|
||||||
spin_lock_irqsave(&dev->spinlock, flags);
|
spin_lock_irqsave(&dev->spinlock, flags);
|
||||||
if (devpriv->enable_irq) {
|
if (devpriv->enable_irq) {
|
||||||
retval = 1;
|
retval = 1;
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) &&
|
||||||
if (devpriv->lcr_iobase) {
|
devpriv->lcr_iobase) {
|
||||||
if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR)
|
if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR)
|
||||||
& PLX9052_INTCSR_LI1STAT_MASK)
|
& PLX9052_INTCSR_LI1STAT_MASK)
|
||||||
== PLX9052_INTCSR_LI1STAT_INACTIVE) {
|
== PLX9052_INTCSR_LI1STAT_INACTIVE) {
|
||||||
|
@ -292,7 +278,6 @@ static int pc236_intr_check(struct comedi_device *dev)
|
||||||
devpriv->lcr_iobase + PLX9052_INTCSR);
|
devpriv->lcr_iobase + PLX9052_INTCSR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&dev->spinlock, flags);
|
spin_unlock_irqrestore(&dev->spinlock, flags);
|
||||||
|
|
||||||
|
@ -437,26 +422,18 @@ static void pc236_report_attach(struct comedi_device *dev, unsigned int irq)
|
||||||
char tmpbuf[60];
|
char tmpbuf[60];
|
||||||
int tmplen;
|
int tmplen;
|
||||||
|
|
||||||
switch (thisboard->bustype) {
|
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) &&
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)
|
thisboard->bustype == isa_bustype)
|
||||||
case isa_bustype:
|
|
||||||
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
|
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
|
||||||
"(base %#lx) ", dev->iobase);
|
"(base %#lx) ", dev->iobase);
|
||||||
break;
|
else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) &&
|
||||||
#endif
|
thisboard->bustype == pci_bustype) {
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
struct pc236_private *devpriv = dev->private;
|
||||||
case pci_bustype: {
|
struct pci_dev *pci_dev = devpriv->pci_dev;
|
||||||
struct pc236_private *devpriv = dev->private;
|
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
|
||||||
struct pci_dev *pci_dev = devpriv->pci_dev;
|
"(pci %s) ", pci_name(pci_dev));
|
||||||
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
|
} else
|
||||||
"(pci %s) ", pci_name(pci_dev));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
tmplen = 0;
|
tmplen = 0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (irq)
|
if (irq)
|
||||||
tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen,
|
tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen,
|
||||||
"(irq %u%s) ", irq,
|
"(irq %u%s) ", irq,
|
||||||
|
@ -514,7 +491,6 @@ static int pc236_common_attach(struct comedi_device *dev, unsigned long iobase,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
|
||||||
static int pc236_pci_common_attach(struct comedi_device *dev,
|
static int pc236_pci_common_attach(struct comedi_device *dev,
|
||||||
struct pci_dev *pci_dev)
|
struct pci_dev *pci_dev)
|
||||||
{
|
{
|
||||||
|
@ -533,7 +509,6 @@ static int pc236_pci_common_attach(struct comedi_device *dev,
|
||||||
iobase = pci_resource_start(pci_dev, 2);
|
iobase = pci_resource_start(pci_dev, 2);
|
||||||
return pc236_common_attach(dev, iobase, pci_dev->irq, IRQF_SHARED);
|
return pc236_common_attach(dev, iobase, pci_dev->irq, IRQF_SHARED);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach is called by the Comedi core to configure the driver
|
* Attach is called by the Comedi core to configure the driver
|
||||||
|
@ -553,37 +528,29 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/* Process options according to bus type. */
|
/* Process options according to bus type. */
|
||||||
switch (thisboard->bustype) {
|
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) &&
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)
|
thisboard->bustype == isa_bustype) {
|
||||||
case isa_bustype: {
|
unsigned long iobase = it->options[0];
|
||||||
unsigned long iobase = it->options[0];
|
unsigned int irq = it->options[1];
|
||||||
unsigned int irq = it->options[1];
|
ret = pc236_request_region(dev, iobase, PC236_IO_SIZE);
|
||||||
ret = pc236_request_region(dev, iobase, PC236_IO_SIZE);
|
if (ret < 0)
|
||||||
if (ret < 0)
|
return ret;
|
||||||
return ret;
|
return pc236_common_attach(dev, iobase, irq, 0);
|
||||||
return pc236_common_attach(dev, iobase, irq, 0);
|
} else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) &&
|
||||||
}
|
thisboard->bustype == pci_bustype) {
|
||||||
break;
|
int bus = it->options[0];
|
||||||
#endif
|
int slot = it->options[1];
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
struct pci_dev *pci_dev;
|
||||||
case pci_bustype: {
|
|
||||||
int bus = it->options[0];
|
|
||||||
int slot = it->options[1];
|
|
||||||
struct pci_dev *pci_dev;
|
|
||||||
|
|
||||||
pci_dev = pc236_find_pci(dev, bus, slot);
|
pci_dev = pc236_find_pci(dev, bus, slot);
|
||||||
if (pci_dev == NULL)
|
if (pci_dev == NULL)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
return pc236_pci_common_attach(dev, pci_dev);
|
return pc236_pci_common_attach(dev, pci_dev);
|
||||||
}
|
} else {
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
dev_err(dev->class_dev, PC236_DRIVER_NAME
|
dev_err(dev->class_dev, PC236_DRIVER_NAME
|
||||||
": BUG! cannot determine board type!\n");
|
": BUG! cannot determine board type!\n");
|
||||||
break;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -591,12 +558,14 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
* to the "manual" attach hook. dev->board_ptr is NULL on entry. There should
|
* to the "manual" attach hook. dev->board_ptr is NULL on entry. There should
|
||||||
* be a board entry matching the supplied PCI device.
|
* be a board entry matching the supplied PCI device.
|
||||||
*/
|
*/
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
|
||||||
static int __devinit pc236_attach_pci(struct comedi_device *dev,
|
static int __devinit pc236_attach_pci(struct comedi_device *dev,
|
||||||
struct pci_dev *pci_dev)
|
struct pci_dev *pci_dev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n",
|
dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n",
|
||||||
pci_name(pci_dev));
|
pci_name(pci_dev));
|
||||||
ret = alloc_private(dev, sizeof(struct pc236_private));
|
ret = alloc_private(dev, sizeof(struct pc236_private));
|
||||||
|
@ -611,7 +580,6 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev,
|
||||||
}
|
}
|
||||||
return pc236_pci_common_attach(dev, pci_dev);
|
return pc236_pci_common_attach(dev, pci_dev);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void pc236_detach(struct comedi_device *dev)
|
static void pc236_detach(struct comedi_device *dev)
|
||||||
{
|
{
|
||||||
|
@ -624,18 +592,14 @@ static void pc236_detach(struct comedi_device *dev)
|
||||||
if (dev->subdevices)
|
if (dev->subdevices)
|
||||||
subdev_8255_cleanup(dev, dev->subdevices + 0);
|
subdev_8255_cleanup(dev, dev->subdevices + 0);
|
||||||
if (devpriv) {
|
if (devpriv) {
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) &&
|
||||||
if (devpriv->pci_dev) {
|
devpriv->pci_dev) {
|
||||||
if (dev->iobase)
|
if (dev->iobase)
|
||||||
comedi_pci_disable(devpriv->pci_dev);
|
comedi_pci_disable(devpriv->pci_dev);
|
||||||
pci_dev_put(devpriv->pci_dev);
|
pci_dev_put(devpriv->pci_dev);
|
||||||
} else
|
} else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)) {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)
|
|
||||||
if (dev->iobase)
|
if (dev->iobase)
|
||||||
release_region(dev->iobase, PC236_IO_SIZE);
|
release_region(dev->iobase, PC236_IO_SIZE);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -650,9 +614,7 @@ static struct comedi_driver amplc_pc236_driver = {
|
||||||
.driver_name = PC236_DRIVER_NAME,
|
.driver_name = PC236_DRIVER_NAME,
|
||||||
.module = THIS_MODULE,
|
.module = THIS_MODULE,
|
||||||
.attach = pc236_attach,
|
.attach = pc236_attach,
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
|
|
||||||
.attach_pci = pc236_attach_pci,
|
.attach_pci = pc236_attach_pci,
|
||||||
#endif
|
|
||||||
.detach = pc236_detach,
|
.detach = pc236_detach,
|
||||||
.board_name = &pc236_boards[0].name,
|
.board_name = &pc236_boards[0].name,
|
||||||
.offset = sizeof(struct pc236_board),
|
.offset = sizeof(struct pc236_board),
|
||||||
|
|
Loading…
Add table
Reference in a new issue