net: dsa: mv88e6xxx: introduce wait bit routine
Many portions of the driver need to wait until a given bit is set or cleared. Some busses even have a specific implementation for this operation. In preparation for such variant, implement a generic Wait Bit routine that can be used by the driver core functions. This allows us to get rid of the custom implementations we may find in the driver. Note that for the EEPROM bits, BUSY and RUNNING bits are independent, thus it is more efficient to wait independently for each bit instead of waiting for their mask. Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
683f2244c5
commit
19fb7f69da
@@ -10,6 +10,7 @@
|
||||
* Vivien Didelot <vivien.didelot@savoirfairelinux.com>
|
||||
*/
|
||||
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/ethtool.h>
|
||||
@@ -103,6 +104,13 @@ int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
|
||||
int bit, int val)
|
||||
{
|
||||
return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
|
||||
val ? BIT(bit) : 0x0000);
|
||||
}
|
||||
|
||||
struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
|
||||
{
|
||||
struct mv88e6xxx_mdio_bus *mdio_bus;
|
||||
@@ -2360,8 +2368,10 @@ static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
|
||||
|
||||
static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
|
||||
{
|
||||
return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
|
||||
PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
|
||||
int bit = __bf_shf(PORT_RESERVED_1A_BUSY);
|
||||
|
||||
return mv88e6xxx_wait_bit(chip, PORT_RESERVED_1A_CTRL_PORT,
|
||||
PORT_RESERVED_1A, bit, 0);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user