From 07ef17372a53aa403d95809f44524824db2e3398 Mon Sep 17 00:00:00 2001 From: wolf Date: Sun, 1 Feb 2009 15:24:41 +0000 Subject: [PATCH] Make CAN bit-timing calculation configurable This patch adds the Kconfig option CAN_CALC_BITTIMING to make the calculation of bit-timing parameters configurable. Disabling it will save some space and will allow user space tools to determine proper bit-timing parameters exclusively. Signed-off-by: Wolfgang Grandegger git-svn-id: svn://svn.berlios.de//socketcan/trunk@920 030b6a49-0b11-0410-94ab-b0dab22257f2 --- kernel/2.6/drivers/net/can/Kconfig | 14 ++++++++++++++ kernel/2.6/drivers/net/can/dev.c | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/kernel/2.6/drivers/net/can/Kconfig b/kernel/2.6/drivers/net/can/Kconfig index 2d4a8c5..722ea83 100644 --- a/kernel/2.6/drivers/net/can/Kconfig +++ b/kernel/2.6/drivers/net/can/Kconfig @@ -46,6 +46,20 @@ config CAN_DEV support. This is the standard library for CAN drivers. If unsure, say Y. +config CAN_CALC_BITTIMING + tristate "CAN bit-timing calculation" + depends on CAN_DEV + default Y + ---help--- + If enabled, CAN bit-timing parameters will be calculated for the + bit-rate specified via SYSFS file "can_bitrate" when the device + gets started. This works fine for the most common CAN controllers + with standard bit-rates but may fail for exotic bit-rates or CAN + source clock frequencies. Disabling saves some space, but then the + bit-timing parameters must be specified directly using the SYSFS + files "tq, prop_seg, phase_seg1, phase_seg2 and sjw". + If unsure, say Y. + config CAN_SJA1000 depends on CAN_DEV tristate "Philips SJA1000" diff --git a/kernel/2.6/drivers/net/can/dev.c b/kernel/2.6/drivers/net/can/dev.c index b123cb6..022fca7 100644 --- a/kernel/2.6/drivers/net/can/dev.c +++ b/kernel/2.6/drivers/net/can/dev.c @@ -36,6 +36,7 @@ MODULE_DESCRIPTION(MOD_DESC); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Wolfgang Grandegger "); +#ifdef CONFIG_CAN_CALC_BITTIMING #define CAN_CALC_MAX_ERROR 50 /* in one-tenth of a percent */ /* @@ -150,6 +151,12 @@ static int can_calc_bittiming(struct net_device *dev) return 0; } +#else /* !CONFIG_CAN_CALC_BITTIMING */ +static int can_calc_bittiming(struct net_device *dev) +{ + return -EINVAL; +} +#endif /* CONFIG_CAN_CALC_BITTIMING */ int can_sample_point(struct can_bittiming *bt) { -- 2.39.2