mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 13:14:07 +08:00
Merge branch 'sfp-eeprom'
Ivan Bornyakov says: ==================== net: fix EEPROM read of absent SFP module The patchset is to improve EEPROM read requests when SFP module is absent. ChangeLog: v1: https://lore.kernel.org/netdev/20230405153900.747-1-i.bornyakov@metrotek.ru/ v2: * reword commit message of "net: sfp: initialize sfp->i2c_block_size at sfp allocation" * add second patch to eliminate excessive I2C transfers in sfp_module_eeprom() and sfp_module_eeprom_by_page() ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
9a06fe08ae
@ -210,6 +210,12 @@ static const enum gpiod_flags gpio_flags[] = {
|
||||
#define SFP_PHY_ADDR 22
|
||||
#define SFP_PHY_ADDR_ROLLBALL 17
|
||||
|
||||
/* SFP_EEPROM_BLOCK_SIZE is the size of data chunk to read the EEPROM
|
||||
* at a time. Some SFP modules and also some Linux I2C drivers do not like
|
||||
* reads longer than 16 bytes.
|
||||
*/
|
||||
#define SFP_EEPROM_BLOCK_SIZE 16
|
||||
|
||||
struct sff_data {
|
||||
unsigned int gpios;
|
||||
bool (*module_supported)(const struct sfp_eeprom_id *id);
|
||||
@ -1929,11 +1935,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
|
||||
u8 check;
|
||||
int ret;
|
||||
|
||||
/* Some SFP modules and also some Linux I2C drivers do not like reads
|
||||
* longer than 16 bytes, so read the EEPROM in chunks of 16 bytes at
|
||||
* a time.
|
||||
*/
|
||||
sfp->i2c_block_size = 16;
|
||||
sfp->i2c_block_size = SFP_EEPROM_BLOCK_SIZE;
|
||||
|
||||
ret = sfp_read(sfp, false, 0, &id.base, sizeof(id.base));
|
||||
if (ret < 0) {
|
||||
@ -2485,6 +2487,9 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee,
|
||||
unsigned int first, last, len;
|
||||
int ret;
|
||||
|
||||
if (!(sfp->state & SFP_F_PRESENT))
|
||||
return -ENODEV;
|
||||
|
||||
if (ee->len == 0)
|
||||
return -EINVAL;
|
||||
|
||||
@ -2517,6 +2522,9 @@ static int sfp_module_eeprom_by_page(struct sfp *sfp,
|
||||
const struct ethtool_module_eeprom *page,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (!(sfp->state & SFP_F_PRESENT))
|
||||
return -ENODEV;
|
||||
|
||||
if (page->bank) {
|
||||
NL_SET_ERR_MSG(extack, "Banks not supported");
|
||||
return -EOPNOTSUPP;
|
||||
@ -2621,6 +2629,7 @@ static struct sfp *sfp_alloc(struct device *dev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
sfp->dev = dev;
|
||||
sfp->i2c_block_size = SFP_EEPROM_BLOCK_SIZE;
|
||||
|
||||
mutex_init(&sfp->sm_mutex);
|
||||
mutex_init(&sfp->st_mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user