Pull hwmon fixes from Guenter Roeck: - Fix error handling in ibmaem driver initialization - Fix bad data reported by occ driver after setting power cap - Fix typos in pmbus/ucd9200 driver comments * tag 'hwmon-for-v5.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (ibmaem) don't call platform_device_del() if platform_device_add() fails hwmon: (pmbus/ucd9200) fix typos in comments hwmon: (occ) Prevent power cap command overwriting poll response
Unified · Split
| @@ -550,7 +550,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) · 549 unmodified lines | ||
| 550 | 550 | |
| 551 | 551 | res = platform_device_add(data->pdev); |
| 552 | 552 | if (res) |
| 553 | − goto ipmi_err; | |
| 553 | + goto dev_add_err; | |
| 554 | 554 | |
| 555 | 555 | platform_set_drvdata(data->pdev, data); |
| 556 | 556 | |
| @@ -598,7 +598,9 @@ hwmon_reg_err: · 41 unmodified lines | ||
| 598 | 598 | ipmi_destroy_user(data->ipmi.user); |
| 599 | 599 | ipmi_err: |
| 600 | 600 | platform_set_drvdata(data->pdev, NULL); |
| 601 | − platform_device_unregister(data->pdev); | |
| 601 | + platform_device_del(data->pdev); | |
| 602 | +dev_add_err: | |
| 603 | + platform_device_put(data->pdev); | |
| 602 | 604 | dev_err: |
| 603 | 605 | ida_free(&aem_ida, data->id); |
| 604 | 606 | id_err: |
| @@ -690,7 +692,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, · 85 unmodified lines | ||
| 690 | 692 | |
| 691 | 693 | res = platform_device_add(data->pdev); |
| 692 | 694 | if (res) |
| 693 | − goto ipmi_err; | |
| 695 | + goto dev_add_err; | |
| 694 | 696 | |
| 695 | 697 | platform_set_drvdata(data->pdev, data); |
| 696 | 698 | |
| @@ -738,7 +740,9 @@ hwmon_reg_err: · 41 unmodified lines | ||
| 738 | 740 | ipmi_destroy_user(data->ipmi.user); |
| 739 | 741 | ipmi_err: |
| 740 | 742 | platform_set_drvdata(data->pdev, NULL); |
| 741 | − platform_device_unregister(data->pdev); | |
| 743 | + platform_device_del(data->pdev); | |
| 744 | +dev_add_err: | |
| 745 | + platform_device_put(data->pdev); | |
| 742 | 746 | dev_err: |
| 743 | 747 | ida_free(&aem_ida, data->id); |
| 744 | 748 | id_err: |
| @@ -145,7 +145,7 @@ static int occ_poll(struct occ *occ) · 144 unmodified lines | ||
| 145 | 145 | cmd[6] = 0; /* checksum lsb */ |
| 146 | 146 | |
| 147 | 147 | /* mutex should already be locked if necessary */ |
| 148 | − rc = occ->send_cmd(occ, cmd, sizeof(cmd)); | |
| 148 | + rc = occ->send_cmd(occ, cmd, sizeof(cmd), &occ->resp, sizeof(occ->resp)); | |
| 149 | 149 | if (rc) { |
| 150 | 150 | occ->last_error = rc; |
| 151 | 151 | if (occ->error_count++ > OCC_ERROR_COUNT_THRESHOLD) |
| @@ -182,6 +182,7 @@ static int occ_set_user_power_cap(struct occ *occ, u16 user_power_cap) · 30 unmodified lines | ||
| 182 | 182 | { |
| 183 | 183 | int rc; |
| 184 | 184 | u8 cmd[8]; |
| 185 | + u8 resp[8]; | |
| 185 | 186 | __be16 user_power_cap_be = cpu_to_be16(user_power_cap); |
| 186 | 187 | |
| 187 | 188 | cmd[0] = 0; /* sequence number */ |
| @@ -198,7 +199,7 @@ static int occ_set_user_power_cap(struct occ *occ, u16 user_power_cap) · 10 unmodified lines | ||
| 198 | 199 | if (rc) |
| 199 | 200 | return rc; |
| 200 | 201 | |
| 201 | − rc = occ->send_cmd(occ, cmd, sizeof(cmd)); | |
| 202 | + rc = occ->send_cmd(occ, cmd, sizeof(cmd), resp, sizeof(resp)); | |
| 202 | 203 | |
| 203 | 204 | mutex_unlock(&occ->lock); |
| 204 | 205 | |
| @@ -96,7 +96,8 @@ struct occ { · 95 unmodified lines | ||
| 96 | 96 | |
| 97 | 97 | int powr_sample_time_us; /* average power sample time */ |
| 98 | 98 | u8 poll_cmd_data; /* to perform OCC poll command */ |
| 99 | − int (*send_cmd)(struct occ *occ, u8 *cmd, size_t len); | |
| 99 | + int (*send_cmd)(struct occ *occ, u8 *cmd, size_t len, void *resp, | |
| 100 | + size_t resp_len); | |
| 100 | 101 | |
| 101 | 102 | unsigned long next_update; |
| 102 | 103 | struct mutex lock; /* lock OCC access */ |
| @@ -111,7 +111,8 @@ static int p8_i2c_occ_putscom_be(struct i2c_client *client, u32 address, · 110 unmodified lines | ||
| 111 | 111 | be32_to_cpu(data1)); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | −static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len) | |
| 114 | +static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len, | |
| 115 | + void *resp, size_t resp_len) | |
| 115 | 116 | { |
| 116 | 117 | int i, rc; |
| 117 | 118 | unsigned long start; |
| @@ -120,7 +121,7 @@ static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len) · 2 unmodified lines | ||
| 120 | 121 | const long wait_time = msecs_to_jiffies(OCC_CMD_IN_PRG_WAIT_MS); |
| 121 | 122 | struct p8_i2c_occ *ctx = to_p8_i2c_occ(occ); |
| 122 | 123 | struct i2c_client *client = ctx->client; |
| 123 | − struct occ_response *resp = &occ->resp; | |
| 124 | + struct occ_response *or = (struct occ_response *)resp; | |
| 124 | 125 | |
| 125 | 126 | start = jiffies; |
| 126 | 127 | |
| @@ -151,7 +152,7 @@ static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len) · 24 unmodified lines | ||
| 151 | 152 | return rc; |
| 152 | 153 | |
| 153 | 154 | /* wait for OCC */ |
| 154 | − if (resp->return_status == OCC_RESP_CMD_IN_PRG) { | |
| 155 | + if (or->return_status == OCC_RESP_CMD_IN_PRG) { | |
| 155 | 156 | rc = -EALREADY; |
| 156 | 157 | |
| 157 | 158 | if (time_after(jiffies, start + timeout)) |
| @@ -163,7 +164,7 @@ static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len) · 5 unmodified lines | ||
| 163 | 164 | } while (rc); |
| 164 | 165 | |
| 165 | 166 | /* check the OCC response */ |
| 166 | − switch (resp->return_status) { | |
| 167 | + switch (or->return_status) { | |
| 167 | 168 | case OCC_RESP_CMD_IN_PRG: |
| 168 | 169 | rc = -ETIMEDOUT; |
| 169 | 170 | break; |
| @@ -192,8 +193,8 @@ static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len) · 22 unmodified lines | ||
| 192 | 193 | if (rc < 0) |
| 193 | 194 | return rc; |
| 194 | 195 | |
| 195 | − data_length = get_unaligned_be16(&resp->data_length); | |
| 196 | − if (data_length > OCC_RESP_DATA_BYTES) | |
| 196 | + data_length = get_unaligned_be16(&or->data_length); | |
| 197 | + if ((data_length + 7) > resp_len) | |
| 197 | 198 | return -EMSGSIZE; |
| 198 | 199 | |
| 199 | 200 | /* fetch the rest of the response data */ |
| @@ -78,11 +78,10 @@ done: · 77 unmodified lines | ||
| 78 | 78 | return notify; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | −static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len) | |
| 81 | +static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len, | |
| 82 | + void *resp, size_t resp_len) | |
| 82 | 83 | { |
| 83 | − struct occ_response *resp = &occ->resp; | |
| 84 | 84 | struct p9_sbe_occ *ctx = to_p9_sbe_occ(occ); |
| 85 | − size_t resp_len = sizeof(*resp); | |
| 86 | 85 | int rc; |
| 87 | 86 | |
| 88 | 87 | rc = fsi_occ_submit(ctx->sbe, cmd, len, resp, &resp_len); |
| @@ -96,7 +95,7 @@ static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd, size_t len) · 7 unmodified lines | ||
| 96 | 95 | return rc; |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | − switch (resp->return_status) { | |
| 98 | + switch (((struct occ_response *)resp)->return_status) { | |
| 100 | 99 | case OCC_RESP_CMD_IN_PRG: |
| 101 | 100 | rc = -ETIMEDOUT; |
| 102 | 101 | break; |
| @@ -148,7 +148,7 @@ static int ucd9200_probe(struct i2c_client *client) · 147 unmodified lines | ||
| 148 | 148 | * This only affects the READ_IOUT and READ_TEMPERATURE2 registers. |
| 149 | 149 | * READ_IOUT will return the sum of currents of all phases of a rail, |
| 150 | 150 | * and READ_TEMPERATURE2 will return the maximum temperature detected |
| 151 | − * for the the phases of the rail. | |
| 151 | + * for the phases of the rail. | |
| 152 | 152 | */ |
| 153 | 153 | for (i = 0; i < info->pages; i++) { |
| 154 | 154 | /* |