diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2012-11-27 23:38:14 -0500 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2013-08-22 14:26:06 -0400 |
commit | 141d748e70a22629ef1e1823f88b3d5741ac38af (patch) | |
tree | 73314a01555bb55dff758af75210d007fa5e9915 | |
parent | b766630b351c68c0383831dba9b81a905e5e84c6 (diff) |
sfc: Move NIC-type-specific MTD partition date into separate structures
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r-- | drivers/net/ethernet/sfc/mtd.c | 197 |
1 files changed, 112 insertions, 85 deletions
diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c index ba6c87a73d86..f5819c746e7a 100644 --- a/drivers/net/ethernet/sfc/mtd.c +++ b/drivers/net/ethernet/sfc/mtd.c | |||
@@ -27,23 +27,19 @@ | |||
27 | struct efx_mtd_partition { | 27 | struct efx_mtd_partition { |
28 | struct list_head node; | 28 | struct list_head node; |
29 | struct mtd_info mtd; | 29 | struct mtd_info mtd; |
30 | union { | ||
31 | struct { | ||
32 | bool updating; | ||
33 | u8 nvram_type; | ||
34 | u16 fw_subtype; | ||
35 | } mcdi; | ||
36 | struct { | ||
37 | const struct falcon_spi_device *spi; | ||
38 | size_t offset; | ||
39 | } falcon; | ||
40 | }; | ||
41 | const char *dev_type_name; | 30 | const char *dev_type_name; |
42 | const char *type_name; | 31 | const char *type_name; |
43 | char name[IFNAMSIZ + 20]; | 32 | char name[IFNAMSIZ + 20]; |
44 | }; | 33 | }; |
45 | 34 | ||
35 | struct falcon_mtd_partition { | ||
36 | struct efx_mtd_partition common; | ||
37 | const struct falcon_spi_device *spi; | ||
38 | size_t offset; | ||
39 | }; | ||
40 | |||
46 | struct efx_mtd_ops { | 41 | struct efx_mtd_ops { |
42 | void (*rename)(struct efx_mtd_partition *part); | ||
47 | int (*read)(struct mtd_info *mtd, loff_t start, size_t len, | 43 | int (*read)(struct mtd_info *mtd, loff_t start, size_t len, |
48 | size_t *retlen, u8 *buffer); | 44 | size_t *retlen, u8 *buffer); |
49 | int (*erase)(struct mtd_info *mtd, loff_t start, size_t len); | 45 | int (*erase)(struct mtd_info *mtd, loff_t start, size_t len); |
@@ -55,16 +51,19 @@ struct efx_mtd_ops { | |||
55 | #define to_efx_mtd_partition(mtd) \ | 51 | #define to_efx_mtd_partition(mtd) \ |
56 | container_of(mtd, struct efx_mtd_partition, mtd) | 52 | container_of(mtd, struct efx_mtd_partition, mtd) |
57 | 53 | ||
54 | #define to_falcon_mtd_partition(mtd) \ | ||
55 | container_of(mtd, struct falcon_mtd_partition, common.mtd) | ||
56 | |||
58 | static int falcon_mtd_probe(struct efx_nic *efx); | 57 | static int falcon_mtd_probe(struct efx_nic *efx); |
59 | static int siena_mtd_probe(struct efx_nic *efx); | 58 | static int siena_mtd_probe(struct efx_nic *efx); |
60 | 59 | ||
61 | /* SPI utilities */ | 60 | /* SPI utilities */ |
62 | 61 | ||
63 | static int | 62 | static int |
64 | falcon_spi_slow_wait(struct efx_mtd_partition *part, bool uninterruptible) | 63 | falcon_spi_slow_wait(struct falcon_mtd_partition *part, bool uninterruptible) |
65 | { | 64 | { |
66 | const struct falcon_spi_device *spi = part->falcon.spi; | 65 | const struct falcon_spi_device *spi = part->spi; |
67 | struct efx_nic *efx = part->mtd.priv; | 66 | struct efx_nic *efx = part->common.mtd.priv; |
68 | u8 status; | 67 | u8 status; |
69 | int rc, i; | 68 | int rc, i; |
70 | 69 | ||
@@ -83,7 +82,7 @@ falcon_spi_slow_wait(struct efx_mtd_partition *part, bool uninterruptible) | |||
83 | return -EINTR; | 82 | return -EINTR; |
84 | } | 83 | } |
85 | pr_err("%s: timed out waiting for %s\n", | 84 | pr_err("%s: timed out waiting for %s\n", |
86 | part->name, part->dev_type_name); | 85 | part->common.name, part->common.dev_type_name); |
87 | return -ETIMEDOUT; | 86 | return -ETIMEDOUT; |
88 | } | 87 | } |
89 | 88 | ||
@@ -123,10 +122,10 @@ falcon_spi_unlock(struct efx_nic *efx, const struct falcon_spi_device *spi) | |||
123 | } | 122 | } |
124 | 123 | ||
125 | static int | 124 | static int |
126 | falcon_spi_erase(struct efx_mtd_partition *part, loff_t start, size_t len) | 125 | falcon_spi_erase(struct falcon_mtd_partition *part, loff_t start, size_t len) |
127 | { | 126 | { |
128 | const struct falcon_spi_device *spi = part->falcon.spi; | 127 | const struct falcon_spi_device *spi = part->spi; |
129 | struct efx_nic *efx = part->mtd.priv; | 128 | struct efx_nic *efx = part->common.mtd.priv; |
130 | unsigned pos, block_len; | 129 | unsigned pos, block_len; |
131 | u8 empty[FALCON_SPI_VERIFY_BUF_LEN]; | 130 | u8 empty[FALCON_SPI_VERIFY_BUF_LEN]; |
132 | u8 buffer[FALCON_SPI_VERIFY_BUF_LEN]; | 131 | u8 buffer[FALCON_SPI_VERIFY_BUF_LEN]; |
@@ -218,22 +217,18 @@ static void efx_mtd_rename_partition(struct efx_mtd_partition *part) | |||
218 | { | 217 | { |
219 | struct efx_nic *efx = part->mtd.priv; | 218 | struct efx_nic *efx = part->mtd.priv; |
220 | 219 | ||
221 | if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) | 220 | efx->mtd_ops->rename(part); |
222 | snprintf(part->name, sizeof(part->name), "%s %s:%02x", | ||
223 | efx->name, part->type_name, part->mcdi.fw_subtype); | ||
224 | else | ||
225 | snprintf(part->name, sizeof(part->name), "%s %s", | ||
226 | efx->name, part->type_name); | ||
227 | } | 221 | } |
228 | 222 | ||
229 | static int efx_mtd_add(struct efx_nic *efx, | 223 | static int efx_mtd_add(struct efx_nic *efx, struct efx_mtd_partition *parts, |
230 | struct efx_mtd_partition *parts, size_t n_parts) | 224 | size_t n_parts, size_t sizeof_part) |
231 | { | 225 | { |
232 | struct efx_mtd_partition *part; | 226 | struct efx_mtd_partition *part; |
233 | size_t i; | 227 | size_t i; |
234 | 228 | ||
235 | for (i = 0; i < n_parts; i++) { | 229 | for (i = 0; i < n_parts; i++) { |
236 | part = &parts[i]; | 230 | part = (struct efx_mtd_partition *)((char *)parts + |
231 | i * sizeof_part); | ||
237 | 232 | ||
238 | part->mtd.writesize = 1; | 233 | part->mtd.writesize = 1; |
239 | 234 | ||
@@ -257,8 +252,11 @@ static int efx_mtd_add(struct efx_nic *efx, | |||
257 | return 0; | 252 | return 0; |
258 | 253 | ||
259 | fail: | 254 | fail: |
260 | while (i--) | 255 | while (i--) { |
261 | efx_mtd_remove_partition(&parts[i]); | 256 | part = (struct efx_mtd_partition *)((char *)parts + |
257 | i * sizeof_part); | ||
258 | efx_mtd_remove_partition(part); | ||
259 | } | ||
262 | /* Failure is unlikely here, but probably means we're out of memory */ | 260 | /* Failure is unlikely here, but probably means we're out of memory */ |
263 | return -ENOMEM; | 261 | return -ENOMEM; |
264 | } | 262 | } |
@@ -301,10 +299,18 @@ int efx_mtd_probe(struct efx_nic *efx) | |||
301 | 299 | ||
302 | /* Implementation of MTD operations for Falcon */ | 300 | /* Implementation of MTD operations for Falcon */ |
303 | 301 | ||
302 | static void falcon_mtd_rename(struct efx_mtd_partition *part) | ||
303 | { | ||
304 | struct efx_nic *efx = part->mtd.priv; | ||
305 | |||
306 | snprintf(part->name, sizeof(part->name), "%s %s", | ||
307 | efx->name, part->type_name); | ||
308 | } | ||
309 | |||
304 | static int falcon_mtd_read(struct mtd_info *mtd, loff_t start, | 310 | static int falcon_mtd_read(struct mtd_info *mtd, loff_t start, |
305 | size_t len, size_t *retlen, u8 *buffer) | 311 | size_t len, size_t *retlen, u8 *buffer) |
306 | { | 312 | { |
307 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 313 | struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd); |
308 | struct efx_nic *efx = mtd->priv; | 314 | struct efx_nic *efx = mtd->priv; |
309 | struct falcon_nic_data *nic_data = efx->nic_data; | 315 | struct falcon_nic_data *nic_data = efx->nic_data; |
310 | int rc; | 316 | int rc; |
@@ -312,7 +318,7 @@ static int falcon_mtd_read(struct mtd_info *mtd, loff_t start, | |||
312 | rc = mutex_lock_interruptible(&nic_data->spi_lock); | 318 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
313 | if (rc) | 319 | if (rc) |
314 | return rc; | 320 | return rc; |
315 | rc = falcon_spi_read(efx, part->falcon.spi, part->falcon.offset + start, | 321 | rc = falcon_spi_read(efx, part->spi, part->offset + start, |
316 | len, retlen, buffer); | 322 | len, retlen, buffer); |
317 | mutex_unlock(&nic_data->spi_lock); | 323 | mutex_unlock(&nic_data->spi_lock); |
318 | return rc; | 324 | return rc; |
@@ -320,7 +326,7 @@ static int falcon_mtd_read(struct mtd_info *mtd, loff_t start, | |||
320 | 326 | ||
321 | static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len) | 327 | static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len) |
322 | { | 328 | { |
323 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 329 | struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd); |
324 | struct efx_nic *efx = mtd->priv; | 330 | struct efx_nic *efx = mtd->priv; |
325 | struct falcon_nic_data *nic_data = efx->nic_data; | 331 | struct falcon_nic_data *nic_data = efx->nic_data; |
326 | int rc; | 332 | int rc; |
@@ -328,7 +334,7 @@ static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len) | |||
328 | rc = mutex_lock_interruptible(&nic_data->spi_lock); | 334 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
329 | if (rc) | 335 | if (rc) |
330 | return rc; | 336 | return rc; |
331 | rc = falcon_spi_erase(part, part->falcon.offset + start, len); | 337 | rc = falcon_spi_erase(part, part->offset + start, len); |
332 | mutex_unlock(&nic_data->spi_lock); | 338 | mutex_unlock(&nic_data->spi_lock); |
333 | return rc; | 339 | return rc; |
334 | } | 340 | } |
@@ -336,7 +342,7 @@ static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len) | |||
336 | static int falcon_mtd_write(struct mtd_info *mtd, loff_t start, | 342 | static int falcon_mtd_write(struct mtd_info *mtd, loff_t start, |
337 | size_t len, size_t *retlen, const u8 *buffer) | 343 | size_t len, size_t *retlen, const u8 *buffer) |
338 | { | 344 | { |
339 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 345 | struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd); |
340 | struct efx_nic *efx = mtd->priv; | 346 | struct efx_nic *efx = mtd->priv; |
341 | struct falcon_nic_data *nic_data = efx->nic_data; | 347 | struct falcon_nic_data *nic_data = efx->nic_data; |
342 | int rc; | 348 | int rc; |
@@ -344,15 +350,15 @@ static int falcon_mtd_write(struct mtd_info *mtd, loff_t start, | |||
344 | rc = mutex_lock_interruptible(&nic_data->spi_lock); | 350 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
345 | if (rc) | 351 | if (rc) |
346 | return rc; | 352 | return rc; |
347 | rc = falcon_spi_write(efx, part->falcon.spi, | 353 | rc = falcon_spi_write(efx, part->spi, part->offset + start, |
348 | part->falcon.offset + start, len, retlen, buffer); | 354 | len, retlen, buffer); |
349 | mutex_unlock(&nic_data->spi_lock); | 355 | mutex_unlock(&nic_data->spi_lock); |
350 | return rc; | 356 | return rc; |
351 | } | 357 | } |
352 | 358 | ||
353 | static int falcon_mtd_sync(struct mtd_info *mtd) | 359 | static int falcon_mtd_sync(struct mtd_info *mtd) |
354 | { | 360 | { |
355 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 361 | struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd); |
356 | struct efx_nic *efx = mtd->priv; | 362 | struct efx_nic *efx = mtd->priv; |
357 | struct falcon_nic_data *nic_data = efx->nic_data; | 363 | struct falcon_nic_data *nic_data = efx->nic_data; |
358 | int rc; | 364 | int rc; |
@@ -364,6 +370,7 @@ static int falcon_mtd_sync(struct mtd_info *mtd) | |||
364 | } | 370 | } |
365 | 371 | ||
366 | static const struct efx_mtd_ops falcon_mtd_ops = { | 372 | static const struct efx_mtd_ops falcon_mtd_ops = { |
373 | .rename = falcon_mtd_rename, | ||
367 | .read = falcon_mtd_read, | 374 | .read = falcon_mtd_read, |
368 | .erase = falcon_mtd_erase, | 375 | .erase = falcon_mtd_erase, |
369 | .write = falcon_mtd_write, | 376 | .write = falcon_mtd_write, |
@@ -373,7 +380,7 @@ static const struct efx_mtd_ops falcon_mtd_ops = { | |||
373 | static int falcon_mtd_probe(struct efx_nic *efx) | 380 | static int falcon_mtd_probe(struct efx_nic *efx) |
374 | { | 381 | { |
375 | struct falcon_nic_data *nic_data = efx->nic_data; | 382 | struct falcon_nic_data *nic_data = efx->nic_data; |
376 | struct efx_mtd_partition *parts; | 383 | struct falcon_mtd_partition *parts; |
377 | struct falcon_spi_device *spi; | 384 | struct falcon_spi_device *spi; |
378 | size_t n_parts; | 385 | size_t n_parts; |
379 | int rc = -ENODEV; | 386 | int rc = -ENODEV; |
@@ -388,33 +395,33 @@ static int falcon_mtd_probe(struct efx_nic *efx) | |||
388 | 395 | ||
389 | spi = &nic_data->spi_flash; | 396 | spi = &nic_data->spi_flash; |
390 | if (falcon_spi_present(spi) && spi->size > FALCON_FLASH_BOOTCODE_START) { | 397 | if (falcon_spi_present(spi) && spi->size > FALCON_FLASH_BOOTCODE_START) { |
391 | parts[n_parts].falcon.spi = spi; | 398 | parts[n_parts].spi = spi; |
392 | parts[n_parts].falcon.offset = FALCON_FLASH_BOOTCODE_START; | 399 | parts[n_parts].offset = FALCON_FLASH_BOOTCODE_START; |
393 | parts[n_parts].dev_type_name = "flash"; | 400 | parts[n_parts].common.dev_type_name = "flash"; |
394 | parts[n_parts].type_name = "sfc_flash_bootrom"; | 401 | parts[n_parts].common.type_name = "sfc_flash_bootrom"; |
395 | parts[n_parts].mtd.type = MTD_NORFLASH; | 402 | parts[n_parts].common.mtd.type = MTD_NORFLASH; |
396 | parts[n_parts].mtd.flags = MTD_CAP_NORFLASH; | 403 | parts[n_parts].common.mtd.flags = MTD_CAP_NORFLASH; |
397 | parts[n_parts].mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START; | 404 | parts[n_parts].common.mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START; |
398 | parts[n_parts].mtd.erasesize = spi->erase_size; | 405 | parts[n_parts].common.mtd.erasesize = spi->erase_size; |
399 | n_parts++; | 406 | n_parts++; |
400 | } | 407 | } |
401 | 408 | ||
402 | spi = &nic_data->spi_eeprom; | 409 | spi = &nic_data->spi_eeprom; |
403 | if (falcon_spi_present(spi) && spi->size > FALCON_EEPROM_BOOTCONFIG_START) { | 410 | if (falcon_spi_present(spi) && spi->size > FALCON_EEPROM_BOOTCONFIG_START) { |
404 | parts[n_parts].falcon.spi = spi; | 411 | parts[n_parts].spi = spi; |
405 | parts[n_parts].falcon.offset = FALCON_EEPROM_BOOTCONFIG_START; | 412 | parts[n_parts].offset = FALCON_EEPROM_BOOTCONFIG_START; |
406 | parts[n_parts].dev_type_name = "EEPROM"; | 413 | parts[n_parts].common.dev_type_name = "EEPROM"; |
407 | parts[n_parts].type_name = "sfc_bootconfig"; | 414 | parts[n_parts].common.type_name = "sfc_bootconfig"; |
408 | parts[n_parts].mtd.type = MTD_RAM; | 415 | parts[n_parts].common.mtd.type = MTD_RAM; |
409 | parts[n_parts].mtd.flags = MTD_CAP_RAM; | 416 | parts[n_parts].common.mtd.flags = MTD_CAP_RAM; |
410 | parts[n_parts].mtd.size = | 417 | parts[n_parts].common.mtd.size = |
411 | min(spi->size, FALCON_EEPROM_BOOTCONFIG_END) - | 418 | min(spi->size, FALCON_EEPROM_BOOTCONFIG_END) - |
412 | FALCON_EEPROM_BOOTCONFIG_START; | 419 | FALCON_EEPROM_BOOTCONFIG_START; |
413 | parts[n_parts].mtd.erasesize = spi->erase_size; | 420 | parts[n_parts].common.mtd.erasesize = spi->erase_size; |
414 | n_parts++; | 421 | n_parts++; |
415 | } | 422 | } |
416 | 423 | ||
417 | rc = efx_mtd_add(efx, parts, n_parts); | 424 | rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts)); |
418 | if (rc) | 425 | if (rc) |
419 | kfree(parts); | 426 | kfree(parts); |
420 | return rc; | 427 | return rc; |
@@ -422,10 +429,30 @@ static int falcon_mtd_probe(struct efx_nic *efx) | |||
422 | 429 | ||
423 | /* Implementation of MTD operations for Siena */ | 430 | /* Implementation of MTD operations for Siena */ |
424 | 431 | ||
432 | struct efx_mcdi_mtd_partition { | ||
433 | struct efx_mtd_partition common; | ||
434 | bool updating; | ||
435 | u8 nvram_type; | ||
436 | u16 fw_subtype; | ||
437 | }; | ||
438 | |||
439 | #define to_efx_mcdi_mtd_partition(mtd) \ | ||
440 | container_of(mtd, struct efx_mcdi_mtd_partition, common.mtd) | ||
441 | |||
442 | static void siena_mtd_rename(struct efx_mtd_partition *part) | ||
443 | { | ||
444 | struct efx_mcdi_mtd_partition *mcdi_part = | ||
445 | container_of(part, struct efx_mcdi_mtd_partition, common); | ||
446 | struct efx_nic *efx = part->mtd.priv; | ||
447 | |||
448 | snprintf(part->name, sizeof(part->name), "%s %s:%02x", | ||
449 | efx->name, part->type_name, mcdi_part->fw_subtype); | ||
450 | } | ||
451 | |||
425 | static int siena_mtd_read(struct mtd_info *mtd, loff_t start, | 452 | static int siena_mtd_read(struct mtd_info *mtd, loff_t start, |
426 | size_t len, size_t *retlen, u8 *buffer) | 453 | size_t len, size_t *retlen, u8 *buffer) |
427 | { | 454 | { |
428 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 455 | struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd); |
429 | struct efx_nic *efx = mtd->priv; | 456 | struct efx_nic *efx = mtd->priv; |
430 | loff_t offset = start; | 457 | loff_t offset = start; |
431 | loff_t end = min_t(loff_t, start + len, mtd->size); | 458 | loff_t end = min_t(loff_t, start + len, mtd->size); |
@@ -434,7 +461,7 @@ static int siena_mtd_read(struct mtd_info *mtd, loff_t start, | |||
434 | 461 | ||
435 | while (offset < end) { | 462 | while (offset < end) { |
436 | chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX); | 463 | chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX); |
437 | rc = efx_mcdi_nvram_read(efx, part->mcdi.nvram_type, offset, | 464 | rc = efx_mcdi_nvram_read(efx, part->nvram_type, offset, |
438 | buffer, chunk); | 465 | buffer, chunk); |
439 | if (rc) | 466 | if (rc) |
440 | goto out; | 467 | goto out; |
@@ -448,25 +475,25 @@ out: | |||
448 | 475 | ||
449 | static int siena_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len) | 476 | static int siena_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len) |
450 | { | 477 | { |
451 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 478 | struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd); |
452 | struct efx_nic *efx = mtd->priv; | 479 | struct efx_nic *efx = mtd->priv; |
453 | loff_t offset = start & ~((loff_t)(mtd->erasesize - 1)); | 480 | loff_t offset = start & ~((loff_t)(mtd->erasesize - 1)); |
454 | loff_t end = min_t(loff_t, start + len, mtd->size); | 481 | loff_t end = min_t(loff_t, start + len, mtd->size); |
455 | size_t chunk = part->mtd.erasesize; | 482 | size_t chunk = part->common.mtd.erasesize; |
456 | int rc = 0; | 483 | int rc = 0; |
457 | 484 | ||
458 | if (!part->mcdi.updating) { | 485 | if (!part->updating) { |
459 | rc = efx_mcdi_nvram_update_start(efx, part->mcdi.nvram_type); | 486 | rc = efx_mcdi_nvram_update_start(efx, part->nvram_type); |
460 | if (rc) | 487 | if (rc) |
461 | goto out; | 488 | goto out; |
462 | part->mcdi.updating = true; | 489 | part->updating = true; |
463 | } | 490 | } |
464 | 491 | ||
465 | /* The MCDI interface can in fact do multiple erase blocks at once; | 492 | /* The MCDI interface can in fact do multiple erase blocks at once; |
466 | * but erasing may be slow, so we make multiple calls here to avoid | 493 | * but erasing may be slow, so we make multiple calls here to avoid |
467 | * tripping the MCDI RPC timeout. */ | 494 | * tripping the MCDI RPC timeout. */ |
468 | while (offset < end) { | 495 | while (offset < end) { |
469 | rc = efx_mcdi_nvram_erase(efx, part->mcdi.nvram_type, offset, | 496 | rc = efx_mcdi_nvram_erase(efx, part->nvram_type, offset, |
470 | chunk); | 497 | chunk); |
471 | if (rc) | 498 | if (rc) |
472 | goto out; | 499 | goto out; |
@@ -479,23 +506,23 @@ out: | |||
479 | static int siena_mtd_write(struct mtd_info *mtd, loff_t start, | 506 | static int siena_mtd_write(struct mtd_info *mtd, loff_t start, |
480 | size_t len, size_t *retlen, const u8 *buffer) | 507 | size_t len, size_t *retlen, const u8 *buffer) |
481 | { | 508 | { |
482 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 509 | struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd); |
483 | struct efx_nic *efx = mtd->priv; | 510 | struct efx_nic *efx = mtd->priv; |
484 | loff_t offset = start; | 511 | loff_t offset = start; |
485 | loff_t end = min_t(loff_t, start + len, mtd->size); | 512 | loff_t end = min_t(loff_t, start + len, mtd->size); |
486 | size_t chunk; | 513 | size_t chunk; |
487 | int rc = 0; | 514 | int rc = 0; |
488 | 515 | ||
489 | if (!part->mcdi.updating) { | 516 | if (!part->updating) { |
490 | rc = efx_mcdi_nvram_update_start(efx, part->mcdi.nvram_type); | 517 | rc = efx_mcdi_nvram_update_start(efx, part->nvram_type); |
491 | if (rc) | 518 | if (rc) |
492 | goto out; | 519 | goto out; |
493 | part->mcdi.updating = true; | 520 | part->updating = true; |
494 | } | 521 | } |
495 | 522 | ||
496 | while (offset < end) { | 523 | while (offset < end) { |
497 | chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX); | 524 | chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX); |
498 | rc = efx_mcdi_nvram_write(efx, part->mcdi.nvram_type, offset, | 525 | rc = efx_mcdi_nvram_write(efx, part->nvram_type, offset, |
499 | buffer, chunk); | 526 | buffer, chunk); |
500 | if (rc) | 527 | if (rc) |
501 | goto out; | 528 | goto out; |
@@ -509,19 +536,20 @@ out: | |||
509 | 536 | ||
510 | static int siena_mtd_sync(struct mtd_info *mtd) | 537 | static int siena_mtd_sync(struct mtd_info *mtd) |
511 | { | 538 | { |
512 | struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); | 539 | struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd); |
513 | struct efx_nic *efx = mtd->priv; | 540 | struct efx_nic *efx = mtd->priv; |
514 | int rc = 0; | 541 | int rc = 0; |
515 | 542 | ||
516 | if (part->mcdi.updating) { | 543 | if (part->updating) { |
517 | part->mcdi.updating = false; | 544 | part->updating = false; |
518 | rc = efx_mcdi_nvram_update_finish(efx, part->mcdi.nvram_type); | 545 | rc = efx_mcdi_nvram_update_finish(efx, part->nvram_type); |
519 | } | 546 | } |
520 | 547 | ||
521 | return rc; | 548 | return rc; |
522 | } | 549 | } |
523 | 550 | ||
524 | static const struct efx_mtd_ops siena_mtd_ops = { | 551 | static const struct efx_mtd_ops siena_mtd_ops = { |
552 | .rename = siena_mtd_rename, | ||
525 | .read = siena_mtd_read, | 553 | .read = siena_mtd_read, |
526 | .erase = siena_mtd_erase, | 554 | .erase = siena_mtd_erase, |
527 | .write = siena_mtd_write, | 555 | .write = siena_mtd_write, |
@@ -550,7 +578,7 @@ static const struct siena_nvram_type_info siena_nvram_types[] = { | |||
550 | }; | 578 | }; |
551 | 579 | ||
552 | static int siena_mtd_probe_partition(struct efx_nic *efx, | 580 | static int siena_mtd_probe_partition(struct efx_nic *efx, |
553 | struct efx_mtd_partition *part, | 581 | struct efx_mcdi_mtd_partition *part, |
554 | unsigned int type) | 582 | unsigned int type) |
555 | { | 583 | { |
556 | const struct siena_nvram_type_info *info; | 584 | const struct siena_nvram_type_info *info; |
@@ -573,20 +601,20 @@ static int siena_mtd_probe_partition(struct efx_nic *efx, | |||
573 | if (protected) | 601 | if (protected) |
574 | return -ENODEV; /* hide it */ | 602 | return -ENODEV; /* hide it */ |
575 | 603 | ||
576 | part->mcdi.nvram_type = type; | 604 | part->nvram_type = type; |
577 | part->dev_type_name = "Siena NVRAM manager"; | 605 | part->common.dev_type_name = "Siena NVRAM manager"; |
578 | part->type_name = info->name; | 606 | part->common.type_name = info->name; |
579 | 607 | ||
580 | part->mtd.type = MTD_NORFLASH; | 608 | part->common.mtd.type = MTD_NORFLASH; |
581 | part->mtd.flags = MTD_CAP_NORFLASH; | 609 | part->common.mtd.flags = MTD_CAP_NORFLASH; |
582 | part->mtd.size = size; | 610 | part->common.mtd.size = size; |
583 | part->mtd.erasesize = erase_size; | 611 | part->common.mtd.erasesize = erase_size; |
584 | 612 | ||
585 | return 0; | 613 | return 0; |
586 | } | 614 | } |
587 | 615 | ||
588 | static int siena_mtd_get_fw_subtypes(struct efx_nic *efx, | 616 | static int siena_mtd_get_fw_subtypes(struct efx_nic *efx, |
589 | struct efx_mtd_partition *parts, | 617 | struct efx_mcdi_mtd_partition *parts, |
590 | size_t n_parts) | 618 | size_t n_parts) |
591 | { | 619 | { |
592 | uint16_t fw_subtype_list[ | 620 | uint16_t fw_subtype_list[ |
@@ -599,15 +627,14 @@ static int siena_mtd_get_fw_subtypes(struct efx_nic *efx, | |||
599 | return rc; | 627 | return rc; |
600 | 628 | ||
601 | for (i = 0; i < n_parts; i++) | 629 | for (i = 0; i < n_parts; i++) |
602 | parts[i].mcdi.fw_subtype = | 630 | parts[i].fw_subtype = fw_subtype_list[parts[i].nvram_type]; |
603 | fw_subtype_list[parts[i].mcdi.nvram_type]; | ||
604 | 631 | ||
605 | return 0; | 632 | return 0; |
606 | } | 633 | } |
607 | 634 | ||
608 | static int siena_mtd_probe(struct efx_nic *efx) | 635 | static int siena_mtd_probe(struct efx_nic *efx) |
609 | { | 636 | { |
610 | struct efx_mtd_partition *parts; | 637 | struct efx_mcdi_mtd_partition *parts; |
611 | u32 nvram_types; | 638 | u32 nvram_types; |
612 | unsigned int type; | 639 | unsigned int type; |
613 | size_t n_parts; | 640 | size_t n_parts; |
@@ -645,7 +672,7 @@ static int siena_mtd_probe(struct efx_nic *efx) | |||
645 | if (rc) | 672 | if (rc) |
646 | goto fail; | 673 | goto fail; |
647 | 674 | ||
648 | rc = efx_mtd_add(efx, parts, n_parts); | 675 | rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts)); |
649 | fail: | 676 | fail: |
650 | if (rc) | 677 | if (rc) |
651 | kfree(parts); | 678 | kfree(parts); |