Commit 0e05c552 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_mio_common: remove devpriv macro

The ni_mio_common.c file is #include'd by the ni_atmio, ni_mio_cs,
and ni_pcimio drivers. Those drivers all have a devpriv macro of
this type:

This macro relies on a local variable having a specific name.
Remove its use in all the files by replacing it with a local
variable.

Some of the functions in ni_mio_common.c don't always use the
devpriv variable due to differences in how the low-level i/o
is handled by the driver. Tag the variable in those functions
with __maybe_unused to avoid compile warnings.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 843690b7
......@@ -284,8 +284,6 @@ struct ni_private {
};
#define devpriv ((struct ni_private *)dev->private)
/* How we access registers */
#define ni_writel(a, b) (outl((a), (b)+dev->iobase))
......@@ -303,6 +301,7 @@ struct ni_private {
static void ni_atmio_win_out(struct comedi_device *dev, uint16_t data, int addr)
{
struct ni_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&devpriv->window_lock, flags);
......@@ -317,6 +316,7 @@ static void ni_atmio_win_out(struct comedi_device *dev, uint16_t data, int addr)
static uint16_t ni_atmio_win_in(struct comedi_device *dev, int addr)
{
struct ni_private *devpriv = dev->private;
unsigned long flags;
uint16_t ret;
......@@ -406,16 +406,17 @@ static int ni_getboardtype(struct comedi_device *dev)
static int ni_atmio_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct ni_private *devpriv;
struct pnp_dev *isapnp_dev;
int ret;
unsigned long iobase;
int board;
unsigned int irq;
/* allocate private area */
ret = ni_alloc_private(dev);
if (ret < 0)
if (ret)
return ret;
devpriv = dev->private;
devpriv->stc_writew = &ni_atmio_win_out;
devpriv->stc_readw = &ni_atmio_win_in;
......@@ -499,6 +500,8 @@ static int ni_atmio_attach(struct comedi_device *dev,
static void ni_atmio_detach(struct comedi_device *dev)
{
struct ni_private *devpriv = dev->private;
mio_common_detach(dev);
if (dev->iobase)
release_region(dev->iobase, NI_SIZE);
......
......@@ -177,8 +177,6 @@ struct ni_private {
NI_PRIVATE_COMMON};
#define devpriv ((struct ni_private *)dev->private)
/* How we access registers */
#define ni_writel(a, b) (outl((a), (b)+dev->iobase))
......@@ -196,6 +194,7 @@ struct ni_private {
static void mio_cs_win_out(struct comedi_device *dev, uint16_t data, int addr)
{
struct ni_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&devpriv->window_lock, flags);
......@@ -210,6 +209,7 @@ static void mio_cs_win_out(struct comedi_device *dev, uint16_t data, int addr)
static uint16_t mio_cs_win_in(struct comedi_device *dev, int addr)
{
struct ni_private *devpriv = dev->private;
unsigned long flags;
uint16_t ret;
......@@ -324,6 +324,7 @@ static void mio_cs_config(struct pcmcia_device *link)
static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct ni_private *devpriv;
struct pcmcia_device *link;
unsigned int irq;
int ret;
......@@ -372,10 +373,10 @@ static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
dev->irq = irq;
/* allocate private area */
ret = ni_alloc_private(dev);
if (ret < 0)
if (ret)
return ret;
devpriv = dev->private;
devpriv->stc_writew = &mio_cs_win_out;
devpriv->stc_readw = &mio_cs_win_in;
......
......@@ -1190,7 +1190,6 @@ static const struct ni_board_struct ni_boards[] = {
struct ni_private {
NI_PRIVATE_COMMON};
#define devpriv ((struct ni_private *)dev->private)
/* How we access registers */
......@@ -1213,6 +1212,7 @@ NI_PRIVATE_COMMON};
static void e_series_win_out(struct comedi_device *dev, uint16_t data, int reg)
{
struct ni_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&devpriv->window_lock, flags);
......@@ -1223,6 +1223,7 @@ static void e_series_win_out(struct comedi_device *dev, uint16_t data, int reg)
static uint16_t e_series_win_in(struct comedi_device *dev, int reg)
{
struct ni_private *devpriv = dev->private;
unsigned long flags;
uint16_t ret;
......@@ -1237,7 +1238,9 @@ static uint16_t e_series_win_in(struct comedi_device *dev, int reg)
static void m_series_stc_writew(struct comedi_device *dev, uint16_t data,
int reg)
{
struct ni_private *devpriv = dev->private;
unsigned offset;
switch (reg) {
case ADC_FIFO_Clear:
offset = M_Offset_AI_FIFO_Clear;
......@@ -1392,7 +1395,9 @@ static void m_series_stc_writew(struct comedi_device *dev, uint16_t data,
static uint16_t m_series_stc_readw(struct comedi_device *dev, int reg)
{
struct ni_private *devpriv = dev->private;
unsigned offset;
switch (reg) {
case AI_Status_1_Register:
offset = M_Offset_AI_Status_1;
......@@ -1428,7 +1433,9 @@ static uint16_t m_series_stc_readw(struct comedi_device *dev, int reg)
static void m_series_stc_writel(struct comedi_device *dev, uint32_t data,
int reg)
{
struct ni_private *devpriv = dev->private;
unsigned offset;
switch (reg) {
case AI_SC_Load_A_Registers:
offset = M_Offset_AI_SC_Load_A;
......@@ -1469,7 +1476,9 @@ static void m_series_stc_writel(struct comedi_device *dev, uint32_t data,
static uint32_t m_series_stc_readl(struct comedi_device *dev, int reg)
{
struct ni_private *devpriv = dev->private;
unsigned offset;
switch (reg) {
case G_HW_Save_Register(0):
offset = M_Offset_G0_HW_Save;
......@@ -1516,6 +1525,7 @@ static int pcimio_dio_change(struct comedi_device *dev,
static void m_series_init_eeprom_buffer(struct comedi_device *dev)
{
struct ni_private *devpriv = dev->private;
static const int Start_Cal_EEPROM = 0x400;
static const unsigned window_size = 10;
static const int serial_number_eeprom_offset = 0x4;
......@@ -1553,6 +1563,8 @@ static void m_series_init_eeprom_buffer(struct comedi_device *dev)
static void init_6143(struct comedi_device *dev)
{
struct ni_private *devpriv = dev->private;
/* Disable interrupts */
devpriv->stc_writew(dev, 0, Interrupt_Control_Register);
......@@ -1572,10 +1584,12 @@ static void init_6143(struct comedi_device *dev)
static void pcimio_detach(struct comedi_device *dev)
{
struct ni_private *devpriv = dev->private;
mio_common_detach(dev);
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->private) {
if (devpriv) {
mite_free_ring(devpriv->ai_mite_ring);
mite_free_ring(devpriv->ao_mite_ring);
mite_free_ring(devpriv->cdo_mite_ring);
......@@ -1605,13 +1619,15 @@ pcimio_find_boardinfo(struct pci_dev *pcidev)
static int __devinit pcimio_attach_pci(struct comedi_device *dev,
struct pci_dev *pcidev)
{
struct ni_private *devpriv;
int ret;
dev_info(dev->class_dev, "ni_pcimio: attach %s\n", pci_name(pcidev));
ret = ni_alloc_private(dev);
if (ret < 0)
if (ret)
return ret;
devpriv = dev->private;
dev->board_ptr = pcimio_find_boardinfo(pcidev);
if (!dev->board_ptr)
......@@ -1693,6 +1709,7 @@ static int __devinit pcimio_attach_pci(struct comedi_device *dev,
static int pcimio_ai_change(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned long new_size)
{
struct ni_private *devpriv = dev->private;
int ret;
ret = mite_buf_change(devpriv->ai_mite_ring, s->async);
......@@ -1705,6 +1722,7 @@ static int pcimio_ai_change(struct comedi_device *dev,
static int pcimio_ao_change(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned long new_size)
{
struct ni_private *devpriv = dev->private;
int ret;
ret = mite_buf_change(devpriv->ao_mite_ring, s->async);
......@@ -1718,6 +1736,7 @@ static int pcimio_gpct0_change(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned long new_size)
{
struct ni_private *devpriv = dev->private;
int ret;
ret = mite_buf_change(devpriv->gpct_mite_ring[0], s->async);
......@@ -1731,6 +1750,7 @@ static int pcimio_gpct1_change(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned long new_size)
{
struct ni_private *devpriv = dev->private;
int ret;
ret = mite_buf_change(devpriv->gpct_mite_ring[1], s->async);
......@@ -1743,6 +1763,7 @@ static int pcimio_gpct1_change(struct comedi_device *dev,
static int pcimio_dio_change(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned long new_size)
{
struct ni_private *devpriv = dev->private;
int ret;
ret = mite_buf_change(devpriv->cdo_mite_ring, s->async);
......
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