elmcan.git
2 years agoRestart on error instead of stopping restart-on-error
norly [Thu, 24 Feb 2022 22:00:14 +0000 (23:00 +0100)]
Restart on error instead of stopping

2 years agoreadme.rst: Add missing word
norly [Thu, 10 Feb 2022 23:42:54 +0000 (00:42 +0100)]
readme.rst: Add missing word

2 years agoAdd thanks for DKMS config
norly [Thu, 10 Feb 2022 23:39:00 +0000 (00:39 +0100)]
Add thanks for DKMS config

2 years agoout-of-tree.rst: Add porting info
norly [Thu, 10 Feb 2022 23:24:16 +0000 (00:24 +0100)]
out-of-tree.rst: Add porting info

2 years agoreadme.rst: Split off out-of-tree documentation
norly [Thu, 10 Feb 2022 23:18:08 +0000 (00:18 +0100)]
readme.rst: Split off out-of-tree documentation

This simplifies syncing changes with a future upstreamed version.

2 years agoreadme.rst: Remove module parameter documentation
norly [Thu, 10 Feb 2022 23:23:40 +0000 (00:23 +0100)]
readme.rst: Remove module parameter documentation

Whoops, forgot to remove the accept_flaky_uart documentation.

2 years agoRemove accept_flaky_uart module option.
norly [Thu, 10 Feb 2022 22:09:35 +0000 (23:09 +0100)]
Remove accept_flaky_uart module option.

Maybe we really shouldn't *too* lenient - the hexdump parsing code bails
on the first strange character anyway.

2 years agoIntroduce _memstrcmp() to beautify elm327_parse_error()
norly [Thu, 10 Feb 2022 21:54:36 +0000 (22:54 +0100)]
Introduce _memstrcmp() to beautify elm327_parse_error()

Also used in elm327_parse_frame() and elm327_parse_line()

2 years agoImprove error handling in case of stray characters
norly [Thu, 10 Feb 2022 20:39:25 +0000 (21:39 +0100)]
Improve error handling in case of stray characters

2 years agoRemove superfluous lines
norly [Thu, 10 Feb 2022 20:21:26 +0000 (21:21 +0100)]
Remove superfluous lines

2 years agoClean up comments
norly [Thu, 10 Feb 2022 19:07:38 +0000 (20:07 +0100)]
Clean up comments

2 years agoForward port to Linux v5.17-rc3
norly [Wed, 9 Feb 2022 23:24:34 +0000 (00:24 +0100)]
Forward port to Linux v5.17-rc3

...while keeping backwards compatibility, tested on v5.10.

2 years agoClean up more strings
norly [Sat, 5 Feb 2022 05:06:15 +0000 (06:06 +0100)]
Clean up more strings

2 years agoChange WARN_ON into WARN_ON_ONCE
norly [Sat, 5 Feb 2022 04:58:47 +0000 (05:58 +0100)]
Change WARN_ON into WARN_ON_ONCE

2 years agoreadme.rst: Update title
norly [Sat, 5 Feb 2022 04:51:29 +0000 (05:51 +0100)]
readme.rst: Update title

2 years agoreadme.rst: Remove empty To-Do list
norly [Sat, 5 Feb 2022 04:35:14 +0000 (05:35 +0100)]
readme.rst: Remove empty To-Do list

2 years agoAdd BSD-3-Clause licence
norly [Sat, 5 Feb 2022 04:29:08 +0000 (05:29 +0100)]
Add BSD-3-Clause licence

2 years agoConvert RX path to NAPI via can_rx_offload_*
norly [Sat, 5 Feb 2022 03:50:56 +0000 (04:50 +0100)]
Convert RX path to NAPI via can_rx_offload_*

2 years agoClarify some error texts and return values
norly [Sat, 15 Jan 2022 23:26:44 +0000 (00:26 +0100)]
Clarify some error texts and return values

2 years agoreadme.rst: Clarify DKMS install command
norly [Wed, 29 Dec 2021 18:42:09 +0000 (19:42 +0100)]
readme.rst: Clarify DKMS install command

The backticks around `pwd` weren't rendered in GitHub's view of the
readme, and eventually led to a misunderstanding. See issue #6.

2 years agoRemove TTY_LDISC_MAGIC
norly [Fri, 22 Oct 2021 16:19:17 +0000 (18:19 +0200)]
Remove TTY_LDISC_MAGIC

