Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 337203
b: refs/heads/master
c: 9186ccd
h: refs/heads/master
i:
  337201: 74c2400
  337199: a70bf9c
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Oct 24, 2012
1 parent b1c12ff commit 0b0d9b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 990b9eeda07b3f0c72dd2afa28e25067752e5222
refs/heads/master: 9186ccdec5b60220e9f10b0ee68f13156d099a10
30 changes: 16 additions & 14 deletions trunk/drivers/staging/comedi/drivers/ni_660x.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,11 @@ struct ni_660x_private {
unsigned short pfi_output_selects[NUM_PFI_CHANNELS];
};

/* initialized in ni_660x_attach_pci() */
static inline const struct ni_660x_board *board(struct comedi_device *dev)
{
return dev->board_ptr;
}

static inline unsigned ni_660x_num_counters(struct comedi_device *dev)
{
return board(dev)->n_chips * counters_per_chip;
const struct ni_660x_board *board = comedi_board(dev);

return board->n_chips * counters_per_chip;
}

static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg)
Expand Down Expand Up @@ -946,11 +942,12 @@ static int ni_660x_allocate_private(struct comedi_device *dev)

static int ni_660x_alloc_mite_rings(struct comedi_device *dev)
{
const struct ni_660x_board *board = comedi_board(dev);
struct ni_660x_private *devpriv = dev->private;
unsigned i;
unsigned j;

for (i = 0; i < board(dev)->n_chips; ++i) {
for (i = 0; i < board->n_chips; ++i) {
for (j = 0; j < counters_per_chip; ++j) {
devpriv->mite_rings[i][j] =
mite_alloc_ring(devpriv->mite);
Expand All @@ -963,11 +960,12 @@ static int ni_660x_alloc_mite_rings(struct comedi_device *dev)

static void ni_660x_free_mite_rings(struct comedi_device *dev)
{
const struct ni_660x_board *board = comedi_board(dev);
struct ni_660x_private *devpriv = dev->private;
unsigned i;
unsigned j;

for (i = 0; i < board(dev)->n_chips; ++i) {
for (i = 0; i < board->n_chips; ++i) {
for (j = 0; j < counters_per_chip; ++j)
mite_free_ring(devpriv->mite_rings[i][j]);
}
Expand Down Expand Up @@ -1051,14 +1049,15 @@ static void ni_660x_select_pfi_output(struct comedi_device *dev,
unsigned pfi_channel,
unsigned output_select)
{
const struct ni_660x_board *board = comedi_board(dev);
static const unsigned counter_4_7_first_pfi = 8;
static const unsigned counter_4_7_last_pfi = 23;
unsigned active_chipset = 0;
unsigned idle_chipset = 0;
unsigned active_bits;
unsigned idle_bits;

if (board(dev)->n_chips > 1) {
if (board->n_chips > 1) {
if (output_select == pfi_output_select_counter &&
pfi_channel >= counter_4_7_first_pfi &&
pfi_channel <= counter_4_7_last_pfi) {
Expand Down Expand Up @@ -1181,6 +1180,7 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev,
static int __devinit ni_660x_attach_pci(struct comedi_device *dev,
struct pci_dev *pcidev)
{
const struct ni_660x_board *board;
struct ni_660x_private *devpriv;
struct comedi_subdevice *s;
int ret;
Expand All @@ -1195,11 +1195,13 @@ static int __devinit ni_660x_attach_pci(struct comedi_device *dev,
dev->board_ptr = ni_660x_find_boardinfo(pcidev);
if (!dev->board_ptr)
return -ENODEV;
board = comedi_board(dev);

devpriv->mite = mite_alloc(pcidev);
if (!devpriv->mite)
return -ENOMEM;

dev->board_name = board(dev)->name;
dev->board_name = board->name;

ret = mite_setup2(devpriv->mite, 1);
if (ret < 0) {
Expand Down Expand Up @@ -1270,7 +1272,7 @@ static int __devinit ni_660x_attach_pci(struct comedi_device *dev,
s->type = COMEDI_SUBD_UNUSED;
}
}
for (i = 0; i < board(dev)->n_chips; ++i)
for (i = 0; i < board->n_chips; ++i)
init_tio_chip(dev, i);

for (i = 0; i < ni_660x_num_counters(dev); ++i)
Expand All @@ -1286,7 +1288,7 @@ static int __devinit ni_660x_attach_pci(struct comedi_device *dev,
}
/* to be safe, set counterswap bits on tio chips after all the counter
outputs have been set to high impedance mode */
for (i = 0; i < board(dev)->n_chips; ++i)
for (i = 0; i < board->n_chips; ++i)
set_tio_counterswap(dev, i);

ret = request_irq(mite_irq(devpriv->mite), ni_660x_interrupt,
Expand All @@ -1297,7 +1299,7 @@ static int __devinit ni_660x_attach_pci(struct comedi_device *dev,
}
dev->irq = mite_irq(devpriv->mite);
global_interrupt_config_bits = Global_Int_Enable_Bit;
if (board(dev)->n_chips > 1)
if (board->n_chips > 1)
global_interrupt_config_bits |= Cascade_Int_Enable_Bit;
ni_660x_write_register(dev, 0, global_interrupt_config_bits,
GlobalInterruptConfigRegister);
Expand Down

0 comments on commit 0b0d9b7

Please sign in to comment.