staging: comedi: addi_eeprom: cleanup i_EepromReadDigitalInputHeader()
authorH Hartley Sweeten <hartleys@visionengravers.com>
Tue, 30 Oct 2012 00:07:45 +0000 (17:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Oct 2012 17:50:14 +0000 (10:50 -0700)
Add namespace by renaming this CamelCase function to
addi_eeprom_read_di_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_DigitalInputHeader
struct.

Leave the reads of the unused eeprom data for now.

The return value is always 0 and it's never checked. Change it to void.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi-data/addi_eeprom.c

index 529f9b1341cd40e17605f16408c833a13da4ac52..438968c261fd728ab315a339d6023e2daa2c9763 100644 (file)
@@ -66,12 +66,6 @@ You should also find the complete GPL in the COPYING file accompanying this sour
 #define EEPROM_WATCHDOG                                        5
 #define EEPROM_TIMER_WATCHDOG_COUNTER  10
 
-struct str_DigitalInputHeader {
-       unsigned short w_Nchannel;
-       unsigned char b_Interruptible;
-       unsigned short w_NinterruptLogic;
-};
-
 struct str_DigitalOutputHeader {
        unsigned short w_Nchannel;
 };
@@ -232,25 +226,24 @@ static unsigned short addi_eeprom_readw(unsigned long iobase,
        return val;
 }
 
-static int i_EepromReadDigitalInputHeader(unsigned long iobase,
-                                         char *type,
-                                         unsigned short w_Address,
-                                         struct str_DigitalInputHeader *s_Header)
+static void addi_eeprom_read_di_info(struct comedi_device *dev,
+                                    unsigned long iobase,
+                                    char *type,
+                                    unsigned short addr)
 {
-       unsigned short w_Temp;
+       struct addi_private *devpriv = dev->private;
+       unsigned short tmp;
 
-       /*  read nbr of channels */
-       s_Header->w_Nchannel = addi_eeprom_readw(iobase, type, w_Address + 6);
+       /* Number of channels */
+       tmp = addi_eeprom_readw(iobase, type, addr + 6);
+       devpriv->s_EeParameters.i_NbrDiChannel = tmp;
 
-       /*  interruptible or not */
-       w_Temp = addi_eeprom_readw(iobase, type, w_Address + 8);
-       s_Header->b_Interruptible = (unsigned char) (w_Temp >> 7) & 0x01;
+       /* Interruptible or not */
+       tmp = addi_eeprom_readw(iobase, type, addr + 8);
+       tmp = (tmp >> 7) & 0x01;
 
        /* How many interruptible logic */
-       s_Header->w_NinterruptLogic = addi_eeprom_readw(iobase, type,
-                                                       w_Address + 10);
-
-       return 0;
+       tmp = addi_eeprom_readw(iobase, type, addr + 10);
 }
 
 static int i_EepromReadDigitalOutputHeader(unsigned long iobase,
@@ -367,7 +360,6 @@ static int i_EepromReadMainHeader(unsigned long iobase,
        const struct addi_board *this_board = comedi_board(dev);
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Temp;
-       struct str_DigitalInputHeader s_DigitalInputHeader;
        struct str_DigitalOutputHeader s_DigitalOutputHeader;
        /* struct str_TimerMainHeader     s_TimerMainHeader,s_WatchdogMainHeader; */
        struct str_AnalogOutputHeader s_AnalogOutputHeader;
@@ -390,11 +382,7 @@ static int i_EepromReadMainHeader(unsigned long iobase,
 
                switch (func) {
                case EEPROM_DIGITALINPUT:
-                       i_EepromReadDigitalInputHeader(iobase, type, addr,
-                                                      &s_DigitalInputHeader);
-
-                       devpriv->s_EeParameters.i_NbrDiChannel =
-                               s_DigitalInputHeader.w_Nchannel;
+                       addi_eeprom_read_di_info(dev, iobase, type, addr);
                        break;
 
                case EEPROM_DIGITALOUTPUT: