Commit graph

127 commits

Author SHA1 Message Date
Maksim Masalski 9f8db3d729 can: cast value 1U to type ULL in function can_stm32_set_filter
Potentially overflowing expression 1U << register_demand
changed to the 1ULL << register_demand to avoid overflow.

Coverity-CID: 190996
Fixes: #13829
Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
2019-02-28 16:57:08 -08:00
Maksim Masalski f32b94c46e can: cast value 1U to type u64_t in function can_stm32_set_filter
Potentially overflowing expression 1U << register_demand
I changed to (u64_t)1U << register_demand
To avoid overflow, I casted 1U to type u64_t.

Coverity-CID: 190996
Fixes: #13829
Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
2019-02-28 16:57:08 -08:00
Alexander Wachter 18680e55e5 drivers: can: Fix userspace handler parameter types
Change the parameter types from can_msg to zcan_frame and from
can_filter to zcan_filter.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-02-28 08:45:44 -06:00
Alexander Wachter b0826442ee drivers: can: Make zcan_frame const for sending
For sending the zcan_frame can be const, because its only
copied to the registers.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-02-28 08:45:44 -06:00
Kumar Gala bb6b1918b2 drivers: can: stm32: Cleanup Kconfig enablement
Follow the pattern we have for other peripherals in that if the driver
class (CAN) is enabled than enable the driver for that class
(CAN_STM32).  Also have the STM32 CAN driver depend on being on a STM32
SoC.

Remove setting of CONFIG_CAN_STM32 in any .conf files as it will get set
of CONFIG_CAN is set/enabled.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-25 10:05:21 -06:00
Jukka Rissanen c478b5bb6e can: Rename can_msg and can_msg_filter structs
In order to follow the naming from Linux, change the name of
can_msg to zcan_frame, and can_msg_filter to zcan_filter.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-22 08:07:03 -05:00
Jukka Rissanen 58f3ae5334 can: Add Linux compatible frame and filter structs
Add new "struct can_frame" which is compatible with Linux so that it
is easier to port socket-can applications from Linux.
Rename existing can_filter to can_msg_filter so that the name will
not conflict with Linux compatible can_filter struct.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-22 08:07:03 -05:00
Alexander Wachter 8757e780fc drivers: can: Update userspace handlers
This commit updates the userspace handlers to thle latest version.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-02-12 09:39:30 -05:00
Alexander Wachter 873875411e drivers: can: stm32_can rework
This commit makes the stm32 CAN driver more readable and fix
a bug where the usage and rx_response array are not shifted correctly.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-02-12 09:39:30 -05:00
Jukka Rissanen fc9e414ebf drivers: can: stm32: Add socket CAN support
Add support for socket CAN functionality. This means that user
is able to use BSD socket interface to send and receive CAN
packets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-08 12:03:34 -05:00
Erwin Rol 28c01b6219 drivers: can: fix typo
Fix another typo in the stm32_can.h header file, swj -> sjw.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2019-02-04 12:59:26 -05:00
Erwin Rol 47fb24fea3 drivers: can: fix typos
- swj -> sjw (Sync Jump Width)
- CAN_MAX_NUMBER_OF_FILTES -> CAN_MAX_NUMBER_OF_FILTERS

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2019-02-01 19:07:57 -05:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Kumar Gala aa2bdbe322 drivers: Remove board.h include
We either don't need board.h in the driver or we should be include soc.h
instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:21:11 -04:00
Anas Nashif c141df09e3 drivers: can: move to new logger
Move to new logger subsystem.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-08 17:49:12 -04:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Alexander Wachter 39cb4b4167 drivers: can: Fix Issue #8226
This commit is a fix for Issue #8226
- Error flags are assigned to the correct mailbox now.
- set_filter_mutex is moved from can_stm32_attach to the wrappers
  can_stm32_attach_isr and can_stm32_attach_msgq. This protects
  response_type variable.
- Waiting for empty mailbox semaphore return value
  is checked for none zero values to check all error states.
- The mailbox tx_int_sem is reset before the sending is triggered.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2018-08-15 08:23:02 -05:00
Ulf Magnusson 27b9c05d4d drivers: can: Kconfig: Remove redundant 'default n' properties
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though, and is
inconsistent.

This will make the auto-generated Kconfig documentation have "No
defaults. Implicitly defaults to n." as well, which is clearer than
'default n if ...'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-03 17:11:31 -04:00
Sritej Kanakadandi Venkata Rama 6f61f09803 drivers: can: Set a initial state to the can device before HAL_CAN_Init
As part of HAL_CAN_Init we check the initial state of the can handle.
Setting it to HAL_CAN_STATE_RESET as an initial state to start the
Init properly.

Resolves: #8416
Coverity-CID: 186580

Signed-off-by: Sritej Kanakadandi Venkata Rama <sritej.kvr@gmail.com>
2018-06-19 20:46:25 -04:00
Alexander Wachter ebc31f6235 drivers: can: Prepare STM32 driver for other series than STM32F0
This commit splits the common interrupt into rx and tx parts because
only STM32F0 series has a common interrupt.
Moved clock source definition to device-tree.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2018-06-18 15:23:29 -04:00
Alexander Wachter b97dd472fb drivers: can: Move bit timing and clock to device tree
This commit moves the bit timing (PROP, BS1, BS2 segments and SWJ)
from Kconfig to the device-tree and fixes issue #7933

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2018-06-01 12:59:42 -05:00
David B. Kinder 44383a394b doc: fix misspellings in Kconfig files
Found some misspellings missed during normal reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-23 16:57:20 -04:00
Alexander Wachter 2976ac351d drivers: can: Add CAN driver support for STM32
This commit adds low level driver support for STM32 micro controllers.
It is tested on stm32f072b in loopback and normal mode.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2018-05-19 20:19:30 +02:00
Alexander Wachter d3101b1fa4 drivers: can: Add syscall handlers for CAN API
This commit adds generic syscall handlers for the CAN API

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2018-05-19 20:19:30 +02:00
Alexander Wachter 023e4518f2 drivers: can: Add Kconfig for CAN driver
This commit adds the Kconfig for generic CAN drivers.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2018-05-19 20:19:30 +02:00