Commit eb4e8ceb4787ffaba4c2ff3b34978138b25ec248
Committed by
Joe Hershberger
1 parent
70f1463686
Exists in
v2017.01-smarct4x
and in
25 other branches
net: e1000: Fix the build with driver model and SPI EEPROM
When adding support for the driver model the SPI EEPROM feature had been ignored. Fix the build with both CONFIG_DM_ETH and CONFIG_E1000_SPI enabled. Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Showing 2 changed files with 35 additions and 30 deletions Side-by-side Diff
drivers/net/e1000.c
... | ... | @@ -5513,7 +5513,8 @@ |
5513 | 5513 | struct udevice *dev; |
5514 | 5514 | char name[30]; |
5515 | 5515 | int ret; |
5516 | -#else | |
5516 | +#endif | |
5517 | +#if !defined(CONFIG_DM_ETH) || defined(CONFIG_E1000_SPI) | |
5517 | 5518 | struct e1000_hw *hw; |
5518 | 5519 | #endif |
5519 | 5520 | int cardnum; |
... | ... | @@ -5549,6 +5550,9 @@ |
5549 | 5550 | } |
5550 | 5551 | |
5551 | 5552 | #ifdef CONFIG_E1000_SPI |
5553 | +#ifdef CONFIG_DM_ETH | |
5554 | + hw = dev_get_priv(dev); | |
5555 | +#endif | |
5552 | 5556 | /* Handle the "SPI" subcommand */ |
5553 | 5557 | if (!strcmp(argv[2], "spi")) |
5554 | 5558 | return do_e1000_spi(cmdtp, hw, argc - 3, argv + 3); |
drivers/net/e1000_spi.c
... | ... | @@ -94,17 +94,17 @@ |
94 | 94 | |
95 | 95 | /* Make sure it has an SPI chip */ |
96 | 96 | if (hw->eeprom.type != e1000_eeprom_spi) { |
97 | - E1000_ERR(hw->nic, "No attached SPI EEPROM found!\n"); | |
97 | + E1000_ERR(hw, "No attached SPI EEPROM found!\n"); | |
98 | 98 | return NULL; |
99 | 99 | } |
100 | 100 | |
101 | 101 | /* Argument sanity checks */ |
102 | 102 | if (cs != 0) { |
103 | - E1000_ERR(hw->nic, "No such SPI chip: %u\n", cs); | |
103 | + E1000_ERR(hw, "No such SPI chip: %u\n", cs); | |
104 | 104 | return NULL; |
105 | 105 | } |
106 | 106 | if (mode != SPI_MODE_0) { |
107 | - E1000_ERR(hw->nic, "Only SPI MODE-0 is supported!\n"); | |
107 | + E1000_ERR(hw, "Only SPI MODE-0 is supported!\n"); | |
108 | 108 | return NULL; |
109 | 109 | } |
110 | 110 | |
... | ... | @@ -124,7 +124,7 @@ |
124 | 124 | struct e1000_hw *hw = e1000_hw_from_spi(spi); |
125 | 125 | |
126 | 126 | if (e1000_acquire_eeprom(hw)) { |
127 | - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); | |
127 | + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); | |
128 | 128 | return -1; |
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | |
133 | 133 | |
134 | 134 | |
135 | 135 | |
136 | 136 | |
... | ... | @@ -342,41 +342,41 @@ |
342 | 342 | |
343 | 343 | /* Extra sanity checks */ |
344 | 344 | if (!length) { |
345 | - E1000_ERR(hw->nic, "Requested zero-sized dump!\n"); | |
345 | + E1000_ERR(hw, "Requested zero-sized dump!\n"); | |
346 | 346 | return 1; |
347 | 347 | } |
348 | 348 | if ((0x10000 < length) || (0x10000 - length < offset)) { |
349 | - E1000_ERR(hw->nic, "Can't dump past 0xFFFF!\n"); | |
349 | + E1000_ERR(hw, "Can't dump past 0xFFFF!\n"); | |
350 | 350 | return 1; |
351 | 351 | } |
352 | 352 | |
353 | 353 | /* Allocate a buffer to hold stuff */ |
354 | 354 | buffer = malloc(length); |
355 | 355 | if (!buffer) { |
356 | - E1000_ERR(hw->nic, "Out of Memory!\n"); | |
356 | + E1000_ERR(hw, "Out of Memory!\n"); | |
357 | 357 | return 1; |
358 | 358 | } |
359 | 359 | |
360 | 360 | /* Acquire the EEPROM and perform the dump */ |
361 | 361 | if (e1000_acquire_eeprom(hw)) { |
362 | - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); | |
362 | + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); | |
363 | 363 | free(buffer); |
364 | 364 | return 1; |
365 | 365 | } |
366 | 366 | err = e1000_spi_eeprom_dump(hw, buffer, offset, length, true); |
367 | 367 | e1000_release_eeprom(hw); |
368 | 368 | if (err) { |
369 | - E1000_ERR(hw->nic, "Interrupted!\n"); | |
369 | + E1000_ERR(hw, "Interrupted!\n"); | |
370 | 370 | free(buffer); |
371 | 371 | return 1; |
372 | 372 | } |
373 | 373 | |
374 | 374 | /* Now hexdump the result */ |
375 | 375 | printf("%s: ===== Intel e1000 EEPROM (0x%04hX - 0x%04hX) =====", |
376 | - hw->nic->name, offset, offset + length - 1); | |
376 | + hw->name, offset, offset + length - 1); | |
377 | 377 | for (i = 0; i < length; i++) { |
378 | 378 | if ((i & 0xF) == 0) |
379 | - printf("\n%s: %04hX: ", hw->nic->name, offset + i); | |
379 | + printf("\n%s: %04hX: ", hw->name, offset + i); | |
380 | 380 | else if ((i & 0xF) == 0x8) |
381 | 381 | printf(" "); |
382 | 382 | printf(" %02hx", buffer[i]); |
383 | 383 | |
384 | 384 | |
385 | 385 | |
386 | 386 | |
... | ... | @@ -407,29 +407,29 @@ |
407 | 407 | |
408 | 408 | /* Extra sanity checks */ |
409 | 409 | if (!length) { |
410 | - E1000_ERR(hw->nic, "Requested zero-sized dump!\n"); | |
410 | + E1000_ERR(hw, "Requested zero-sized dump!\n"); | |
411 | 411 | return 1; |
412 | 412 | } |
413 | 413 | if ((0x10000 < length) || (0x10000 - length < offset)) { |
414 | - E1000_ERR(hw->nic, "Can't dump past 0xFFFF!\n"); | |
414 | + E1000_ERR(hw, "Can't dump past 0xFFFF!\n"); | |
415 | 415 | return 1; |
416 | 416 | } |
417 | 417 | |
418 | 418 | /* Acquire the EEPROM */ |
419 | 419 | if (e1000_acquire_eeprom(hw)) { |
420 | - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); | |
420 | + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); | |
421 | 421 | return 1; |
422 | 422 | } |
423 | 423 | |
424 | 424 | /* Perform the programming operation */ |
425 | 425 | if (e1000_spi_eeprom_dump(hw, dest, offset, length, true) < 0) { |
426 | - E1000_ERR(hw->nic, "Interrupted!\n"); | |
426 | + E1000_ERR(hw, "Interrupted!\n"); | |
427 | 427 | e1000_release_eeprom(hw); |
428 | 428 | return 1; |
429 | 429 | } |
430 | 430 | |
431 | 431 | e1000_release_eeprom(hw); |
432 | - printf("%s: ===== EEPROM DUMP COMPLETE =====\n", hw->nic->name); | |
432 | + printf("%s: ===== EEPROM DUMP COMPLETE =====\n", hw->name); | |
433 | 433 | return 0; |
434 | 434 | } |
435 | 435 | |
436 | 436 | |
437 | 437 | |
... | ... | @@ -452,19 +452,19 @@ |
452 | 452 | |
453 | 453 | /* Acquire the EEPROM */ |
454 | 454 | if (e1000_acquire_eeprom(hw)) { |
455 | - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); | |
455 | + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); | |
456 | 456 | return 1; |
457 | 457 | } |
458 | 458 | |
459 | 459 | /* Perform the programming operation */ |
460 | 460 | if (e1000_spi_eeprom_program(hw, source, offset, length, true) < 0) { |
461 | - E1000_ERR(hw->nic, "Interrupted!\n"); | |
461 | + E1000_ERR(hw, "Interrupted!\n"); | |
462 | 462 | e1000_release_eeprom(hw); |
463 | 463 | return 1; |
464 | 464 | } |
465 | 465 | |
466 | 466 | e1000_release_eeprom(hw); |
467 | - printf("%s: ===== EEPROM PROGRAMMED =====\n", hw->nic->name); | |
467 | + printf("%s: ===== EEPROM PROGRAMMED =====\n", hw->name); | |
468 | 468 | return 0; |
469 | 469 | } |
470 | 470 | |
471 | 471 | |
472 | 472 | |
... | ... | @@ -488,19 +488,19 @@ |
488 | 488 | length = sizeof(uint16_t) * (EEPROM_CHECKSUM_REG + 1); |
489 | 489 | buffer = malloc(length); |
490 | 490 | if (!buffer) { |
491 | - E1000_ERR(hw->nic, "Unable to allocate EEPROM buffer!\n"); | |
491 | + E1000_ERR(hw, "Unable to allocate EEPROM buffer!\n"); | |
492 | 492 | return 1; |
493 | 493 | } |
494 | 494 | |
495 | 495 | /* Acquire the EEPROM */ |
496 | 496 | if (e1000_acquire_eeprom(hw)) { |
497 | - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); | |
497 | + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); | |
498 | 498 | return 1; |
499 | 499 | } |
500 | 500 | |
501 | 501 | /* Read the EEPROM */ |
502 | 502 | if (e1000_spi_eeprom_dump(hw, buffer, 0, length, true) < 0) { |
503 | - E1000_ERR(hw->nic, "Interrupted!\n"); | |
503 | + E1000_ERR(hw, "Interrupted!\n"); | |
504 | 504 | e1000_release_eeprom(hw); |
505 | 505 | return 1; |
506 | 506 | } |
507 | 507 | |
... | ... | @@ -514,15 +514,15 @@ |
514 | 514 | /* Verify it! */ |
515 | 515 | if (checksum_reg == checksum) { |
516 | 516 | printf("%s: INFO: EEPROM checksum is correct! (0x%04hx)\n", |
517 | - hw->nic->name, checksum); | |
517 | + hw->name, checksum); | |
518 | 518 | e1000_release_eeprom(hw); |
519 | 519 | return 0; |
520 | 520 | } |
521 | 521 | |
522 | 522 | /* Hrm, verification failed, print an error */ |
523 | - E1000_ERR(hw->nic, "EEPROM checksum is incorrect!\n"); | |
524 | - E1000_ERR(hw->nic, " ...register was 0x%04hx, calculated 0x%04hx\n", | |
525 | - checksum_reg, checksum); | |
523 | + E1000_ERR(hw, "EEPROM checksum is incorrect!\n"); | |
524 | + E1000_ERR(hw, " ...register was 0x%04hx, calculated 0x%04hx\n", | |
525 | + checksum_reg, checksum); | |
526 | 526 | |
527 | 527 | /* If they didn't ask us to update it, just return an error */ |
528 | 528 | if (!upd) { |
529 | 529 | |
... | ... | @@ -531,11 +531,11 @@ |
531 | 531 | } |
532 | 532 | |
533 | 533 | /* Ok, correct it! */ |
534 | - printf("%s: Reprogramming the EEPROM checksum...\n", hw->nic->name); | |
534 | + printf("%s: Reprogramming the EEPROM checksum...\n", hw->name); | |
535 | 535 | buffer[i] = cpu_to_le16(checksum); |
536 | 536 | if (e1000_spi_eeprom_program(hw, &buffer[i], i * sizeof(uint16_t), |
537 | 537 | sizeof(uint16_t), true)) { |
538 | - E1000_ERR(hw->nic, "Interrupted!\n"); | |
538 | + E1000_ERR(hw, "Interrupted!\n"); | |
539 | 539 | e1000_release_eeprom(hw); |
540 | 540 | return 1; |
541 | 541 | } |
... | ... | @@ -554,7 +554,8 @@ |
554 | 554 | |
555 | 555 | /* Make sure it has an SPI chip */ |
556 | 556 | if (hw->eeprom.type != e1000_eeprom_spi) { |
557 | - E1000_ERR(hw->nic, "No attached SPI EEPROM found!\n"); | |
557 | + E1000_ERR(hw, "No attached SPI EEPROM found (%d)!\n", | |
558 | + hw->eeprom.type); | |
558 | 559 | return 1; |
559 | 560 | } |
560 | 561 |