Skip to content

Commit

Permalink
hwmon: fix occ hwmon driver compile warning message
Browse files Browse the repository at this point in the history
Fixed warning message when compiling occ hwmon driver.
The issue is tracked by: openbmc#44

Signed-off-by: Yi Li <[email protected]>
  • Loading branch information
adamliyi committed Feb 29, 2016
1 parent 35d2cfb commit 4caaf17
Showing 1 changed file with 36 additions and 18 deletions.
54 changes: 36 additions & 18 deletions drivers/hwmon/power8_occ_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static int occ_renew_sensor(struct occ_response *resp, uint8_t sensor_length,

static inline uint16_t get_occdata_length(uint8_t *data)
{
return be16_to_cpup(&data[RESP_DATA_LENGTH]);
return be16_to_cpup((const __be16 *)&data[RESP_DATA_LENGTH]);
}

static int parse_occ_response(struct i2c_client *client,
Expand Down Expand Up @@ -421,8 +421,11 @@ static int parse_occ_response(struct i2c_client *client,
resp->freq_block_id = b;
for (s = 0; s < num_of_sensors; s++) {
f_sensor = &resp->blocks[b].sensor[s];
f_sensor->sensor_id = be16_to_cpup(&data[dnum]);
f_sensor->value = be16_to_cpup(&data[dnum+2]);
f_sensor->sensor_id =
be16_to_cpup((const __be16 *)
&data[dnum]);
f_sensor->value = be16_to_cpup((const __be16 *)
&data[dnum+2]);
dev_dbg(&client->dev,
"sensor[%d]-[%d]: id: %u, value: %u\n",
b, s, f_sensor->sensor_id,
Expand All @@ -438,8 +441,11 @@ static int parse_occ_response(struct i2c_client *client,
resp->temp_block_id = b;
for (s = 0; s < num_of_sensors; s++) {
t_sensor = &resp->blocks[b].sensor[s];
t_sensor->sensor_id = be16_to_cpup(&data[dnum]);
t_sensor->value = be16_to_cpup(&data[dnum+2]);
t_sensor->sensor_id =
be16_to_cpup((const __be16 *)
&data[dnum]);
t_sensor->value = be16_to_cpup((const __be16 *)
&data[dnum+2]);
dev_dbg(&client->dev,
"sensor[%d]-[%d]: id: %u, value: %u\n",
b, s, t_sensor->sensor_id,
Expand All @@ -455,12 +461,17 @@ static int parse_occ_response(struct i2c_client *client,
resp->power_block_id = b;
for (s = 0; s < num_of_sensors; s++) {
p_sensor = &resp->blocks[b].power[s];
p_sensor->sensor_id = be16_to_cpup(&data[dnum]);
p_sensor->sensor_id =
be16_to_cpup((const __be16 *)
&data[dnum]);
p_sensor->update_tag =
be32_to_cpup(&data[dnum+2]);
be32_to_cpup((const __be32 *)
&data[dnum+2]);
p_sensor->accumulator =
be32_to_cpup(&data[dnum+6]);
p_sensor->value = be16_to_cpup(&data[dnum+10]);
be32_to_cpup((const __be32 *)
&data[dnum+6]);
p_sensor->value = be16_to_cpup((const __be16 *)
&data[dnum+10]);

dev_dbg(&client->dev,
"sensor[%d]-[%d]: id: %u, value: %u\n",
Expand All @@ -479,17 +490,23 @@ static int parse_occ_response(struct i2c_client *client,
for (s = 0; s < num_of_sensors; s++) {
c_sensor = &resp->blocks[b].caps[s];
c_sensor->curr_powercap =
be16_to_cpup(&data[dnum]);
be16_to_cpup((const __be16 *)
&data[dnum]);
c_sensor->curr_powerreading =
be16_to_cpup(&data[dnum+2]);
be16_to_cpup((const __be16 *)
&data[dnum+2]);
c_sensor->norm_powercap =
be16_to_cpup(&data[dnum+4]);
be16_to_cpup((const __be16 *)
&data[dnum+4]);
c_sensor->max_powercap =
be16_to_cpup(&data[dnum+6]);
be16_to_cpup((const __be16 *)
&data[dnum+6]);
c_sensor->min_powercap =
be16_to_cpup(&data[dnum+8]);
be16_to_cpup((const __be16 *)
&data[dnum+8]);
c_sensor->user_powerlimit =
be16_to_cpup(&data[dnum+10]);
be16_to_cpup((const __be16 *)
&data[dnum+10]);

dnum = dnum + sensor_length;
dev_dbg(&client->dev, "CAPS sensor #%d:\n", s);
Expand Down Expand Up @@ -539,6 +556,7 @@ static uint8_t occ_send_cmd(struct i2c_client *client, uint8_t seq,
uint16_t checksum;
int i;

length = cpu_to_le16(length);
cmd1 = (seq << 24) | (type << 16) | length;
memcpy(&cmd2, data, length);
cmd2 <<= ((4 - length) * 8);
Expand Down Expand Up @@ -1132,16 +1150,16 @@ static ssize_t set_user_powercap(struct device *hwmon_dev,
struct occ_drv_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
uint16_t val;
uint32_t powercap;
uint8_t resp[8];
int err;

err = kstrtou16(buf, 10, &val);
if (err)
return err;

dev_dbg(dev, "set user powercap to: %lu\n", val);
err = occ_send_cmd(client, 0, 0x22, 2, &val, resp);
dev_dbg(dev, "set user powercap to: %u\n", val);
val = cpu_to_le16(val);
err = occ_send_cmd(client, 0, 0x22, 2, (uint8_t *)&val, resp);
if (err != 0) {
dev_err(dev, "Set User Powercap: wrong return status: %x\n",
err);
Expand Down

0 comments on commit 4caaf17

Please sign in to comment.