Commit 2f3da417 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_eeprom: cleanup i_EepromReadAnlogInputHeader()

Add namespace by renaming this CamelCase function to
addi_eeprom_read_ai_info().

Refactor the function so that it stores the data from the eeprom directly
in the private data instead of using the a struct to pass the data back
to i_EepromReadMainHeader(). This allows removing the str_AnalogInputHeader
struct.

The return value is always 0 and it's never checked. Change it to void.
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 6dbae1ff
...@@ -80,14 +80,6 @@ struct str_TimerMainHeader { ...@@ -80,14 +80,6 @@ struct str_TimerMainHeader {
struct str_TimerDetails s_TimerDetails[4]; /* supports 4 timers */ struct str_TimerDetails s_TimerDetails[4]; /* supports 4 timers */
}; };
struct str_AnalogInputHeader {
unsigned short w_Nchannel;
unsigned short w_MinConvertTiming;
unsigned short w_MinDelayTiming;
unsigned char b_HasDma;
unsigned char b_Resolution;
};
static void addi_eeprom_clk_93c76(unsigned long iobase, unsigned int val) static void addi_eeprom_clk_93c76(unsigned long iobase, unsigned int val)
{ {
outl(val & ~EE93C76_CLK_BIT, iobase); outl(val & ~EE93C76_CLK_BIT, iobase);
...@@ -313,52 +305,50 @@ static void addi_eeprom_read_ao_info(struct comedi_device *dev, ...@@ -313,52 +305,50 @@ static void addi_eeprom_read_ao_info(struct comedi_device *dev,
devpriv->s_EeParameters.i_AoMaxdata = 0xfff >> (16 - tmp); devpriv->s_EeParameters.i_AoMaxdata = 0xfff >> (16 - tmp);
} }
/* Reads only for ONE hardware component */ static void addi_eeprom_read_ai_info(struct comedi_device *dev,
static int i_EepromReadAnlogInputHeader(unsigned long iobase, unsigned long iobase,
char *type, char *type,
unsigned short w_Address, unsigned short addr)
struct str_AnalogInputHeader *s_Header)
{ {
unsigned short w_Temp, w_Offset; const struct addi_board *this_board = comedi_board(dev);
w_Temp = addi_eeprom_readw(iobase, type, w_Address + 10); struct addi_private *devpriv = dev->private;
s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF; unsigned short offset;
s_Header->w_MinConvertTiming = addi_eeprom_readw(iobase, type, unsigned short tmp;
w_Address + 16);
s_Header->w_MinDelayTiming = addi_eeprom_readw(iobase, type,
w_Address + 30);
w_Temp = addi_eeprom_readw(iobase, type,
w_Address + 20);
s_Header->b_HasDma = (w_Temp >> 13) & 0x01; /* whether dma present or not */
/* reading Y */
w_Temp = addi_eeprom_readw(iobase, type, w_Address + 72);
w_Temp = w_Temp & 0x00FF;
if (w_Temp) /* Y>0 */
{
w_Offset = 74 + (2 * w_Temp) + (10 * (1 + (w_Temp / 16))); /* offset of first analog input single header */
w_Offset = w_Offset + 2; /* resolution */
} else /* Y=0 */
{
w_Offset = 74;
w_Offset = w_Offset + 2; /* resolution */
}
/* read Resolution */ /* No of channels for 1st hard component */
w_Temp = addi_eeprom_readw(iobase, type, w_Address + w_Offset); tmp = addi_eeprom_readw(iobase, type, addr + 10);
s_Header->b_Resolution = w_Temp & 0x001F; /* last 5 bits */ devpriv->s_EeParameters.i_NbrAiChannel = (tmp >> 4) & 0x3ff;
if (!strcmp(this_board->pc_DriverName, "apci3200"))
devpriv->s_EeParameters.i_NbrAiChannel *= 4;
return 0; tmp = addi_eeprom_readw(iobase, type, addr + 16);
devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = tmp * 1000;
tmp = addi_eeprom_readw(iobase, type, addr + 30);
devpriv->s_EeParameters.ui_MinDelaytimeNs = tmp * 1000;
tmp = addi_eeprom_readw(iobase, type, addr + 20);
devpriv->s_EeParameters.i_Dma = (tmp >> 13) & 0x01;
tmp = addi_eeprom_readw(iobase, type, addr + 72) & 0xff;
if (tmp) { /* > 0 */
/* offset of first analog input single header */
offset = 74 + (2 * tmp) + (10 * (1 + (tmp / 16)));
} else { /* = 0 */
offset = 74;
}
/* Resolution */
tmp = addi_eeprom_readw(iobase, type, addr + offset + 2) & 0x1f;
devpriv->s_EeParameters.i_AiMaxdata = 0xffff >> (16 - tmp);
} }
static int i_EepromReadMainHeader(unsigned long iobase, static int i_EepromReadMainHeader(unsigned long iobase,
char *type, char *type,
struct comedi_device *dev) struct comedi_device *dev)
{ {
const struct addi_board *this_board = comedi_board(dev);
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
unsigned int ui_Temp;
/* struct str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader; */ /* struct str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader; */
struct str_AnalogInputHeader s_AnalogInputHeader;
unsigned short size; unsigned short size;
unsigned char nfuncs; unsigned char nfuncs;
int i; int i;
...@@ -385,27 +375,7 @@ static int i_EepromReadMainHeader(unsigned long iobase, ...@@ -385,27 +375,7 @@ static int i_EepromReadMainHeader(unsigned long iobase,
break; break;
case EEPROM_ANALOGINPUT: case EEPROM_ANALOGINPUT:
i_EepromReadAnlogInputHeader(iobase, type, addr, addi_eeprom_read_ai_info(dev, iobase, type, addr);
&s_AnalogInputHeader);
if (!(strcmp(this_board->pc_DriverName, "apci3200")))
devpriv->s_EeParameters.i_NbrAiChannel =
s_AnalogInputHeader.w_Nchannel * 4;
else
devpriv->s_EeParameters.i_NbrAiChannel =
s_AnalogInputHeader.w_Nchannel;
devpriv->s_EeParameters.i_Dma =
s_AnalogInputHeader.b_HasDma;
devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
(unsigned int) s_AnalogInputHeader.w_MinConvertTiming *
1000;
devpriv->s_EeParameters.ui_MinDelaytimeNs =
(unsigned int) s_AnalogInputHeader.w_MinDelayTiming *
1000;
ui_Temp = 0xffff;
devpriv->s_EeParameters.i_AiMaxdata =
ui_Temp >> (16 -
s_AnalogInputHeader.b_Resolution);
break; break;
case EEPROM_ANALOGOUTPUT: case EEPROM_ANALOGOUTPUT:
......
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