cb22 / macbook12-spi-driver

WIP input driver for the SPI touchpad / keyboard found in the 12" MacBook (MacBook8,1 + MacBook9,1)
GNU General Public License v2.0
300 stars 106 forks source link

Updates for 4.14 #46

Closed roadrunner2 closed 7 years ago

roadrunner2 commented 7 years ago

This contains the work to exclude the DSDT hacks on kernels 4.14+, as promised in https://github.com/cb22/macbook12-spi-driver/pull/29#issuecomment-327672918 - tested on 4.14-rc1. Also included are some README updates and a small #ifdef fix.

cb22 commented 7 years ago

@roadrunner2 great, this looks good to me. Unfortunately I cannot test at the moment, since I'm away and I've messed up my Linux installation (again).

I'm happy to merge it in if you are.

I guess at this point, we could probably start looking at doing some cleanup of the driver and getting it ready to send it upstream, now that it can attach without any hacks? (or not?)

roadrunner2 commented 7 years ago

@cb22 On the one hand these changes are quite safe - other than a little code shuffling and conditional compilation, nothing changes. So yes, I'm quite comfortable with them. On the other hand there's no big hurry to get these in: things will work find on 4.14 even without these changes (it'll just keep using my hack instead of the new core features). So I'm fine either way, merging now or later.

Regarding cleanup, agreed: I've had that pretty much next on my list. Besides cleanup there is one piece of functionality mising: the code currently assumes the touchpad data always arrives in single 256-byte packet, but when more than 6 fingers are pressed (and the palm sometimes triggers that too) it can be split among 2 256-byte packets. As I head mentioned elsewhere I managed to figure out a few more of the header fields, which provide the info to recognize continuation packets, so I need to make some changes to handle that. After that there's some small stuff like #44 , though I think we could consider upstreaming even without that.

Dunedan commented 7 years ago

I can confirm the driver continues to work fine with this PR under Linux 4.14rc1. :+1:

l1k commented 7 years ago

Regarding upstreaming, a few things that caught my eye while briefly looking over the code:

roadrunner2 commented 7 years ago

@1lk Thanks for the feedback. My responses are:

l1k commented 7 years ago
calling applespi_setup_spi_message() once: I don't think that's safe, as the message is modified by the spi driver (at the very least the status and some length fields); while it may be possible to trace the code and determine exactly what is modified, I think that would be brittle and unsafe.

A lot of IIO drivers do that, see e.g. mcp320x.c: struct mcp320x contains the spi_message, two spi_transfers and the tx_buf and rx_buf. The ->probe hook initializes the spi_transfers with the buffers, then initializes the spi_message with the spi_transfers. The spi_message is then used again and again and again by mcp320x_adc_conversion().

roadrunner2 commented 7 years ago

I see - thanks for the pointer. I've made this change now (see #48).