diff options
-rw-r--r-- | drivers/nvdimm/dimm_devs.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c index e00d45522b80..8d348b22ba45 100644 --- a/drivers/nvdimm/dimm_devs.c +++ b/drivers/nvdimm/dimm_devs.c | |||
@@ -88,9 +88,9 @@ int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd) | |||
88 | int nvdimm_init_config_data(struct nvdimm_drvdata *ndd) | 88 | int nvdimm_init_config_data(struct nvdimm_drvdata *ndd) |
89 | { | 89 | { |
90 | struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(ndd->dev); | 90 | struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(ndd->dev); |
91 | int rc = validate_dimm(ndd), cmd_rc = 0; | ||
91 | struct nd_cmd_get_config_data_hdr *cmd; | 92 | struct nd_cmd_get_config_data_hdr *cmd; |
92 | struct nvdimm_bus_descriptor *nd_desc; | 93 | struct nvdimm_bus_descriptor *nd_desc; |
93 | int rc = validate_dimm(ndd); | ||
94 | u32 max_cmd_size, config_size; | 94 | u32 max_cmd_size, config_size; |
95 | size_t offset; | 95 | size_t offset; |
96 | 96 | ||
@@ -124,9 +124,11 @@ int nvdimm_init_config_data(struct nvdimm_drvdata *ndd) | |||
124 | cmd->in_offset = offset; | 124 | cmd->in_offset = offset; |
125 | rc = nd_desc->ndctl(nd_desc, to_nvdimm(ndd->dev), | 125 | rc = nd_desc->ndctl(nd_desc, to_nvdimm(ndd->dev), |
126 | ND_CMD_GET_CONFIG_DATA, cmd, | 126 | ND_CMD_GET_CONFIG_DATA, cmd, |
127 | cmd->in_length + sizeof(*cmd), NULL); | 127 | cmd->in_length + sizeof(*cmd), &cmd_rc); |
128 | if (rc || cmd->status) { | 128 | if (rc < 0) |
129 | rc = -ENXIO; | 129 | break; |
130 | if (cmd_rc < 0) { | ||
131 | rc = cmd_rc; | ||
130 | break; | 132 | break; |
131 | } | 133 | } |
132 | memcpy(ndd->data + offset, cmd->out_buf, cmd->in_length); | 134 | memcpy(ndd->data + offset, cmd->out_buf, cmd->in_length); |
@@ -140,9 +142,9 @@ int nvdimm_init_config_data(struct nvdimm_drvdata *ndd) | |||
140 | int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, | 142 | int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, |
141 | void *buf, size_t len) | 143 | void *buf, size_t len) |
142 | { | 144 | { |
143 | int rc = validate_dimm(ndd); | ||
144 | size_t max_cmd_size, buf_offset; | 145 | size_t max_cmd_size, buf_offset; |
145 | struct nd_cmd_set_config_hdr *cmd; | 146 | struct nd_cmd_set_config_hdr *cmd; |
147 | int rc = validate_dimm(ndd), cmd_rc = 0; | ||
146 | struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(ndd->dev); | 148 | struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(ndd->dev); |
147 | struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; | 149 | struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; |
148 | 150 | ||
@@ -164,7 +166,6 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, | |||
164 | for (buf_offset = 0; len; len -= cmd->in_length, | 166 | for (buf_offset = 0; len; len -= cmd->in_length, |
165 | buf_offset += cmd->in_length) { | 167 | buf_offset += cmd->in_length) { |
166 | size_t cmd_size; | 168 | size_t cmd_size; |
167 | u32 *status; | ||
168 | 169 | ||
169 | cmd->in_offset = offset + buf_offset; | 170 | cmd->in_offset = offset + buf_offset; |
170 | cmd->in_length = min(max_cmd_size, len); | 171 | cmd->in_length = min(max_cmd_size, len); |
@@ -172,12 +173,13 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, | |||
172 | 173 | ||
173 | /* status is output in the last 4-bytes of the command buffer */ | 174 | /* status is output in the last 4-bytes of the command buffer */ |
174 | cmd_size = sizeof(*cmd) + cmd->in_length + sizeof(u32); | 175 | cmd_size = sizeof(*cmd) + cmd->in_length + sizeof(u32); |
175 | status = ((void *) cmd) + cmd_size - sizeof(u32); | ||
176 | 176 | ||
177 | rc = nd_desc->ndctl(nd_desc, to_nvdimm(ndd->dev), | 177 | rc = nd_desc->ndctl(nd_desc, to_nvdimm(ndd->dev), |
178 | ND_CMD_SET_CONFIG_DATA, cmd, cmd_size, NULL); | 178 | ND_CMD_SET_CONFIG_DATA, cmd, cmd_size, &cmd_rc); |
179 | if (rc || *status) { | 179 | if (rc < 0) |
180 | rc = rc ? rc : -ENXIO; | 180 | break; |
181 | if (cmd_rc < 0) { | ||
182 | rc = cmd_rc; | ||
181 | break; | 183 | break; |
182 | } | 184 | } |
183 | } | 185 | } |