This is in sync with upstream 981b22b8777df7de070be1803f6d7ed4f634a43c
which removed .magic from struct tty_ldisc_ops in Linux 5.13.

2 years agoMerge pull request #4 from tomaszduda23/master
norly [Mon, 17 May 2021 21:05:39 +0000 (23:05 +0200)]
Merge pull request #4 from tomaszduda23/master

Adds dkms.conf to sign kernel module

2 years agoAdds dkms.conf to sign kernel module
Tomasz [Mon, 17 May 2021 18:55:35 +0000 (20:55 +0200)]
Adds dkms.conf to sign kernel module

4 years agoAdd thanks
norly [Mon, 10 Jun 2019 20:27:08 +0000 (22:27 +0200)]
Add thanks

4 years agoStyle: According to linux-5.2-rc4 checkpatch.pl
norly [Mon, 10 Jun 2019 19:46:58 +0000 (21:46 +0200)]
Style: According to linux-5.2-rc4 checkpatch.pl

4 years agoFlush worker earlier, resolving the last to-do item.
norly [Mon, 10 Jun 2019 15:32:04 +0000 (17:32 +0200)]
Flush worker earlier, resolving the last to-do item.

4 years agoUndo buffer rework for TTY RX
norly [Sat, 1 Jun 2019 13:54:41 +0000 (15:54 +0200)]
Undo buffer rework for TTY RX

Actually, we fully control the RX buffer, so DMA shouldn't be a concern.

Fixes: 40ac32acdae89383ae44f32e612bf37fa0493631
4 years agoStyle: Fix one more block comment
norly [Sat, 1 Jun 2019 13:44:55 +0000 (15:44 +0200)]
Style: Fix one more block comment

4 years agoSeparate buffers from struct elm
norly [Thu, 30 May 2019 23:20:17 +0000 (01:20 +0200)]
Separate buffers from struct elm

This avoids trouble with CPU caches racing DMA accesses on ARM.

4 years agoStyle: Fix big comments
norly [Thu, 30 May 2019 21:24:48 +0000 (23:24 +0200)]
Style: Fix big comments

5 years agoreadme.rst: Clarifications
norly [Tue, 26 Mar 2019 23:42:57 +0000 (00:42 +0100)]
readme.rst: Clarifications

5 years agoDocument dependency on can-dev
norly [Thu, 28 Feb 2019 00:51:05 +0000 (01:51 +0100)]
Document dependency on can-dev

5 years agoSilence unused parameter in elmcan_do_set_bittiming()
norly [Thu, 28 Feb 2019 00:48:08 +0000 (01:48 +0100)]
Silence unused parameter in elmcan_do_set_bittiming()

5 years agoExtract RX sanity checker into separate function
norly [Mon, 25 Feb 2019 15:35:52 +0000 (16:35 +0100)]
Extract RX sanity checker into separate function

5 years agoComments
norly [Mon, 25 Feb 2019 15:25:27 +0000 (16:25 +0100)]
Comments

5 years agoAvoid return in function bodies
norly [Mon, 25 Feb 2019 15:24:11 +0000 (16:24 +0100)]
Avoid return in function bodies

5 years agoUse can_change_mtu() instead of hand-made function
norly [Mon, 25 Feb 2019 14:27:45 +0000 (15:27 +0100)]
Use can_change_mtu() instead of hand-made function

5 years agoreadme.rst: Document minimum Linux version
norly [Fri, 22 Feb 2019 14:22:30 +0000 (15:22 +0100)]
readme.rst: Document minimum Linux version

5 years agoreadme.rst: Add note on termination, minor fixes
norly [Fri, 22 Feb 2019 14:14:17 +0000 (15:14 +0100)]
readme.rst: Add note on termination, minor fixes

5 years agoComments and minor style
norly [Tue, 19 Feb 2019 22:47:35 +0000 (23:47 +0100)]
Comments and minor style

5 years agoTurn BUG_ON() into WARN_ON()
norly [Tue, 19 Feb 2019 22:00:11 +0000 (23:00 +0100)]
Turn BUG_ON() into WARN_ON()

5 years agoStyle: Move elm327_is_ready_char() further down to where it is used
norly [Tue, 19 Feb 2019 21:56:48 +0000 (22:56 +0100)]
Style: Move elm327_is_ready_char() further down to where it is used

