Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/usb/r8152: adjust relative ocp function

- fix the conversion between cpu and __le32
- replace some pla_ocp and usb_ocp functions with generic_ocp function

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

hayeswang and committed by
David S. Miller
c8826de8 31787f53

+23 -43
+23 -43
drivers/net/usb/r8152.c
··· 514 514 515 515 static u32 ocp_read_dword(struct r8152 *tp, u16 type, u16 index) 516 516 { 517 - u32 data; 517 + __le32 data; 518 518 519 - if (type == MCU_TYPE_PLA) 520 - pla_ocp_read(tp, index, sizeof(data), &data); 521 - else 522 - usb_ocp_read(tp, index, sizeof(data), &data); 519 + generic_ocp_read(tp, index, sizeof(data), &data, type); 523 520 524 521 return __le32_to_cpu(data); 525 522 } 526 523 527 524 static void ocp_write_dword(struct r8152 *tp, u16 type, u16 index, u32 data) 528 525 { 529 - if (type == MCU_TYPE_PLA) 530 - pla_ocp_write(tp, index, BYTE_EN_DWORD, sizeof(data), &data); 531 - else 532 - usb_ocp_write(tp, index, BYTE_EN_DWORD, sizeof(data), &data); 526 + __le32 tmp = __cpu_to_le32(data); 527 + 528 + generic_ocp_write(tp, index, BYTE_EN_DWORD, sizeof(tmp), &tmp, type); 533 529 } 534 530 535 531 static u16 ocp_read_word(struct r8152 *tp, u16 type, u16 index) 536 532 { 537 533 u32 data; 534 + __le32 tmp; 538 535 u8 shift = index & 2; 539 536 540 537 index &= ~3; 541 538 542 - if (type == MCU_TYPE_PLA) 543 - pla_ocp_read(tp, index, sizeof(data), &data); 544 - else 545 - usb_ocp_read(tp, index, sizeof(data), &data); 539 + generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); 546 540 547 - data = __le32_to_cpu(data); 541 + data = __le32_to_cpu(tmp); 548 542 data >>= (shift * 8); 549 543 data &= 0xffff; 550 544 ··· 547 553 548 554 static void ocp_write_word(struct r8152 *tp, u16 type, u16 index, u32 data) 549 555 { 550 - u32 tmp, mask = 0xffff; 556 + u32 mask = 0xffff; 557 + __le32 tmp; 551 558 u16 byen = BYTE_EN_WORD; 552 559 u8 shift = index & 2; 553 560 ··· 561 566 index &= ~3; 562 567 } 563 568 564 - if (type == MCU_TYPE_PLA) 565 - pla_ocp_read(tp, index, sizeof(tmp), &tmp); 566 - else 567 - usb_ocp_read(tp, index, sizeof(tmp), &tmp); 569 + generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); 568 570 569 - tmp = __le32_to_cpu(tmp) & ~mask; 570 - tmp |= data; 571 - tmp = __cpu_to_le32(tmp); 571 + data |= __le32_to_cpu(tmp) & ~mask; 572 + tmp = __cpu_to_le32(data); 572 573 573 - if (type == MCU_TYPE_PLA) 574 - pla_ocp_write(tp, index, byen, sizeof(tmp), &tmp); 575 - else 576 - usb_ocp_write(tp, index, byen, sizeof(tmp), &tmp); 574 + generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); 577 575 } 578 576 579 577 static u8 ocp_read_byte(struct r8152 *tp, u16 type, u16 index) 580 578 { 581 579 u32 data; 580 + __le32 tmp; 582 581 u8 shift = index & 3; 583 582 584 583 index &= ~3; 585 584 586 - if (type == MCU_TYPE_PLA) 587 - pla_ocp_read(tp, index, sizeof(data), &data); 588 - else 589 - usb_ocp_read(tp, index, sizeof(data), &data); 585 + generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); 590 586 591 - data = __le32_to_cpu(data); 587 + data = __le32_to_cpu(tmp); 592 588 data >>= (shift * 8); 593 589 data &= 0xff; 594 590 ··· 588 602 589 603 static void ocp_write_byte(struct r8152 *tp, u16 type, u16 index, u32 data) 590 604 { 591 - u32 tmp, mask = 0xff; 605 + u32 mask = 0xff; 606 + __le32 tmp; 592 607 u16 byen = BYTE_EN_BYTE; 593 608 u8 shift = index & 3; 594 609 ··· 602 615 index &= ~3; 603 616 } 604 617 605 - if (type == MCU_TYPE_PLA) 606 - pla_ocp_read(tp, index, sizeof(tmp), &tmp); 607 - else 608 - usb_ocp_read(tp, index, sizeof(tmp), &tmp); 618 + generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); 609 619 610 - tmp = __le32_to_cpu(tmp) & ~mask; 611 - tmp |= data; 612 - tmp = __cpu_to_le32(tmp); 620 + data |= __le32_to_cpu(tmp) & ~mask; 621 + tmp = __cpu_to_le32(data); 613 622 614 - if (type == MCU_TYPE_PLA) 615 - pla_ocp_write(tp, index, byen, sizeof(tmp), &tmp); 616 - else 617 - usb_ocp_write(tp, index, byen, sizeof(tmp), &tmp); 623 + generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); 618 624 } 619 625 620 626 static void r8152_mdio_write(struct r8152 *tp, u32 reg_addr, u32 value)