qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] eeprom93xx: fix coding style
@ 2013-12-04  6:27 Antony Pavlov
  2013-12-04  6:29 ` Stefan Weil
  2013-12-06 18:59 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  0 siblings, 2 replies; 4+ messages in thread
From: Antony Pavlov @ 2013-12-04  6:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Antony Pavlov

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:

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Cc: Stefan Weil <sw@weilnetz.de>
Cc: qemu-trivial@nongnu.org
---
 hw/nvram/eeprom93xx.c | 62 +++++++++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c
index 08f4df5..a98f924 100644
--- a/hw/nvram/eeprom93xx.c
+++ b/hw/nvram/eeprom93xx.c
@@ -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);
-- 
1.8.4.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] eeprom93xx: fix coding style
  2013-12-04  6:27 [Qemu-devel] [PATCH] eeprom93xx: fix coding style Antony Pavlov
@ 2013-12-04  6:29 ` Stefan Weil
  2013-12-06 18:59 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Weil @ 2013-12-04  6:29 UTC (permalink / raw)
  To: Antony Pavlov, qemu-devel; +Cc: qemu-trivial

Am 04.12.2013 07:27, schrieb Antony Pavlov:
> scripts/checkpatch.pl reports about some style problems,
> this commit fixes some of them:

Reviewed-by: Stefan Weil <sw@weilnetz.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] eeprom93xx: fix coding style
  2013-12-04  6:27 [Qemu-devel] [PATCH] eeprom93xx: fix coding style Antony Pavlov
  2013-12-04  6:29 ` Stefan Weil
@ 2013-12-06 18:59 ` Michael Tokarev
  2013-12-07  1:14   ` Antony Pavlov
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2013-12-06 18:59 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: qemu-trivial, Stefan Weil, qemu-devel

04.12.2013 10:27, Antony Pavlov wrote:
> scripts/checkpatch.pl reports 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] eeprom93xx: fix coding style
  2013-12-06 18:59 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
@ 2013-12-07  1:14   ` Antony Pavlov
  0 siblings, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2013-12-07  1:14 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-trivial, Stefan Weil, qemu-devel, Dmitry Smagin

On Fri, 06 Dec 2013 22:59:29 +0400
Michael Tokarev <mjt@tls.msk.ru> wrote:

> 04.12.2013 10:27, Antony Pavlov wrote:
> > scripts/checkpatch.pl reports 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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-07  1:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-04  6:27 [Qemu-devel] [PATCH] eeprom93xx: fix coding style Antony Pavlov
2013-12-04  6:29 ` Stefan Weil
2013-12-06 18:59 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-12-07  1:14   ` Antony Pavlov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).