Skip to content

Commit

Permalink
staging:iio:sca3000 extract old event handling and move to poll for e…
Browse files Browse the repository at this point in the history
…vents from buffer

Fairly substantial rewrite as the code had bitrotted.
A rethink is needed for how to handle variable types in the new chan_spec world.

This patch restores sca3000 buffer usage to a working state.
V3: Rebase fixups.
V2: Move to new version of IIO_CHAN macro

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed May 19, 2011
1 parent 1e3345b commit 25888dc
Show file tree
Hide file tree
Showing 3 changed files with 510 additions and 709 deletions.
76 changes: 22 additions & 54 deletions drivers/staging/iio/accel/sca3000.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@

/**
* struct sca3000_state - device instance state information
* @us: the associated spi device
* @info: chip variant information
* @indio_dev: device information used by the IIO core
* @interrupt_handler_ws: event interrupt handler for all events
* @last_timestamp: the timestamp of the last event
* @mo_det_use_count: reference counter for the motion detection unit
* @lock: lock used to protect elements of sca3000_state
* and the underlying device state.
* @bpse: number of bits per scan element
* @tx: dma-able transmit buffer
* @rx: dma-able receive buffer
* @us: the associated spi device
* @info: chip variant information
* @indio_dev: device information used by the IIO core
* @interrupt_handler_ws: event interrupt handler for all events
* @last_timestamp: the timestamp of the last event
* @mo_det_use_count: reference counter for the motion detection unit
* @lock: lock used to protect elements of sca3000_state
* and the underlying device state.
* @bpse: number of bits per scan element
* @tx: dma-able transmit buffer
* @rx: dma-able receive buffer
**/
struct sca3000_state {
struct spi_device *us;
Expand All @@ -179,15 +179,15 @@ struct sca3000_state {
int mo_det_use_count;
struct mutex lock;
int bpse;
u8 *tx;
/* not used during a ring buffer read */
u8 *rx;
/* Can these share a cacheline ? */
u8 rx[2] ____cacheline_aligned;
u8 tx[6] ____cacheline_aligned;
};

/**
* struct sca3000_chip_info - model dependent parameters
* @name: model identification
* @scale: string containing floating point scale factor
* @name: model identification
* @scale: scale * 10^-6
* @temp_output: some devices have temperature sensors.
* @measurement_mode_freq: normal mode sampling frequency
* @option_mode_1: first optional mode. Not all models have one
Expand All @@ -200,29 +200,20 @@ struct sca3000_state {
**/
struct sca3000_chip_info {
const char *name;
const char *scale;
unsigned int scale;
bool temp_output;
int measurement_mode_freq;
int option_mode_1;
int option_mode_1_freq;
int option_mode_2;
int option_mode_2_freq;
int mot_det_mult_xz[6];
int mot_det_mult_y[7];
};

/**
* sca3000_read_data() read a series of values from the device
* @dev: device
* @reg_address_high: start address (decremented read)
* @rx: pointer where received data is placed. Callee
* responsible for freeing this.
* @len: number of bytes to read
*
* The main lock must be held.
**/
int sca3000_read_data(struct sca3000_state *st,
u8 reg_address_high,
u8 **rx_p,
int len);
int sca3000_read_data_short(struct sca3000_state *st,
u8 reg_address_high,
int len);

/**
* sca3000_write_reg() write a single register
Expand All @@ -233,29 +224,6 @@ int sca3000_read_data(struct sca3000_state *st,
**/
int sca3000_write_reg(struct sca3000_state *st, u8 address, u8 val);

/* Conversion function for use with the ring buffer when in 11bit mode */
static inline int sca3000_11bit_convert(uint8_t msb, uint8_t lsb)
{
int16_t val;

val = ((lsb >> 3) & 0x1C) | (msb << 5);
val |= (val & (1 << 12)) ? 0xE000 : 0;

return val;
}

static inline int sca3000_13bit_convert(uint8_t msb, uint8_t lsb)
{
s16 val;

val = ((lsb >> 3) & 0x1F) | (msb << 5);
/* sign fill */
val |= (val & (1 << 12)) ? 0xE000 : 0;

return val;
}


#ifdef CONFIG_IIO_RING_BUFFER
/**
* sca3000_register_ring_funcs() setup the ring state change functions
Expand Down
Loading

0 comments on commit 25888dc

Please sign in to comment.