#include "mscan.h"
-
#define DRV_NAME "mpc5xxx_can"
static struct of_device_id mpc52xx_cdm_ids[] __devinitdata = {
if (in_8(&cdm->ipb_clk_sel) & 0x1)
freq *= 2;
- val = in_be32(&cdm->rstcfg);
- if (val & (1 << 5))
- freq *= 8;
- else
- freq *= 4;
- if (val & (1 << 6))
- freq /= 12;
- else
- freq /= 16;
+ val = in_be32(&cdm->rstcfg);
+
+ freq *= (val & (1 << 5)) ? 8 : 4;
+ freq /= (val & (1 << 6)) ? 12 : 16;
iounmap(cdm);
struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
regs->canctl0 |= MSCAN_INITRQ;
- while ((regs->canctl1 & MSCAN_INITAK) == 0)
+ while (!(regs->canctl1 & MSCAN_INITAK))
udelay(10);
regs->canctl1 = saved_regs.canctl1;
u8 canctl1;
if (mode != MSCAN_NORMAL_MODE) {
-
if (priv->tx_active) {
/* Abort transfers before going to sleep */#
out_8(®s->cantarq, priv->tx_active);
}
canctl1 = in_8(®s->canctl1);
- if ((mode & MSCAN_SLPRQ) && (canctl1 & MSCAN_SLPAK) == 0) {
+ if ((mode & MSCAN_SLPRQ) && !(canctl1 & MSCAN_SLPAK)) {
out_8(®s->canctl0,
in_8(®s->canctl0) | MSCAN_SLPRQ);
for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
priv->can.state = CAN_STATE_SLEEPING;
}
- if ((mode & MSCAN_INITRQ) && (canctl1 & MSCAN_INITAK) == 0) {
+ if ((mode & MSCAN_INITRQ) && !(canctl1 & MSCAN_INITAK)) {
out_8(®s->canctl0,
in_8(®s->canctl0) | MSCAN_INITRQ);
for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
if (!rtr) {
void __iomem *data = ®s->tx.dsr1_0;
- u16 *payload = (u16 *) frame->data;
+ u16 *payload = (u16 *)frame->data;
+
/* It is safe to write into dsr[dlc+1] */
for (i = 0; i < (frame->can_dlc + 1) / 2; i++) {
out_be16(data, *payload++);
if (!(frame->can_id & CAN_RTR_FLAG)) {
void __iomem *data = ®s->rx.dsr1_0;
- u16 *payload = (u16 *) frame->data;
+ u16 *payload = (u16 *)frame->data;
+
for (i = 0; i < (frame->can_dlc + 1) / 2; i++) {
*payload++ = in_be16(data);
data += 2 + _MSCAN_RESERVED_DSR_SIZE;
frame->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
stats->rx_over_errors++;
stats->rx_errors++;
- } else
+ } else {
frame->data[1] = 0;
+ }
old_state = check_set_state(dev, canrflg);
/* State changed */
if ((priv->shadow_statflg & MSCAN_RSTAT_MSK) <
(canrflg & MSCAN_RSTAT_MSK))
frame->data[1] |= CAN_ERR_CRTL_RX_WARNING;
-
if ((priv->shadow_statflg & MSCAN_TSTAT_MSK) <
(canrflg & MSCAN_TSTAT_MSK))
frame->data[1] |= CAN_ERR_CRTL_TX_WARNING;
if (canrflg & MSCAN_RXF)
mscan_get_rx_frame(dev, frame);
- else if (canrflg & MSCAN_ERR_IF)
+ else if (canrflg & MSCAN_ERR_IF)
mscan_get_err_frame(dev, frame, canrflg);
stats->rx_packets++;
cantflg = in_8(®s->cantflg) & cantier;
if (cantier && cantflg) {
-
struct list_head *tmp, *pos;
list_for_each_safe(pos, tmp, &priv->tx_head) {
clear_bit(F_TX_WAIT_ALL, &priv->flags);
clear_bit(F_TX_PROGRESS, &priv->flags);
priv->cur_pri = 0;
- } else
+ } else {
dev->trans_start = jiffies;
+ }
if (!test_bit(F_TX_WAIT_ALL, &priv->flags))
netif_wake_queue(dev);
out_8(®s->canrier, 0);
napi_schedule(&priv->napi);
ret = IRQ_HANDLED;
- } else
+ } else {
clear_bit(F_RX_PROGRESS, &priv->flags);
+ }
}
return ret;
}
static int mscan_do_set_mode(struct net_device *dev, enum can_mode mode)
{
-
struct mscan_priv *priv = netdev_priv(dev);
int ret = 0;