diff options
author | Steve Wise <swise@opengridcomputing.com> | 2016-02-18 09:34:24 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-02-19 15:49:31 -0500 |
commit | 1003e19c466dc37812b5f88b2d5308ee63bb3fa0 (patch) | |
tree | 95a017bd4b07638853150e223d6c9dded99d29cf | |
parent | c868ee7063bdb53f3ef9eac7bcec84960980b471 (diff) |
cxgb3: fix up vpd strings for kstrto*()
The vpd strings are left justified, in a fixed length array, with possible
trailing white space and no NUL. So fix them up before calling kstrto*().
This is a recent regression which causes cxgb3 to fail to load.
Fixes: e72c932 ("cxgb3: Convert simple_strtoul to kstrtox")
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c index ee04caa6c4d8..a89721fad633 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | |||
@@ -681,6 +681,24 @@ int t3_seeprom_wp(struct adapter *adapter, int enable) | |||
681 | return t3_seeprom_write(adapter, EEPROM_STAT_ADDR, enable ? 0xc : 0); | 681 | return t3_seeprom_write(adapter, EEPROM_STAT_ADDR, enable ? 0xc : 0); |
682 | } | 682 | } |
683 | 683 | ||
684 | static int vpdstrtouint(char *s, int len, unsigned int base, unsigned int *val) | ||
685 | { | ||
686 | char tok[len + 1]; | ||
687 | |||
688 | memcpy(tok, s, len); | ||
689 | tok[len] = 0; | ||
690 | return kstrtouint(strim(tok), base, val); | ||
691 | } | ||
692 | |||
693 | static int vpdstrtou16(char *s, int len, unsigned int base, u16 *val) | ||
694 | { | ||
695 | char tok[len + 1]; | ||
696 | |||
697 | memcpy(tok, s, len); | ||
698 | tok[len] = 0; | ||
699 | return kstrtou16(strim(tok), base, val); | ||
700 | } | ||
701 | |||
684 | /** | 702 | /** |
685 | * get_vpd_params - read VPD parameters from VPD EEPROM | 703 | * get_vpd_params - read VPD parameters from VPD EEPROM |
686 | * @adapter: adapter to read | 704 | * @adapter: adapter to read |
@@ -709,19 +727,19 @@ static int get_vpd_params(struct adapter *adapter, struct vpd_params *p) | |||
709 | return ret; | 727 | return ret; |
710 | } | 728 | } |
711 | 729 | ||
712 | ret = kstrtouint(vpd.cclk_data, 10, &p->cclk); | 730 | ret = vpdstrtouint(vpd.cclk_data, vpd.cclk_len, 10, &p->cclk); |
713 | if (ret) | 731 | if (ret) |
714 | return ret; | 732 | return ret; |
715 | ret = kstrtouint(vpd.mclk_data, 10, &p->mclk); | 733 | ret = vpdstrtouint(vpd.mclk_data, vpd.mclk_len, 10, &p->mclk); |
716 | if (ret) | 734 | if (ret) |
717 | return ret; | 735 | return ret; |
718 | ret = kstrtouint(vpd.uclk_data, 10, &p->uclk); | 736 | ret = vpdstrtouint(vpd.uclk_data, vpd.uclk_len, 10, &p->uclk); |
719 | if (ret) | 737 | if (ret) |
720 | return ret; | 738 | return ret; |
721 | ret = kstrtouint(vpd.mdc_data, 10, &p->mdc); | 739 | ret = vpdstrtouint(vpd.mdc_data, vpd.mdc_len, 10, &p->mdc); |
722 | if (ret) | 740 | if (ret) |
723 | return ret; | 741 | return ret; |
724 | ret = kstrtouint(vpd.mt_data, 10, &p->mem_timing); | 742 | ret = vpdstrtouint(vpd.mt_data, vpd.mt_len, 10, &p->mem_timing); |
725 | if (ret) | 743 | if (ret) |
726 | return ret; | 744 | return ret; |
727 | memcpy(p->sn, vpd.sn_data, SERNUM_LEN); | 745 | memcpy(p->sn, vpd.sn_data, SERNUM_LEN); |
@@ -733,10 +751,12 @@ static int get_vpd_params(struct adapter *adapter, struct vpd_params *p) | |||
733 | } else { | 751 | } else { |
734 | p->port_type[0] = hex_to_bin(vpd.port0_data[0]); | 752 | p->port_type[0] = hex_to_bin(vpd.port0_data[0]); |
735 | p->port_type[1] = hex_to_bin(vpd.port1_data[0]); | 753 | p->port_type[1] = hex_to_bin(vpd.port1_data[0]); |
736 | ret = kstrtou16(vpd.xaui0cfg_data, 16, &p->xauicfg[0]); | 754 | ret = vpdstrtou16(vpd.xaui0cfg_data, vpd.xaui0cfg_len, 16, |
755 | &p->xauicfg[0]); | ||
737 | if (ret) | 756 | if (ret) |
738 | return ret; | 757 | return ret; |
739 | ret = kstrtou16(vpd.xaui1cfg_data, 16, &p->xauicfg[1]); | 758 | ret = vpdstrtou16(vpd.xaui1cfg_data, vpd.xaui1cfg_len, 16, |
759 | &p->xauicfg[1]); | ||
740 | if (ret) | 760 | if (ret) |
741 | return ret; | 761 | return ret; |
742 | } | 762 | } |