eeepc-laptop: replace magic numbers with defines
authorFrans Klaver <fransklaver@gmail.com>
Wed, 22 Oct 2014 19:12:41 +0000 (21:12 +0200)
committerDarren Hart <dvhart@linux.intel.com>
Wed, 19 Nov 2014 17:07:08 +0000 (09:07 -0800)
eeepc_[gs]et_fan_ctrl uses some magic numbers. These numbers mean
something more than just the number. Describe them with macros instead
of comments in one of the functions.

Signed-off-by: Frans Klaver <fransklaver@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
drivers/platform/x86/eeepc-laptop.c

index e92ea4187cdff247742411604e8e7f28b545581f..c1758ec3c61baf6c9ab9915b529dedcfcea9ec18 100644 (file)
@@ -1005,15 +1005,19 @@ static int eeepc_get_fan_rpm(void)
        return high << 8 | low;
 }
 
+#define EEEPC_EC_FAN_CTRL_BIT  0x02
+#define EEEPC_FAN_CTRL_MANUAL  1
+#define EEEPC_FAN_CTRL_AUTO    2
+
 static int eeepc_get_fan_ctrl(void)
 {
        u8 value = 0;
 
        ec_read(EEEPC_EC_FAN_CTRL, &value);
-       if (value & 0x02)
-               return 1; /* manual */
+       if (value & EEEPC_EC_FAN_CTRL_BIT)
+               return EEEPC_FAN_CTRL_MANUAL;
        else
-               return 2; /* automatic */
+               return EEEPC_FAN_CTRL_AUTO;
 }
 
 static void eeepc_set_fan_ctrl(int manual)
@@ -1021,10 +1025,10 @@ static void eeepc_set_fan_ctrl(int manual)
        u8 value = 0;
 
        ec_read(EEEPC_EC_FAN_CTRL, &value);
-       if (manual == 1)
-               value |= 0x02;
+       if (manual == EEEPC_FAN_CTRL_MANUAL)
+               value |= EEEPC_EC_FAN_CTRL_BIT;
        else
-               value &= ~0x02;
+               value &= ~EEEPC_EC_FAN_CTRL_BIT;
        ec_write(EEEPC_EC_FAN_CTRL, value);
 }