Re: [PATCH] Enabling rcar_can changelink support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/30/2017 01:33 PM, Mirea, Bogdan-Stefan wrote:
> Hello Marc,
> 
>> On 04/29/2017 09:48 PM, Bogdan Mirea wrote:
>>> Added rcar_can_set_bittiming as can.do_set_bittiming callback that
>>> will be called from can_changelink generic callback when link state
>>> is 
>>> changed.
>>>
>>> This enables set bittiming support:
>>>     ip link set can0 type can bitrate 500000 triple-sampling on
>>
>> Why is this needed? rcar_can_set_bittiming() is called during
>> rcar_can_open().
> 
> I know that rcar_can_set_bittiming() is called during rcar_can_open()
> and setting bittiming works fine when setting can up with a command
> like:
> (1st approah)
>     $ip link set can0 up type can bitrate 500000
> 
> But most of tutorials online[1] are presenting as a TODO the following
> pair of commands:
> (2nd approah)
>     $ip link set can0 type can bitrate 500000
>     $ip link set up can0
> 
> And in this 2nd approah, the first command will fail since it will call
> can_changelink which on its turn will try calling .do_set_bittiming
> callback and the former callback is not defined for rcar_can.

Why should it fail?

>                 memcpy(&bt, nla_data(data[IFLA_CAN_BITTIMING]), sizeof(bt));
>                 err = can_get_bittiming(dev, &bt,
>                                         priv->bittiming_const,
>                                         priv->bitrate_const,
>                                         priv->bitrate_const_cnt);
>                 if (err)
>                         return err;
>                 memcpy(&priv->bittiming, &bt, sizeof(bt));

Here the bittiming settings are copied to priv->bittiming
> 
>                 if (priv->do_set_bittiming) {
>                         /* Finally, set the bit-timing registers */
>                         err = priv->do_set_bittiming(dev);
>                         if (err)
>                                 return err;
>                 }

and it will only call the set_bittiming if it's defined.

> I don't say this is a must-have feature, since calling iproute2 with
> "set bitrate" and "set can up"  as in 1st approach will work just fine,
> will work just fine, but it is a nice to have feature for the second
> approach of setting bitrate.
> Also peak_usb pcan[2] uses this second approach (the changelink one) and
> this patch updates rcar_can for it.

Sorry I still don't get why this is necessary.

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


[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux