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

staging: comedi: dt9812: pass the comedi_device * to dt9812_configure_gain()

For aesthetic reasons, instead of passing the struct usb_dt9812 pointer,
pass the comedi_device pointer to this function.

Tidy up the function and use the comedi_device class_dev for the
dev_err() message.
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 c13626a2
...@@ -462,18 +462,23 @@ static void dt9812_configure_mux(struct usb_dt9812 *dev, ...@@ -462,18 +462,23 @@ static void dt9812_configure_mux(struct usb_dt9812 *dev,
} }
} }
static void dt9812_configure_gain(struct usb_dt9812 *dev, static void dt9812_configure_gain(struct comedi_device *dev,
struct dt9812_rmw_byte *rmw, struct dt9812_rmw_byte *rmw,
enum dt9812_gain gain) enum dt9812_gain gain)
{ {
if (dev->device == DT9812_DEVID_DT9812_10) { struct dt9812_private *devpriv = dev->private;
/* In the DT9812/10V, there is an external gain of 0.5 */ struct slot_dt9812 *slot = devpriv->slot;
struct usb_dt9812 *usb = slot->usb;
/* In the DT9812/10V, there is an external gain of 0.5 */
if (usb->device == DT9812_DEVID_DT9812_10)
gain <<= 1; gain <<= 1;
}
rmw->address = F020_SFR_ADC0CF; rmw->address = F020_SFR_ADC0CF;
rmw->and_mask = F020_MASK_ADC0CF_AMP0GN2 | rmw->and_mask = F020_MASK_ADC0CF_AMP0GN2 |
F020_MASK_ADC0CF_AMP0GN1 | F020_MASK_ADC0CF_AMP0GN0; F020_MASK_ADC0CF_AMP0GN1 |
F020_MASK_ADC0CF_AMP0GN0;
switch (gain) { switch (gain) {
/* /*
* 000 -> Gain = 1 * 000 -> Gain = 1
...@@ -485,7 +490,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev, ...@@ -485,7 +490,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
*/ */
case DT9812_GAIN_0PT5: case DT9812_GAIN_0PT5:
rmw->or_value = F020_MASK_ADC0CF_AMP0GN2 | rmw->or_value = F020_MASK_ADC0CF_AMP0GN2 |
F020_MASK_ADC0CF_AMP0GN1; F020_MASK_ADC0CF_AMP0GN1;
break; break;
case DT9812_GAIN_1: case DT9812_GAIN_1:
rmw->or_value = 0x00; rmw->or_value = 0x00;
...@@ -498,14 +503,14 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev, ...@@ -498,14 +503,14 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
break; break;
case DT9812_GAIN_8: case DT9812_GAIN_8:
rmw->or_value = F020_MASK_ADC0CF_AMP0GN1 | rmw->or_value = F020_MASK_ADC0CF_AMP0GN1 |
F020_MASK_ADC0CF_AMP0GN0; F020_MASK_ADC0CF_AMP0GN0;
break; break;
case DT9812_GAIN_16: case DT9812_GAIN_16:
rmw->or_value = F020_MASK_ADC0CF_AMP0GN2; rmw->or_value = F020_MASK_ADC0CF_AMP0GN2;
break; break;
default: default:
dev_err(&dev->interface->dev, "Illegal gain %d\n", gain); dev_err(dev->class_dev, "Illegal gain %d\n", gain);
break;
} }
} }
...@@ -528,7 +533,7 @@ static int dt9812_analog_in(struct comedi_device *dev, ...@@ -528,7 +533,7 @@ static int dt9812_analog_in(struct comedi_device *dev,
goto exit; goto exit;
/* 1 select the gain */ /* 1 select the gain */
dt9812_configure_gain(slot->usb, &rmw[0], gain); dt9812_configure_gain(dev, &rmw[0], gain);
/* 2 set the MUX to select the channel */ /* 2 set the MUX to select the channel */
dt9812_configure_mux(slot->usb, &rmw[1], channel); dt9812_configure_mux(slot->usb, &rmw[1], channel);
......
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