Loading drivers/net/can/c_can/c_can.c +16 −44 Original line number Original line Diff line number Diff line Loading @@ -261,61 +261,33 @@ static void c_can_irq_control(struct c_can_priv *priv, bool enable) priv->write_reg(priv, C_CAN_CTRL_REG, ctrl); priv->write_reg(priv, C_CAN_CTRL_REG, ctrl); } } static inline int c_can_msg_obj_is_busy(struct c_can_priv *priv, int iface) static void c_can_obj_update(struct net_device *dev, int iface, u32 cmd, u32 obj) { { int count = MIN_TIMEOUT_VALUE; struct c_can_priv *priv = netdev_priv(dev); int cnt, reg = C_CAN_IFACE(COMREQ_REG, iface); priv->write_reg(priv, reg + 1, cmd); priv->write_reg(priv, reg, obj); while (count && priv->read_reg(priv, for (cnt = MIN_TIMEOUT_VALUE; cnt; cnt--) { C_CAN_IFACE(COMREQ_REG, iface)) & if (!(priv->read_reg(priv, reg) & IF_COMR_BUSY)) IF_COMR_BUSY) { return; count--; udelay(1); udelay(1); } } netdev_err(dev, "Updating object timed out\n"); if (!count) return 1; return 0; } } static inline void c_can_object_get(struct net_device *dev, static inline void c_can_object_get(struct net_device *dev, int iface, int iface, int objno, int mask) u32 obj, u32 cmd) { { struct c_can_priv *priv = netdev_priv(dev); c_can_obj_update(dev, iface, cmd, obj); /* * As per specs, after writting the message object number in the * IF command request register the transfer b/w interface * register and message RAM must be complete in 6 CAN-CLK * period. */ priv->write_reg(priv, C_CAN_IFACE(COMMSK_REG, iface), IFX_WRITE_LOW_16BIT(mask)); priv->write_reg(priv, C_CAN_IFACE(COMREQ_REG, iface), IFX_WRITE_LOW_16BIT(objno)); if (c_can_msg_obj_is_busy(priv, iface)) netdev_err(dev, "timed out in object get\n"); } } static inline void c_can_object_put(struct net_device *dev, static inline void c_can_object_put(struct net_device *dev, int iface, int iface, int objno, int mask) u32 obj, u32 cmd) { { struct c_can_priv *priv = netdev_priv(dev); c_can_obj_update(dev, iface, cmd | IF_COMM_WR, obj); /* * As per specs, after writting the message object number in the * IF command request register the transfer b/w interface * register and message RAM must be complete in 6 CAN-CLK * period. */ priv->write_reg(priv, C_CAN_IFACE(COMMSK_REG, iface), (IF_COMM_WR | IFX_WRITE_LOW_16BIT(mask))); priv->write_reg(priv, C_CAN_IFACE(COMREQ_REG, iface), IFX_WRITE_LOW_16BIT(objno)); if (c_can_msg_obj_is_busy(priv, iface)) netdev_err(dev, "timed out in object put\n"); } } static void c_can_write_msg_object(struct net_device *dev, static void c_can_write_msg_object(struct net_device *dev, Loading Loading
drivers/net/can/c_can/c_can.c +16 −44 Original line number Original line Diff line number Diff line Loading @@ -261,61 +261,33 @@ static void c_can_irq_control(struct c_can_priv *priv, bool enable) priv->write_reg(priv, C_CAN_CTRL_REG, ctrl); priv->write_reg(priv, C_CAN_CTRL_REG, ctrl); } } static inline int c_can_msg_obj_is_busy(struct c_can_priv *priv, int iface) static void c_can_obj_update(struct net_device *dev, int iface, u32 cmd, u32 obj) { { int count = MIN_TIMEOUT_VALUE; struct c_can_priv *priv = netdev_priv(dev); int cnt, reg = C_CAN_IFACE(COMREQ_REG, iface); priv->write_reg(priv, reg + 1, cmd); priv->write_reg(priv, reg, obj); while (count && priv->read_reg(priv, for (cnt = MIN_TIMEOUT_VALUE; cnt; cnt--) { C_CAN_IFACE(COMREQ_REG, iface)) & if (!(priv->read_reg(priv, reg) & IF_COMR_BUSY)) IF_COMR_BUSY) { return; count--; udelay(1); udelay(1); } } netdev_err(dev, "Updating object timed out\n"); if (!count) return 1; return 0; } } static inline void c_can_object_get(struct net_device *dev, static inline void c_can_object_get(struct net_device *dev, int iface, int iface, int objno, int mask) u32 obj, u32 cmd) { { struct c_can_priv *priv = netdev_priv(dev); c_can_obj_update(dev, iface, cmd, obj); /* * As per specs, after writting the message object number in the * IF command request register the transfer b/w interface * register and message RAM must be complete in 6 CAN-CLK * period. */ priv->write_reg(priv, C_CAN_IFACE(COMMSK_REG, iface), IFX_WRITE_LOW_16BIT(mask)); priv->write_reg(priv, C_CAN_IFACE(COMREQ_REG, iface), IFX_WRITE_LOW_16BIT(objno)); if (c_can_msg_obj_is_busy(priv, iface)) netdev_err(dev, "timed out in object get\n"); } } static inline void c_can_object_put(struct net_device *dev, static inline void c_can_object_put(struct net_device *dev, int iface, int iface, int objno, int mask) u32 obj, u32 cmd) { { struct c_can_priv *priv = netdev_priv(dev); c_can_obj_update(dev, iface, cmd | IF_COMM_WR, obj); /* * As per specs, after writting the message object number in the * IF command request register the transfer b/w interface * register and message RAM must be complete in 6 CAN-CLK * period. */ priv->write_reg(priv, C_CAN_IFACE(COMMSK_REG, iface), (IF_COMM_WR | IFX_WRITE_LOW_16BIT(mask))); priv->write_reg(priv, C_CAN_IFACE(COMREQ_REG, iface), IFX_WRITE_LOW_16BIT(objno)); if (c_can_msg_obj_is_busy(priv, iface)) netdev_err(dev, "timed out in object put\n"); } } static void c_can_write_msg_object(struct net_device *dev, static void c_can_write_msg_object(struct net_device *dev, Loading