eeprom93xx: fix coding style
PATCH 1/1 eeprom93xx: fix coding style
scripts/checkpatch.pl reports about some style problems, this commit fixes some of them:
ERROR: space prohibited before open square bracket '['
+ .fields = (VMStateField []) {
ERROR: space prohibited after that '!' (ctx:BxW)
+ if (! eeprom->eecs && eecs) {
^ERROR: space prohibited after that '!' (ctx:WxW)
+ } else if (eeprom->eecs && ! eecs) {
^ERROR: space prohibited after that '!' (ctx:WxW)
+ } else if (eecs && ! eeprom->eesk && eesk) {
^ERROR: switch and case should be at the same indent
switch (address >> (eeprom->addrbits - 2)) {+ case 0:
[...]
+ case 1:
[...]
+ case 2:
[...]
+ case 3:
ERROR: return is not a function, parentheses are not required
+ return (eeprom->eedo);
ERROR: switch and case should be at the same indent
switch (nwords) {+ case 16:
+ case 64:
[...]
+ case 128:
+ case 256:
[...]
+ default:
--- hw/nvram/eeprom93xx.c | 62 +++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-)
hw/nvram/eeprom93xx.c +31 -31
@@ -126,7 +126,7 @@ static const VMStateDescription vmstate_eeprom = { .version_id = EEPROM_VERSION, .minimum_version_id = OLD_EEPROM_VERSION, .minimum_version_id_old = OLD_EEPROM_VERSION, - .fields = (VMStateField []) { + .fields = (VMStateField []) {VMSTATE_UINT8 (tick, eeprom_t),VMSTATE_UINT8 (address, eeprom_t),VMSTATE_UINT8 (command, eeprom_t),
@@ -157,13 +157,13 @@ void eeprom93xx_write(eeprom_t *eeprom, int eecs, int eesk, int eedi)logout ("CS=%u SK=%u DI=%u DO=%u, tick = %u\n" , eecs, eesk, eedi, eedo, tick); -if (! eeprom->eecs && eecs) { +if (!eeprom->eecs && eecs) {/* Start chip select cycle. */ logout ("Cycle start, waiting for 1st start bit (0)\n" ); tick =0 ; command =0x0 ; address =0x0 ; - }else if (eeprom->eecs && ! eecs) { + }else if (eeprom->eecs && !eecs) {/* End chip select cycle. This triggers write / erase. */ if (eeprom->writable) {uint8_t subcommand = address >> (eeprom->addrbits -2 );
@@ -189,7 +189,7 @@ void eeprom93xx_write(eeprom_t *eeprom, int eecs, int eesk, int eedi) }/* Output DO is tristate, read results in 1. */ eedo =1 ; - }else if (eecs && ! eeprom->eesk && eesk) { + }else if (eecs && !eeprom->eesk && eesk) {/* Raising edge of clock shifts data in. */ if (tick ==0 ) {/* Wait for 1st start bit. */
@@ -230,20 +230,20 @@ void eeprom93xx_write(eeprom_t *eeprom, int eecs, int eesk, int eedi)if (command ==0 ) {/* Command code in upper 2 bits of address. */ switch (address >> (eeprom->addrbits -2 )) { -case 0 : -logout ("write disable command\n" ); - eeprom->writable =0 ; -break ; -case 1 : -logout ("write all command\n" ); -break ; -case 2 : -logout ("erase all command\n" ); -break ; -case 3 : -logout ("write enable command\n" ); - eeprom->writable =1 ; -break ; +case 0 : +logout ("write disable command\n" ); + eeprom->writable =0 ; +break ; +case 1 : +logout ("write all command\n" ); +break ; +case 2 : +logout ("erase all command\n" ); +break ; +case 3 : +logout ("write enable command\n" ); + eeprom->writable =1 ; +break ; } }else {/* Read, write or erase word. */
@@ -276,7 +276,7 @@ uint16_t eeprom93xx_read(eeprom_t *eeprom) {/* Return status of pin DO (0 or 1). */ logout ("CS=%u DO=%u\n" , eeprom->eecs, eeprom->eedo); -return (eeprom->eedo); +return eeprom->eedo; }#if 0
@@ -296,18 +296,18 @@ eeprom_t *eeprom93xx_new(DeviceState *dev, uint16_t nwords)uint8_t addrbits;switch (nwords) { -case 16 : -case 64 : - addrbits =6 ; -break ; -case 128 : -case 256 : - addrbits =8 ; -break ; -default : -assert (!"Unsupported EEPROM size, fallback to 64 words!" ); - nwords =64 ; - addrbits =6 ; +case 16 : +case 64 : + addrbits =6 ; +break ; +case 128 : +case 256 : + addrbits =8 ; +break ; +default : +assert (!"Unsupported EEPROM size, fallback to 64 words!" ); + nwords =64 ; + addrbits =6 ; } eeprom = (eeprom_t *)g_malloc0 (sizeof (*eeprom) + nwords *2 );
Signature · 1 line
1.8.4.4
Am 04.12.2013 07:27, schrieb Antony Pavlov:
Quoted 2 lines
scripts/checkpatch.plreports about some style problems, this commit fixes some of them:
Michael Tokarev
AppliedQuoted 2 lines · Antony Pavlov
scripts/checkpatch.plreports about some style problems, this commit fixes some of them:
Thanks, applied to trivial-patches queue.
I'm a bit afraid of this sort of patches - there are LOTS of coding style issues in current qemu code base, and applying a patch like this may open a really large can of worms...
Generally it has been agreed to fix coding style only when doing some other code changes nearby, as far as I remember.
/mjt
Quoted 4 lines · On Fri, 06 Dec 2013 22:59:29 +0400 Michael Tokarev <[email protected]> wrote:
Quoted 2 lines · Antony Pavlov
scripts/checkpatch.plreports about some style problems, this commit fixes some of them:
Quoted 8 lines
Thanks, applied to trivial-patches queue.
I'm a bit afraid of this sort of patches - there are LOTS of coding style issues in current qemu code base, and applying a patch like this may open a really large can of worms...
Generally it has been agreed to fix coding style only when doing some other code changes nearby, as far as I remember.
Some times ago there was a patch on adding DEC Tulip NIC support (see http://lists.gnu.org/archive/html/qemu-devel/2013-11/msg02878.html).
In this patch the 93LC46B Serial EEPROM emulation was added. But it's like reinventing the wheel because Stefan Weil already have done this work in 2006! So I used eeprom93xx for the next tulip patch version and occasionally I fixed some coding style issues.
--
Best regards,
Antony Pavlov