5 years agoSimplify init script sending
norly [Tue, 19 Feb 2019 21:55:18 +0000 (22:55 +0100)]
Simplify init script sending

My problems with initializing the chip should now be solved by the
'accept_flaky_uart' module parameter.

5 years agoioctl(SIOCGIFNAME): Copy at most IFNAMSIZ bytes, but less if possible
norly [Tue, 19 Feb 2019 21:10:16 +0000 (22:10 +0100)]
ioctl(SIOCGIFNAME): Copy at most IFNAMSIZ bytes, but less if possible

Thus, we don't leak any trailing bytes that may be in the name buffer.

5 years agoAlways copy IFNAMSIZ bytes on ioctl(SIOCGIFNAME)
norly [Tue, 19 Feb 2019 19:19:53 +0000 (20:19 +0100)]
Always copy IFNAMSIZ bytes on ioctl(SIOCGIFNAME)

Just in case dev->name is ever not NUL terminated

5 years agoRemove stray spin_lock_bh()
norly [Tue, 19 Feb 2019 18:59:11 +0000 (19:59 +0100)]
Remove stray spin_lock_bh()

5 years agoStyle fixes
norly [Tue, 19 Feb 2019 14:18:26 +0000 (15:18 +0100)]
Style fixes

5 years agoSynchronize email addresses
norly [Tue, 19 Feb 2019 01:20:42 +0000 (02:20 +0100)]
Synchronize email addresses

5 years agoFix up stray comments now that we have elm327_is_ready_char()
norly [Mon, 18 Feb 2019 23:49:06 +0000 (00:49 +0100)]
Fix up stray comments now that we have elm327_is_ready_char()

5 years agoSanity check TTY input and bail on problems
norly [Mon, 18 Feb 2019 23:24:21 +0000 (00:24 +0100)]
Sanity check TTY input and bail on problems

Also, introduce module parameter 'accept_flaky_uart'.

If your adapter or its connection is unreliable, set this option to
true to try and make the best of a bad situation, but undefined
behavior is prone to occur.

5 years agoIgnore tty RX after HW failure, locking fix
norly [Mon, 18 Feb 2019 23:23:12 +0000 (00:23 +0100)]
Ignore tty RX after HW failure, locking fix

5 years agoreadme.rst: Add rationale behind the chosen configuration
norly [Mon, 18 Feb 2019 20:38:04 +0000 (21:38 +0100)]
readme.rst: Add rationale behind the chosen configuration

Plus minor fixes.

5 years agoREADME.txt: Add limitations for 'v1.5' clones
norly [Mon, 18 Feb 2019 13:48:44 +0000 (14:48 +0100)]
README.txt: Add limitations for 'v1.5' clones

5 years agoREADME.rst: We actually use can_bus_off() now
norly [Mon, 18 Feb 2019 13:30:29 +0000 (14:30 +0100)]
README.rst: We actually use can_bus_off() now

5 years agoREADME.rst: Forgot to bump the ldisc number
norly [Mon, 18 Feb 2019 13:27:21 +0000 (14:27 +0100)]
README.rst: Forgot to bump the ldisc number

5 years agoWork around hardware bug when waiting for '>' prompt
norly [Mon, 18 Feb 2019 13:23:33 +0000 (14:23 +0100)]
Work around hardware bug when waiting for '>' prompt

Sometimes the ELM327 sets 0x80 and/or 0x40 when sending '>' to indicate
that it is ready to receive the next command.

Masking these two bits out seems to take care of most or all hangs
during initialization.

5 years agoShut down ELM327's 'protocol' before reconfiguring CAN
norly [Sun, 17 Feb 2019 23:34:10 +0000 (00:34 +0100)]
Shut down ELM327's 'protocol' before reconfiguring CAN

According to ELM327's manual, AT PC should be sent before issuing AT PB.

5 years agoDrop fake bittimings in favor of bitrate table
norly [Sun, 17 Feb 2019 23:24:02 +0000 (00:24 +0100)]
Drop fake bittimings in favor of bitrate table

The fake bittiming table produces wrong results in Linux 4.19's bitrate
based parameter calculation.

SocketCAN support for fixed bitrates was introduced in 431af779256c in
Jan 2017, and as of Linux 4.18 the only driver using it is mcba_usb.
Bitrates are also fixed in ELM327, and none of the other parameters can
be tuned, so using this API makes sense here as well.

