Skip to content

Commit

Permalink
eeepc-laptop: replace magic numbers with defines
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Frans Klaver authored and Darren Hart committed Nov 19, 2014
1 parent 792bd2a commit a5de681
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/platform/x86/eeepc-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,26 +1005,30 @@ 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)
{
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);
}

Expand Down

0 comments on commit a5de681

Please sign in to comment.