Hello,

I just notided that the "ctrlmode" variable is handled in most drivers
only in "set_bittiming" function, here the function from the sja:

> static int sja1000_set_bittiming(struct net_device *dev)
> {
>       struct sja1000_priv *priv = netdev_priv(dev);
>       struct can_bittiming *bt = &priv->can.bittiming;
>       u8 btr0, btr1;
> 
>       btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6);
>       btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) |
>               (((bt->phase_seg2 - 1) & 0x7) << 4);
>       if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
>               btr1 |= 0x80;
> 
>       dev_info(dev->dev.parent,
>                "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
> 
>       priv->write_reg(priv, REG_BTR0, btr0);
>       priv->write_reg(priv, REG_BTR1, btr1);
> 
>       return 0;
> }

Consider the following sequence:
$ modprobe sja1000-platform
$ canconfig can0 bitrate 250000         # using pengutronix's canutils
$ ifconfig can0 up

# do some testing, with a bitrate of 250000

$ ifconfig can0 down

# decide to activate tripple samling:

$ canconfig can0 ctrlmode triple-sampling on
$ ifconfig can0

Contrary to the expectation the tripple sampling mode isn't activated.
All other control modes that are set during bittiming aren't handled as
well. For e.g. the flexcan (I'm just hacking on) it's the tripple
sample, listen only and loopback mode.

Thinking a bit about the problem...what are the pros and cons of calling
the do_set_bittiming when the bittiming is changed comapred to call it
in the "ndo_open" function, e.g. via "open_candev".

This would simplify the flexcan driver, because it must be in a certain
state (clocks enabled but device in freeze mode) for the bittiming
configuration. For power saving reasons the clock stay off between
_probe and _open.

Cheers, Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to