5 years agoImprove readability of elm327_handle_prompt()
norly [Thu, 14 Feb 2019 18:29:31 +0000 (19:29 +0100)]
Improve readability of elm327_handle_prompt()

5 years agoNull stack variables before use
norly [Thu, 14 Feb 2019 18:22:20 +0000 (19:22 +0100)]
Null stack variables before use

5 years agoDon't try to send garbage after each init script entry
norly [Sun, 17 Feb 2019 23:45:42 +0000 (00:45 +0100)]
Don't try to send garbage after each init script entry

Previously, we'd try to send the local txbuf even though it had not been
written to. Thus strlen() would overrun the buffer, which recent Linux
versions catch in a BUG_ON().

5 years agoUse more netdev_err() instead of pr_err()
norly [Thu, 31 Jan 2019 00:53:14 +0000 (01:53 +0100)]
Use more netdev_err() instead of pr_err()

...and remove a stray comment

5 years agoReturn cleanly in functions calling elm327_hw_failure()
norly [Thu, 31 Jan 2019 00:49:33 +0000 (01:49 +0100)]
Return cleanly in functions calling elm327_hw_failure()

5 years agoDon't reset on HW fault, but take the interface down.
norly [Thu, 31 Jan 2019 00:08:15 +0000 (01:08 +0100)]
Don't reset on HW fault, but take the interface down.

There is currently no interface to try again, other than detaching and
re-attaching the line discipline. It wouldn't make much sense either,
unless we've run into an unexpected state in the ELM327's firmware.

5 years agoelmcan_ldisc_ioctl(): Use elm->dev->name again
norly [Thu, 24 Jan 2019 02:44:04 +0000 (03:44 +0100)]
elmcan_ldisc_ioctl(): Use elm->dev->name again

We now have proper locking, so dev->name is guaranteed to exist.

5 years agoUse netdev_* prints throughout
norly [Wed, 23 Jan 2019 16:04:12 +0000 (17:04 +0100)]
Use netdev_* prints throughout

5 years agoRename elm327_panic() to elm327_hw_failure() to avoid confusion
norly [Wed, 23 Jan 2019 15:41:56 +0000 (16:41 +0100)]
Rename elm327_panic() to elm327_hw_failure() to avoid confusion

5 years agoHandle tty->ops->write() returning error
norly [Wed, 23 Jan 2019 15:37:39 +0000 (16:37 +0100)]
Handle tty->ops->write() returning error

This was already the case in elmcan_ldisc_tx_worker(), but was missing
in elm327_send().

5 years agoReplace '>' with constant ELM327_READY_CHAR
norly [Wed, 23 Jan 2019 15:19:18 +0000 (16:19 +0100)]
Replace '>' with constant ELM327_READY_CHAR

5 years agoBump N_ELMCAN to avoid conflicts with future in-tree line disciplines.
norly [Wed, 23 Jan 2019 01:54:41 +0000 (02:54 +0100)]
Bump N_ELMCAN to avoid conflicts with future in-tree line disciplines.

We can't go higher than 29 because of NR_LDISCS == 30 in Linux 5.0.
We can't go lower than 28 because of N_NULL == 27 in Linux 5.0.

5 years agoFix race between ldisc_close() and ldisc_*()
norly [Wed, 23 Jan 2019 01:39:46 +0000 (02:39 +0100)]
Fix race between ldisc_close() and ldisc_*()

There was a chance that something needed the elm object after it was
freed. Proper locking stops this.

5 years agoAvoid ldisc_ioctl() racing unregister_candev()
norly [Fri, 11 Jan 2019 02:38:35 +0000 (03:38 +0100)]
Avoid ldisc_ioctl() racing unregister_candev()

When getting the CAN interface's name via the SIOCGIFNAME ioctl,
elm->dev->name may no longer exist because the interface is being shut
down.

Also, print the name of the interface to dmesg.

5 years agoComments
norly [Mon, 7 Jan 2019 02:33:07 +0000 (03:33 +0100)]
Comments

5 years agoImport first public commit
norly [Tue, 13 Nov 2018 22:38:17 +0000 (23:38 +0100)]
Import first public commit

5 years agoInitial commit
norly [Tue, 13 Nov 2018 22:38:01 +0000 (23:38 +0100)]
Initial commit