Skip to content

Commit

Permalink
can: flexcan: factor out soft reset into seperate funtion
Browse files Browse the repository at this point in the history
This patch moves the soft reset into a seperate function.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Marc Kleine-Budde committed Mar 3, 2014
1 parent d96e43e commit 4b5b822
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions drivers/net/can/flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,21 @@ static int flexcan_chip_unfreeze(struct flexcan_priv *priv)
return 0;
}

static int flexcan_chip_softreset(struct flexcan_priv *priv)
{
struct flexcan_regs __iomem *regs = priv->base;
unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;

flexcan_write(FLEXCAN_MCR_SOFTRST, &regs->mcr);
while (timeout-- && (flexcan_read(&regs->mcr) & FLEXCAN_MCR_SOFTRST))
usleep_range(10, 20);

if (flexcan_read(&regs->mcr) & FLEXCAN_MCR_SOFTRST)
return -ETIMEDOUT;

return 0;
}

static int flexcan_get_berr_counter(const struct net_device *dev,
struct can_berr_counter *bec)
{
Expand Down Expand Up @@ -786,16 +801,9 @@ static int flexcan_chip_start(struct net_device *dev)
return err;

/* soft reset */
flexcan_write(FLEXCAN_MCR_SOFTRST, &regs->mcr);
udelay(10);

reg_mcr = flexcan_read(&regs->mcr);
if (reg_mcr & FLEXCAN_MCR_SOFTRST) {
netdev_err(dev, "Failed to softreset can module (mcr=0x%08x)\n",
reg_mcr);
err = -ENODEV;
err = flexcan_chip_softreset(priv);
if (err)
goto out_chip_disable;
}

flexcan_set_bittiming(dev);

Expand Down

0 comments on commit 4b5b822

Please sign in to comment.