Fix indentation and CamelCase issue in staging/pi433
v2 cover Fix indentation and CamelCase issue in staging/pi433
These patches fixes a bunch of code style issues in staging/pi433. The first patch fixes indentation in rf69_enum.h and the rest of the patches fixes CamelCase issues and other minor issues in all of staging/pi433.
Changes in v2:
- Instead of fixing CamelCase issue in enum data_mode, remove it completely.
- Split multiple functions of type "rf69_set_x_enabled(dev, enum option_on_off)" to two functions:
"rf69_enable_x(dev)" and "rf69_disable_x(dev)".
- Move enum option_on_off to pi433_if.h as it's now only used for ioctl.
- Fix issue where GPIOs and device not being deallocated in pi433_probe() if SET_CHECKED fails.
- Simon
---
Simon Sandström (11):
staging: pi433: Fix indentation in rf69_enum.h
staging: pi433: Capitalize constant definitions
staging: pi433: Rename variable in struct pi433_rx_cfg
staging: pi433: Rename enum optionOnOff in rf69_enum.h
staging: pi433: Rename enum modShaping in rf69_enum.h
staging: pi433: Split rf69_set_crc_enabled into two functions
staging: pi433: Split rf69_set_sync_enabled into two functions
staging: pi433: Remove enum data_mode
staging: pi433: Combine all rf69_set_amplifier_x()
staging: pi433: Move enum option_on_off to pi433_if.h
staging: pi433: Remove SET_CHECKED usage from pi433_probe
drivers/staging/pi433/pi433_if.c | 135 ++++++++++++++------- drivers/staging/pi433/pi433_if.h | 25 ++-- drivers/staging/pi433/rf69.c | 113 +++++------------- drivers/staging/pi433/rf69.h | 15 +-- drivers/staging/pi433/rf69_enum.h | 210 ++++++++++++++++----------------- drivers/staging/pi433/rf69_registers.h | 44 +++---- 6 files changed, 265 insertions(+), 277 deletions(-)
Signature · 1 line
2.11.0
PATCH v2 1/11 staging: pi433: Fix indentation in rf69_enum.h
Basically just 's/ /\t/', to fix checkpatch.pl warnings:
"please, no spaces at the start of a line".
--- drivers/staging/pi433/rf69_enum.h | 207 +++++++++++++++++++------------------- 1 file changed, 103 insertions(+), 104 deletions(-)
drivers/staging/pi433/rf69_enum.h +103 -104
@@ -19,164 +19,163 @@#define RF69_ENUM_H enum optionOnOff { - optionOff, - optionOn + optionOff, + optionOn };enum mode { - mode_sleep, - standby, - synthesizer, - transmit, - receive + mode_sleep, + standby, + synthesizer, + transmit, + receive };enum dataMode { - packet, - continuous, - continuousNoSync + packet, + continuous, + continuousNoSync };enum modulation { -OOK , -FSK +OOK , +FSK };enum modShaping { - shapingOff, - shaping1_0, - shaping0_5, - shaping0_3, - shapingBR, - shaping2BR + shapingOff, + shaping1_0, + shaping0_5, + shaping0_3, + shapingBR, + shaping2BR };enum paRamp { - ramp3400, - ramp2000, - ramp1000, - ramp500, - ramp250, - ramp125, - ramp100, - ramp62, - ramp50, - ramp40, - ramp31, - ramp25, - ramp20, - ramp15, - ramp12, - ramp10 + ramp3400, + ramp2000, + ramp1000, + ramp500, + ramp250, + ramp125, + ramp100, + ramp62, + ramp50, + ramp40, + ramp31, + ramp25, + ramp20, + ramp15, + ramp12, + ramp10 };enum antennaImpedance { - fiftyOhm, - twohundretOhm + fiftyOhm, + twohundretOhm };enum lnaGain { - automatic, - max, - maxMinus6, - maxMinus12, - maxMinus24, - maxMinus36, - maxMinus48, - undefined + automatic, + max, + maxMinus6, + maxMinus12, + maxMinus24, + maxMinus36, + maxMinus48, + undefined };enum dccPercent { - dcc16Percent, - dcc8Percent, - dcc4Percent, - dcc2Percent, - dcc1Percent, - dcc0_5Percent, - dcc0_25Percent, - dcc0_125Percent + dcc16Percent, + dcc8Percent, + dcc4Percent, + dcc2Percent, + dcc1Percent, + dcc0_5Percent, + dcc0_25Percent, + dcc0_125Percent };enum mantisse { - mantisse16, - mantisse20, - mantisse24 + mantisse16, + mantisse20, + mantisse24 };enum thresholdType { - fixed, - peak, - average + fixed, + peak, + average };enum thresholdStep { - step_0_5db, - step_1_0db, - step_1_5db, - step_2_0db, - step_3_0db, - step_4_0db, - step_5_0db, - step_6_0db + step_0_5db, + step_1_0db, + step_1_5db, + step_2_0db, + step_3_0db, + step_4_0db, + step_5_0db, + step_6_0db };enum thresholdDecrement { - dec_every8th, - dec_every4th, - dec_every2nd, - dec_once, - dec_twice, - dec_4times, - dec_8times, - dec_16times + dec_every8th, + dec_every4th, + dec_every2nd, + dec_once, + dec_twice, + dec_4times, + dec_8times, + dec_16times };enum flag { - modeSwitchCompleted, - readyToReceive, - readyToSend, - pllLocked, - rssiExceededThreshold, - timeout, - automode, - syncAddressMatch, - fifoFull, -// fifoNotEmpty, collision with next enum; replaced by following enum... - fifoEmpty, - fifoLevelBelowThreshold, - fifoOverrun, - packetSent, - payloadReady, - crcOk, - batteryLow + modeSwitchCompleted, + readyToReceive, + readyToSend, + pllLocked, + rssiExceededThreshold, + timeout, + automode, + syncAddressMatch, + fifoFull, +// fifoNotEmpty, collision with next enum; replaced by following enum... + fifoEmpty, + fifoLevelBelowThreshold, + fifoOverrun, + packetSent, + payloadReady, + crcOk, + batteryLow };enum fifoFillCondition { - afterSyncInterrupt, - always + afterSyncInterrupt, + always };enum packetFormat { - packetLengthFix, - packetLengthVar + packetLengthFix, + packetLengthVar };enum txStartCondition { - fifoLevel, - fifoNotEmpty + fifoLevel, + fifoNotEmpty };enum addressFiltering { - filteringOff, - nodeAddress, - nodeOrBroadcastAddress + filteringOff, + nodeAddress, + nodeOrBroadcastAddress };enum dagc { - normalMode, - improve, - improve4LowModulationIndex + normalMode, + improve, + improve4LowModulationIndex }; -#endif
Signature · 1 line
2.11.0
PATCH v2 2/11 staging: pi433: Capitalize constant definitions
In reply to Simon SandströmFixes checkpatch.pl warnings "Avoid CamelCase <DIO_x>".
--- drivers/staging/pi433/pi433_if.c | 32 ++++++++++++------------- drivers/staging/pi433/rf69_registers.h | 44 +++++++++++++++++----------------- 2 files changed, 38 insertions(+), 38 deletions(-)
drivers/staging/pi433/pi433_if.c +16 -16
@@ -133,20 +133,20 @@ static irqreturn_t DIO0_irq_handler(int irq, void *dev_id) {struct pi433_device *device = dev_id; -if (device->irq_state[DIO0 ] == DIO_PacketSent) +if (device->irq_state[DIO0 ] ==DIO_PACKET_SENT ) { device->free_in_fifo =FIFO_SIZE ;dev_dbg (device->dev,"DIO0 irq: Packet sent\n" );wake_up_interruptible (&device->fifo_wait_queue); } -else if (device->irq_state[DIO0 ] == DIO_Rssi_DIO0) +else if (device->irq_state[DIO0 ] ==DIO_RSSI_DIO0 ) {dev_dbg (device->dev,"DIO0 irq: RSSI level over threshold\n" );wake_up_interruptible (&device->rx_wait_queue); } -else if (device->irq_state[DIO0 ] == DIO_PayloadReady) +else if (device->irq_state[DIO0 ] ==DIO_PAYLOAD_READY ) { -dev_dbg (device->dev,"DIO0 irq: PayloadReady\n" ); +dev_dbg (device->dev,"DIO0 irq: Payload ready\n" ); device->free_in_fifo =0 ;wake_up_interruptible (&device->fifo_wait_queue); }
@@ -158,11 +158,11 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id) {struct pi433_device *device = dev_id; -if (device->irq_state[DIO1 ] == DIO_FifoNotEmpty_DIO1) +if (device->irq_state[DIO1 ] ==DIO_FIFO_NOT_EMPTY_DIO1 ) { device->free_in_fifo =FIFO_SIZE ; } -else if (device->irq_state[DIO1 ] == DIO_FifoLevel) +else if (device->irq_state[DIO1 ] ==DIO_FIFO_LEVEL ) {if (device->rx_active) device->free_in_fifo =FIFO_THRESHOLD -1 ;else device->free_in_fifo =FIFO_SIZE -FIFO_THRESHOLD -1 ;
@@ -309,14 +309,14 @@ pi433_start_rx(struct pi433_device *dev)if (retval)return retval;/* setup rssi irq */ -SET_CHECKED (rf69_set_dio_mapping (dev->spi,DIO0 , DIO_Rssi_DIO0)); - dev->irq_state[DIO0 ] = DIO_Rssi_DIO0; +SET_CHECKED (rf69_set_dio_mapping (dev->spi,DIO0 ,DIO_RSSI_DIO0 )); + dev->irq_state[DIO0 ] =DIO_RSSI_DIO0 ;irq_set_irq_type (dev->irq_num[DIO0 ],IRQ_TYPE_EDGE_RISING );/* setup fifo level interrupt */ SET_CHECKED (rf69_set_fifo_threshold (dev->spi,FIFO_SIZE -FIFO_THRESHOLD )); -SET_CHECKED (rf69_set_dio_mapping (dev->spi,DIO1 , DIO_FifoLevel)); - dev->irq_state[DIO1 ] = DIO_FifoLevel; +SET_CHECKED (rf69_set_dio_mapping (dev->spi,DIO1 ,DIO_FIFO_LEVEL )); + dev->irq_state[DIO1 ] =DIO_FIFO_LEVEL ;irq_set_irq_type (dev->irq_num[DIO1 ],IRQ_TYPE_EDGE_RISING );/* set module to receiving mode */
@@ -378,8 +378,8 @@ pi433_receive(void *data) }/* configure payload ready irq */ -SET_CHECKED (rf69_set_dio_mapping (spi,DIO0 , DIO_PayloadReady)); - dev->irq_state[DIO0 ] = DIO_PayloadReady; +SET_CHECKED (rf69_set_dio_mapping (spi,DIO0 ,DIO_PAYLOAD_READY )); + dev->irq_state[DIO0 ] =DIO_PAYLOAD_READY ;irq_set_irq_type (dev->irq_num[DIO0 ],IRQ_TYPE_EDGE_RISING );/* fixed or unlimited length? */
@@ -590,13 +590,13 @@ pi433_tx_thread(void *data)rf69_set_tx_cfg (device, &tx_cfg);/* enable fifo level interrupt */ -SET_CHECKED (rf69_set_dio_mapping (spi,DIO1 , DIO_FifoLevel)); - device->irq_state[DIO1 ] = DIO_FifoLevel; +SET_CHECKED (rf69_set_dio_mapping (spi,DIO1 ,DIO_FIFO_LEVEL )); + device->irq_state[DIO1 ] =DIO_FIFO_LEVEL ;irq_set_irq_type (device->irq_num[DIO1 ],IRQ_TYPE_EDGE_FALLING );/* enable packet sent interrupt */ -SET_CHECKED (rf69_set_dio_mapping (spi,DIO0 , DIO_PacketSent)); - device->irq_state[DIO0 ] = DIO_PacketSent; +SET_CHECKED (rf69_set_dio_mapping (spi,DIO0 ,DIO_PACKET_SENT )); + device->irq_state[DIO0 ] =DIO_PACKET_SENT ;irq_set_irq_type (device->irq_num[DIO0 ],IRQ_TYPE_EDGE_RISING );enable_irq (device->irq_num[DIO0 ]);/* was disabled by rx active check */
drivers/staging/pi433/rf69_registers.h +22 -22
50 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v2 3/11 staging: pi433: Rename variable in struct pi433_rx_cfg
In reply to Simon SandströmRenames variable thresholdDecrement in struct pi433_rx_cfg to threshold_decrement to get rid of checkpatch.pl warning "Avoid CamelCase: <thresholdDecrement>".
--- drivers/staging/pi433/pi433_if.c | 2 +- drivers/staging/pi433/pi433_if.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/pi433/pi433_if.c +1 -1
@@ -188,7 +188,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)SET_CHECKED (rf69_set_modulation (dev->spi, rx_cfg->modulation));SET_CHECKED (rf69_set_antenna_impedance (dev->spi, rx_cfg->antenna_impedance));SET_CHECKED (rf69_set_rssi_threshold (dev->spi, rx_cfg->rssi_threshold)); -SET_CHECKED (rf69_set_ook_threshold_dec (dev->spi, rx_cfg->thresholdDecrement)); +SET_CHECKED (rf69_set_ook_threshold_dec (dev->spi, rx_cfg->threshold_decrement));SET_CHECKED (rf69_set_bandwidth (dev->spi, rx_cfg->bw_mantisse, rx_cfg->bw_exponent));SET_CHECKED (rf69_set_bandwidth_during_afc (dev->spi, rx_cfg->bw_mantisse, rx_cfg->bw_exponent));SET_CHECKED (rf69_set_dagc (dev->spi, rx_cfg->dagc));
drivers/staging/pi433/pi433_if.h +1 -1
@@ -115,7 +115,7 @@ struct pi433_rx_cfg {enum modulation modulation;__u8 rssi_threshold; -enum thresholdDecrement thresholdDecrement; +enum thresholdDecrement threshold_decrement;enum antennaImpedance antenna_impedance;enum lnaGain lna_gain;enum mantisse bw_mantisse;/* normal: 0x50 */
Signature · 1 line
2.11.0
PATCH v2 4/11 staging: pi433: Rename enum optionOnOff in rf69_enum.h
In reply to Simon SandströmRenames the enum optionOnOff and its values optionOn, optionOff to enum option_on_off and OPTION_ON, OPTION_OFF. Fixes checkpatch.pl warnings:
"Avoid CamelCase: <optionOnOff>, <optionOn>, <optionOff>".
--- drivers/staging/pi433/pi433_if.c | 34 ++++++++++++++--------------- drivers/staging/pi433/pi433_if.h | 16 +++++++------- drivers/staging/pi433/rf69.c | 45 ++++++++++++++++++++++----------------- drivers/staging/pi433/rf69.h | 15 ++++++++----- drivers/staging/pi433/rf69_enum.h | 6 +++--- 5 files changed, 63 insertions(+), 53 deletions(-)
drivers/staging/pi433/pi433_if.c +17 -17
@@ -198,7 +198,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)/* packet config */ /* enable */ SET_CHECKED (rf69_set_sync_enable (dev->spi, rx_cfg->enable_sync)); -if (rx_cfg->enable_sync == optionOn) +if (rx_cfg->enable_sync ==OPTION_ON ) {SET_CHECKED (rf69_set_fifo_fill_condition (dev->spi, afterSyncInterrupt)); }
@@ -206,7 +206,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) {SET_CHECKED (rf69_set_fifo_fill_condition (dev->spi, always)); } -if (rx_cfg->enable_length_byte == optionOn) { +if (rx_cfg->enable_length_byte ==OPTION_ON ) { ret =rf69_set_packet_format (dev->spi, packetLengthVar);if (ret <0 )return ret;
@@ -220,14 +220,14 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)/* lengths */ SET_CHECKED (rf69_set_sync_size (dev->spi, rx_cfg->sync_length)); -if (rx_cfg->enable_length_byte == optionOn) +if (rx_cfg->enable_length_byte ==OPTION_ON ) {SET_CHECKED (rf69_set_payload_length (dev->spi,0xff )); }else if (rx_cfg->fixed_message_length !=0 ) { payload_length = rx_cfg->fixed_message_length; -if (rx_cfg->enable_length_byte == optionOn) payload_length++; +if (rx_cfg->enable_length_byte ==OPTION_ON ) payload_length++;if (rx_cfg->enable_address_filtering != filteringOff) payload_length++;SET_CHECKED (rf69_set_payload_length (dev->spi, payload_length)); }
@@ -237,7 +237,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) }/* values */ -if (rx_cfg->enable_sync == optionOn) +if (rx_cfg->enable_sync ==OPTION_ON ) {SET_CHECKED (rf69_set_sync_values (dev->spi, rx_cfg->sync_pattern)); }
@@ -264,7 +264,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)SET_CHECKED (rf69_set_tx_start_condition (dev->spi, tx_cfg->tx_start_condition));/* packet format enable */ -if (tx_cfg->enable_preamble == optionOn) +if (tx_cfg->enable_preamble ==OPTION_ON ) {SET_CHECKED (rf69_set_preamble_length (dev->spi, tx_cfg->preamble_length)); }
@@ -273,7 +273,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)SET_CHECKED (rf69_set_preamble_length (dev->spi,0 )); }SET_CHECKED (rf69_set_sync_enable (dev->spi, tx_cfg->enable_sync)); -if (tx_cfg->enable_length_byte == optionOn) { +if (tx_cfg->enable_length_byte ==OPTION_ON ) { ret =rf69_set_packet_format (dev->spi, packetLengthVar);if (ret <0 )return ret;
@@ -285,7 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)SET_CHECKED (rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc));/* configure sync, if enabled */ -if (tx_cfg->enable_sync == optionOn) { +if (tx_cfg->enable_sync ==OPTION_ON ) {SET_CHECKED (rf69_set_sync_size (dev->spi, tx_cfg->sync_length));SET_CHECKED (rf69_set_sync_values (dev->spi, tx_cfg->sync_pattern)); }
@@ -400,7 +400,7 @@ pi433_receive(void *data) }/* length byte enabled? */ -if (dev->rx_cfg.enable_length_byte == optionOn) +if (dev->rx_cfg.enable_length_byte ==OPTION_ON ) { retval =wait_event_interruptible (dev->fifo_wait_queue, dev->free_in_fifo <FIFO_SIZE );
@@ -525,11 +525,11 @@ pi433_tx_thread(void *data) size = tx_cfg.fixed_message_length;/* increase size, if len byte is requested */ -if (tx_cfg.enable_length_byte == optionOn) +if (tx_cfg.enable_length_byte ==OPTION_ON ) size++;/* increase size, if adr byte is requested */ -if (tx_cfg.enable_address_byte == optionOn) +if (tx_cfg.enable_address_byte ==OPTION_ON ) size++;/* prime buffer */
@@ -537,11 +537,11 @@ pi433_tx_thread(void *data) position =0 ;/* add length byte, if requested */ -if (tx_cfg.enable_length_byte == optionOn) +if (tx_cfg.enable_length_byte ==OPTION_ON ) buffer[position++] = size-1 ;/* according to spec length byte itself must be excluded from the length calculation */ /* add adr byte, if requested */ -if (tx_cfg.enable_address_byte == optionOn) +if (tx_cfg.enable_address_byte ==OPTION_ON ) buffer[position++] = tx_cfg.address_byte;/* finally get message data from fifo */
@@ -577,7 +577,7 @@ pi433_tx_thread(void *data)/* clear fifo, set fifo threshold, set payload length */ SET_CHECKED (rf69_set_mode (spi, standby));/* this clears the fifo */ SET_CHECKED (rf69_set_fifo_threshold (spi,FIFO_THRESHOLD )); -if (tx_cfg.enable_length_byte == optionOn) +if (tx_cfg.enable_length_byte ==OPTION_ON ) {SET_CHECKED (rf69_set_payload_length (spi, size * tx_cfg.repetitions)); }
@@ -1091,9 +1091,9 @@ static int pi433_probe(struct spi_device *spi)/* setup the radio module */ SET_CHECKED (rf69_set_mode (spi, standby));SET_CHECKED (rf69_set_data_mode (spi, packet)); -SET_CHECKED (rf69_set_amplifier_0 (spi, optionOn)); -SET_CHECKED (rf69_set_amplifier_1 (spi, optionOff)); -SET_CHECKED (rf69_set_amplifier_2 (spi, optionOff)); +SET_CHECKED (rf69_set_amplifier_0 (spi,OPTION_ON )); +SET_CHECKED (rf69_set_amplifier_1 (spi,OPTION_OFF )); +SET_CHECKED (rf69_set_amplifier_2 (spi,OPTION_OFF ));SET_CHECKED (rf69_set_output_power_level (spi,13 ));SET_CHECKED (rf69_set_antenna_impedance (spi, fiftyOhm));
drivers/staging/pi433/pi433_if.h +8 -8
@@ -73,11 +73,11 @@ struct pi433_tx_cfg {/* packet format */ -enum optionOnOff enable_preamble; -enum optionOnOff enable_sync; -enum optionOnOff enable_length_byte; -enum optionOnOff enable_address_byte; -enum optionOnOff enable_crc; +enum option_on_off enable_preamble; +enum option_on_off enable_sync; +enum option_on_off enable_length_byte; +enum option_on_off enable_address_byte; +enum option_on_off enable_crc;__u16 preamble_length;__u8 sync_length;
@@ -125,10 +125,10 @@ struct pi433_rx_cfg {/* packet format */ -enum optionOnOff enable_sync; -enum optionOnOff enable_length_byte;/* should be used in combination with sync, only */ +enum option_on_off enable_sync; +enum option_on_off enable_length_byte;/* should be used in combination with sync, only */ enum addressFiltering enable_address_filtering;/* operational with sync, only */ -enum optionOnOff enable_crc;/* only operational, if sync on and fixed length or length byte is used */ +enum option_on_off enable_crc;/* only operational, if sync on and fixed length or length byte is used */ __u8 sync_length;__u8 fixed_message_length;
drivers/staging/pi433/rf69.c +25 -20
100 lines not on this page · raw message
drivers/staging/pi433/rf69.h +10 -5
@@ -33,9 +33,12 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapiint rf69_set_bit_rate (struct spi_device *spi,u16 bitRate);int rf69_set_deviation (struct spi_device *spi,u32 deviation);int rf69_set_frequency (struct spi_device *spi,u32 frequency); -int rf69_set_amplifier_0 (struct spi_device *spi,enum optionOnOff optionOnOff); -int rf69_set_amplifier_1 (struct spi_device *spi,enum optionOnOff optionOnOff); -int rf69_set_amplifier_2 (struct spi_device *spi,enum optionOnOff optionOnOff); +int rf69_set_amplifier_0 (struct spi_device *spi, +enum option_on_off option_on_off); +int rf69_set_amplifier_1 (struct spi_device *spi, +enum option_on_off option_on_off); +int rf69_set_amplifier_2 (struct spi_device *spi, +enum option_on_off option_on_off);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_antenna_impedance (struct spi_device *spi,enum antennaImpedance antennaImpedance);
@@ -56,13 +59,15 @@ int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);int rf69_set_rx_start_timeout (struct spi_device *spi,u8 timeout);int rf69_set_rssi_timeout (struct spi_device *spi,u8 timeout);int rf69_set_preamble_length (struct spi_device *spi,u16 preambleLength); -int rf69_set_sync_enable (struct spi_device *spi,enum optionOnOff optionOnOff); +int rf69_set_sync_enable (struct spi_device *spi, +enum option_on_off option_on_off);int rf69_set_fifo_fill_condition (struct spi_device *spi,enum fifoFillCondition fifoFillCondition);int rf69_set_sync_size (struct spi_device *spi,u8 sync_size);int rf69_set_sync_tolerance (struct spi_device *spi,u8 syncTolerance);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_crc_enable (struct spi_device *spi,enum optionOnOff optionOnOff); +int rf69_set_crc_enable (struct spi_device *spi, +enum option_on_off option_on_off);int rf69_set_adressFiltering (struct spi_device *spi,enum addressFiltering addressFiltering);int rf69_set_payload_length (struct spi_device *spi,u8 payloadLength);u8 rf69_get_payload_length (struct spi_device *spi);
drivers/staging/pi433/rf69_enum.h +3 -3
@@ -18,9 +18,9 @@#ifndef RF69_ENUM_H #define RF69_ENUM_H -enum optionOnOff { - optionOff, - optionOn +enum option_on_off { +OPTION_OFF , +OPTION_ON }; enum mode {
Signature · 1 line
2.11.0
Re: [PATCH v2 04/11] staging: pi433: Rename enum optionOnOff in rf69_enum.h
Am 06.12.2017 um 00:08 schrieb Simon Sandström:
Quoted 335 lines
Renames the enum optionOnOff and its values optionOn, optionOff to enum
option_on_offandOPTION_ON,OPTION_OFF. Fixes checkpatch.pl warnings:
"Avoid CamelCase: <optionOnOff>, <optionOn>, <optionOff>".Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/pi433/pi433_if.c | 34 ++++++++++++++--------------- drivers/staging/pi433/pi433_if.h | 16 +++++++------- drivers/staging/pi433/rf69.c | 45 ++++++++++++++++++++++----------------- drivers/staging/pi433/rf69.h | 15 ++++++++----- drivers/staging/pi433/rf69_enum.h | 6 +++--- 5 files changed, 63 insertions(+), 53 deletions(-)drivers/staging/pi433/pi433_if.c +17
-17@@ -198,7 +198,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)/* packet config */ /* enable */ SET_CHECKED (rf69_set_sync_enable (dev->spi, rx_cfg->enable_sync)); -if (rx_cfg->enable_sync == optionOn) +if (rx_cfg->enable_sync ==OPTION_ON ) {SET_CHECKED (rf69_set_fifo_fill_condition (dev->spi, afterSyncInterrupt)); }@@ -206,7 +206,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) {SET_CHECKED (rf69_set_fifo_fill_condition (dev->spi, always)); } -if (rx_cfg->enable_length_byte == optionOn) { +if (rx_cfg->enable_length_byte ==OPTION_ON ) { ret =rf69_set_packet_format (dev->spi, packetLengthVar);if (ret <0 )return ret;@@ -220,14 +220,14 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)/* lengths */ SET_CHECKED (rf69_set_sync_size (dev->spi, rx_cfg->sync_length)); -if (rx_cfg->enable_length_byte == optionOn) +if (rx_cfg->enable_length_byte ==OPTION_ON ) {SET_CHECKED (rf69_set_payload_length (dev->spi,0xff )); }else if (rx_cfg->fixed_message_length !=0 ) { payload_length = rx_cfg->fixed_message_length; -if (rx_cfg->enable_length_byte == optionOn) payload_length++; +if (rx_cfg->enable_length_byte ==OPTION_ON ) payload_length++;if (rx_cfg->enable_address_filtering != filteringOff) payload_length++;SET_CHECKED (rf69_set_payload_length (dev->spi, payload_length)); }@@ -237,7 +237,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) }/* values */ -if (rx_cfg->enable_sync == optionOn) +if (rx_cfg->enable_sync ==OPTION_ON ) {SET_CHECKED (rf69_set_sync_values (dev->spi, rx_cfg->sync_pattern)); }@@ -264,7 +264,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)SET_CHECKED (rf69_set_tx_start_condition (dev->spi, tx_cfg->tx_start_condition));/* packet format enable */ -if (tx_cfg->enable_preamble == optionOn) +if (tx_cfg->enable_preamble ==OPTION_ON ) {SET_CHECKED (rf69_set_preamble_length (dev->spi, tx_cfg->preamble_length)); }@@ -273,7 +273,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)SET_CHECKED (rf69_set_preamble_length (dev->spi,0 )); }SET_CHECKED (rf69_set_sync_enable (dev->spi, tx_cfg->enable_sync)); -if (tx_cfg->enable_length_byte == optionOn) { +if (tx_cfg->enable_length_byte ==OPTION_ON ) { ret =rf69_set_packet_format (dev->spi, packetLengthVar);if (ret <0 )return ret;@@ -285,7 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)SET_CHECKED (rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc));/* configure sync, if enabled */ -if (tx_cfg->enable_sync == optionOn) { +if (tx_cfg->enable_sync ==OPTION_ON ) {SET_CHECKED (rf69_set_sync_size (dev->spi, tx_cfg->sync_length));SET_CHECKED (rf69_set_sync_values (dev->spi, tx_cfg->sync_pattern)); }@@ -400,7 +400,7 @@ pi433_receive(void *data) }/* length byte enabled? */ -if (dev->rx_cfg.enable_length_byte == optionOn) +if (dev->rx_cfg.enable_length_byte ==OPTION_ON ) { retval =wait_event_interruptible (dev->fifo_wait_queue, dev->free_in_fifo <FIFO_SIZE );@@ -525,11 +525,11 @@ pi433_tx_thread(void *data) size = tx_cfg.fixed_message_length;/* increase size, if len byte is requested */ -if (tx_cfg.enable_length_byte == optionOn) +if (tx_cfg.enable_length_byte ==OPTION_ON ) size++;/* increase size, if adr byte is requested */ -if (tx_cfg.enable_address_byte == optionOn) +if (tx_cfg.enable_address_byte ==OPTION_ON ) size++;/* prime buffer */ @@ -537,11 +537,11 @@ pi433_tx_thread(void *data) position =0 ;/* add length byte, if requested */ -if (tx_cfg.enable_length_byte == optionOn) +if (tx_cfg.enable_length_byte ==OPTION_ON ) buffer[position++] = size-1 ;/* according to spec length byte itself must be excluded from the length calculation */ /* add adr byte, if requested */ -if (tx_cfg.enable_address_byte == optionOn) +if (tx_cfg.enable_address_byte ==OPTION_ON ) buffer[position++] = tx_cfg.address_byte;/* finally get message data from fifo */ @@ -577,7 +577,7 @@ pi433_tx_thread(void *data)/* clear fifo, set fifo threshold, set payload length */ SET_CHECKED (rf69_set_mode (spi, standby));/* this clears the fifo */ SET_CHECKED (rf69_set_fifo_threshold (spi,FIFO_THRESHOLD )); -if (tx_cfg.enable_length_byte == optionOn) +if (tx_cfg.enable_length_byte ==OPTION_ON ) {SET_CHECKED (rf69_set_payload_length (spi, size * tx_cfg.repetitions)); }@@ -1091,9 +1091,9 @@ static int pi433_probe(struct spi_device *spi)/* setup the radio module */ SET_CHECKED (rf69_set_mode (spi, standby));SET_CHECKED (rf69_set_data_mode (spi, packet)); -SET_CHECKED (rf69_set_amplifier_0 (spi, optionOn)); -SET_CHECKED (rf69_set_amplifier_1 (spi, optionOff)); -SET_CHECKED (rf69_set_amplifier_2 (spi, optionOff)); +SET_CHECKED (rf69_set_amplifier_0 (spi,OPTION_ON )); +SET_CHECKED (rf69_set_amplifier_1 (spi,OPTION_OFF )); +SET_CHECKED (rf69_set_amplifier_2 (spi,OPTION_OFF ));SET_CHECKED (rf69_set_output_power_level (spi,13 ));SET_CHECKED (rf69_set_antenna_impedance (spi, fiftyOhm));drivers/staging/pi433/pi433_if.h +8
-8@@ -73,11 +73,11 @@ struct pi433_tx_cfg {/* packet format */ -enum optionOnOff enable_preamble; -enum optionOnOff enable_sync; -enum optionOnOff enable_length_byte; -enum optionOnOff enable_address_byte; -enum optionOnOff enable_crc; +enum option_on_off enable_preamble; +enum option_on_off enable_sync; +enum option_on_off enable_length_byte; +enum option_on_off enable_address_byte; +enum option_on_off enable_crc;__u16 preamble_length;__u8 sync_length;@@ -125,10 +125,10 @@ struct pi433_rx_cfg {/* packet format */ -enum optionOnOff enable_sync; -enum optionOnOff enable_length_byte;/* should be used in combination with sync, only */ +enum option_on_off enable_sync; +enum option_on_off enable_length_byte;/* should be used in combination with sync, only */ enum addressFiltering enable_address_filtering;/* operational with sync, only */ -enum optionOnOff enable_crc;/* only operational, if sync on and fixed length or length byte is used */ +enum option_on_off enable_crc;/* only operational, if sync on and fixed length or length byte is used */ __u8 sync_length;__u8 fixed_message_length;drivers/staging/pi433/rf69.c +25
-20@@ -272,45 +272,48 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency)return 0 ; } -int rf69_set_amplifier_0 (struct spi_device *spi,enum optionOnOff optionOnOff) +int rf69_set_amplifier_0 (struct spi_device *spi, +enum option_on_off option_on_off) {#ifdef DEBUG dev_dbg (&spi->dev,"set: amp #0" );#endif -switch (optionOnOff) { -case optionOn:return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA0 )); -case optionOff:return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA0 )); +switch (option_on_off) { +case OPTION_ON :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA0 )); +case OPTION_OFF :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA0 ));default :dev_dbg (&spi->dev,"set: illegal input param" );return -EINVAL ; } } -int rf69_set_amplifier_1 (struct spi_device *spi,enum optionOnOff optionOnOff) +int rf69_set_amplifier_1 (struct spi_device *spi, +enum option_on_off option_on_off) {#ifdef DEBUG dev_dbg (&spi->dev,"set: amp #1" );#endif -switch (optionOnOff) { -case optionOn:return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA1 )); -case optionOff:return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA1 )); +switch (option_on_off) { +case OPTION_ON :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA1 )); +case OPTION_OFF :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA1 ));default :dev_dbg (&spi->dev,"set: illegal input param" );return -EINVAL ; } } -int rf69_set_amplifier_2 (struct spi_device *spi,enum optionOnOff optionOnOff) +int rf69_set_amplifier_2 (struct spi_device *spi, +enum option_on_off option_on_off) {#ifdef DEBUG dev_dbg (&spi->dev,"set: amp #2" );#endif -switch (optionOnOff) { -case optionOn:return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA2 )); -case optionOff:return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA2 )); +switch (option_on_off) { +case OPTION_ON :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA2 )); +case OPTION_OFF :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA2 ));default :dev_dbg (&spi->dev,"set: illegal input param" );return -EINVAL ;@@ -720,15 +723,16 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength)return WRITE_REG (REG_PREAMBLE_LSB , lsb); } -int rf69_set_sync_enable (struct spi_device *spi,enum optionOnOff optionOnOff) +int rf69_set_sync_enable (struct spi_device *spi, +enum option_on_off option_on_off) {#ifdef DEBUG dev_dbg (&spi->dev,"set: sync enable" );#endif -switch (optionOnOff) { -case optionOn:return WRITE_REG (REG_SYNC_CONFIG , (READ_REG (REG_SYNC_CONFIG ) |MASK_SYNC_CONFIG_SYNC_ON )); -case optionOff:return WRITE_REG (REG_SYNC_CONFIG , (READ_REG (REG_SYNC_CONFIG ) & ~MASK_SYNC_CONFIG_SYNC_ON )); +switch (option_on_off) { +case OPTION_ON :return WRITE_REG (REG_SYNC_CONFIG , (READ_REG (REG_SYNC_CONFIG ) |MASK_SYNC_CONFIG_SYNC_ON )); +case OPTION_OFF :return WRITE_REG (REG_SYNC_CONFIG , (READ_REG (REG_SYNC_CONFIG ) & ~MASK_SYNC_CONFIG_SYNC_ON ));default :dev_dbg (&spi->dev,"set: illegal input param" );return -EINVAL ;@@ -817,15 +821,16 @@ int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetForma } } -int rf69_set_crc_enable (struct spi_device *spi,enum optionOnOff optionOnOff) +int rf69_set_crc_enable (struct spi_device *spi, +enum option_on_off option_on_off) {#ifdef DEBUG dev_dbg (&spi->dev,"set: crc enable" );#endif -switch (optionOnOff) { -case optionOn:return WRITE_REG (REG_PACKETCONFIG1 , (READ_REG (REG_PACKETCONFIG1 ) |MASK_PACKETCONFIG1_CRC_ON )); -case optionOff:return WRITE_REG (REG_PACKETCONFIG1 , (READ_REG (REG_PACKETCONFIG1 ) & ~MASK_PACKETCONFIG1_CRC_ON )); +switch (option_on_off) { +case OPTION_ON :return WRITE_REG (REG_PACKETCONFIG1 , (READ_REG (REG_PACKETCONFIG1 ) |MASK_PACKETCONFIG1_CRC_ON )); +case OPTION_OFF :return WRITE_REG (REG_PACKETCONFIG1 , (READ_REG (REG_PACKETCONFIG1 ) & ~MASK_PACKETCONFIG1_CRC_ON ));default :dev_dbg (&spi->dev,"set: illegal input param" );return -EINVAL ;drivers/staging/pi433/rf69.h +10
-5@@ -33,9 +33,12 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapiint rf69_set_bit_rate (struct spi_device *spi,u16 bitRate);int rf69_set_deviation (struct spi_device *spi,u32 deviation);int rf69_set_frequency (struct spi_device *spi,u32 frequency); -int rf69_set_amplifier_0 (struct spi_device *spi,enum optionOnOff optionOnOff); -int rf69_set_amplifier_1 (struct spi_device *spi,enum optionOnOff optionOnOff); -int rf69_set_amplifier_2 (struct spi_device *spi,enum optionOnOff optionOnOff); +int rf69_set_amplifier_0 (struct spi_device *spi, +enum option_on_off option_on_off); +int rf69_set_amplifier_1 (struct spi_device *spi, +enum option_on_off option_on_off); +int rf69_set_amplifier_2 (struct spi_device *spi, +enum option_on_off option_on_off);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_antenna_impedance (struct spi_device *spi,enum antennaImpedance antennaImpedance);@@ -56,13 +59,15 @@ int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);int rf69_set_rx_start_timeout (struct spi_device *spi,u8 timeout);int rf69_set_rssi_timeout (struct spi_device *spi,u8 timeout);int rf69_set_preamble_length (struct spi_device *spi,u16 preambleLength); -int rf69_set_sync_enable (struct spi_device *spi,enum optionOnOff optionOnOff); +int rf69_set_sync_enable (struct spi_device *spi, +enum option_on_off option_on_off);int rf69_set_fifo_fill_condition (struct spi_device *spi,enum fifoFillCondition fifoFillCondition);int rf69_set_sync_size (struct spi_device *spi,u8 sync_size);int rf69_set_sync_tolerance (struct spi_device *spi,u8 syncTolerance);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_crc_enable (struct spi_device *spi,enum optionOnOff optionOnOff); +int rf69_set_crc_enable (struct spi_device *spi, +enum option_on_off option_on_off);int rf69_set_adressFiltering (struct spi_device *spi,enum addressFiltering addressFiltering);int rf69_set_payload_length (struct spi_device *spi,u8 payloadLength);u8 rf69_get_payload_length (struct spi_device *spi);drivers/staging/pi433/rf69_enum.h +0
-0@@ -18,9 +18,9 @@#ifndef RF69_ENUM_H #define RF69_ENUM_H
drivers/staging/pi433/rf69_enum.h line 26
Quoted 10 lines
drivers/staging/pi433/rf69_enum.h +3
-3-enum optionOnOff { - optionOff, - optionOn +enum option_on_off { +OPTION_OFF , +OPTION_ON };enum mode {
Hi Simon,
nice work.
Thank you very much for all the style fixes :-)
Cheers,
Marcus
Re: [PATCH v2 04/11] staging: pi433: Rename enum optionOnOff in rf69_enum.h
Quoted 19 lines · Marcus Wolf
Quoted 6 lines
drivers/staging/pi433/rf69_enum.h +0
-0@@ -18,9 +18,9 @@#ifndef RF69_ENUM_H drivers/staging/pi433/rf69_enum.h line 25
Quoted 10 lines
drivers/staging/pi433/rf69_enum.h +3
-3#define RF69_ENUM_H -enum optionOnOff { - optionOff, - optionOn +enum option_on_off { +OPTION_OFF , +OPTION_ON };enum mode {Hi Simon,
Quoted 4 lines
nice work.
Thank you very much for all the style fixes :-)
Wow... This was the one patch I thought was going to sink this patchset... Isn't enum optionOnOff part of the userspace headers?
I thought we weren't allowed to change that.
regards,
dan carpenter
Re: [PATCH v2 04/11] staging: pi433: Rename enum optionOnOff in rf69_enum.h
Am 06.12.2017 um 12:23 schrieb Dan Carpenter:
Quoted 20 lines · Marcus Wolf
Quoted 19 lines
Quoted 6 lines
drivers/staging/pi433/rf69_enum.h +0
-0@@ -18,9 +18,9 @@#ifndef RF69_ENUM_H drivers/staging/pi433/rf69_enum.h line 25
Quoted 10 lines
drivers/staging/pi433/rf69_enum.h +3
-3#define RF69_ENUM_H -enum optionOnOff { - optionOff, - optionOn +enum option_on_off { +OPTION_OFF , +OPTION_ON };enum mode {Hi Simon,
Quoted 8 lines
Quoted 4 lines
nice work.
Thank you very much for all the style fixes :-)
Wow... This was the one patch I thought was going to sink this patchset...
I don't get that. What do you mean?
Quoted 3 lines
Isn't enum optionOnOff part of the userspace headers?
I thought we weren't allowed to change that.
All enums are for user space (or inteded to be used in userspace in future). Didn't introduce enums for internal use.
Reagrds,
Marcus
Re: [PATCH v2 04/11] staging: pi433: Rename enum optionOnOff in rf69_enum.h
Quoted 32 lines · Marcus Wolf
Am 06.12.2017 um 12:23 schrieb Dan Carpenter:
Quoted 20 lines · Marcus Wolf
Quoted 19 lines
Quoted 6 lines
drivers/staging/pi433/rf69_enum.h +0
-0@@ -18,9 +18,9 @@#ifndef RF69_ENUM_H drivers/staging/pi433/rf69_enum.h line 25
Quoted 10 lines
drivers/staging/pi433/rf69_enum.h +3
-3#define RF69_ENUM_H -enum optionOnOff { - optionOff, - optionOn +enum option_on_off { +OPTION_OFF , +OPTION_ON };enum mode {Hi Simon,
Quoted 8 lines
Quoted 4 lines
nice work.
Thank you very much for all the style fixes :-)
Wow... This was the one patch I thought was going to sink this patchset...
Quoted 8 lines
I don't get that. What do you mean?
Quoted 3 lines
Isn't enum optionOnOff part of the userspace headers?
I thought we weren't allowed to change that.
All enums are for user space (or inteded to be used in userspace in future). Didn't introduce enums for internal use.
So what I'm asking is if we do this change, does it break any userspace programs which are used *right now*. In other words will programs stop compiling because we've renamed an enum?
regards,
dan carpenter
Re: [PATCH v2 04/11] staging: pi433: Rename enum optionOnOff in rf69_enum.h
Sorry, for sending HTML as well - I am writing from my phone...
Yes, you will break something, when renaming.
Since order isn't changed, most probably old programs will still compile with old enum.h.
If we want to move from optionOnOff to bool, we will also break old progs.
Since driver is new (mainline for just something like 2 monthes) and stil under devel, I think we should "risk" it.
Gruß,
Marcus
Quoted 50 lines
Am 06.12.2017 um 11:44 schrieb Dan Carpenter <[email protected]>:
Quoted 33 lines · Marcus Wolf
Quoted 23 lines
Am 06.12.2017 um 12:23 schrieb Dan Carpenter:
Quoted 19 lines · Marcus Wolf
Quoted 6 lines
drivers/staging/pi433/rf69_enum.h +0
-0@@ -18,9 +18,9 @@#ifndef RF69_ENUM_H drivers/staging/pi433/rf69_enum.h line 25
Quoted 10 lines
drivers/staging/pi433/rf69_enum.h +3
-3#define RF69_ENUM_H -enum optionOnOff { - optionOff, - optionOn +enum option_on_off { +OPTION_OFF , +OPTION_ON };enum mode {Hi Simon,
Quoted 8 lines
Quoted 4 lines
nice work.
Thank you very much for all the style fixes :-)
Wow... This was the one patch I thought was going to sink this patchset...
Quoted 8 lines
I don't get that. What do you mean?
Quoted 3 lines
Isn't enum optionOnOff part of the userspace headers?
I thought we weren't allowed to change that.
All enums are for user space (or inteded to be used in userspace in future). Didn't introduce enums for internal use.
So what I'm asking is if we do this change, does it break any userspace programs which are used *right now*. In other words will programs stop compiling because we've renamed an enum?
regards,
dan carpenter
Re: [PATCH v2 04/11] staging: pi433: Rename enum optionOnOff in rf69_enum.h
In reply to Dan CarpenterQuoted 18 lines · Dan Carpenter
Quoted 8 lines · Marcus Wolf
Am 06.12.2017 um 12:23 schrieb Dan Carpenter:
Quoted 4 lines
Wow... This was the one patch I thought was going to sink this patchset...
Quoted 8 lines
I don't get that. What do you mean?
Quoted 3 lines
Isn't enum optionOnOff part of the userspace headers?
I thought we weren't allowed to change that.
All enums are for user space (or inteded to be used in userspace in future). Didn't introduce enums for internal use.
Quoted 7 lines
So what I'm asking is if we do this change, does it break any userspace programs which are used *right now*. In other words will programs stop compiling because we've renamed an enum?
regards,
dan carpenter
Hi,
I'm not sure about this so I have to ask: wouldn't the header need to be in include/uapi/ for userspace to use them? Or is it "allowed" for userspace programs to use this internal header? Or are we afraid to break userspace programs that keeps a copy of pi433_if.h?
Regards,
Simon
Re: [PATCH v2 04/11] staging: pi433: Rename enum optionOnOff in rf69_enum.h
Am 06.12.2017 um 21:57 schrieb Simon Sandström:
Quoted 29 lines · Dan Carpenter
Quoted 18 lines · Marcus Wolf
Quoted 8 lines
Am 06.12.2017 um 12:23 schrieb Dan Carpenter:
Quoted 4 lines
Wow... This was the one patch I thought was going to sink this patchset...
Quoted 8 lines
I don't get that. What do you mean?
Quoted 3 lines
Isn't enum optionOnOff part of the userspace headers?
I thought we weren't allowed to change that.
All enums are for user space (or inteded to be used in userspace in future). Didn't introduce enums for internal use.
Quoted 7 lines
So what I'm asking is if we do this change, does it break any userspace programs which are used *right now*. In other words will programs stop compiling because we've renamed an enum?
regards,
dan carpenterHi,
Quoted 9 lines
I'm not sure about this so I have to ask: wouldn't the header need to be in
include/uapi/for userspace to use them? Or is it "allowed" for userspace programs to use this internal header? Or are we afraid to break userspace programs that keeps a copy ofpi433_if.h?Regards,
Simon
Hi Simon,
in principle, I think you are right. With my first patch, offering the driver I did it that way, but Greg asked me to migrate everything (including docu) into staging/pi433. I think, that's related to being in staging. At the moment, I copy pi433_if.h and rf69_enum.h to my userspace program, in order to be able to compile it.
To be honest, I am a little bit astonished about that question. Don't you do a regression test after such a redesign? I would be a little bit afraid to offer such redesign without testing.
Regards,
Marcus
Re: [PATCH v2 04/11] staging: pi433: Rename enum optionOnOff in rf69_enum.h
Quoted 3 lines · Marcus Wolf
To be honest, I am a little bit astonished about that question. Don't you do a regression test after such a redesign? I would be a little bit afraid to offer such redesign without testing.
He probably doesn't have the hardware... That's fine. Most patches to staging are like this. We have a pretty good track record for rarely introducing bugs.
This patchset is pretty easy to review with confidence because it's mostly just renames so there are only a few bits to review by hand. I've attached the perl script I use for reviewing renames and indent changes.
regards,
dan carpenter
#!/usr/bin/perl
# This is a tool to help review variable rename patches. The goal is
# to strip out the automatic sed renames and the white space changes # and leaves the interesting code changes. # # Example 1: A patch renames openInfo to open_info: # cat diff | rename_review.pl openInfo open_info # # Example 2: A patch swaps the first two arguments to some_func(): # cat diff | rename_review.pl \ # -e 's/some_func\((.*?),(.*?),/some_func\($2, $1,/' # # Example 3: A patch removes the xkcd_ prefix from some but not all the # variables. Instead of trying to figure out which variables were renamed # just remove the prefix from them all: # cat diff | rename_review.pl -ea 's/xkcd_//g' # # Example 4: A patch renames 20 CamelCase variables. To review this let's # just ignore all case changes and all '_' chars. # cat diff | rename_review -ea 'tr/[A-Z]/[a-z]/' -ea 's/_//g' # # The other arguments are: # -nc removes comments # -ns removes '\' chars if they are at the end of the line.
use strict;
use File::Temp qw/ :mktemp /;
sub usage() {
print "usage: cat diff | $0 old new old new old new...\n";
print " or: cat diff | $0 -e 's/old/new/g'\n";
print " -a : auto";
print " -e : execute on old lines\n";
print " -ea: execute on all lines\n";
print " -nc: no comments\n";
print " -nb: no unneeded braces\n";
print " -ns: no slashes at the end of a line\n";
print " -pull: for function pull. deletes context.\n";
print " -r <recipe>: NULL, bool";
exit(1);
}my @subs;
my @strict_subs;
my @cmds;
my $strip_comments;
my $strip_braces;
my $strip_slashes;
my $pull_context;
my $auto;
sub filter($) {
my $line = shift();
my $old = 0;
if ($line =~ /^-/) {
$old = 1;
}
# remove the first char
$line =~ s/^[ +-]//;
if ($strip_comments) {
$line =~ s/\/\*.*?\*\///g;
$line =~ s/\/\/.*//;
}
foreach my $cmd (@cmds) {
if ($old || $cmd->[0] =~ /^-ea$/) {
eval "\$line =~ $cmd->[1]";
}
}
foreach my $sub (@subs) {
if ($old) {
$line =~ s/$sub->[0]/$sub->[1]/g;
}
}
foreach my $sub (@strict_subs) {
if ($old) {
$line =~ s/\b$sub->[0]\b/$sub->[1]/g;
}
}
# remove the newline so we can move curly braces here if we want.
$line =~ s/\n//;
return $line;
}while (my $param1 = shift()) {
if ($param1 =~ /^-a$/) {
$auto = 1;
next;
}
if ($param1 =~ /^-nc$/) {
$strip_comments = 1;
next;
}
if ($param1 =~ /^-nb$/) {
$strip_braces = 1;
next;
}
if ($param1 =~ /^-ns$/) {
$strip_slashes = 1;
next;
}
if ($param1 =~ /^-pull$/) {
$pull_context = 1;
next;
}
my $param2 = shift();
if ($param2 =~ /^$/) {
usage();
}
if ($param1 =~ /^-e(a|)$/) {
push @cmds, [$param1, $param2];
next;
}
if ($param1 =~ /^-r$/) {
if ($param2 =~ /bool/) {
push @cmds, ["-e", "s/== true//"];
push @cmds, ["-e", "s/true ==//"];
push @cmds, ["-e", "s/([a-zA-Z\-\>\._]+) == false/!\$1/"];
next;
} elsif ($param2 =~ /NULL/) {
push @cmds, ["-e", "s/ != NULL//"];
push @cmds, ["-e", "s/([a-zA-Z\-\>\._0-9]+) == NULL/!\$1/"];
next;
} elsif ($param2 =~ /BIT/) {
push @cmds, ["-e", 's/1[uU]* *<< *(\d+)/BIT($1)/'];
push @cmds, ["-e", 's/\(1 *<< *(\w+)\)/BIT($1)/'];
push @cmds, ["-e", 's/\(BIT\((.*?)\)\)/BIT($1)/'];
next;
}
usage();
}
push @subs, [$param1, $param2];
}my ($oldfh, $oldfile) = mkstemp("/tmp/oldXXXXX");
my ($newfh, $newfile) = mkstemp("/tmp/newXXXXX");
my @input = <STDIN>;
# auto works on the observation that the - line comes before the + line when we
# rename variables. Take the first - line. Find the first + line. Find the
# one word difference. Test that the old word never occurs in the new text.
if ($auto) {
my %c_keywords = ( auto => 1,
break => 1,
case => 1,
char => 1,
const => 1,
continue => 1,
default => 1,
do => 1,
double => 1,
else => 1,
enum => 1,
extern => 1,
float => 1,
for => 1,
goto => 1,
if => 1,
int => 1,
long => 1,
register => 1,
return => 1,
short => 1,
signed => 1,
sizeof => 1,
static => 1,
struct => 1,
switch => 1,
typedef => 1,
union => 1,
unsigned => 1,
void => 1,
volatile => 1,
while => 1);
my %old_words;
my %new_words;
my %added_cmds;
my @new_subs; my $inside = 0;
foreach my $line (@input) {
if ($line =~ /^(---|\+\+\+)/) {
next;
}
if ($line =~ /^@/) {
$inside = 1;
}
if ($inside && !(($_ =~ /^[- @+]/) || ($_ =~ /^$/))) {
$inside = 0;
}
if (!$inside) {
next;
}
if ($line =~ /^-/) {
s/-//;
my @words = split(/\W+/, $line);
foreach my $word (@words) {
$old_words{$word} = 1;
}
} elsif ($line =~ /^\+/) {
s/\+//;
my @words = split(/\W+/, $line);
foreach my $word (@words) {
$new_words{$word} = 1;
}
}
}
my $old_line;
my $new_line;
$inside = 0;
foreach my $line (@input) {
if ($line =~ /^(---|\+\+\+)/) {
next;
}
if ($line =~ /^@/) {
$inside = 1;
}
if ($inside && !(($_ =~ /^[- @+]/) || ($_ =~ /^$/))) {
$inside = 0;
}
if (!$inside) {
next;
}
if ($line =~ /^-/ && !$old_line) {
s/^-//;
$old_line = $line;
next;
} elsif ($old_line && $line =~ /^\+/) {
s/^\+//;
$new_line = $line;
} else {
next;
}
my @old_words = split(/\W+/, $old_line);
my @new_words = split(/\W+/, $new_line);
my @new_cmds;
my $i;
my $diff_count = 0;
for ($i = 0; ; $i++) {
if (!defined($old_words[$i]) && !defined($new_words[$i])) {
last;
}
if (!defined($old_words[$i]) || !defined($new_words[$i])) {
$diff_count = 1000;
last;
}
if ($old_words[$i] eq $new_words[$i]) {
next;
}
if ($c_keywords{$old_words[$i]}) {
$diff_count = 1000;
last;
}
if ($new_words{$old_words[$i]}) {
$diff_count++;
}
push @new_cmds, [$old_words[$i], $new_words[$i]];
}
if ($diff_count <= 2) {
foreach my $sub (@new_cmds) {
if ($added_cmds{$sub->[0] . $sub->[1]}) {
next;
}
$added_cmds{$sub->[0] . $sub->[1]} = 1;
push @new_subs, [$sub->[0] , $sub->[1]];
}
}
$old_line = 0;
}
if (@new_subs) {
print "RENAMES:\n";
foreach my $sub (@new_subs) {
print "$sub->[0] => $sub->[1]\n";
push @strict_subs, [$sub->[0] , $sub->[1]];
}
print "---\n";
}
}my $output;
#recreate an old file and a new file
my $stored_brace_line = "";
my $stored_remove_output = "";
my $del_close_brace = 0;
my $inside = 0;
foreach (@input) {
my $orig = $_;
if ($pull_context && !($orig =~ /^[+-@]/)) {
next;
}
if ($orig =~ /^(---|\+\+\+)/) {
next;
}
if ($orig =~ /^@/) {
$inside = 1;
}
if ($inside && !(($orig =~ /^[- @+]/) || ($orig =~ /^$/))) {
$inside = 0;
}
if (!$inside) {
next;
}
$output = filter($orig);
if ($strip_braces && $stored_brace_line =~ /^$/ && $orig =~ /^-(.*)\{$/) {
$stored_brace_line = $output;
next;
}
if ($strip_braces && $orig =~ /^-/ && !($stored_brace_line =~ /^$/)) {
$stored_remove_output = $stored_remove_output . "\n" . $output;
next;
}
if ($strip_braces && $del_close_brace && $orig =~ /^-\W+}\W+/) {
$del_close_brace = 0;
next;
}
if ($strip_braces && $orig =~ /^\+.*/ && !($stored_brace_line =~ /^$/)) {
my $stripped_old = $stored_brace_line;
my $stripped_new = $output;
$stripped_old =~ s/(.*)\w*{/$1/;
if ($stripped_old eq $stripped_new) {
$orig = " ";
$output = $stripped_new;
$stored_brace_line = "";
$del_close_brace = 1;
}
}
if ($strip_braces && $orig =~ /^(\+|-)\W+{/) {
$output =~ s/^[\t ]+(.*)/ $1/;
} else {
$output = "\n" . $output;
}
if ($orig =~ /^-/) {
print $oldfh $output;
next;
}
if ($orig =~ /^\+/) {
print $newfh $output;
next;
}
print $oldfh $output;
print $newfh $output;
if (!($stored_remove_output =~ /^$/)) {
print $oldfh $stored_brace_line;
print $oldfh $stored_remove_output;
$stored_brace_line = "";
$stored_remove_output = "";
}
}
print $oldfh "\n";
print $newfh "\n";
# git diff puts a -- and version at the end of the diff. put the -- into the
# new file as well so it's ignored
if ($output =~ /\n-/) {
print $newfh "-\n";
}my $hunk;
my $old_txt;
my $new_txt;
open diff, "diff -uw $oldfile $newfile |";
while (<diff>) {
if ($_ =~ /^(---|\+\+\+)/) {
next;
}
if ($_ =~ /^@/) {
if ($strip_comments) {
$old_txt =~ s/\/\*.*?\*\///g;
$new_txt =~ s/\/\*.*?\*\///g;
}
if ($strip_braces) {
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
# this is a hack because i don't know how to replace nested
# unneeded curly braces.
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
}
if ($old_txt ne $new_txt) {
print $hunk;
print $_;
}
$hunk = "";
$old_txt = "";
$new_txt = "";
next;
}
$hunk = $hunk . $_;
if ($strip_slashes) {
s/\\$//;
}
if ($_ =~ /^-/) {
s/-//;
s/[ \t\n]//g;
$old_txt = $old_txt . $_;
next;
}
if ($_ =~ /^\+/) {
s/\+//;
s/[ \t\n]//g;
$new_txt = $new_txt . $_;
next;
}
if ($_ =~ /^ /) {
s/^ //;
s/[ \t\n]//g;
$old_txt = $old_txt . $_;
$new_txt = $new_txt . $_;
}
}if ($old_txt ne $new_txt) {
if ($strip_comments) {
$old_txt =~ s/\/\*.*?\*\///g;
$new_txt =~ s/\/\*.*?\*\///g;
}
if ($strip_braces) {
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
}
print $hunk;
}# print "old = $oldfile new = $newfile\n"; unlink($oldfile); unlink($newfile);
print "\ndone.\n";
PATCH v2 5/11 staging: pi433: Rename enum modShaping in rf69_enum.h
In reply to Simon SandströmRenames enum modShaping and its values to get rid of checkpatch.pl
warnings: "Avoid CamelCase: <modShaping>".
--- drivers/staging/pi433/pi433_if.c | 2 +- drivers/staging/pi433/pi433_if.h | 2 +- drivers/staging/pi433/rf69.c | 21 +++++++++++---------- drivers/staging/pi433/rf69.h | 2 +- drivers/staging/pi433/rf69_enum.h | 14 +++++++------- 5 files changed, 21 insertions(+), 20 deletions(-)
drivers/staging/pi433/pi433_if.c +1 -1
@@ -260,7 +260,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)SET_CHECKED (rf69_set_modulation (dev->spi, tx_cfg->modulation));SET_CHECKED (rf69_set_deviation (dev->spi, tx_cfg->dev_frequency));SET_CHECKED (rf69_set_pa_ramp (dev->spi, tx_cfg->pa_ramp)); -SET_CHECKED (rf69_set_modulation_shaping (dev->spi, tx_cfg->modShaping)); +SET_CHECKED (rf69_set_modulation_shaping (dev->spi, tx_cfg->mod_shaping));SET_CHECKED (rf69_set_tx_start_condition (dev->spi, tx_cfg->tx_start_condition));/* packet format enable */
drivers/staging/pi433/pi433_if.h +1 -1
@@ -63,7 +63,7 @@ struct pi433_tx_cfg {__u16 bit_rate;__u32 dev_frequency;enum modulation modulation; -enum modShaping modShaping; +enum mod_shaping mod_shaping;enum paRamp pa_ramp;
drivers/staging/pi433/rf69.c +11 -10
@@ -109,27 +109,28 @@ enum modulation rf69_get_modulation(struct spi_device *spi) } } -int rf69_set_modulation_shaping (struct spi_device *spi,enum modShaping modShaping) +int rf69_set_modulation_shaping (struct spi_device *spi, +enum mod_shaping mod_shaping) {#ifdef DEBUG dev_dbg (&spi->dev,"set: mod shaping" );#endif if (rf69_get_modulation (spi) ==FSK ) { -switch (modShaping) { -case shapingOff:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_NONE ); -case shaping1_0:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_1_0 ); -case shaping0_5:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_0_3 ); -case shaping0_3:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_0_5 ); +switch (mod_shaping) { +case SHAPING_OFF :return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_NONE ); +case SHAPING_1_0 :return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_1_0 ); +case SHAPING_0_5 :return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_0_3 ); +case SHAPING_0_3 :return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_0_5 );default :dev_dbg (&spi->dev,"set: illegal input param" );return -EINVAL ; } }else { -switch (modShaping) { -case shapingOff:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_NONE ); -case shapingBR:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_BR ); -case shaping2BR:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_2BR ); +switch (mod_shaping) { +case SHAPING_OFF :return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_NONE ); +case SHAPING_BR :return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_BR ); +case SHAPING_2BR :return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODULATION_SHAPE ) |DATAMODUL_MODULATION_SHAPE_2BR );default :dev_dbg (&spi->dev,"set: illegal input param" );return -EINVAL ;
drivers/staging/pi433/rf69.h +1 -1
@@ -29,7 +29,7 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode);int rf69_set_data_mode (struct spi_device *spi,enum dataMode dataMode);int rf69_set_modulation (struct spi_device *spi,enum modulation modulation);enum modulation rf69_get_modulation (struct spi_device *spi); -int rf69_set_modulation_shaping (struct spi_device *spi,enum modShaping modShaping); +int rf69_set_modulation_shaping (struct spi_device *spi,enum mod_shaping mod_shaping);int rf69_set_bit_rate (struct spi_device *spi,u16 bitRate);int rf69_set_deviation (struct spi_device *spi,u32 deviation);int rf69_set_frequency (struct spi_device *spi,u32 frequency);
drivers/staging/pi433/rf69_enum.h +7 -7
@@ -42,13 +42,13 @@ enum modulation {FSK }; -enum modShaping { - shapingOff, - shaping1_0, - shaping0_5, - shaping0_3, - shapingBR, - shaping2BR +enum mod_shaping { +SHAPING_OFF , +SHAPING_1_0 , +SHAPING_0_5 , +SHAPING_0_3 , +SHAPING_BR , +SHAPING_2BR };enum paRamp {
Signature · 1 line
2.11.0
PATCH v2 6/11 staging: pi433: Split rf69_set_crc_enabled into two functions
In reply to Simon SandströmSplits rf69_set_crc_enabled(dev, enabled) intorf69_enable_crc(dev) and rf69_disable_crc(dev).
--- drivers/staging/pi433/pi433_if.c | 22 ++++++++++++++++++++-- drivers/staging/pi433/rf69.c | 18 ++++++------------ drivers/staging/pi433/rf69.h | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-)
drivers/staging/pi433/pi433_if.c +20 -2
@@ -216,7 +216,16 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)return ret; }SET_CHECKED (rf69_set_adressFiltering (dev->spi, rx_cfg->enable_address_filtering)); -SET_CHECKED (rf69_set_crc_enable (dev->spi, rx_cfg->enable_crc)); + +if (rx_cfg->enable_crc ==OPTION_ON ) { + ret =rf69_enable_crc (dev->spi); +if (ret <0 ) +return ret; + }else { + ret =rf69_disable_crc (dev->spi); +if (ret <0 ) +return ret; + }/* lengths */ SET_CHECKED (rf69_set_sync_size (dev->spi, rx_cfg->sync_length));
@@ -282,7 +291,16 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg)if (ret <0 )return ret; } -SET_CHECKED (rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc)); + +if (tx_cfg->enable_crc ==OPTION_ON ) { + ret =rf69_enable_crc (dev->spi); +if (ret <0 ) +return ret; + }else { + ret =rf69_disable_crc (dev->spi); +if (ret <0 ) +return ret; + }/* configure sync, if enabled */ if (tx_cfg->enable_sync ==OPTION_ON ) {
drivers/staging/pi433/rf69.c +6 -12
@@ -822,20 +822,14 @@ int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetForma } } -int rf69_set_crc_enable (struct spi_device *spi, -enum option_on_off option_on_off) +int rf69_enable_crc (struct spi_device *spi) { -#ifdef DEBUG -dev_dbg (&spi->dev,"set: crc enable" ); -#endif +return WRITE_REG (REG_PACKETCONFIG1 , (READ_REG (REG_PACKETCONFIG1 ) |MASK_PACKETCONFIG1_CRC_ON )); +} -switch (option_on_off) { -case OPTION_ON :return WRITE_REG (REG_PACKETCONFIG1 , (READ_REG (REG_PACKETCONFIG1 ) |MASK_PACKETCONFIG1_CRC_ON )); -case OPTION_OFF :return WRITE_REG (REG_PACKETCONFIG1 , (READ_REG (REG_PACKETCONFIG1 ) & ~MASK_PACKETCONFIG1_CRC_ON )); -default : -dev_dbg (&spi->dev,"set: illegal input param" ); -return -EINVAL ; - } +int rf69_disable_crc (struct spi_device *spi) +{ +return WRITE_REG (REG_PACKETCONFIG1 , (READ_REG (REG_PACKETCONFIG1 ) & ~MASK_PACKETCONFIG1_CRC_ON )); }int rf69_set_adressFiltering (struct spi_device *spi,enum addressFiltering addressFiltering)
drivers/staging/pi433/rf69.h +2 -2
@@ -66,8 +66,8 @@ int rf69_set_sync_size(struct spi_device *spi, u8 sync_size);int rf69_set_sync_tolerance (struct spi_device *spi,u8 syncTolerance);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_crc_enable (struct spi_device *spi, -enum option_on_off option_on_off); +int rf69_enable_crc (struct spi_device *spi); +int rf69_disable_crc (struct spi_device *spi);int rf69_set_adressFiltering (struct spi_device *spi,enum addressFiltering addressFiltering);int rf69_set_payload_length (struct spi_device *spi,u8 payloadLength);u8 rf69_get_payload_length (struct spi_device *spi);
Signature · 1 line
2.11.0
Re: [PATCH v2 06/11] staging: pi433: Split rf69_set_crc_enabled into two functions
Am 06.12.2017 um 00:08 schrieb Simon Sandström:
Quoted 19 lines
Splits
rf69_set_crc_enabled(dev, enabled)intorf69_enable_crc(dev)andrf69_disable_crc(dev).Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/pi433/pi433_if.c | 22 ++++++++++++++++++++-- drivers/staging/pi433/rf69.c | 18 ++++++------------ drivers/staging/pi433/rf69.h | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-)drivers/staging/pi433/pi433_if.c +0
-1@@ -216,7 +216,16 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)return ret; }SET_CHECKED (rf69_set_adressFiltering (dev->spi, rx_cfg->enable_address_filtering)); -SET_CHECKED (rf69_set_crc_enable (dev->spi, rx_cfg->enable_crc));
drivers/staging/pi433/pi433_if.c rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) · line 228
Quoted 10 lines
drivers/staging/pi433/pi433_if.c +10
-0+ +if (rx_cfg->enable_crc ==OPTION_ON ) { + ret =rf69_enable_crc (dev->spi); +if (ret <0 ) +return ret; + }else { + ret =rf69_disable_crc (dev->spi); +if (ret <0 ) +return ret; + }
Why don't you use SET_CHECKED(...)?
I stil don't like this kind of changes - and not using SET_CHECKED makes it even worse, since that further increases code length.
The idea was to have the configuration as compact, as you can see in the receiver config section. It's a pitty that the packet config already needs such a huge number of exceptions due to technical reasons. We shouldn't further extend the numbers of exceptions and shouldn't extend the number of lines for setting a reg.
Initially this function was just likeset_rx_cfg()
{
SET_CHECKED(...)
SET_CHECKED(...)
SET_CHECKED(...)
SET_CHECKED(...)
}It should be easy,
* to survey, which chip settings are touched, if set_rx_cfg is called.
* to survey, that all params of the rx_cfg struct are taken care of.
The longer the function gets, the harder it is, to service it. I really would be happy, if we don't go this way.
Anyway, please keep the naming convention of rf69.c:
rf69 -set/get - action
-> rf69_set_crc_enable
Thanks,
Marcus
Re: [PATCH v2 06/11] staging: pi433: Split rf69_set_crc_enabled into two functions
Quoted 26 lines · Marcus Wolf
Am 06.12.2017 um 00:08 schrieb Simon Sandström:
Quoted 23 lines
Splits
rf69_set_crc_enabled(dev, enabled)intorf69_enable_crc(dev)andrf69_disable_crc(dev).Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/pi433/pi433_if.c | 22 ++++++++++++++++++++-- drivers/staging/pi433/rf69.c | 18 ++++++------------ drivers/staging/pi433/rf69.h | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-)drivers/staging/pi433/pi433_if.c +4
-1@@ -216,7 +216,16 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)return ret; }SET_CHECKED (rf69_set_adressFiltering (dev->spi, rx_cfg->enable_address_filtering)); -SET_CHECKED (rf69_set_crc_enable (dev->spi, rx_cfg->enable_crc)); + +if (rx_cfg->enable_crc ==OPTION_ON ) { + ret =rf69_enable_crc (dev->spi); +if (ret <0 )
Quoted 9 lines
drivers/staging/pi433/pi433_if.c rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) · line 228
Quoted 6 lines
drivers/staging/pi433/pi433_if.c +6
-0+return ret; + }else { + ret =rf69_disable_crc (dev->spi); +if (ret <0 ) +return ret; + }Why don't you use
SET_CHECKED(...)?
Marcus, please don't introduce new uses of SET_CHECKED(). It has a hidden return in it which is against kernel style and introduces very predictable and avoidable bugs. For example, in probe().
Quoted 22 lines
I stil don't like this kind of changes - and not using
SET_CHECKEDmakes it even worse, since that further increases code length.The idea was to have the configuration as compact, as you can see in the receiver config section. It's a pitty that the packet config already needs such a huge number of exceptions due to technical reasons. We shouldn't further extend the numbers of exceptions and shouldn't extend the number of lines for setting a reg.
Initially this function was just like
set_rx_cfg(){ SET_CHECKED(...) SET_CHECKED(...) SET_CHECKED(...) SET_CHECKED(...) }It should be easy,
* to survey, which chip settings are touched, ifset_rx_cfgis called.
* to survey, that all params of therx_cfgstruct are taken care of.
Quoted 8 lines
The longer the function gets, the harder it is, to service it. I really would be happy, if we don't go this way.
Anyway, please keep the naming convention of
rf69.c:rf69 -set/get - action
->rf69_set_crc_enable
No... Simon's name is better. His is shorter and makes more sense. :(
regards,
dan carpenter
Re: [PATCH v2 06/11] staging: pi433: Split rf69_set_crc_enabled into two functions
Am 06.12.2017 um 11:37 schrieb Dan Carpenter:
Quoted 37 lines · Marcus Wolf
Quoted 26 lines
Am 06.12.2017 um 00:08 schrieb Simon Sandström:
Quoted 23 lines
Splits
rf69_set_crc_enabled(dev, enabled)intorf69_enable_crc(dev)andrf69_disable_crc(dev).Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/pi433/pi433_if.c | 22 ++++++++++++++++++++-- drivers/staging/pi433/rf69.c | 18 ++++++------------ drivers/staging/pi433/rf69.h | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-)drivers/staging/pi433/pi433_if.c +4
-1@@ -216,7 +216,16 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)return ret; }SET_CHECKED (rf69_set_adressFiltering (dev->spi, rx_cfg->enable_address_filtering)); -SET_CHECKED (rf69_set_crc_enable (dev->spi, rx_cfg->enable_crc)); + +if (rx_cfg->enable_crc ==OPTION_ON ) { + ret =rf69_enable_crc (dev->spi); +if (ret <0 )Quoted 9 lines
drivers/staging/pi433/pi433_if.c rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) · line 228
Quoted 6 lines
drivers/staging/pi433/pi433_if.c +6
-0+return ret; + }else { + ret =rf69_disable_crc (dev->spi); +if (ret <0 ) +return ret; + }Why don't you use
SET_CHECKED(...)?
Quoted 3 lines
Marcus, please don't introduce new uses of
SET_CHECKED(). It has a hidden return in it which is against kernel style and introduces very predictable and avoidable bugs. For example, inprobe().
Ah ok.
Thanks for clarifiytion!
What a pitty - another bunch of extra lines of code...
Or is there an other construction, allowing for one line per register change? Something like
ret = rf69_set_xyz(...); if (ret) return ret; ret = rf69_set_abc(...); if (ret) return ret;
is pretty ugly and voids the style guide...
Thx,
Marcus
Greg KH
maintainerRe: [PATCH v2 06/11] staging: pi433: Split rf69_set_crc_enabled into two functions
Quoted 50 lines · Marcus Wolf
Am 06.12.2017 um 11:37 schrieb Dan Carpenter:
Quoted 37 lines · Marcus Wolf
Quoted 26 lines
Am 06.12.2017 um 00:08 schrieb Simon Sandström:
Quoted 23 lines
Splits
rf69_set_crc_enabled(dev, enabled)intorf69_enable_crc(dev)andrf69_disable_crc(dev).Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/pi433/pi433_if.c | 22 ++++++++++++++++++++-- drivers/staging/pi433/rf69.c | 18 ++++++------------ drivers/staging/pi433/rf69.h | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-)drivers/staging/pi433/pi433_if.c +4
-1@@ -216,7 +216,16 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)return ret; }SET_CHECKED (rf69_set_adressFiltering (dev->spi, rx_cfg->enable_address_filtering)); -SET_CHECKED (rf69_set_crc_enable (dev->spi, rx_cfg->enable_crc)); + +if (rx_cfg->enable_crc ==OPTION_ON ) { + ret =rf69_enable_crc (dev->spi); +if (ret <0 )Quoted 9 lines
drivers/staging/pi433/pi433_if.c rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) · line 228
Quoted 6 lines
drivers/staging/pi433/pi433_if.c +6
-0+return ret; + }else { + ret =rf69_disable_crc (dev->spi); +if (ret <0 ) +return ret; + }Why don't you use
SET_CHECKED(...)?Quoted 3 lines
Marcus, please don't introduce new uses of
SET_CHECKED(). It has a hidden return in it which is against kernel style and introduces very predictable and avoidable bugs. For example, inprobe().Ah ok.
Thanks for clarifiytion!
What a pitty - another bunch of extra lines of code...
Quoted 7 lines
Or is there an other construction, allowing for one line per register change? Something like
ret = rf69_set_xyz(...); if (ret) return ret; ret = rf69_set_abc(...); if (ret) return ret;is pretty ugly and voids the style guide...
Just spell it out:
ret = rf69_set_xyz(); if (ret) goto unwind_xyz;
Almost never do you want to instantly return. You should clean up from the error first.
But if you do just want to exit, that's fine too, just return. That's the normal way here, don't do funny things in macros (like return from a function), that way lies madness...
thanks,
greg k-h
Re: [PATCH v2 06/11] staging: pi433: Split rf69_set_crc_enabled into two functions
In reply to Dan CarpenterQuoted 6 lines
Quoted 4 lines
rf69 -set/get - action
->rf69_set_crc_enableNo... Simon's name is better. His is shorter and makes more sense.
I disagree. If I am going to implement a new functionality and need to think about the naming of the function name, every time I need to change a register setting that's awfull.
I usually have code on one monitor and datasheet on the other. So if I want to set a bit/reg/whatever, I have the datasheet in front of my nose. I can easy write the code, if function names refer to the names in the datasheet and follow a strict naming convention. If the naming convetion is broken, I need to switch to the header and search manually for each register, I want to set.
There is so much potential in this young driver, that could be developed. Would be pitty, if all that wouldn't take place some day.
Marcus
Greg KH
maintainerRe: [PATCH v2 06/11] staging: pi433: Split rf69_set_crc_enabled into two functions
In reply to Simon SandströmQuoted 9 lines · Simon Sandström
Splits
rf69_set_crc_enabled(dev, enabled)intorf69_enable_crc(dev)andrf69_disable_crc(dev).Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/pi433/pi433_if.c | 22 ++++++++++++++++++++-- drivers/staging/pi433/rf69.c | 18 ++++++------------ drivers/staging/pi433/rf69.h | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-)
I had to stop here in applying this series, as the merge conflicts just got too much for me to resolve by hand.
Can you rebase this series on my staging-testing branch of staging.git and send the remaining patches please?
thanks,
greg k-h
Re: [PATCH v2 06/11] staging: pi433: Split rf69_set_crc_enabled into two functions
Quoted 10 lines · Greg KH
I had to stop here in applying this series, as the merge conflicts just got too much for me to resolve by hand.
Can you rebase this series on my staging-testing branch of staging.git and send the remaining patches please?
thanks,
greg k-h
Hi,
Yes, I'll send a new patchset with the remaining patches.
Regards,
Simon
PATCH v2 7/11 staging: pi433: Split rf69_set_sync_enabled into two functions
In reply to Simon SandströmSplits rf69_set_sync_enabled(dev, enabled) intorf69_enable_sync(dev) and rf69_disable_sync(dev).
--- drivers/staging/pi433/pi433_if.c | 21 +++++++++++++++++++-- drivers/staging/pi433/rf69.c | 18 ++++++------------ drivers/staging/pi433/rf69.h | 4 ++-- 3 files changed, 27 insertions(+), 16 deletions(-)
drivers/staging/pi433/pi433_if.c +19 -2
@@ -197,13 +197,20 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)/* packet config */ /* enable */ -SET_CHECKED (rf69_set_sync_enable (dev->spi, rx_cfg->enable_sync));if (rx_cfg->enable_sync ==OPTION_ON ) { + ret =rf69_enable_sync (dev->spi); +if (ret <0 ) +return ret; +SET_CHECKED (rf69_set_fifo_fill_condition (dev->spi, afterSyncInterrupt)); }else { + ret =rf69_disable_sync (dev->spi); +if (ret <0 ) +return ret; +SET_CHECKED (rf69_set_fifo_fill_condition (dev->spi, always)); }if (rx_cfg->enable_length_byte ==OPTION_ON ) {
@@ -281,7 +288,17 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg) {SET_CHECKED (rf69_set_preamble_length (dev->spi,0 )); } -SET_CHECKED (rf69_set_sync_enable (dev->spi, tx_cfg->enable_sync)); + +if (tx_cfg->enable_sync ==OPTION_ON ) { + ret =rf69_enable_sync (dev->spi); +if (ret <0 ) +return ret; + }else { + ret =rf69_disable_sync (dev->spi); +if (ret <0 ) +return ret; + } +if (tx_cfg->enable_length_byte ==OPTION_ON ) { ret =rf69_set_packet_format (dev->spi, packetLengthVar);if (ret <0 )
drivers/staging/pi433/rf69.c +6 -12
@@ -724,20 +724,14 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength)return WRITE_REG (REG_PREAMBLE_LSB , lsb); } -int rf69_set_sync_enable (struct spi_device *spi, -enum option_on_off option_on_off) +int rf69_enable_sync (struct spi_device *spi) { -#ifdef DEBUG -dev_dbg (&spi->dev,"set: sync enable" ); -#endif +return WRITE_REG (REG_SYNC_CONFIG , (READ_REG (REG_SYNC_CONFIG ) |MASK_SYNC_CONFIG_SYNC_ON )); +} -switch (option_on_off) { -case OPTION_ON :return WRITE_REG (REG_SYNC_CONFIG , (READ_REG (REG_SYNC_CONFIG ) |MASK_SYNC_CONFIG_SYNC_ON )); -case OPTION_OFF :return WRITE_REG (REG_SYNC_CONFIG , (READ_REG (REG_SYNC_CONFIG ) & ~MASK_SYNC_CONFIG_SYNC_ON )); -default : -dev_dbg (&spi->dev,"set: illegal input param" ); -return -EINVAL ; - } +int rf69_disable_sync (struct spi_device *spi) +{ +return WRITE_REG (REG_SYNC_CONFIG , (READ_REG (REG_SYNC_CONFIG ) & ~MASK_SYNC_CONFIG_SYNC_ON )); }int rf69_set_fifo_fill_condition (struct spi_device *spi,enum fifoFillCondition fifoFillCondition)
drivers/staging/pi433/rf69.h +2 -2
@@ -59,8 +59,8 @@ int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);int rf69_set_rx_start_timeout (struct spi_device *spi,u8 timeout);int rf69_set_rssi_timeout (struct spi_device *spi,u8 timeout);int rf69_set_preamble_length (struct spi_device *spi,u16 preambleLength); -int rf69_set_sync_enable (struct spi_device *spi, -enum option_on_off option_on_off); +int rf69_enable_sync (struct spi_device *spi); +int rf69_disable_sync (struct spi_device *spi);int rf69_set_fifo_fill_condition (struct spi_device *spi,enum fifoFillCondition fifoFillCondition);int rf69_set_sync_size (struct spi_device *spi,u8 sync_size);int rf69_set_sync_tolerance (struct spi_device *spi,u8 syncTolerance);
Signature · 1 line
2.11.0
PATCH v2 8/11 staging: pi433: Remove enum data_mode
In reply to Simon SandströmCall rf69_set_data_mode with DATAMODUL_MODE value directly.
--- drivers/staging/pi433/pi433_if.c | 2 +- drivers/staging/pi433/rf69.c | 15 ++------------- drivers/staging/pi433/rf69.h | 2 +- drivers/staging/pi433/rf69_enum.h | 6 ------ 4 files changed, 4 insertions(+), 21 deletions(-)
drivers/staging/pi433/pi433_if.c +1 -1
@@ -1125,7 +1125,7 @@ static int pi433_probe(struct spi_device *spi)/* setup the radio module */ SET_CHECKED (rf69_set_mode (spi, standby)); -SET_CHECKED (rf69_set_data_mode (spi, packet)); +SET_CHECKED (rf69_set_data_mode (spi,DATAMODUL_MODE_PACKET ));SET_CHECKED (rf69_set_amplifier_0 (spi,OPTION_ON ));SET_CHECKED (rf69_set_amplifier_1 (spi,OPTION_OFF ));SET_CHECKED (rf69_set_amplifier_2 (spi,OPTION_OFF ));
drivers/staging/pi433/rf69.c +2 -13
@@ -61,20 +61,9 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) } -int rf69_set_data_mode (struct spi_device *spi,enum dataMode dataMode) +int rf69_set_data_mode (struct spi_device *spi,u8 data_mode) { -#ifdef DEBUG -dev_dbg (&spi->dev,"set: data mode" ); -#endif - -switch (dataMode) { -case packet:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODE ) |DATAMODUL_MODE_PACKET ); -case continuous:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODE ) |DATAMODUL_MODE_CONTINUOUS ); -case continuousNoSync:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODE ) |DATAMODUL_MODE_CONTINUOUS_NOSYNC ); -default : -dev_dbg (&spi->dev,"set: illegal input param" ); -return -EINVAL ; - } +return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODE ) | data_mode); }int rf69_set_modulation (struct spi_device *spi,enum modulation modulation)
drivers/staging/pi433/rf69.h +1 -1
@@ -26,7 +26,7 @@#define FIFO_THRESHOLD 15/* in byte */ int rf69_set_mode (struct spi_device *spi,enum mode mode); -int rf69_set_data_mode (struct spi_device *spi,enum dataMode dataMode); +int rf69_set_data_mode (struct spi_device *spi,u8 data_mode);int rf69_set_modulation (struct spi_device *spi,enum modulation modulation);enum modulation rf69_get_modulation (struct spi_device *spi);int rf69_set_modulation_shaping (struct spi_device *spi,enum mod_shaping mod_shaping);
drivers/staging/pi433/rf69_enum.h +0 -6
@@ -31,12 +31,6 @@ enum mode {receive }; -enum dataMode { - packet, - continuous, - continuousNoSync -}; -enum modulation {OOK ,FSK
Signature · 1 line
2.11.0
Re: [PATCH v2 08/11] staging: pi433: Remove enum data_mode
Am 06.12.2017 um 00:08 schrieb Simon Sandström:
Quoted 71 lines
Call
rf69_set_data_modewithDATAMODUL_MODEvalue directly.Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/pi433/pi433_if.c | 2 +- drivers/staging/pi433/rf69.c | 15 ++------------- drivers/staging/pi433/rf69.h | 2 +- drivers/staging/pi433/rf69_enum.h | 6 ------ 4 files changed, 4 insertions(+), 21 deletions(-)drivers/staging/pi433/pi433_if.c +1
-1@@ -1125,7 +1125,7 @@ static int pi433_probe(struct spi_device *spi)/* setup the radio module */ SET_CHECKED (rf69_set_mode (spi, standby)); -SET_CHECKED (rf69_set_data_mode (spi, packet)); +SET_CHECKED (rf69_set_data_mode (spi,DATAMODUL_MODE_PACKET ));SET_CHECKED (rf69_set_amplifier_0 (spi,OPTION_ON ));SET_CHECKED (rf69_set_amplifier_1 (spi,OPTION_OFF ));SET_CHECKED (rf69_set_amplifier_2 (spi,OPTION_OFF ));drivers/staging/pi433/rf69.c +2
-13@@ -61,20 +61,9 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) } -int rf69_set_data_mode (struct spi_device *spi,enum dataMode dataMode) +int rf69_set_data_mode (struct spi_device *spi,u8 data_mode) { -#ifdef DEBUG -dev_dbg (&spi->dev,"set: data mode" ); -#endif - -switch (dataMode) { -case packet:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODE ) |DATAMODUL_MODE_PACKET ); -case continuous:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODE ) |DATAMODUL_MODE_CONTINUOUS ); -case continuousNoSync:return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODE ) |DATAMODUL_MODE_CONTINUOUS_NOSYNC ); -default : -dev_dbg (&spi->dev,"set: illegal input param" ); -return -EINVAL ; - } +return WRITE_REG (REG_DATAMODUL , (READ_REG (REG_DATAMODUL ) & ~MASK_DATAMODUL_MODE ) | data_mode); }int rf69_set_modulation (struct spi_device *spi,enum modulation modulation)drivers/staging/pi433/rf69.h +1
-1@@ -26,7 +26,7 @@#define FIFO_THRESHOLD 15/* in byte */ int rf69_set_mode (struct spi_device *spi,enum mode mode); -int rf69_set_data_mode (struct spi_device *spi,enum dataMode dataMode); +int rf69_set_data_mode (struct spi_device *spi,u8 data_mode);int rf69_set_modulation (struct spi_device *spi,enum modulation modulation);enum modulation rf69_get_modulation (struct spi_device *spi);int rf69_set_modulation_shaping (struct spi_device *spi,enum mod_shaping mod_shaping);drivers/staging/pi433/rf69_enum.h +0
-0@@ -31,12 +31,6 @@ enum mode { receive };
drivers/staging/pi433/rf69_enum.h enum mode { · line 36
Quoted 10 lines
drivers/staging/pi433/rf69_enum.h +0
-6-enum dataMode { - packet, - continuous, - continuousNoSync -}; -enum modulation {OOK ,FSK
Hi Simon,
this change is "closing a door".
The rf69 is able to work in an advanced packet mode or in a simple continuous mode.
The driver so far is using the advanced packet mode, only. But if it will support continuous mode some day, it will be necessary to configure this.
The open source projects fhem and domoticz already asked for such a change, since for their architecture, they'll need a pi433 working in continuous mode. But so far I am not planning to implement such a functionality.
Since the rule for kernel development seems to be, not to care about future, most probably you patch is fine, anyway.
Marcus
Re: [PATCH v2 08/11] staging: pi433: Remove enum data_mode
Quoted 4 lines · Marcus Wolf
Since the rule for kernel development seems to be, not to care about future, most probably you patch is fine, anyway.
Yeah. Deleting code if there is no user is required to move this code out of staging...
I've worked in staging for a long time and I've seen patches from thousands of people. Simon really seems to understand kernel style and that's less common than one might think. It's a valuable skill. If you would just leave him to work then this driver would get fixed...
You're making it very difficult because you're complaining about the work which *needs* to be done. It's discouraging for people sending patches. This is very frustrating... :(
On the naming, I think having a function which is named "enable" but actually disables a feature is a non-starter. What about we do either one of these:
pi433_enable_<feature>(spi);
pi433_disable_<feature>(spi);
Or:
pi433_set_<feature>(spi, SETTING);It's still a standard and we'll just decide on a case by case basis what to use. This is a tiny driver and it's really easy to grep for the feature name to find the functions you want. Plus all the config is done in one location so it's really not that hard.
regards,
dan carpenter
staging: pi433: Plans from Smarthome-Wolf
Am 06.12.2017 um 14:47 schrieb Dan Carpenter:
Quoted 26 lines · Marcus Wolf
Quoted 4 lines
Since the rule for kernel development seems to be, not to care about future, most probably you patch is fine, anyway.
Yeah. Deleting code if there is no user is required to move this code out of staging...
I've worked in staging for a long time and I've seen patches from thousands of people. Simon really seems to understand kernel style and that's less common than one might think. It's a valuable skill. If you would just leave him to work then this driver would get fixed...
You're making it very difficult because you're complaining about the work which *needs* to be done. It's discouraging for people sending patches. This is very frustrating... :(
On the naming, I think having a function which is named "enable" but actually disables a feature is a non-starter. What about we do either one of these:
pi433_enable_<feature>(spi); pi433_disable_<feature>(spi); Or: pi433_set_<feature>(spi, SETTING);
Quoted 8 lines
It's still a standard and we'll just decide on a case by case basis what to use. This is a tiny driver and it's really easy to grep for the feature name to find the functions you want. Plus all the config is done in one location so it's really not that hard.
regards,
dan carpenter
Hi Greg, Dan, Simon and all others,
yesterday we had a project meeting. Though I am the boss, I was "punished" that I spend such a bunch of time to discuss here, instead of finishing stuff from my todo list :-P
I get the point, that I am not really deep in the kernel style guide and it is better, if I don't disturb the nerds.
Both facts in combination tell me, that I should lean back, wait a while and see, what the driver will become.
On the other hand, my team was - like me - a little bit in worry about this "closing a door", that happend a few times during the last weeks and the possible redesign of the driver architecture. It would be pitty, if the effort for integration of new features will be complicated a lot.
We finally decided, that I actually should reduce focussing on the driver for the moment and let things go. We'd like to use this mail, to tell our ideas and the plan for next year:
When submitting the driver, we wanted to add support to the kernel for the technical really good modules from HopeRf. The idea was to support serveral chips and several modules (carrying those chips). Due to financial and time restrictions, we finally had to reduce to rfm69cw and focused on Pi433.
Plan for the next year:
* Tweak the driver (if needed) to enable the reception of telegrams without preamble and sync pattern. We never tested this before. This feature will be needed aprox. in March'18.
* Support for the rfm69cw-868 - Almost the same module as the current, but for the 868MHz ISM band. Will be needed approx. end of summer next year.
* We would like to add support for some more features of the chip (e. g. AES) - you can see, there are lots of so far not covered registers (commented lines in rf69_registers.h). No shedule for this.
* If we will have a (financially) successfull 2018, we think about integration of the rf95 chip.
Quoted 1 line
From third parties we were asked about the follwoing features:
* Implement support for continuous mode (e. g. from projects fhem, domotics).
* Do a little bit more generic inteface implementation, to also support other hardware setups, using the rf69 chip.
Second sounds very interesting - especially in terms of a real Linux driver. But both topics so far aren't on our agenda.
So I will withdraw from the development of pi433 driver for the next monthes and will be back at the beginning of spring. I hope, there are not too many closed doors, so I can easily start over with head rev. and don't have to fall back to my old base. To ease a start over, I would love the following things (as much, as possible without breaking the rules):
* do not modify the register abstraction in a way, that it doesn't represent the real hardware any more (e. g. the stuff with amp - the chip does not have two registers, taking chipnumbers, but 3 bits, taking on/off information). In doubt have a look at the data sheet.
* stay with the naming convention for the register abstraction (rf69_set_... and rf69_get_...). If for some reason a register (or bit) needs to be read back for some reason in future, it is unlovely to have rf69_do_something and you need to find a adequate name for the getter. rf69_get_do_something is ugly most times.
* if possible, do not remove my tiny "debug system" in the register abstraction. It's very powerfull, if you work on config changes.
* try to keep the current or find a new way, that a setting from user space could be mapped to (not identical) register sets of different chips.
If you have any questions - especially concerning the hardware facts - feel free to ask. To be sure, I don't miss the mail between others from the mailing list, write something like Hi Marcus! in the first line or even in the subject.
Thanks a lot for your effort!
Merry Christmas and a happy new year,
Marcus
PATCH v2 9/11 staging: pi433: Combine all rf69_set_amplifier_x()
In reply to Simon SandströmReplaces the functions rf69_set_amplifier_1, _2, _3 with two
functions: rf69_enable_amplifier(dev, amp_mask) and rf69_disable_amplifier(dev, amp_mask).
--- drivers/staging/pi433/pi433_if.c | 6 +++--- drivers/staging/pi433/rf69.c | 46 ++++------------------------------------ drivers/staging/pi433/rf69.h | 8 ++----- 3 files changed, 9 insertions(+), 51 deletions(-)
drivers/staging/pi433/pi433_if.c +3 -3
@@ -1126,9 +1126,9 @@ static int pi433_probe(struct spi_device *spi)/* setup the radio module */ SET_CHECKED (rf69_set_mode (spi, standby));SET_CHECKED (rf69_set_data_mode (spi,DATAMODUL_MODE_PACKET )); -SET_CHECKED (rf69_set_amplifier_0 (spi,OPTION_ON )); -SET_CHECKED (rf69_set_amplifier_1 (spi,OPTION_OFF )); -SET_CHECKED (rf69_set_amplifier_2 (spi,OPTION_OFF )); +SET_CHECKED (rf69_enable_amplifier (spi,MASK_PALEVEL_PA0 )); +SET_CHECKED (rf69_disable_amplifier (spi,MASK_PALEVEL_PA1 )); +SET_CHECKED (rf69_disable_amplifier (spi,MASK_PALEVEL_PA2 ));SET_CHECKED (rf69_set_output_power_level (spi,13 ));SET_CHECKED (rf69_set_antenna_impedance (spi, fiftyOhm));
drivers/staging/pi433/rf69.c +4 -42
56 lines not on this page · raw message
drivers/staging/pi433/rf69.h +2 -6
@@ -33,12 +33,8 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping mod_shaint rf69_set_bit_rate (struct spi_device *spi,u16 bitRate);int rf69_set_deviation (struct spi_device *spi,u32 deviation);int rf69_set_frequency (struct spi_device *spi,u32 frequency); -int rf69_set_amplifier_0 (struct spi_device *spi, -enum option_on_off option_on_off); -int rf69_set_amplifier_1 (struct spi_device *spi, -enum option_on_off option_on_off); -int rf69_set_amplifier_2 (struct spi_device *spi, -enum option_on_off option_on_off); +int rf69_enable_amplifier (struct spi_device *spi,u8 amplifier_mask); +int rf69_disable_amplifier (struct spi_device *spi,u8 amplifier_mask);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_antenna_impedance (struct spi_device *spi,enum antennaImpedance antennaImpedance);
Signature · 1 line
2.11.0
Re: [PATCH v2 09/11] staging: pi433: Combine all rf69_set_amplifier_x()
Am 06.12.2017 um 00:08 schrieb Simon Sandström:
Quoted 99 lines
Replaces the functions
rf69_set_amplifier_1, _2, _3 with two
functions:rf69_enable_amplifier(dev, amp_mask)andrf69_disable_amplifier(dev, amp_mask).Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/pi433/pi433_if.c | 6 +++--- drivers/staging/pi433/rf69.c | 46 ++++------------------------------------ drivers/staging/pi433/rf69.h | 8 ++----- 3 files changed, 9 insertions(+), 51 deletions(-)drivers/staging/pi433/pi433_if.c +3
-3@@ -1126,9 +1126,9 @@ static int pi433_probe(struct spi_device *spi)/* setup the radio module */ SET_CHECKED (rf69_set_mode (spi, standby));SET_CHECKED (rf69_set_data_mode (spi,DATAMODUL_MODE_PACKET )); -SET_CHECKED (rf69_set_amplifier_0 (spi,OPTION_ON )); -SET_CHECKED (rf69_set_amplifier_1 (spi,OPTION_OFF )); -SET_CHECKED (rf69_set_amplifier_2 (spi,OPTION_OFF )); +SET_CHECKED (rf69_enable_amplifier (spi,MASK_PALEVEL_PA0 )); +SET_CHECKED (rf69_disable_amplifier (spi,MASK_PALEVEL_PA1 )); +SET_CHECKED (rf69_disable_amplifier (spi,MASK_PALEVEL_PA2 ));SET_CHECKED (rf69_set_output_power_level (spi,13 ));SET_CHECKED (rf69_set_antenna_impedance (spi, fiftyOhm));drivers/staging/pi433/rf69.c +4
-42@@ -262,52 +262,14 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency)return 0 ; } -int rf69_set_amplifier_0 (struct spi_device *spi, -enum option_on_off option_on_off) +int rf69_enable_amplifier (struct spi_device *spi,u8 amplifier_mask) { -#ifdef DEBUG -dev_dbg (&spi->dev,"set: amp #0" ); -#endif - -switch (option_on_off) { -case OPTION_ON :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA0 )); -case OPTION_OFF :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA0 )); -default : -dev_dbg (&spi->dev,"set: illegal input param" ); -return -EINVAL ; - } -} - -int rf69_set_amplifier_1 (struct spi_device *spi, -enum option_on_off option_on_off) -{ -#ifdef DEBUG -dev_dbg (&spi->dev,"set: amp #1" ); -#endif - -switch (option_on_off) { -case OPTION_ON :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA1 )); -case OPTION_OFF :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA1 )); -default : -dev_dbg (&spi->dev,"set: illegal input param" ); -return -EINVAL ; - } +return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) | amplifier_mask)); } -int rf69_set_amplifier_2 (struct spi_device *spi, -enum option_on_off option_on_off) +int rf69_disable_amplifier (struct spi_device *spi,u8 amplifier_mask) { -#ifdef DEBUG -dev_dbg (&spi->dev,"set: amp #2" ); -#endif - -switch (option_on_off) { -case OPTION_ON :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) |MASK_PALEVEL_PA2 )); -case OPTION_OFF :return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~MASK_PALEVEL_PA2 )); -default : -dev_dbg (&spi->dev,"set: illegal input param" ); -return -EINVAL ; - } +return WRITE_REG (REG_PALEVEL , (READ_REG (REG_PALEVEL ) & ~amplifier_mask)); }int rf69_set_output_power_level (struct spi_device *spi,u8 powerLevel)drivers/staging/pi433/rf69.h +0
-1@@ -33,12 +33,8 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping mod_shaint rf69_set_bit_rate (struct spi_device *spi,u16 bitRate);int rf69_set_deviation (struct spi_device *spi,u32 deviation);int rf69_set_frequency (struct spi_device *spi,u32 frequency); -int rf69_set_amplifier_0(struct spi_device *spi,
drivers/staging/pi433/rf69.h int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping mod_sha · line 40
Quoted 10 lines
drivers/staging/pi433/rf69.h +2
-5- enum option_on_off option_on_off); -int rf69_set_amplifier_1 (struct spi_device *spi, -enum option_on_off option_on_off); -int rf69_set_amplifier_2 (struct spi_device *spi, -enum option_on_off option_on_off); +int rf69_enable_amplifier (struct spi_device *spi,u8 amplifier_mask); +int rf69_disable_amplifier (struct spi_device *spi,u8 amplifier_mask);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_antenna_impedance (struct spi_device *spi,enum antennaImpedance antennaImpedance);
Hi Simon,
I am sorry. I don't like that.
You expand to two functions, to get the luxury of having an enable and a disable function.
On the other hand, you colapse from 3 function - one for each amp - to a single, taking the amp number as argument.
Although I don't see the big benefit, in programming theory this might be a better solution.
But the old implementation reflects the hardware and the datasheet, since the chip does not have a register to enable and a register to disable, taking the amp number, but the chip has three bits, saying on or off. For someone, not reading the code as a "novel", but work with it, he for sure will read the datasheet. Then the new construction will be uncomfortable for him.
I tried to reflect the chip in every function I wrote. And the DEFINES in rf69.h are (almost) exactly named, as the you'll find the namings in the datasheet. That eases working with such a complex chip a lot.
Sorry,
Marcus
PATCH v2 10/11 staging: pi433: Move enum option_on_off to pi433_if.h
In reply to Simon SandströmThe enum is now only used for ioctl, so move it pi433_if.h.
--- drivers/staging/pi433/pi433_if.h | 5 +++++ drivers/staging/pi433/rf69_enum.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/pi433/pi433_if.h +5 -0
@@ -37,6 +37,11 @@/*---------------------------------------------------------------------------*/ +enum option_on_off { +OPTION_OFF , +OPTION_ON +}; +/* IOCTL structs and commands */ /**
drivers/staging/pi433/rf69_enum.h +0 -5
@@ -18,11 +18,6 @@#ifndef RF69_ENUM_H #define RF69_ENUM_H -enum option_on_off { -OPTION_OFF , -OPTION_ON -}; -enum mode { mode_sleep, standby,
Signature · 1 line
2.11.0
PATCH v2 11/11 staging: pi433: Remove SET_CHECKED usage from pi433_probe
In reply to Simon SandströmSET_CHECKED returns from the function on failure and in pi433_probe it is necessary to free the GPIOs and the device on failure.
--- drivers/staging/pi433/pi433_if.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/staging/pi433/pi433_if.c +21 -7
@@ -1124,13 +1124,27 @@ static int pi433_probe(struct spi_device *spi) }/* setup the radio module */ -SET_CHECKED (rf69_set_mode (spi, standby)); -SET_CHECKED (rf69_set_data_mode (spi,DATAMODUL_MODE_PACKET )); -SET_CHECKED (rf69_enable_amplifier (spi,MASK_PALEVEL_PA0 )); -SET_CHECKED (rf69_disable_amplifier (spi,MASK_PALEVEL_PA1 )); -SET_CHECKED (rf69_disable_amplifier (spi,MASK_PALEVEL_PA2 )); -SET_CHECKED (rf69_set_output_power_level (spi,13 )); -SET_CHECKED (rf69_set_antenna_impedance (spi, fiftyOhm)); + retval =rf69_set_mode (spi, standby); +if (retval <0 ) + goto minor_failed; + retval =rf69_set_data_mode (spi,DATAMODUL_MODE_PACKET ); +if (retval <0 ) + goto minor_failed; + retval =rf69_enable_amplifier (spi,MASK_PALEVEL_PA0 ); +if (retval <0 ) + goto minor_failed; + retval =rf69_disable_amplifier (spi,MASK_PALEVEL_PA1 ); +if (retval <0 ) + goto minor_failed; + retval =rf69_disable_amplifier (spi,MASK_PALEVEL_PA2 ); +if (retval <0 ) + goto minor_failed; + retval =rf69_set_output_power_level (spi,13 ); +if (retval <0 ) + goto minor_failed; + retval =rf69_set_antenna_impedance (spi, fiftyOhm); +if (retval <0 ) + goto minor_failed;/* determ minor number */ retval =pi433_get_minor (device);
Signature · 1 line
2.11.0