Commit a66a4e8e authored by Michael Panzlaff's avatar Michael Panzlaff Committed by Greg Kroah-Hartman

staging: pi433: Cleanup codestyle, indent statements after case labels

This patch changes the indentation of the statements after case labels.
The linux coding guidelines do not explicitly mentiond this but pretty
much all existing code doesn't put any statements into the same line of
their belonging case labels. Therefore this adapts to the more usual style.

Please note that there is still a lot of > 80 character lines which will
cause checkpatch warnings. This patch does not intent to fix this
already existing issue.
Signed-off-by: default avatarMichael Panzlaff <michael.panzlaff@fau.de>
Signed-off-by: default avatarTillmann Zipperer <tillmann.zipperer@fau.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 71b32612
...@@ -111,11 +111,16 @@ static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg, u8 mask, u ...@@ -111,11 +111,16 @@ static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg, u8 mask, u
int rf69_set_mode(struct spi_device *spi, enum mode mode) int rf69_set_mode(struct spi_device *spi, enum mode mode)
{ {
switch (mode) { switch (mode) {
case transmit: return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_TRANSMIT); case transmit:
case receive: return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_RECEIVE); return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_TRANSMIT);
case synthesizer: return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_SYNTHESIZER); case receive:
case standby: return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_STANDBY); return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_RECEIVE);
case mode_sleep: return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_SLEEP); case synthesizer:
return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_SYNTHESIZER);
case standby:
return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_STANDBY);
case mode_sleep:
return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, OPMODE_MODE_SLEEP);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -134,8 +139,10 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mode) ...@@ -134,8 +139,10 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
int rf69_set_modulation(struct spi_device *spi, enum modulation modulation) int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
{ {
switch (modulation) { switch (modulation) {
case OOK: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK); case OOK:
case FSK: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_FSK); return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK);
case FSK:
return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_FSK);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -149,9 +156,12 @@ static enum modulation rf69_get_modulation(struct spi_device *spi) ...@@ -149,9 +156,12 @@ static enum modulation rf69_get_modulation(struct spi_device *spi)
currentValue = rf69_read_reg(spi, REG_DATAMODUL); currentValue = rf69_read_reg(spi, REG_DATAMODUL);
switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE) { switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE) {
case DATAMODUL_MODULATION_TYPE_OOK: return OOK; case DATAMODUL_MODULATION_TYPE_OOK:
case DATAMODUL_MODULATION_TYPE_FSK: return FSK; return OOK;
default: return UNDEF; case DATAMODUL_MODULATION_TYPE_FSK:
return FSK;
default:
return UNDEF;
} }
} }
...@@ -161,19 +171,26 @@ int rf69_set_modulation_shaping(struct spi_device *spi, ...@@ -161,19 +171,26 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
switch (rf69_get_modulation(spi)) { switch (rf69_get_modulation(spi)) {
case FSK: case FSK:
switch (mod_shaping) { switch (mod_shaping) {
case SHAPING_OFF: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_NONE); case SHAPING_OFF:
case SHAPING_1_0: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_1_0); return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_NONE);
case SHAPING_0_5: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_0_5); case SHAPING_1_0:
case SHAPING_0_3: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_0_3); return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_1_0);
case SHAPING_0_5:
return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_0_5);
case SHAPING_0_3:
return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_0_3);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
} }
case OOK: case OOK:
switch (mod_shaping) { switch (mod_shaping) {
case SHAPING_OFF: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_NONE); case SHAPING_OFF:
case SHAPING_BR: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_BR); return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_NONE);
case SHAPING_2BR: return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_2BR); case SHAPING_BR:
return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_BR);
case SHAPING_2BR:
return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_2BR);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -331,22 +348,38 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel) ...@@ -331,22 +348,38 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel)
int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp) int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
{ {
switch (paRamp) { switch (paRamp) {
case ramp3400: return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400); case ramp3400:
case ramp2000: return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000); return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
case ramp1000: return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000); case ramp2000:
case ramp500: return rf69_write_reg(spi, REG_PARAMP, PARAMP_500); return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
case ramp250: return rf69_write_reg(spi, REG_PARAMP, PARAMP_250); case ramp1000:
case ramp125: return rf69_write_reg(spi, REG_PARAMP, PARAMP_125); return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000);
case ramp100: return rf69_write_reg(spi, REG_PARAMP, PARAMP_100); case ramp500:
case ramp62: return rf69_write_reg(spi, REG_PARAMP, PARAMP_62); return rf69_write_reg(spi, REG_PARAMP, PARAMP_500);
case ramp50: return rf69_write_reg(spi, REG_PARAMP, PARAMP_50); case ramp250:
case ramp40: return rf69_write_reg(spi, REG_PARAMP, PARAMP_40); return rf69_write_reg(spi, REG_PARAMP, PARAMP_250);
case ramp31: return rf69_write_reg(spi, REG_PARAMP, PARAMP_31); case ramp125:
case ramp25: return rf69_write_reg(spi, REG_PARAMP, PARAMP_25); return rf69_write_reg(spi, REG_PARAMP, PARAMP_125);
case ramp20: return rf69_write_reg(spi, REG_PARAMP, PARAMP_20); case ramp100:
case ramp15: return rf69_write_reg(spi, REG_PARAMP, PARAMP_15); return rf69_write_reg(spi, REG_PARAMP, PARAMP_100);
case ramp12: return rf69_write_reg(spi, REG_PARAMP, PARAMP_12); case ramp62:
case ramp10: return rf69_write_reg(spi, REG_PARAMP, PARAMP_10); return rf69_write_reg(spi, REG_PARAMP, PARAMP_62);
case ramp50:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_50);
case ramp40:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_40);
case ramp31:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_31);
case ramp25:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_25);
case ramp20:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_20);
case ramp15:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_15);
case ramp12:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_12);
case ramp10:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_10);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -356,8 +389,10 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp) ...@@ -356,8 +389,10 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance) int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance)
{ {
switch (antennaImpedance) { switch (antennaImpedance) {
case fiftyOhm: return rf69_clear_bit(spi, REG_LNA, MASK_LNA_ZIN); case fiftyOhm:
case twohundretOhm: return rf69_set_bit(spi, REG_LNA, MASK_LNA_ZIN); return rf69_clear_bit(spi, REG_LNA, MASK_LNA_ZIN);
case twohundretOhm:
return rf69_set_bit(spi, REG_LNA, MASK_LNA_ZIN);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -367,13 +402,20 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance ant ...@@ -367,13 +402,20 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance ant
int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain) int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
{ {
switch (lnaGain) { switch (lnaGain) {
case automatic: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_AUTO); case automatic:
case max: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX); return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_AUTO);
case max_minus_6: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_6); case max:
case max_minus_12: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_12); return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX);
case max_minus_24: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_24); case max_minus_6:
case max_minus_36: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_36); return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_6);
case max_minus_48: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_48); case max_minus_12:
return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_12);
case max_minus_24:
return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_24);
case max_minus_36:
return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_36);
case max_minus_48:
return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_48);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -437,14 +479,22 @@ int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse mantisse ...@@ -437,14 +479,22 @@ int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse mantisse
int rf69_set_ook_threshold_dec(struct spi_device *spi, enum thresholdDecrement thresholdDecrement) int rf69_set_ook_threshold_dec(struct spi_device *spi, enum thresholdDecrement thresholdDecrement)
{ {
switch (thresholdDecrement) { switch (thresholdDecrement) {
case dec_every8th: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_8TH); case dec_every8th:
case dec_every4th: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_4TH); return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_8TH);
case dec_every2nd: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_2ND); case dec_every4th:
case dec_once: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_ONCE); return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_4TH);
case dec_twice: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_TWICE); case dec_every2nd:
case dec_4times: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_4_TIMES); return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_2ND);
case dec_8times: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_8_TIMES); case dec_once:
case dec_16times: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_16_TIMES); return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_ONCE);
case dec_twice:
return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_TWICE);
case dec_4times:
return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_4_TIMES);
case dec_8times:
return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_8_TIMES);
case dec_16times:
return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_16_TIMES);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -495,23 +545,40 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) ...@@ -495,23 +545,40 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value)
bool rf69_get_flag(struct spi_device *spi, enum flag flag) bool rf69_get_flag(struct spi_device *spi, enum flag flag)
{ {
switch (flag) { switch (flag) {
case modeSwitchCompleted: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY); case modeSwitchCompleted:
case readyToReceive: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RX_READY); return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY);
case readyToSend: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_TX_READY); case readyToReceive:
case pllLocked: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_PLL_LOCK); return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RX_READY);
case rssiExceededThreshold: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RSSI); case readyToSend:
case timeout: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_TIMEOUT); return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_TX_READY);
case automode: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_AUTOMODE); case pllLocked:
case syncAddressMatch: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH); return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_PLL_LOCK);
case fifo_full: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_FULL); case rssiExceededThreshold:
/* case fifo_not_empty: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY); */ return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RSSI);
case fifo_empty: return !(rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY); case timeout:
case fifo_level_below_threshold: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_LEVEL); return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_TIMEOUT);
case fifo_overrun: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_OVERRUN); case automode:
case packetSent: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PACKET_SENT); return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_AUTOMODE);
case payload_ready: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PAYLOAD_READY); case syncAddressMatch:
case crcOk: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_CRC_OK); return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH);
case batteryLow: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_LOW_BAT); case fifo_full:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_FULL);
/* case fifo_not_empty:
* return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY); */
case fifo_empty:
return !(rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY);
case fifo_level_below_threshold:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_LEVEL);
case fifo_overrun:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_OVERRUN);
case packetSent:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PACKET_SENT);
case payload_ready:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PAYLOAD_READY);
case crcOk:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_CRC_OK);
case batteryLow:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_LOW_BAT);
default: return false; default: return false;
} }
} }
...@@ -556,8 +623,10 @@ int rf69_disable_sync(struct spi_device *spi) ...@@ -556,8 +623,10 @@ int rf69_disable_sync(struct spi_device *spi)
int rf69_set_fifo_fill_condition(struct spi_device *spi, enum fifo_fill_condition fifo_fill_condition) int rf69_set_fifo_fill_condition(struct spi_device *spi, enum fifo_fill_condition fifo_fill_condition)
{ {
switch (fifo_fill_condition) { switch (fifo_fill_condition) {
case always: return rf69_set_bit(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_FIFO_FILL_CONDITION); case always:
case afterSyncInterrupt: return rf69_clear_bit(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_FIFO_FILL_CONDITION); return rf69_set_bit(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
case afterSyncInterrupt:
return rf69_clear_bit(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -595,8 +664,10 @@ int rf69_set_sync_values(struct spi_device *spi, u8 syncValues[8]) ...@@ -595,8 +664,10 @@ int rf69_set_sync_values(struct spi_device *spi, u8 syncValues[8])
int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetFormat) int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetFormat)
{ {
switch (packetFormat) { switch (packetFormat) {
case packetLengthVar: return rf69_set_bit(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE); case packetLengthVar:
case packetLengthFix: return rf69_clear_bit(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE); return rf69_set_bit(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
case packetLengthFix:
return rf69_clear_bit(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -616,9 +687,12 @@ int rf69_disable_crc(struct spi_device *spi) ...@@ -616,9 +687,12 @@ int rf69_disable_crc(struct spi_device *spi)
int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addressFiltering) int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addressFiltering)
{ {
switch (addressFiltering) { switch (addressFiltering) {
case filteringOff: return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_OFF); case filteringOff:
case nodeAddress: return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_NODE); return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_OFF);
case nodeOrBroadcastAddress: return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST); case nodeAddress:
return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_NODE);
case nodeOrBroadcastAddress:
return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -643,8 +717,10 @@ int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcastAddress) ...@@ -643,8 +717,10 @@ int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcastAddress)
int rf69_set_tx_start_condition(struct spi_device *spi, enum txStartCondition txStartCondition) int rf69_set_tx_start_condition(struct spi_device *spi, enum txStartCondition txStartCondition)
{ {
switch (txStartCondition) { switch (txStartCondition) {
case fifo_level: return rf69_clear_bit(spi, REG_FIFO_THRESH, MASK_FIFO_THRESH_TXSTART); case fifo_level:
case fifo_not_empty: return rf69_set_bit(spi, REG_FIFO_THRESH, MASK_FIFO_THRESH_TXSTART); return rf69_clear_bit(spi, REG_FIFO_THRESH, MASK_FIFO_THRESH_TXSTART);
case fifo_not_empty:
return rf69_set_bit(spi, REG_FIFO_THRESH, MASK_FIFO_THRESH_TXSTART);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
...@@ -675,9 +751,12 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold) ...@@ -675,9 +751,12 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold)
int rf69_set_dagc(struct spi_device *spi, enum dagc dagc) int rf69_set_dagc(struct spi_device *spi, enum dagc dagc)
{ {
switch (dagc) { switch (dagc) {
case normalMode: return rf69_write_reg(spi, REG_TESTDAGC, DAGC_NORMAL); case normalMode:
case improve: return rf69_write_reg(spi, REG_TESTDAGC, DAGC_IMPROVED_LOWBETA0); return rf69_write_reg(spi, REG_TESTDAGC, DAGC_NORMAL);
case improve4LowModulationIndex: return rf69_write_reg(spi, REG_TESTDAGC, DAGC_IMPROVED_LOWBETA1); case improve:
return rf69_write_reg(spi, REG_TESTDAGC, DAGC_IMPROVED_LOWBETA0);
case improve4LowModulationIndex:
return rf69_write_reg(spi, REG_TESTDAGC, DAGC_IMPROVED_LOWBETA1);
default: default:
dev_dbg(&spi->dev, "set: illegal input param"); dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL; return -EINVAL;
......
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