Commit 193c5b26 authored by Pavana Sharma's avatar Pavana Sharma Committed by David S. Miller

net: dsa: mv88e6xxx: change serdes lane parameter type from u8 type to int

Returning 0 is no more an error case with MV88E6393 family
which has serdes lane numbers 0, 9 or 10.
So with this change .serdes_get_lane will return lane number
or -errno (-ENODEV or -EOPNOTSUPP).
Signed-off-by: default avatarPavana Sharma <pavana.sharma@digi.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac1bbf8a
...@@ -485,12 +485,12 @@ static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port, ...@@ -485,12 +485,12 @@ static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
struct phylink_link_state *state) struct phylink_link_state *state)
{ {
struct mv88e6xxx_chip *chip = ds->priv; struct mv88e6xxx_chip *chip = ds->priv;
u8 lane; int lane;
int err; int err;
mv88e6xxx_reg_lock(chip); mv88e6xxx_reg_lock(chip);
lane = mv88e6xxx_serdes_get_lane(chip, port); lane = mv88e6xxx_serdes_get_lane(chip, port);
if (lane && chip->info->ops->serdes_pcs_get_state) if (lane >= 0 && chip->info->ops->serdes_pcs_get_state)
err = chip->info->ops->serdes_pcs_get_state(chip, port, lane, err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
state); state);
else else
...@@ -506,11 +506,11 @@ static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, ...@@ -506,11 +506,11 @@ static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
const unsigned long *advertise) const unsigned long *advertise)
{ {
const struct mv88e6xxx_ops *ops = chip->info->ops; const struct mv88e6xxx_ops *ops = chip->info->ops;
u8 lane; int lane;
if (ops->serdes_pcs_config) { if (ops->serdes_pcs_config) {
lane = mv88e6xxx_serdes_get_lane(chip, port); lane = mv88e6xxx_serdes_get_lane(chip, port);
if (lane) if (lane >= 0)
return ops->serdes_pcs_config(chip, port, lane, mode, return ops->serdes_pcs_config(chip, port, lane, mode,
interface, advertise); interface, advertise);
} }
...@@ -523,14 +523,14 @@ static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port) ...@@ -523,14 +523,14 @@ static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
struct mv88e6xxx_chip *chip = ds->priv; struct mv88e6xxx_chip *chip = ds->priv;
const struct mv88e6xxx_ops *ops; const struct mv88e6xxx_ops *ops;
int err = 0; int err = 0;
u8 lane; int lane;
ops = chip->info->ops; ops = chip->info->ops;
if (ops->serdes_pcs_an_restart) { if (ops->serdes_pcs_an_restart) {
mv88e6xxx_reg_lock(chip); mv88e6xxx_reg_lock(chip);
lane = mv88e6xxx_serdes_get_lane(chip, port); lane = mv88e6xxx_serdes_get_lane(chip, port);
if (lane) if (lane >= 0)
err = ops->serdes_pcs_an_restart(chip, port, lane); err = ops->serdes_pcs_an_restart(chip, port, lane);
mv88e6xxx_reg_unlock(chip); mv88e6xxx_reg_unlock(chip);
...@@ -544,11 +544,11 @@ static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port, ...@@ -544,11 +544,11 @@ static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
int speed, int duplex) int speed, int duplex)
{ {
const struct mv88e6xxx_ops *ops = chip->info->ops; const struct mv88e6xxx_ops *ops = chip->info->ops;
u8 lane; int lane;
if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) { if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
lane = mv88e6xxx_serdes_get_lane(chip, port); lane = mv88e6xxx_serdes_get_lane(chip, port);
if (lane) if (lane >= 0)
return ops->serdes_pcs_link_up(chip, port, lane, return ops->serdes_pcs_link_up(chip, port, lane,
speed, duplex); speed, duplex);
} }
...@@ -2460,11 +2460,11 @@ static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id) ...@@ -2460,11 +2460,11 @@ static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
struct mv88e6xxx_chip *chip = mvp->chip; struct mv88e6xxx_chip *chip = mvp->chip;
irqreturn_t ret = IRQ_NONE; irqreturn_t ret = IRQ_NONE;
int port = mvp->port; int port = mvp->port;
u8 lane; int lane;
mv88e6xxx_reg_lock(chip); mv88e6xxx_reg_lock(chip);
lane = mv88e6xxx_serdes_get_lane(chip, port); lane = mv88e6xxx_serdes_get_lane(chip, port);
if (lane) if (lane >= 0)
ret = mv88e6xxx_serdes_irq_status(chip, port, lane); ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
mv88e6xxx_reg_unlock(chip); mv88e6xxx_reg_unlock(chip);
...@@ -2472,7 +2472,7 @@ static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id) ...@@ -2472,7 +2472,7 @@ static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
} }
static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port, static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
u8 lane) int lane)
{ {
struct mv88e6xxx_port *dev_id = &chip->ports[port]; struct mv88e6xxx_port *dev_id = &chip->ports[port];
unsigned int irq; unsigned int irq;
...@@ -2501,7 +2501,7 @@ static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port, ...@@ -2501,7 +2501,7 @@ static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
} }
static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port, static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
u8 lane) int lane)
{ {
struct mv88e6xxx_port *dev_id = &chip->ports[port]; struct mv88e6xxx_port *dev_id = &chip->ports[port];
unsigned int irq = dev_id->serdes_irq; unsigned int irq = dev_id->serdes_irq;
...@@ -2526,11 +2526,11 @@ static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port, ...@@ -2526,11 +2526,11 @@ static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
bool on) bool on)
{ {
u8 lane; int lane;
int err; int err;
lane = mv88e6xxx_serdes_get_lane(chip, port); lane = mv88e6xxx_serdes_get_lane(chip, port);
if (!lane) if (lane < 0)
return 0; return 0;
if (on) { if (on) {
......
...@@ -513,30 +513,30 @@ struct mv88e6xxx_ops { ...@@ -513,30 +513,30 @@ struct mv88e6xxx_ops {
int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip); int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip);
/* Power on/off a SERDES interface */ /* Power on/off a SERDES interface */
int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, u8 lane, int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, int lane,
bool up); bool up);
/* SERDES lane mapping */ /* SERDES lane mapping */
u8 (*serdes_get_lane)(struct mv88e6xxx_chip *chip, int port); int (*serdes_get_lane)(struct mv88e6xxx_chip *chip, int port);
int (*serdes_pcs_get_state)(struct mv88e6xxx_chip *chip, int port, int (*serdes_pcs_get_state)(struct mv88e6xxx_chip *chip, int port,
u8 lane, struct phylink_link_state *state); int lane, struct phylink_link_state *state);
int (*serdes_pcs_config)(struct mv88e6xxx_chip *chip, int port, int (*serdes_pcs_config)(struct mv88e6xxx_chip *chip, int port,
u8 lane, unsigned int mode, int lane, unsigned int mode,
phy_interface_t interface, phy_interface_t interface,
const unsigned long *advertise); const unsigned long *advertise);
int (*serdes_pcs_an_restart)(struct mv88e6xxx_chip *chip, int port, int (*serdes_pcs_an_restart)(struct mv88e6xxx_chip *chip, int port,
u8 lane); int lane);
int (*serdes_pcs_link_up)(struct mv88e6xxx_chip *chip, int port, int (*serdes_pcs_link_up)(struct mv88e6xxx_chip *chip, int port,
u8 lane, int speed, int duplex); int lane, int speed, int duplex);
/* SERDES interrupt handling */ /* SERDES interrupt handling */
unsigned int (*serdes_irq_mapping)(struct mv88e6xxx_chip *chip, unsigned int (*serdes_irq_mapping)(struct mv88e6xxx_chip *chip,
int port); int port);
int (*serdes_irq_enable)(struct mv88e6xxx_chip *chip, int port, u8 lane, int (*serdes_irq_enable)(struct mv88e6xxx_chip *chip, int port, int lane,
bool enable); bool enable);
irqreturn_t (*serdes_irq_status)(struct mv88e6xxx_chip *chip, int port, irqreturn_t (*serdes_irq_status)(struct mv88e6xxx_chip *chip, int port,
u8 lane); int lane);
/* Statistics from the SERDES interface */ /* Statistics from the SERDES interface */
int (*serdes_get_sset_count)(struct mv88e6xxx_chip *chip, int port); int (*serdes_get_sset_count)(struct mv88e6xxx_chip *chip, int port);
......
...@@ -429,8 +429,8 @@ phy_interface_t mv88e6390x_port_max_speed_mode(int port) ...@@ -429,8 +429,8 @@ phy_interface_t mv88e6390x_port_max_speed_mode(int port)
static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port, static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
phy_interface_t mode, bool force) phy_interface_t mode, bool force)
{ {
u8 lane;
u16 cmode; u16 cmode;
int lane;
u16 reg; u16 reg;
int err; int err;
...@@ -466,7 +466,7 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port, ...@@ -466,7 +466,7 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
return 0; return 0;
lane = mv88e6xxx_serdes_get_lane(chip, port); lane = mv88e6xxx_serdes_get_lane(chip, port);
if (lane) { if (lane >= 0) {
if (chip->ports[port].serdes_irq) { if (chip->ports[port].serdes_irq) {
err = mv88e6xxx_serdes_irq_disable(chip, port, lane); err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
if (err) if (err)
...@@ -495,8 +495,8 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port, ...@@ -495,8 +495,8 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
chip->ports[port].cmode = cmode; chip->ports[port].cmode = cmode;
lane = mv88e6xxx_serdes_get_lane(chip, port); lane = mv88e6xxx_serdes_get_lane(chip, port);
if (!lane) if (lane < 0)
return -ENODEV; return lane;
err = mv88e6xxx_serdes_power_up(chip, port, lane); err = mv88e6xxx_serdes_power_up(chip, port, lane);
if (err) if (err)
......
This diff is collapsed.
...@@ -73,55 +73,55 @@ ...@@ -73,55 +73,55 @@
#define MV88E6390_PG_CONTROL 0xf010 #define MV88E6390_PG_CONTROL 0xf010
#define MV88E6390_PG_CONTROL_ENABLE_PC BIT(0) #define MV88E6390_PG_CONTROL_ENABLE_PC BIT(0)
u8 mv88e6185_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6185_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
u8 mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
u8 mv88e6352_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6352_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
u8 mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
u8 mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6352_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, int mv88e6352_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
u8 lane, unsigned int mode, int lane, unsigned int mode,
phy_interface_t interface, phy_interface_t interface,
const unsigned long *advertise); const unsigned long *advertise);
int mv88e6390_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, int mv88e6390_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
u8 lane, unsigned int mode, int lane, unsigned int mode,
phy_interface_t interface, phy_interface_t interface,
const unsigned long *advertise); const unsigned long *advertise);
int mv88e6185_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, int port, int mv88e6185_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, int port,
u8 lane, struct phylink_link_state *state); int lane, struct phylink_link_state *state);
int mv88e6352_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, int port, int mv88e6352_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, int port,
u8 lane, struct phylink_link_state *state); int lane, struct phylink_link_state *state);
int mv88e6390_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, int port, int mv88e6390_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, int port,
u8 lane, struct phylink_link_state *state); int lane, struct phylink_link_state *state);
int mv88e6352_serdes_pcs_an_restart(struct mv88e6xxx_chip *chip, int port, int mv88e6352_serdes_pcs_an_restart(struct mv88e6xxx_chip *chip, int port,
u8 lane); int lane);
int mv88e6390_serdes_pcs_an_restart(struct mv88e6xxx_chip *chip, int port, int mv88e6390_serdes_pcs_an_restart(struct mv88e6xxx_chip *chip, int port,
u8 lane); int lane);
int mv88e6352_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port, int mv88e6352_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
u8 lane, int speed, int duplex); int lane, int speed, int duplex);
int mv88e6390_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port, int mv88e6390_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
u8 lane, int speed, int duplex); int lane, int speed, int duplex);
unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip, unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip,
int port); int port);
unsigned int mv88e6390_serdes_irq_mapping(struct mv88e6xxx_chip *chip, unsigned int mv88e6390_serdes_irq_mapping(struct mv88e6xxx_chip *chip,
int port); int port);
int mv88e6185_serdes_power(struct mv88e6xxx_chip *chip, int port, u8 lane, int mv88e6185_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
bool up); bool up);
int mv88e6352_serdes_power(struct mv88e6xxx_chip *chip, int port, u8 lane, int mv88e6352_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
bool on); bool on);
int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, u8 lane, int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
bool on); bool on);
int mv88e6097_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, u8 lane, int mv88e6097_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, int lane,
bool enable); bool enable);
int mv88e6352_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, u8 lane, int mv88e6352_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, int lane,
bool enable); bool enable);
int mv88e6390_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, u8 lane, int mv88e6390_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, int lane,
bool enable); bool enable);
irqreturn_t mv88e6097_serdes_irq_status(struct mv88e6xxx_chip *chip, int port, irqreturn_t mv88e6097_serdes_irq_status(struct mv88e6xxx_chip *chip, int port,
u8 lane); int lane);
irqreturn_t mv88e6352_serdes_irq_status(struct mv88e6xxx_chip *chip, int port, irqreturn_t mv88e6352_serdes_irq_status(struct mv88e6xxx_chip *chip, int port,
u8 lane); int lane);
irqreturn_t mv88e6390_serdes_irq_status(struct mv88e6xxx_chip *chip, int port, irqreturn_t mv88e6390_serdes_irq_status(struct mv88e6xxx_chip *chip, int port,
u8 lane); int lane);
int mv88e6352_serdes_get_sset_count(struct mv88e6xxx_chip *chip, int port); int mv88e6352_serdes_get_sset_count(struct mv88e6xxx_chip *chip, int port);
int mv88e6352_serdes_get_strings(struct mv88e6xxx_chip *chip, int mv88e6352_serdes_get_strings(struct mv88e6xxx_chip *chip,
int port, uint8_t *data); int port, uint8_t *data);
...@@ -138,18 +138,18 @@ void mv88e6352_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p); ...@@ -138,18 +138,18 @@ void mv88e6352_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p);
int mv88e6390_serdes_get_regs_len(struct mv88e6xxx_chip *chip, int port); int mv88e6390_serdes_get_regs_len(struct mv88e6xxx_chip *chip, int port);
void mv88e6390_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p); void mv88e6390_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p);
/* Return the (first) SERDES lane address a port is using, 0 otherwise. */ /* Return the (first) SERDES lane address a port is using, -errno otherwise. */
static inline u8 mv88e6xxx_serdes_get_lane(struct mv88e6xxx_chip *chip, static inline int mv88e6xxx_serdes_get_lane(struct mv88e6xxx_chip *chip,
int port) int port)
{ {
if (!chip->info->ops->serdes_get_lane) if (!chip->info->ops->serdes_get_lane)
return 0; return -EOPNOTSUPP;
return chip->info->ops->serdes_get_lane(chip, port); return chip->info->ops->serdes_get_lane(chip, port);
} }
static inline int mv88e6xxx_serdes_power_up(struct mv88e6xxx_chip *chip, static inline int mv88e6xxx_serdes_power_up(struct mv88e6xxx_chip *chip,
int port, u8 lane) int port, int lane)
{ {
if (!chip->info->ops->serdes_power) if (!chip->info->ops->serdes_power)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -158,7 +158,7 @@ static inline int mv88e6xxx_serdes_power_up(struct mv88e6xxx_chip *chip, ...@@ -158,7 +158,7 @@ static inline int mv88e6xxx_serdes_power_up(struct mv88e6xxx_chip *chip,
} }
static inline int mv88e6xxx_serdes_power_down(struct mv88e6xxx_chip *chip, static inline int mv88e6xxx_serdes_power_down(struct mv88e6xxx_chip *chip,
int port, u8 lane) int port, int lane)
{ {
if (!chip->info->ops->serdes_power) if (!chip->info->ops->serdes_power)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -176,7 +176,7 @@ mv88e6xxx_serdes_irq_mapping(struct mv88e6xxx_chip *chip, int port) ...@@ -176,7 +176,7 @@ mv88e6xxx_serdes_irq_mapping(struct mv88e6xxx_chip *chip, int port)
} }
static inline int mv88e6xxx_serdes_irq_enable(struct mv88e6xxx_chip *chip, static inline int mv88e6xxx_serdes_irq_enable(struct mv88e6xxx_chip *chip,
int port, u8 lane) int port, int lane)
{ {
if (!chip->info->ops->serdes_irq_enable) if (!chip->info->ops->serdes_irq_enable)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -185,7 +185,7 @@ static inline int mv88e6xxx_serdes_irq_enable(struct mv88e6xxx_chip *chip, ...@@ -185,7 +185,7 @@ static inline int mv88e6xxx_serdes_irq_enable(struct mv88e6xxx_chip *chip,
} }
static inline int mv88e6xxx_serdes_irq_disable(struct mv88e6xxx_chip *chip, static inline int mv88e6xxx_serdes_irq_disable(struct mv88e6xxx_chip *chip,
int port, u8 lane) int port, int lane)
{ {
if (!chip->info->ops->serdes_irq_enable) if (!chip->info->ops->serdes_irq_enable)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -194,7 +194,7 @@ static inline int mv88e6xxx_serdes_irq_disable(struct mv88e6xxx_chip *chip, ...@@ -194,7 +194,7 @@ static inline int mv88e6xxx_serdes_irq_disable(struct mv88e6xxx_chip *chip,
} }
static inline irqreturn_t static inline irqreturn_t
mv88e6xxx_serdes_irq_status(struct mv88e6xxx_chip *chip, int port, u8 lane) mv88e6xxx_serdes_irq_status(struct mv88e6xxx_chip *chip, int port, int lane)
{ {
if (!chip->info->ops->serdes_irq_status) if (!chip->info->ops->serdes_irq_status)
return IRQ_NONE; return IRQ_NONE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment