On Thu, Feb 18, 2010 at 10:19:22PM +0100, Wolfgang Grandegger wrote: > Ira W. Snyder wrote: > > Hello all, > > > > I'm working on a driver for the Janz ICAN3 module. Now that I'm getting > > good review feedback, I've found some errors in the driver. One of them > > was that I was missing candev_open() and candev_close() in the netdevice > > open() and close() routines. > > Ah, missed that. > > > So I added them, but I cannot bring up the the CAN devices anymore. I > > get this message in the kernel log: > > > > janz-ican3 janz-ican3.0: bit-timing not yet defined > > > > Great, so I need to set the bit timing. Let's try that: > > Yes. > > > $ ip link set can0 up type can bitrate 1000000 > > RTNETLINK answers: Numerical argument out of domain > > > > That doesn't work either! What, why? The kernel logs show: > > janz-ican3 janz-ican3.0: bitrate error 100.0% too high > > Like a problem with your clock setting: > > priv->can.clock.freq = 8000000; /* if your osclillator clock is 16MHz */ > > Maybe this line is even mising. >
Yep, that was it. With this line added, everything works great. Perhaps adding a check to the can_calc_bittiming() function, right next to the check for priv->bittiming_const would be helpful for other driver authors. One of the following would have let me solve the problem, rather than relying on the mailing list: BUG_ON(priv->clock.freq == 0); WARN_ON(priv->clock.freq == 0); > > My driver is setup exactly the same as the SJA1000 driver. The > > bittiming_const and do_set_bittiming() functions are copied almost > > exactly from the sja1000.c driver. > > > > Does anyone have any insight to offer about what I did wrong? > > See above. The clock setting is in the SJA1000 card/board drivers, e.g. > ems_pci.c. > Yep, I guess I missed it, since I was mainly following the sja1000 driver, which doesn't set it. > > For completeness, my janz-ican3 driver is included below, just in case > > anyone needs to look at the code. It has changed slightly, as I am > > incorporating comments from the last RFCv2 posting. > > > > Also, is there some way to set the default bitrate of a device, so a > > user doesn't have to specify the bitrate to bring the device up? This > > card comes out of reset with a bitrate of 1000000, and is ready to run. > > No, that's by purpose. A default bitrate is error-prune. > Ok. Thanks for all the help, Ira _______________________________________________ Socketcan-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-users
