Commit 25888dc5 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging:iio:sca3000 extract old event handling and move to poll for events 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: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1e3345bc
...@@ -158,17 +158,17 @@ ...@@ -158,17 +158,17 @@
/** /**
* struct sca3000_state - device instance state information * struct sca3000_state - device instance state information
* @us: the associated spi device * @us: the associated spi device
* @info: chip variant information * @info: chip variant information
* @indio_dev: device information used by the IIO core * @indio_dev: device information used by the IIO core
* @interrupt_handler_ws: event interrupt handler for all events * @interrupt_handler_ws: event interrupt handler for all events
* @last_timestamp: the timestamp of the last event * @last_timestamp: the timestamp of the last event
* @mo_det_use_count: reference counter for the motion detection unit * @mo_det_use_count: reference counter for the motion detection unit
* @lock: lock used to protect elements of sca3000_state * @lock: lock used to protect elements of sca3000_state
* and the underlying device state. * and the underlying device state.
* @bpse: number of bits per scan element * @bpse: number of bits per scan element
* @tx: dma-able transmit buffer * @tx: dma-able transmit buffer
* @rx: dma-able receive buffer * @rx: dma-able receive buffer
**/ **/
struct sca3000_state { struct sca3000_state {
struct spi_device *us; struct spi_device *us;
...@@ -179,15 +179,15 @@ struct sca3000_state { ...@@ -179,15 +179,15 @@ struct sca3000_state {
int mo_det_use_count; int mo_det_use_count;
struct mutex lock; struct mutex lock;
int bpse; int bpse;
u8 *tx; /* Can these share a cacheline ? */
/* not used during a ring buffer read */ u8 rx[2] ____cacheline_aligned;
u8 *rx; u8 tx[6] ____cacheline_aligned;
}; };
/** /**
* struct sca3000_chip_info - model dependent parameters * struct sca3000_chip_info - model dependent parameters
* @name: model identification * @name: model identification
* @scale: string containing floating point scale factor * @scale: scale * 10^-6
* @temp_output: some devices have temperature sensors. * @temp_output: some devices have temperature sensors.
* @measurement_mode_freq: normal mode sampling frequency * @measurement_mode_freq: normal mode sampling frequency
* @option_mode_1: first optional mode. Not all models have one * @option_mode_1: first optional mode. Not all models have one
...@@ -200,29 +200,20 @@ struct sca3000_state { ...@@ -200,29 +200,20 @@ struct sca3000_state {
**/ **/
struct sca3000_chip_info { struct sca3000_chip_info {
const char *name; const char *name;
const char *scale; unsigned int scale;
bool temp_output; bool temp_output;
int measurement_mode_freq; int measurement_mode_freq;
int option_mode_1; int option_mode_1;
int option_mode_1_freq; int option_mode_1_freq;
int option_mode_2; int option_mode_2;
int option_mode_2_freq; int option_mode_2_freq;
int mot_det_mult_xz[6];
int mot_det_mult_y[7];
}; };
/** int sca3000_read_data_short(struct sca3000_state *st,
* sca3000_read_data() read a series of values from the device u8 reg_address_high,
* @dev: device int len);
* @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);
/** /**
* sca3000_write_reg() write a single register * sca3000_write_reg() write a single register
...@@ -233,29 +224,6 @@ int sca3000_read_data(struct sca3000_state *st, ...@@ -233,29 +224,6 @@ int sca3000_read_data(struct sca3000_state *st,
**/ **/
int sca3000_write_reg(struct sca3000_state *st, u8 address, u8 val); 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 #ifdef CONFIG_IIO_RING_BUFFER
/** /**
* sca3000_register_ring_funcs() setup the ring state change functions * sca3000_register_ring_funcs() setup the ring state change functions
......
This diff is collapsed.
This diff is collapsed.
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