lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjD6Hdjz78aZL/Wz@lunn.ch>
Date:   Tue, 15 Mar 2022 21:42:05 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     Raju Lakkaraju <Raju.Lakkaraju@...rochip.com>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
        UNGLinuxDriver@...rochip.com, Ian.Saturley@...rochip.com
Subject: Re: [PATCH net-next 2/5] net: lan743x: Add support for EEPROM

> +static int lan743x_hs_syslock_acquire(struct lan743x_adapter *adapter,
> +				      u16 timeout)
> +{
> +	u16 timeout_cnt = 0;
> +	u32 val;
> +
> +	do {
> +		spin_lock(&adapter->eth_syslock_spinlock);
> +		if (adapter->eth_syslock_acquire_cnt == 0) {
> +			lan743x_csr_write(adapter, ETH_SYSTEM_SYS_LOCK_REG,
> +					  SYS_LOCK_REG_ENET_SS_LOCK_);
> +			val = lan743x_csr_read(adapter, ETH_SYSTEM_SYS_LOCK_REG);
> +			if (val & SYS_LOCK_REG_ENET_SS_LOCK_) {
> +				adapter->eth_syslock_acquire_cnt++;
> +				WARN_ON(adapter->eth_syslock_acquire_cnt == 0);
> +				spin_unlock(&adapter->eth_syslock_spinlock);
> +				break;
> +			}
> +		} else {
> +			adapter->eth_syslock_acquire_cnt++;
> +			WARN_ON(adapter->eth_syslock_acquire_cnt == 0);
> +			spin_unlock(&adapter->eth_syslock_spinlock);
> +			break;
> +		}
> +
> +		spin_unlock(&adapter->eth_syslock_spinlock);
> +
> +		if (timeout_cnt++ < timeout)
> +			usleep_range(10000, 11000);
> +		else
> +			return -EINVAL;

ETIMEDOUT should be used for a timeout.

> +static int lan743x_hs_eeprom_cmd_cmplt_chk(struct lan743x_adapter *adapter)
> +{
> +	unsigned long start_time = jiffies;
> +	u32 val;
> +
> +	do {
> +		val = lan743x_csr_read(adapter, HS_E2P_CMD);
> +		if (!(val & HS_E2P_CMD_EPC_BUSY_) ||
> +		    (val & HS_E2P_CMD_EPC_TIMEOUT_))
> +			break;
> +
> +		usleep_range(50, 60);
> +	} while (!time_after(jiffies, start_time + HZ));
> +
> +	if (val & (HS_E2P_CMD_EPC_TIMEOUT_ | HS_E2P_CMD_EPC_BUSY_)) {
> +		netif_warn(adapter, drv, adapter->netdev,
> +			   "HS EEPROM operation timeout/busy\n");
> +		return -ETIMEDOUT;
> +	}

It looks like iopoll.h should be used here.

> +static int lan743x_hs_eeprom_write(struct lan743x_adapter *adapter,
> +				   u32 offset, u32 length, u8 *data)
> +{
> +	int retval;
> +	u32 val;
> +	int i;
> +
> +	if (offset + length > MAX_EEPROM_SIZE)
> +		return -EINVAL;

The core should of already checked this. Look at net/ethtool/ioctl.c

    Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