Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

adc-as3514.c: cosmetics

reduce indentation level, return early on error condition

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26063 a1c6a512-1295-4272-9138-f99709370657

+24 -24
+24 -24
firmware/target/arm/adc-as3514.c
··· 28 28 { 29 29 unsigned short data = 0; 30 30 31 - if ((unsigned)channel < NUM_ADC_CHANNELS) 32 - { 33 - ascodec_lock(); 31 + if ((unsigned)channel >= NUM_ADC_CHANNELS) 32 + return 0; 34 33 35 - /* Select channel */ 36 - if (ascodec_write(AS3514_ADC_0, (channel << 4)) >= 0) 37 - { 38 - unsigned char buf[2]; 34 + ascodec_lock(); 39 35 40 - /* 41 - * The AS3514 ADC will trigger an interrupt when the conversion 42 - * is finished, if the corresponding enable bit in IRQ_ENRD2 43 - * is set. 44 - * Previously the code did not wait and this apparently did 45 - * not pose any problems, but this should be more correct. 46 - * Without the wait the data read back may be completely or 47 - * partially (first one of the two bytes) stale. 48 - */ 49 - ascodec_wait_adc_finished(); 36 + /* Select channel */ 37 + if (ascodec_write(AS3514_ADC_0, (channel << 4)) >= 0) 38 + { 39 + unsigned char buf[2]; 50 40 41 + /* 42 + * The AS3514 ADC will trigger an interrupt when the conversion 43 + * is finished, if the corresponding enable bit in IRQ_ENRD2 44 + * is set. 45 + * Previously the code did not wait and this apparently did 46 + * not pose any problems, but this should be more correct. 47 + * Without the wait the data read back may be completely or 48 + * partially (first one of the two bytes) stale. 49 + */ 50 + ascodec_wait_adc_finished(); 51 51 52 - /* Read data */ 53 - if (ascodec_readbytes(AS3514_ADC_0, 2, buf) >= 0) 54 - { 55 - data = (((buf[0] & 0x3) << 8) | buf[1]); 56 - } 57 - } 58 52 59 - ascodec_unlock(); 53 + /* Read data */ 54 + if (ascodec_readbytes(AS3514_ADC_0, 2, buf) >= 0) 55 + { 56 + data = (((buf[0] & 0x3) << 8) | buf[1]); 57 + } 60 58 } 59 + 60 + ascodec_unlock(); 61 61 62 62 return data; 63 63 }