Patchwork [v2,1/6] tmp105: Drop unused faults field

login
register
mail settings
Submitter Jan Kiszka
Date May 15, 2010, 11:32 a.m.
Message ID <caddc227d2b976be4267fccc2d82f4b87c62fc76.1273923157.git.jan.kiszka@web.de>
Download mbox | patch
Permalink /patch/52711/
State New
Headers show

Comments

Jan Kiszka - May 15, 2010, 11:32 a.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

It was only written, but never read.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Andrzej Zaborowski <balrogg@gmail.com>
---
 hw/tmp105.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)
andrzej zaborowski - May 15, 2010, 12:33 p.m.
Hi Jan,

On 15 May 2010 13:32, Jan Kiszka <jan.kiszka@web.de> wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> It was only written, but never read.

I pushed an alternate version to just move the update from post_save
to post_load.  If you think of code as documentation, the struct
becomes less complete in representing the state of the device if you
remove the register.  State doesn't have to be readable through the
busses, some state may be readable through qemu monitor and the like.

Cheers
Jan Kiszka - May 15, 2010, 1:22 p.m.
andrzej zaborowski wrote:
> Hi Jan,
> 
> On 15 May 2010 13:32, Jan Kiszka <jan.kiszka@web.de> wrote:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> It was only written, but never read.
> 
> I pushed an alternate version to just move the update from post_save
> to post_load.  If you think of code as documentation, the struct
> becomes less complete in representing the state of the device if you
> remove the register.  State doesn't have to be readable through the
> busses, some state may be readable through qemu monitor and the like.

That particular state is unreadable via any existing interface (except a
debugger). For pretty-printing TMP105State::config, there will once be
better mechanisms based on vmstate.

I don't mind if that dead code remains, I just want to underline that
it's useless (code as documentation was important before versioning
control entered the scene).

Jan

Patch

diff --git a/hw/tmp105.c b/hw/tmp105.c
index 8343aff..cac5f2b 100644
--- a/hw/tmp105.c
+++ b/hw/tmp105.c
@@ -31,7 +31,6 @@  typedef struct {
     uint8_t config;
     int16_t temperature;
     int16_t limit[2];
-    int faults;
     uint8_t alarm;
 } TMP105State;
 
@@ -124,7 +123,6 @@  static void tmp105_write(TMP105State *s)
         if (s->buf[0] & ~s->config & (1 << 0))			/* SD */
             printf("%s: TMP105 shutdown\n", __FUNCTION__);
         s->config = s->buf[0];
-        s->faults = tmp105_faultq[(s->config >> 3) & 3];	/* F */
         tmp105_alarm_update(s);
         break;
 
@@ -173,12 +171,6 @@  static void tmp105_event(i2c_slave *i2c, enum i2c_event event)
     s->len = 0;
 }
 
-static void tmp105_post_save(void *opaque)
-{
-    TMP105State *s = opaque;
-    s->faults = tmp105_faultq[(s->config >> 3) & 3];		/* F */
-}
-
 static int tmp105_post_load(void *opaque, int version_id)
 {
     TMP105State *s = opaque;
@@ -192,7 +184,6 @@  static const VMStateDescription vmstate_tmp105 = {
     .version_id = 0,
     .minimum_version_id = 0,
     .minimum_version_id_old = 0,
-    .post_save = tmp105_post_save,
     .post_load = tmp105_post_load,
     .fields      = (VMStateField []) {
         VMSTATE_UINT8(len, TMP105State),
@@ -214,7 +205,6 @@  static void tmp105_reset(i2c_slave *i2c)
     s->temperature = 0;
     s->pointer = 0;
     s->config = 0;
-    s->faults = tmp105_faultq[(s->config >> 3) & 3];
     s->alarm = 0;
 
     tmp105_interrupt_update(s);