Skip to content

Commit

Permalink
staging: comedi: amplc_pc236: Remove thisboard and devpriv macros
Browse files Browse the repository at this point in the history
The 'thisboard' and 'devpriv' macros rely on a local variable having a
specific name and yield pointers derived from that local variable.
Replace the macros with local variables wherever they occur.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Jun 5, 2012
1 parent 273ba54 commit 24ffe74
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions drivers/staging/comedi/drivers/amplc_pc236.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ static const struct pc236_board pc236_boards[] = {
#endif
};

/*
* Useful for shorthand access to the particular board structure
*/
#define thisboard ((const struct pc236_board *)dev->board_ptr)

/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct.
Expand All @@ -144,8 +139,6 @@ struct pc236_private {
int enable_irq;
};

#define devpriv ((struct pc236_private *)dev->private)

/*
* This function looks for a PCI device matching the requested board name,
* bus and slot.
Expand All @@ -154,6 +147,7 @@ struct pc236_private {
struct pci_dev *
pc236_find_pci(struct comedi_device *dev, int bus, int slot)
{
const struct pc236_board *thisboard = comedi_board(dev);
struct pci_dev *pci_dev = NULL;

/* Look for matching PCI device. */
Expand All @@ -177,6 +171,7 @@ pc236_find_pci(struct comedi_device *dev, int bus, int slot)
if (pci_dev->device == pc236_boards[i].devid) {
/* Change board_ptr to matched board. */
dev->board_ptr = &pc236_boards[i];
thisboard = comedi_board(dev);
break;
}
}
Expand Down Expand Up @@ -228,6 +223,7 @@ static int pc236_request_region(struct comedi_device *dev, unsigned long from,
*/
static void pc236_intr_disable(struct comedi_device *dev)
{
struct pc236_private *devpriv = dev->private;
unsigned long flags;

spin_lock_irqsave(&dev->spinlock, flags);
Expand All @@ -246,6 +242,7 @@ static void pc236_intr_disable(struct comedi_device *dev)
*/
static void pc236_intr_enable(struct comedi_device *dev)
{
struct pc236_private *devpriv = dev->private;
unsigned long flags;

spin_lock_irqsave(&dev->spinlock, flags);
Expand All @@ -266,6 +263,7 @@ static void pc236_intr_enable(struct comedi_device *dev)
*/
static int pc236_intr_check(struct comedi_device *dev)
{
struct pc236_private *devpriv = dev->private;
int retval = 0;
unsigned long flags;

Expand Down Expand Up @@ -425,6 +423,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d)

static void pc236_report_attach(struct comedi_device *dev, unsigned int irq)
{
const struct pc236_board *thisboard = comedi_board(dev);
char tmpbuf[60];
int tmplen;

Expand All @@ -436,9 +435,12 @@ static void pc236_report_attach(struct comedi_device *dev, unsigned int irq)
break;
#endif
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
case pci_bustype:
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
"(pci %s) ", pci_name(devpriv->pci_dev));
case pci_bustype: {
struct pc236_private *devpriv = dev->private;
struct pci_dev *pci_dev = devpriv->pci_dev;
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
"(pci %s) ", pci_name(pci_dev));
}
break;
#endif
default:
Expand All @@ -464,10 +466,12 @@ static void pc236_report_attach(struct comedi_device *dev, unsigned int irq)
*/
static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pc236_board *thisboard = comedi_board(dev);
struct comedi_subdevice *s;
unsigned long iobase = 0;
unsigned int irq = 0;
#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
struct pc236_private *devpriv = dev->private;
struct pci_dev *pci_dev = NULL;
int bus = 0, slot = 0;
#endif
Expand Down Expand Up @@ -498,6 +502,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
pci_dev = pc236_find_pci(dev, bus, slot);
if (pci_dev == NULL)
return -EIO;
thisboard = comedi_board(dev); /* replaced wildcard board */
devpriv->pci_dev = pci_dev;
break;
#endif
Expand Down Expand Up @@ -575,6 +580,8 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)

static void pc236_detach(struct comedi_device *dev)
{
struct pc236_private *devpriv = dev->private;

if (devpriv)
pc236_intr_disable(dev);
if (dev->irq)
Expand Down

0 comments on commit 24ffe74

Please sign in to comment.