|
18 | 18 | #define EEPROM_MAC_OFFSET (0x01)
|
19 | 19 | #define MAX_EEPROM_SIZE (512)
|
20 | 20 | #define MAX_OTP_SIZE (1024)
|
| 21 | +#define MAX_HS_OTP_SIZE (8 * 1024) |
| 22 | +#define MAX_HS_EEPROM_SIZE (64 * 1024) |
21 | 23 | #define OTP_INDICATOR_1 (0xF3)
|
22 | 24 | #define OTP_INDICATOR_2 (0xF7)
|
23 | 25 |
|
@@ -272,6 +274,9 @@ static int lan743x_hs_otp_read(struct lan743x_adapter *adapter, u32 offset,
|
272 | 274 | int ret;
|
273 | 275 | int i;
|
274 | 276 |
|
| 277 | + if (offset + length > MAX_HS_OTP_SIZE) |
| 278 | + return -EINVAL; |
| 279 | + |
275 | 280 | ret = lan743x_hs_syslock_acquire(adapter, LOCK_TIMEOUT_MAX_CNT);
|
276 | 281 | if (ret < 0)
|
277 | 282 | return ret;
|
@@ -320,6 +325,9 @@ static int lan743x_hs_otp_write(struct lan743x_adapter *adapter, u32 offset,
|
320 | 325 | int ret;
|
321 | 326 | int i;
|
322 | 327 |
|
| 328 | + if (offset + length > MAX_HS_OTP_SIZE) |
| 329 | + return -EINVAL; |
| 330 | + |
323 | 331 | ret = lan743x_hs_syslock_acquire(adapter, LOCK_TIMEOUT_MAX_CNT);
|
324 | 332 | if (ret < 0)
|
325 | 333 | return ret;
|
@@ -497,6 +505,9 @@ static int lan743x_hs_eeprom_read(struct lan743x_adapter *adapter,
|
497 | 505 | u32 val;
|
498 | 506 | int i;
|
499 | 507 |
|
| 508 | + if (offset + length > MAX_HS_EEPROM_SIZE) |
| 509 | + return -EINVAL; |
| 510 | + |
500 | 511 | retval = lan743x_hs_syslock_acquire(adapter, LOCK_TIMEOUT_MAX_CNT);
|
501 | 512 | if (retval < 0)
|
502 | 513 | return retval;
|
@@ -539,6 +550,9 @@ static int lan743x_hs_eeprom_write(struct lan743x_adapter *adapter,
|
539 | 550 | u32 val;
|
540 | 551 | int i;
|
541 | 552 |
|
| 553 | + if (offset + length > MAX_HS_EEPROM_SIZE) |
| 554 | + return -EINVAL; |
| 555 | + |
542 | 556 | retval = lan743x_hs_syslock_acquire(adapter, LOCK_TIMEOUT_MAX_CNT);
|
543 | 557 | if (retval < 0)
|
544 | 558 | return retval;
|
@@ -604,9 +618,9 @@ static int lan743x_ethtool_get_eeprom_len(struct net_device *netdev)
|
604 | 618 | struct lan743x_adapter *adapter = netdev_priv(netdev);
|
605 | 619 |
|
606 | 620 | if (adapter->flags & LAN743X_ADAPTER_FLAG_OTP)
|
607 |
| - return MAX_OTP_SIZE; |
| 621 | + return adapter->is_pci11x1x ? MAX_HS_OTP_SIZE : MAX_OTP_SIZE; |
608 | 622 |
|
609 |
| - return MAX_EEPROM_SIZE; |
| 623 | + return adapter->is_pci11x1x ? MAX_HS_EEPROM_SIZE : MAX_EEPROM_SIZE; |
610 | 624 | }
|
611 | 625 |
|
612 | 626 | static int lan743x_ethtool_get_eeprom(struct net_device *netdev,
|
|
0 commit comments