Add Apple SPI keyboard and trackpad driver
Subsystems (8)
v3 cover Add Apple SPI keyboard and trackpad driver
This changeset adds a driver for the SPI keyboard and trackpad on recent MacBook's and MacBook Pro's. The driver has seen a fair amount of use over the last 2 years (basically anybody running linux on these machines), with only relatively small changes in the last year or so. For those interested, the driver development has been hosted at
https://github.com/cb22/macbook12-spi-driver/ (as well as my clone at
https://github.com/roadrunner2/macbook12-spi-driver/).
The first patch is just a placeholder for now and is provided in case somebody wants to compile the driver while it's being reviewed here; the real patch has been submitted to dri-devel and is being discussed there, with the intent/hope that I can get an Ack and permission to merge it through the input subsystem tree here as part of this patch series.
The second and third patches add a new dev_print_hex_dump() helper as the dev_xxx() analog of print_hex_dump().
The fourth patch finally contains the new applespi driver.
Changes in v3:
Applied all feedback from review by Andy Shevchenko, including:
- move dev_print_hex_dump() to driver core
- clean up keyboard modifier bits testing/modifying
- remove DEV() macro
- minor style issues
The full set of changes to applespi can be viewed at
https://github.com/roadrunner2/macbook12-spi-driver/ as individual commits f832caa..3a6262e in the upstreaming-review branch.
Ronald Tschalär (4):
drm/bridge: sil_sii8620: depend on INPUT instead of selecting it. lib/hexdump.c: factor out generic hexdump formatting for reuse. driver core: add dev_print_hex_dump() logging function.
Input: add Apple SPI keyboard and trackpad driver.
drivers/base/core.c | 43 + drivers/gpu/drm/bridge/Kconfig | 2 +- drivers/input/keyboard/Kconfig | 15 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/applespi.c | 1988 +++++++++++++++++++++++++++++ include/linux/device.h | 15 + include/linux/printk.h | 12 + lib/hexdump.c | 95 +- 8 files changed, 2146 insertions(+), 25 deletions(-) create mode 100644 drivers/input/keyboard/applespi.c
Signature · 1 line
2.20.1
PATCH v3 1/4 drm/bridge: sil_sii8620: depend on INPUT instead of selecting it.
commit d6abe6df706c66d803e6dd4fe98c1b6b7f125a56 (drm/bridge:sil_sii8620: do not have a dependency of RC_CORE) added a dependency on INPUT. However, this causes problems with other drivers, in particular an input driver that depends on MFD_INTEL_LPSS_PCI (to be added in a future commit):
drivers/clk/Kconfig:9:error: recursive dependency detected!
drivers/clk/Kconfig:9: symbol COMMON_CLK is selected by MFD_INTEL_LPSS drivers/mfd/Kconfig:566: symbol MFD_INTEL_LPSS is selected by MFD_INTEL_LPSS_PCI drivers/mfd/Kconfig:580: symbol MFD_INTEL_LPSS_PCI is implied by KEYBOARD_APPLESPI drivers/input/keyboard/Kconfig:73: symbol KEYBOARD_APPLESPI depends on INPUT drivers/input/Kconfig:8: symbol INPUT is selected by DRM_SIL_SII8620 drivers/gpu/drm/bridge/Kconfig:83: symbol DRM_SIL_SII8620 depends on DRM_BRIDGE drivers/gpu/drm/bridge/Kconfig:1: symbol DRM_BRIDGE is selected by DRM_PL111 drivers/gpu/drm/pl111/Kconfig:1: symbol DRM_PL111 depends on COMMON_CLK
According to the docs, select should only be used for non-visible symbols. Furthermore almost all other references to INPUT throughout the kernel config are depends, not selects. Hence this change.
--- drivers/gpu/drm/bridge/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/Kconfig +1 -1
@@ -83,9 +83,9 @@ config DRM_PARADE_PS8622 config DRM_SIL_SII8620 tristate "Silicon Image SII8620 HDMI/MHL bridge" depends on OF + depends on INPUT select DRM_KMS_HELPER imply EXTCON - select INPUT select RC_CORE help Silicon Image SII8620 HDMI/MHL bridge chip driver.
Signature · 1 line
2.20.1
Re: [PATCH v3 1/4] drm/bridge: sil_sii8620: depend on INPUT instead of selecting it.
+cc: dri-devel
Quoted 16 lines · Ronald Tschalär
commit
d6abe6df706c66d803e6dd4fe98c1b6b7f125a56(drm/bridge:sil_sii8620: do not have a dependency ofRC_CORE) added a dependency on INPUT. However, this causes problems with other drivers, in particular an input driver that depends onMFD_INTEL_LPSS_PCI(to be added in a future commit):drivers/clk/Kconfig:9:error: recursive dependency detected!
drivers/clk/Kconfig:9: symbol COMMON_CLK is selected by MFD_INTEL_LPSS drivers/mfd/Kconfig:566: symbol MFD_INTEL_LPSS is selected by MFD_INTEL_LPSS_PCI drivers/mfd/Kconfig:580: symbol MFD_INTEL_LPSS_PCI is implied by KEYBOARD_APPLESPI drivers/input/keyboard/Kconfig:73: symbol KEYBOARD_APPLESPI depends on INPUT drivers/input/Kconfig:8: symbol INPUT is selected by DRM_SIL_SII8620 drivers/gpu/drm/bridge/Kconfig:83: symbol DRM_SIL_SII8620 depends on DRM_BRIDGE drivers/gpu/drm/bridge/Kconfig:1: symbol DRM_BRIDGE is selected by DRM_PL111 drivers/gpu/drm/pl111/Kconfig:1: symbol DRM_PL111 depends on COMMON_CLK
Quoted 7 lines
According to the docs, select should only be used for non-visible symbols. Furthermore almost all other references to INPUT throughout the kernel config are depends, not selects. Hence this change.
CC Inki Dae <[email protected]>CC Andrzej Hajda <[email protected]>Signed-off-by Ronald Tschalär <[email protected]>
This is drm bridge driver, next time please cc it to dri-devel ML also.
Anyway this is not the solution we have agreed to.
Why have you abandoned the patch [1]? It needed just some minor polishing, as I wrote in response to this mail.
[1]:
https://lore.kernel.org/lkml/[email protected]/T/#mf620df0b1583096a214d8e2e690387078583472f
Regards
Andrzej
Quoted 19 lines
--- drivers/gpu/drm/bridge/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/bridge/Kconfig +1
-1@@ -83,9 +83,9 @@ config DRM_PARADE_PS8622 config DRM_SIL_SII8620 tristate "Silicon Image SII8620 HDMI/MHL bridge" depends on OF + depends on INPUT select DRM_KMS_HELPER imply EXTCON - select INPUT select RC_CORE help Silicon Image SII8620 HDMI/MHL bridge chip driver.
Re: [PATCH v3 1/4] drm/bridge: sil_sii8620: depend on INPUT instead of selecting it.
Hi Andrzej,
Quoted 23 lines · Andrzej Hajda
+cc: dri-devel
Quoted 20 lines · Ronald Tschalär
commit
d6abe6df706c66d803e6dd4fe98c1b6b7f125a56(drm/bridge:sil_sii8620: do not have a dependency ofRC_CORE) added a dependency on INPUT. However, this causes problems with other drivers, in particular an input driver that depends onMFD_INTEL_LPSS_PCI(to be added in a future commit):drivers/clk/Kconfig:9:error: recursive dependency detected!
drivers/clk/Kconfig:9: symbol COMMON_CLK is selected by MFD_INTEL_LPSS drivers/mfd/Kconfig:566: symbol MFD_INTEL_LPSS is selected by MFD_INTEL_LPSS_PCI drivers/mfd/Kconfig:580: symbol MFD_INTEL_LPSS_PCI is implied by KEYBOARD_APPLESPI drivers/input/keyboard/Kconfig:73: symbol KEYBOARD_APPLESPI depends on INPUT drivers/input/Kconfig:8: symbol INPUT is selected by DRM_SIL_SII8620 drivers/gpu/drm/bridge/Kconfig:83: symbol DRM_SIL_SII8620 depends on DRM_BRIDGE drivers/gpu/drm/bridge/Kconfig:1: symbol DRM_BRIDGE is selected by DRM_PL111 drivers/gpu/drm/pl111/Kconfig:1: symbol DRM_PL111 depends on COMMON_CLKAccording to the docs, select should only be used for non-visible symbols. Furthermore almost all other references to INPUT throughout the kernel config are depends, not selects. Hence this change.
Quoted 5 lines
Quoted 3 lines
CC Inki Dae <[email protected]>CC Andrzej Hajda <[email protected]>Signed-off-by Ronald Tschalär <[email protected]>This is drm bridge driver, next time please cc it to dri-devel ML also.
Ok. Though as noted in the cover letter, the patch here is meant as a placeholder till the real thing being discussed on dri-devel is finalized. I was trying to avoid cross-posting too much, hence the separate submission on dri-devel.
Quoted 7 lines
Anyway this is not the solution we have agreed to.
Why have you abandoned the patch [1]? It needed just some minor polishing, as I wrote in response to this mail.
[1]:
https://lore.kernel.org/lkml/[email protected]/T/#mf620df0b1583096a214d8e2e690387078583472f
It seems your mail client doesn't like me :-) I got neither of your responses. Sorry, I should've checked the archives when I didn't hear anything. In any case thank you for your review, and I will update that patch and send out a new version shortly.
Cheers,
Ronald
Quoted 21 lines
Quoted 19 lines
--- drivers/gpu/drm/bridge/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/bridge/Kconfig +1
-1@@ -83,9 +83,9 @@ config DRM_PARADE_PS8622 config DRM_SIL_SII8620 tristate "Silicon Image SII8620 HDMI/MHL bridge" depends on OF + depends on INPUT select DRM_KMS_HELPER imply EXTCON - select INPUT select RC_CORE help Silicon Image SII8620 HDMI/MHL bridge chip driver.
Re: Re: [PATCH v3 1/4] drm/bridge: sil_sii8620: depend on INPUT instead of selecting it.
Quoted 40 lines · and then you die
Hi Andrzej,
Quoted 19 lines · Andrzej Hajda
+cc: dri-devel
Quoted 16 lines · Ronald Tschalär
commit
d6abe6df706c66d803e6dd4fe98c1b6b7f125a56(drm/bridge:sil_sii8620: do not have a dependency ofRC_CORE) added a dependency on INPUT. However, this causes problems with other drivers, in particular an input driver that depends onMFD_INTEL_LPSS_PCI(to be added in a future commit):drivers/clk/Kconfig:9:error: recursive dependency detected!
drivers/clk/Kconfig:9: symbol COMMON_CLK is selected by MFD_INTEL_LPSS drivers/mfd/Kconfig:566: symbol MFD_INTEL_LPSS is selected by MFD_INTEL_LPSS_PCI drivers/mfd/Kconfig:580: symbol MFD_INTEL_LPSS_PCI is implied by KEYBOARD_APPLESPI drivers/input/keyboard/Kconfig:73: symbol KEYBOARD_APPLESPI depends on INPUT drivers/input/Kconfig:8: symbol INPUT is selected by DRM_SIL_SII8620 drivers/gpu/drm/bridge/Kconfig:83: symbol DRM_SIL_SII8620 depends on DRM_BRIDGE drivers/gpu/drm/bridge/Kconfig:1: symbol DRM_BRIDGE is selected by DRM_PL111 drivers/gpu/drm/pl111/Kconfig:1: symbol DRM_PL111 depends on COMMON_CLKQuoted 8 lines
Quoted 7 lines
According to the docs, select should only be used for non-visible symbols. Furthermore almost all other references to INPUT throughout the kernel config are depends, not selects. Hence this change.
CC Inki Dae <[email protected]>CC Andrzej Hajda <[email protected]>Signed-off-by Ronald Tschalär <[email protected]>This is drm bridge driver, next time please cc it to dri-devel ML also.
Ok. Though as noted in the cover letter, the patch here is meant as a placeholder till the real thing being discussed on dri-devel is finalized. I was trying to avoid cross-posting too much, hence the separate submission on dri-devel.
Quoted 5 lines
Anyway this is not the solution we have agreed to.
Why have you abandoned the patch [1]? It needed just some minor polishing, as I wrote in response to this mail.
Quoted 6 lines
Quoted 2 lines
[1]:
https://lore.kernel.org/lkml/[email protected]/T/#mf620df0b1583096a214d8e2e690387078583472fIt seems your mail client doesn't like me :-) I got neither of your responses. Sorry, I should've checked the archives when I didn't hear anything. In any case thank you for your review, and I will update that patch and send out a new version shortly.
I see where is the problem: Your mail client (mutt I suppose) sets Mail-Followup-To header to all recipients (To and Cc) without the sender. And my client (thunderbird) after pressing "Reply-All" checks for Mail-Followup-To field, if present it uses only it to set recipients, so in your case it does not response to the original author.
I do not know which mail client works incorrectly in this case, but for sure it is not what we want :)
I do not know how to solve the issue in thunderbird, maybe mutt is more configurable?
Regards
Andrzej
Quoted 28 lines
Cheers,
Ronald
Quoted 20 lines
Quoted 19 lines
--- drivers/gpu/drm/bridge/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/bridge/Kconfig +1
-1@@ -83,9 +83,9 @@ config DRM_PARADE_PS8622 config DRM_SIL_SII8620 tristate "Silicon Image SII8620 HDMI/MHL bridge" depends on OF + depends on INPUT select DRM_KMS_HELPER imply EXTCON - select INPUT select RC_CORE help Silicon Image SII8620 HDMI/MHL bridge chip driver.
Re: Re: [PATCH v3 1/4] drm/bridge: sil_sii8620: depend on INPUT instead of selecting it.
Quoted 4 lines · Andrzej Hajda
Quoted 3 lines · and then you die
Quoted 1 line · Andrzej Hajda
+cc: dri-devel
[snip]
Quoted 11 lines
Quoted 4 lines
It seems your mail client doesn't like me :-) I got neither of your responses. Sorry, I should've checked the archives when I didn't hear anything. In any case thank you for your review, and I will update that patch and send out a new version shortly.
I see where is the problem: Your mail client (mutt I suppose) sets Mail-Followup-To header to all recipients (To and Cc) without the sender. And my client (thunderbird) after pressing "Reply-All" checks for Mail-Followup-To field, if present it uses only it to set recipients, so in your case it does not response to the original author.
Quoted 5 lines
I do not know which mail client works incorrectly in this case, but for sure it is not what we want :)
I do not know how to solve the issue in thunderbird, maybe mutt is more configurable?
Thanks for debugging this! I'm sorry, but it looks like this was an error on my part. So for anybody else using mutt: by default, mutt will add a Mail-Followup-To header without your own address when sending mail to any lists you are subscribed to, as defined by the 'subscribe' command (to avoid receiving replies in duplicate, i.e. once via to/cc and once via the list). Unfortunately I was using a regex there that included all freedesktop.org lists, not just ones I'm actually subscribed to, and hence it thought I was subscribed dri-devel too, leading to the this screwup.
Apologies for this - I guess even after more than 2 decades of mutt and mailing lists I still manage to not know all its ins and outs. But it should be fixed now.
Cheers,
Ronald
PATCH v3 2/4 lib/hexdump.c: factor out generic hexdump formatting for reuse.
In reply to Ronald TschalärThis introduces print_hex_dump_to_cb() which contains all the hexdump formatting minus the actual printk() call, allowing an arbitrary print function to be supplied instead. And print_hex_dump() is re-implemented using print_hex_dump_to_cb().
This allows other hex-dump logging functions to be provided which call printk() differently or even log the hexdump somewhere entirely different.
--- include/linux/printk.h | 12 ++++++ lib/hexdump.c | 95 +++++++++++++++++++++++++++++++----------- 2 files changed, 83 insertions(+), 24 deletions(-)
include/linux/printk.h +12 -0
@@ -483,10 +483,16 @@ enum {extern int hex_dump_to_buffer (const void *buf,size_t len,int rowsize,int groupsize,char *linebuf,size_t linebuflen,bool ascii); +typedef +void (*hex_dump_callback )(const char *level,void *arg,const char *fmt, ...);#ifdef CONFIG_PRINTK extern void print_hex_dump (const char *level,const char *prefix_str,int prefix_type,int rowsize,int groupsize,const void *buf,size_t len,bool ascii); +extern void print_hex_dump_to_cb (const char *level,const char *prefix_str, +int prefix_type,int rowsize,int groupsize, +const void *buf,size_t len,bool ascii, +hex_dump_callback print,void *print_arg);#if defined(CONFIG_DYNAMIC_DEBUG )#define print_hex_dump_bytes (prefix_str, prefix_type, buf, len) \ dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true)
@@ -500,6 +506,12 @@ static inline void print_hex_dump(const char *level, const char *prefix_str, const void *buf, size_t len, bool ascii) { } +extern void print_hex_dump_to_cb(const char *level, const char *prefix_str, +int prefix_type,int rowsize,int groupsize, +const void *buf,size_t len,bool ascii, +hex_dump_callback *print,void *print_arg); +{ +}static inline void print_hex_dump_bytes (const char *prefix_str,int prefix_type,const void *buf,size_t len) {
lib/hexdump.c +71 -24
124 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v3 2/4] lib/hexdump.c: factor out generic hexdump formatting for reuse.
Quoted 9 lines · Ronald Tschalär
This introduces
print_hex_dump_to_cb()which contains all the hexdump formatting minus the actualprintk()call, allowing an arbitrary print function to be supplied instead. Andprint_hex_dump()is re-implemented usingprint_hex_dump_to_cb().This allows other hex-dump logging functions to be provided which call
printk()differently or even log the hexdump somewhere entirely different.
No Sign-off?
In any case, don't do it like this. smaller non-recursive printf() is better than one big receursive call.
When it looks like an optimization, it's actually a regression.
And yes, debugfs idea is not bad.
P.S. Also check %*ph specifier.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 2/4] lib/hexdump.c: factor out generic hexdump formatting for reuse.
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Ronald Tschalär
This introduces
print_hex_dump_to_cb()which contains all the hexdump formatting minus the actualprintk()call, allowing an arbitrary print function to be supplied instead. Andprint_hex_dump()is re-implemented usingprint_hex_dump_to_cb().
Quoted 5 lines
Quoted 3 lines
This allows other hex-dump logging functions to be provided which call
printk()differently or even log the hexdump somewhere entirely different.No Sign-off?
Yeah, my screwup.
Quoted 3 lines
In any case, don't do it like this. smaller non-recursive
printf()is better than one big receursive call.
When it looks like an optimization, it's actually a regression.
Not sure where you see recursion here - are you referring to the callback approach? Since dev_printk() ends up calling printk with a dictionary as well as additional formatting, vs print_hex_dump()'s stright use of printk, this seemed like the best way accommodate various possible ways of logging the messages. But as per below I guess this is moot.
Quoted 1 line
And yes, debugfs idea is not bad.
So it seems like that is the consensus. As per my other response, I'll do this then and leave the print_hex_dump() alone.
Quoted 1 line
P.S. Also check %*ph specifier.
Thanks!
Cheers,
Ronald
Re: [PATCH v3 2/4] lib/hexdump.c: factor out generic hexdump formatting for reuse.
Quoted 13 lines · and then you die
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Ronald Tschalär
This introduces
print_hex_dump_to_cb()which contains all the hexdump formatting minus the actualprintk()call, allowing an arbitrary print function to be supplied instead. Andprint_hex_dump()is re-implemented usingprint_hex_dump_to_cb().This allows other hex-dump logging functions to be provided which call
printk()differently or even log the hexdump somewhere entirely different.
Quoted 6 lines
Quoted 3 lines
In any case, don't do it like this. smaller non-recursive
printf()is better than one big receursive call.
When it looks like an optimization, it's actually a regression.Not sure where you see recursion here - are you referring to the callback approach?
%pV is a recursive printf().
Quoted 5 lines
Since
dev_printk()ends up calling printk with a dictionary as well as additional formatting, vs print_hex_dump()'s stright use of printk, this seemed like the best way accommodate various possible ways of logging the messages. But as per below I guess this is moot.
I recommend to read this: https://lwn.net/Articles/780556/
Quoted 6 lines
Quoted 1 line
And yes, debugfs idea is not bad.
So it seems like that is the consensus. As per my other response, I'll do this then and leave the
print_hex_dump()alone.Quoted 1 line
P.S. Also check %*ph specifier.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 2/4] lib/hexdump.c: factor out generic hexdump formatting for reuse.
Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · and then you die
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Ronald Tschalär
This introduces
print_hex_dump_to_cb()which contains all the hexdump formatting minus the actualprintk()call, allowing an arbitrary print function to be supplied instead. Andprint_hex_dump()is re-implemented usingprint_hex_dump_to_cb().This allows other hex-dump logging functions to be provided which call
printk()differently or even log the hexdump somewhere entirely different.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
In any case, don't do it like this. smaller non-recursive
printf()is better than one big receursive call.
When it looks like an optimization, it's actually a regression.Not sure where you see recursion here - are you referring to the callback approach?
%pV is a recursive
printf().
Ah!
Quoted 7 lines
Quoted 5 lines
Since
dev_printk()ends up calling printk with a dictionary as well as additional formatting, vs print_hex_dump()'s stright use of printk, this seemed like the best way accommodate various possible ways of logging the messages. But as per below I guess this is moot.I recommend to read this: https://lwn.net/Articles/780556/
Thanks, quite informative.
Cheers,
Ronald
PATCH v3 3/4 driver core: add dev_print_hex_dump() logging function.
In reply to Ronald TschalärThis is the dev_xxx() analog to print_hex_dump(), using dev_printk() instead of straight printk() to match other dev_xxx() logging functions.
--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)
drivers/base/core.c +43 -0
@@ -3097,6 +3097,49 @@ define_dev_printk_level(_dev_warn, KERN_WARNING);define_dev_printk_level (_dev_notice,KERN_NOTICE );define_dev_printk_level (_dev_info,KERN_INFO ); +static void +print_to_dev_printk (const char *level,void *arg,const char *fmt, ...) +{ +struct va_format vaf; +va_list args; + +va_start (args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + +__dev_printk (level, (const struct device *)arg, &vaf); + +va_end (args); +} + +/** +* _dev_print_hex_dump - print a text hex dump to syslog for a binary blob of +* data +* @level: kernel log level (e.g. KERN_DEBUG) +* @dev: the device to which this log message pertains +* @prefix_str: string to prefix each line with; +* caller supplies trailing spaces for alignment if desired +* @prefix_type: controls whether prefix of an offset, address, or none +* is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE) +* @rowsize: number of bytes to print per line; must be 16 or 32 +* @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1) +* @buf: data blob to dump +* @len: number of bytes in the @buf +* @ascii: include ASCII after the hex output +* +* See print_hex_dump() for additional details and examples. +*/ +void _dev_print_hex_dump (const char *level,const struct device *dev, +const char *prefix_str,int prefix_type, +int rowsize,int groupsize, +const void *buf,size_t len,bool ascii) +{ +print_hex_dump_to_cb (level, prefix_str, prefix_type, rowsize, groupsize, + buf, len, ascii, print_to_dev_printk, (void *)dev); +} +EXPORT_SYMBOL (_dev_print_hex_dump); +#endif static inline bool fwnode_is_primary (struct fwnode_handle *fwnode)
include/linux/device.h +15 -0
@@ -1405,6 +1405,10 @@ __printf(2, 3)void _dev_notice (const struct device *dev,const char *fmt, ...); __printf(2, 3)void _dev_info (const struct device *dev,const char *fmt, ...); +void _dev_print_hex_dump (const char *level,const struct device *dev, +const char *prefix_str,int prefix_type, +int rowsize,int groupsize, +const void *buf,size_t len,bool ascii);#else
@@ -1445,6 +1449,12 @@ void _dev_notice(const struct device *dev, const char *fmt, ...) static inline __printf(2, 3) void _dev_info(const struct device *dev, const char *fmt, ...) {} +static inline +void _dev_print_hex_dump (const char *level,const struct device *dev, +const char *prefix_str,int prefix_type, +int rowsize,int groupsize, +const void *buf,size_t len,bool ascii); +{}#endif
@@ -1467,6 +1477,11 @@ void _dev_info(const struct device *dev, const char *fmt, ...) _dev_notice(dev, dev_fmt(fmt), ##__VA_ARGS__)#define dev_info (dev, fmt, ...) \ _dev_info(dev, dev_fmt(fmt), ##__VA_ARGS__) +#define dev_print_hex_dump (level, dev, prefix_str, prefix_type, \ + rowsize, groupsize, buf, len, ascii) \ + _dev_print_hex_dump(level, dev, dev_fmt(prefix_str), \ + prefix_type, rowsize, groupsize, buf, len, \ + ascii);#if defined(CONFIG_DYNAMIC_DEBUG )#define dev_dbg (dev, fmt, ...) \
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerRe: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 6 lines · Ronald Tschalär
This is the
dev_xxx()analog toprint_hex_dump(), usingdev_printk()instead of straightprintk()to match otherdev_xxx()logging functions.--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)
No signed-off-by?
Anyway, no, please do not do this. Please do not dump large hex values like this to the kernel log, it does not help anyone.
You can do this while debugging, sure, but not for "real" kernel code.
Worst case, just create a debugfs file for your device that you can read the binary data from if you really need it. For any "normal" operation, this is not something that you should ever need.
thanks,
greg k-h
Re: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 9 lines · Greg Kroah-Hartman
Quoted 6 lines · Ronald Tschalär
This is the
dev_xxx()analog toprint_hex_dump(), usingdev_printk()instead of straightprintk()to match otherdev_xxx()logging functions.--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)No signed-off-by?
Aargh! Apologies, fixed for the future.
Quoted 4 lines
Anyway, no, please do not do this. Please do not dump large hex values like this to the kernel log, it does not help anyone.
You can do this while debugging, sure, but not for "real" kernel code.
As used by this driver, it is definitely called for debugging only and must be explicitly enabled via a module param. But having the ability for folks to easily generate and print out debugging info has proven quite valuable.
Quoted 3 lines
Worst case, just create a debugfs file for your device that you can read the binary data from if you really need it. For any "normal" operation, this is not something that you should ever need.
Ok, can do that.
I'll retract the two print_hex_dump related patches then.
Cheers,
Ronald
Greg Kroah-Hartman
maintainerRe: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 17 lines · and then you die
Quoted 9 lines · Greg Kroah-Hartman
Quoted 6 lines · Ronald Tschalär
This is the
dev_xxx()analog toprint_hex_dump(), usingdev_printk()instead of straightprintk()to match otherdev_xxx()logging functions.--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)No signed-off-by?
Aargh! Apologies, fixed for the future.
Quoted 3 lines
Anyway, no, please do not do this. Please do not dump large hex values like this to the kernel log, it does not help anyone.
Quoted 6 lines
Quoted 1 line
You can do this while debugging, sure, but not for "real" kernel code.
As used by this driver, it is definitely called for debugging only and must be explicitly enabled via a module param. But having the ability for folks to easily generate and print out debugging info has proven quite valuable.
We have dynamic debugging, no need for module parameters at all. This isn't the 1990's anymore :)
thanks,
greg k-h
Re: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 20 lines · Greg Kroah-Hartman
Quoted 19 lines · and then you die
Quoted 9 lines · Greg Kroah-Hartman
Quoted 6 lines · Ronald Tschalär
This is the
dev_xxx()analog toprint_hex_dump(), usingdev_printk()instead of straightprintk()to match otherdev_xxx()logging functions.--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)No signed-off-by?
Aargh! Apologies, fixed for the future.
Quoted 4 lines
Anyway, no, please do not do this. Please do not dump large hex values like this to the kernel log, it does not help anyone.
You can do this while debugging, sure, but not for "real" kernel code.
Quoted 7 lines
Quoted 4 lines
As used by this driver, it is definitely called for debugging only and must be explicitly enabled via a module param. But having the ability for folks to easily generate and print out debugging info has proven quite valuable.
We have dynamic debugging, no need for module parameters at all. This isn't the 1990's anymore :)
I am aware of dynamic debugging, but there are several issues with it from the perspective of the logging I'm doing here (I mentioned these in response to an earlier review already):
1. Dynamic debugging can't be enabled at a function or line level on the kernel command line, so this means that to debug issues during boot you have to enable everything, which can be way too verbose
2. The expressions to enable the individual logging statements are quite brittle (in particular the line-based ones) since they (may) change any time the code is changed - having stable commands to give to users and put in documentation (e.g. "echo 0x200 > /sys/module/applespi/parameters/debug") is quite valuable.
One way to work around this would be to put every single logging statement in a function of its own, thereby ensuring a stable name is associated with each one.
3. In at least two places we log different types of packets in the same lines of code (protected by a "if (log_mask & PKT_TYPE)") - dynamic-debug would only allow enabling or disabling logging of all packets. This could be worked around by creating a separate (but essentially duplicate) logging function for each packet type and some lookup table to call the appropriate one. Not very pretty IMO, though.
4. In a couple places we log both the sent command and the received response, with the log-mask determining for which types of packets to do this. With a log mask there is one bit to set to get both logged; with dynamic debugging you'd have to enable the writing and receiving parts separately (not a huge deal, but yet one place where things are a bit more complicated than necessary).
Except for the first, none of these are insurmountable, but together they don't make dynamic debugging very attractive for this sort of logging.
Cheers,
Ronald
Greg Kroah-Hartman
maintainerRe: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 30 lines · and then you die
Quoted 20 lines · Greg Kroah-Hartman
Quoted 19 lines · and then you die
Quoted 9 lines · Greg Kroah-Hartman
Quoted 6 lines · Ronald Tschalär
This is the
dev_xxx()analog toprint_hex_dump(), usingdev_printk()instead of straightprintk()to match otherdev_xxx()logging functions.--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)No signed-off-by?
Aargh! Apologies, fixed for the future.
Quoted 4 lines
Anyway, no, please do not do this. Please do not dump large hex values like this to the kernel log, it does not help anyone.
You can do this while debugging, sure, but not for "real" kernel code.
Quoted 7 lines
Quoted 4 lines
As used by this driver, it is definitely called for debugging only and must be explicitly enabled via a module param. But having the ability for folks to easily generate and print out debugging info has proven quite valuable.
We have dynamic debugging, no need for module parameters at all. This isn't the 1990's anymore :)
Quoted 8 lines
I am aware of dynamic debugging, but there are several issues with it from the perspective of the logging I'm doing here (I mentioned these in response to an earlier review already):
1. Dynamic debugging can't be enabled at a function or line level on the kernel command line, so this means that to debug issues during boot you have to enable everything, which can be way too verbose
You can, and should enable it at a function or line level by writing to the proper kernel file in debugfs.
You have read Documentation/admin-guide/dynamic-debug-howto.rst, right?
No need to do anything on the command line, that's so old-school :)
Quoted 10 lines
2. The expressions to enable the individual logging statements are quite brittle (in particular the line-based ones) since they (may) change any time the code is changed - having stable commands to give to users and put in documentation (e.g. "echo
0x200>/sys/module/applespi/parameters/debug") is quite valuable.One way to work around this would be to put every single logging statement in a function of its own, thereby ensuring a stable name is associated with each one.
Again, read the documentation, this works today as-is.
Quoted 7 lines
3. In at least two places we log different types of packets in the same lines of code (protected by a "if (
log_mask&PKT_TYPE)") - dynamic-debug would only allow enabling or disabling logging of all packets. This could be worked around by creating a separate (but essentially duplicate) logging function for each packet type and some lookup table to call the appropriate one. Not very pretty IMO, though.
True, but you can use tracepoints as well, that would probably be much easier when you are logging data streams. You can also use an ebpf program with the tracepoints to log just what you need/want to when you want to as well.
Quoted 11 lines
4. In a couple places we log both the sent command and the received response, with the log-mask determining for which types of packets to do this. With a log mask there is one bit to set to get both logged; with dynamic debugging you'd have to enable the writing and receiving parts separately (not a huge deal, but yet one place where things are a bit more complicated than necessary).
Except for the first, none of these are insurmountable, but together they don't make dynamic debugging very attractive for this sort of logging.
Look into it some more, we have all of this covered today, no need for just a single driver to do something fancy on its own :)
thanks,
greg k-h
Steven Rostedt
reviewerRe: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 8 lines · On Thu, 28 Mar 2019 12:29:52 +0100 Greg Kroah-Hartman…
Quoted 7 lines
3. In at least two places we log different types of packets in the same lines of code (protected by a "if (
log_mask&PKT_TYPE)") - dynamic-debug would only allow enabling or disabling logging of all packets. This could be worked around by creating a separate (but essentially duplicate) logging function for each packet type and some lookup table to call the appropriate one. Not very pretty IMO, though.
Quoted 4 lines
True, but you can use tracepoints as well, that would probably be much easier when you are logging data streams. You can also use an ebpf program with the tracepoints to log just what you need/want to when you want to as well.
And tracepoints have filters where you don't even need ebpf to do such filtering.
See Documentation/trace/events.rst Section 5: Event Filtering
-- Steve
Re: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
In reply to Greg Kroah-HartmanQuoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · and then you die
Quoted 10 lines · Greg Kroah-Hartman
Quoted 9 lines · and then you die
Quoted 7 lines · Greg Kroah-Hartman
Quoted 6 lines · Ronald Tschalär
This is the
dev_xxx()analog toprint_hex_dump(), usingdev_printk()instead of straightprintk()to match otherdev_xxx()logging functions.--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)
[snip]
Quoted 22 lines
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Anyway, no, please do not do this. Please do not dump large hex values like this to the kernel log, it does not help anyone.
You can do this while debugging, sure, but not for "real" kernel code.
Quoted 7 lines
Quoted 4 lines
As used by this driver, it is definitely called for debugging only and must be explicitly enabled via a module param. But having the ability for folks to easily generate and print out debugging info has proven quite valuable.
We have dynamic debugging, no need for module parameters at all. This isn't the 1990's anymore :)
Quoted 8 lines
I am aware of dynamic debugging, but there are several issues with it from the perspective of the logging I'm doing here (I mentioned these in response to an earlier review already):
1. Dynamic debugging can't be enabled at a function or line level on the kernel command line, so this means that to debug issues during boot you have to enable everything, which can be way too verbose
Quoted 4 lines
You can, and should enable it at a function or line level by writing to the proper kernel file in debugfs.
You have read
Documentation/admin-guide/dynamic-debug-howto.rst, right?
Yes, and I've played with the parameters quite a bit.
Quoted 1 line
No need to do anything on the command line, that's so old-school :)
Sorry if I'm being unduly dense, but then how to enable debugging during early boot? The only other alternative I see is modifying the initrd, and asking folks to do that is noticeably more complicated than having them add something to the command line in grub. So from my perspective I find kernel params far from old-school :-)
Quoted 7 lines
Quoted 7 lines
2. The expressions to enable the individual logging statements are quite brittle (in particular the line-based ones) since they (may) change any time the code is changed - having stable commands to give to users and put in documentation (e.g. "echo
0x200>/sys/module/applespi/parameters/debug") is quite valuable.
Quoted 5 lines
Quoted 3 lines
One way to work around this would be to put every single logging statement in a function of its own, thereby ensuring a stable name is associated with each one.
Again, read the documentation, this works today as-is.
I have read it (we're talking about the dynamic debug docs here), but I just don't see how it addresses this in any way.
Quoted 8 lines
Quoted 7 lines
3. In at least two places we log different types of packets in the same lines of code (protected by a "if (
log_mask&PKT_TYPE)") - dynamic-debug would only allow enabling or disabling logging of all packets. This could be worked around by creating a separate (but essentially duplicate) logging function for each packet type and some lookup table to call the appropriate one. Not very pretty IMO, though.
Quoted 4 lines
True, but you can use tracepoints as well, that would probably be much easier when you are logging data streams. You can also use an ebpf program with the tracepoints to log just what you need/want to when you want to as well.
Thanks for the hint, I hadn't paid much attention to tracepoints till now. They do solve most of these issues I've mentioned here, though. So I've actually gone and implemented the tracing as tracepoints now. Two issues I noticed though:
1. since filters can't be enabled on the command line (and yes, we seem to disagree on the usefulness of the command line) it means I had to essentially create tracepoints for every trace+filter combo I may want to enable (in my case it's just one field, so I ended up with 8 tracepoints instead of 1). Not a big deal in my case, but could get ugly.
2. in cases where there is relevant log output too, folks have to be told to provide both trace and dmesg output, the outputs have to merged back together again. Though I note that with the use of the tp_printk kernel param this inconvenience goes away again (but we're back to logging the traces in the kernel log :-) ).
Quoted 8 lines
Quoted 8 lines
4. In a couple places we log both the sent command and the received response, with the log-mask determining for which types of packets to do this. With a log mask there is one bit to set to get both logged; with dynamic debugging you'd have to enable the writing and receiving parts separately (not a huge deal, but yet one place where things are a bit more complicated than necessary).
Quoted 6 lines
Quoted 3 lines
Except for the first, none of these are insurmountable, but together they don't make dynamic debugging very attractive for this sort of logging.
Look into it some more, we have all of this covered today, no need for just a single driver to do something fancy on its own :)
The tracepoints do indeed cover this too.
Cheers,
Ronald
Greg Kroah-Hartman
maintainerRe: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 45 lines · and then you die
Quoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · and then you die
Quoted 10 lines · Greg Kroah-Hartman
Quoted 9 lines · and then you die
Quoted 7 lines · Greg Kroah-Hartman
Quoted 6 lines · Ronald Tschalär
This is the
dev_xxx()analog toprint_hex_dump(), usingdev_printk()instead of straightprintk()to match otherdev_xxx()logging functions.--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)[snip]
Quoted 22 lines
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Anyway, no, please do not do this. Please do not dump large hex values like this to the kernel log, it does not help anyone.
You can do this while debugging, sure, but not for "real" kernel code.
Quoted 7 lines
Quoted 4 lines
As used by this driver, it is definitely called for debugging only and must be explicitly enabled via a module param. But having the ability for folks to easily generate and print out debugging info has proven quite valuable.
We have dynamic debugging, no need for module parameters at all. This isn't the 1990's anymore :)
Quoted 8 lines
I am aware of dynamic debugging, but there are several issues with it from the perspective of the logging I'm doing here (I mentioned these in response to an earlier review already):
1. Dynamic debugging can't be enabled at a function or line level on the kernel command line, so this means that to debug issues during boot you have to enable everything, which can be way too verbose
Quoted 4 lines
You can, and should enable it at a function or line level by writing to the proper kernel file in debugfs.
You have read
Documentation/admin-guide/dynamic-debug-howto.rst, right?Yes, and I've played with the parameters quite a bit.
Quoted 7 lines
Quoted 1 line
No need to do anything on the command line, that's so old-school :)
Sorry if I'm being unduly dense, but then how to enable debugging during early boot? The only other alternative I see is modifying the initrd, and asking folks to do that is noticeably more complicated than having them add something to the command line in grub. So from my perspective I find kernel params far from old-school :-)
You can do dynamic debugging from the kernel command line, if your code is built into the kernel (but why would a tiny driver under testing like this, not be built into the kernel?) what specifically did not work for you?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
2. The expressions to enable the individual logging statements are quite brittle (in particular the line-based ones) since they (may) change any time the code is changed - having stable commands to give to users and put in documentation (e.g. "echo
0x200>/sys/module/applespi/parameters/debug") is quite valuable.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
One way to work around this would be to put every single logging statement in a function of its own, thereby ensuring a stable name is associated with each one.
Again, read the documentation, this works today as-is.
I have read it (we're talking about the dynamic debug docs here), but I just don't see how it addresses this in any way.
You can enable/disable logging per-function, which is what you want, right?
Anyway, I'm glad tracepoints work for you, that should be all that is now needed.
good luck with your driver!
greg k-h
Re: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 55 lines · and then you die
Quoted 45 lines · Greg Kroah-Hartman
Quoted 13 lines · and then you die
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · and then you die
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Ronald Tschalär
Quoted 6 lines
This is the
dev_xxx()analog toprint_hex_dump(), usingdev_printk()instead of straightprintk()to match otherdev_xxx()logging functions.--- drivers/base/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+)[snip]
Quoted 22 lines
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Anyway, no, please do not do this. Please do not dump large hex values like this to the kernel log, it does not help anyone.
You can do this while debugging, sure, but not for "real" kernel code.
Quoted 7 lines
Quoted 4 lines
As used by this driver, it is definitely called for debugging only and must be explicitly enabled via a module param. But having the ability for folks to easily generate and print out debugging info has proven quite valuable.
We have dynamic debugging, no need for module parameters at all. This isn't the 1990's anymore :)
Quoted 8 lines
I am aware of dynamic debugging, but there are several issues with it from the perspective of the logging I'm doing here (I mentioned these in response to an earlier review already):
1. Dynamic debugging can't be enabled at a function or line level on the kernel command line, so this means that to debug issues during boot you have to enable everything, which can be way too verbose
Quoted 4 lines
You can, and should enable it at a function or line level by writing to the proper kernel file in debugfs.
You have read
Documentation/admin-guide/dynamic-debug-howto.rst, right?Yes, and I've played with the parameters quite a bit.
Quoted 7 lines
Quoted 1 line
No need to do anything on the command line, that's so old-school :)
Sorry if I'm being unduly dense, but then how to enable debugging during early boot? The only other alternative I see is modifying the initrd, and asking folks to do that is noticeably more complicated than having them add something to the command line in grub. So from my perspective I find kernel params far from old-school :-)
Quoted 3 lines
You can do dynamic debugging from the kernel command line, if your code is built into the kernel (but why would a tiny driver under testing like this, not be built into the kernel?) what specifically did not work for you?
This may be part of our disconnect: there's almost no reason (and several downsides) to building it into the kernel instead of as a module:
- When developing, being able to just reload the module instead of rebooting is just so much faster and more convenient.
- For other users, having them build the driver as a dkms managed module is also by far the simplest and least error-prone approach - explaning to users how to rebuild their kernel (something most of them have never done) takes a bunch of time and effort on both sides for essentially no gain.
- Once the driver is part of the regular kernel, practically all distro's will build it as a module (at least I'm fairly certain about this).
In the case where a problem happens during early boot, if I can reproduce myself then of course I can build the driver into the kernel and debug it; but if I need others to test/debug things, then this is a much harder sell.
In my experience, every time you make something even a little harder for a user to do, the chance of them doing it and you getting useful feedback goes down exponentially and the amount of work you need to do to handhold them goes up significantly. So I think it's absolutely vital to try and keep things as simple as possible.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
2. The expressions to enable the individual logging statements are quite brittle (in particular the line-based ones) since they (may) change any time the code is changed - having stable commands to give to users and put in documentation (e.g. "echo
0x200>/sys/module/applespi/parameters/debug") is quite valuable.One way to work around this would be to put every single logging statement in a function of its own, thereby ensuring a stable name is associated with each one.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Again, read the documentation, this works today as-is.
I have read it (we're talking about the dynamic debug docs here), but I just don't see how it addresses this in any way.
You can enable/disable logging per-function, which is what you want, right?
Yes'ish: the problem is that if they are just part of regular functions, A) the chances are higher that the function may get renamed and hence any existing debug instructions broken, and B) this doesn't work if there are multiple debug statements in a function. Hence my assertion that for this work well (and yes, it can work well) you basically need to create a separate function for each debug statement (which that contains just that debug statement) (a sort of stable labelling of each debug statement).
Cheers,
Ronald
Re: [PATCH v3 3/4] driver core: add dev_print_hex_dump() logging function.
Quoted 12 lines · and then you die
Quoted 11 lines · and then you die
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · and then you die
Quoted 4 lines · Greg Kroah-Hartman
Quoted 3 lines · and then you die
Quoted 2 lines · Greg Kroah-Hartman
Quoted 1 line · Ronald Tschalär
You can do dynamic debugging from the kernel command line, if your code is built into the kernel (but why would a tiny driver under testing like this, not be built into the kernel?) what specifically did not work for you?
Quoted 6 lines
This may be part of our disconnect: there's almost no reason (and several downsides) to building it into the kernel instead of as a module:
- When developing, being able to just reload the module instead of rebooting is just so much faster and more convenient.
modprobe -r foo
modprobe foo dyndbg=...
Not an argument.
Quoted 9 lines
- For other users, having them build the driver as a dkms managed module is also by far the simplest and least error-prone approach - explaning to users how to rebuild their kernel (something most of them have never done) takes a bunch of time and effort on both sides for essentially no gain.
- Once the driver is part of the regular kernel, practically all distro's will build it as a module (at least I'm fairly certain about this).
Above seems a sub-items to the first one. So, reloading module with dyndbg parameter is quite flexible. What else?
Quoted 11 lines
Quoted 2 lines
You can enable/disable logging per-function, which is what you want, right?
Yes'ish: the problem is that if they are just part of regular functions, A) the chances are higher that the function may get renamed and hence any existing debug instructions broken, and B) this doesn't work if there are multiple debug statements in a function. Hence my assertion that for this work well (and yes, it can work well) you basically need to create a separate function for each debug statement (which that contains just that debug statement) (a sort of stable labelling of each debug statement).
I guess you tried and have an examples?
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 4/4 Input: add Apple SPI keyboard and trackpad driver.
In reply to Ronald TschalärThe keyboard and trackpad on recent MacBook's (since 8,1) and MacBookPro's (13,* and 14,*) are attached to an SPI controller instead of USB, as previously. The higher level protocol is not publicly documented and hence has been reverse engineered. As a consequence there are still a number of unknown fields and commands. However, the known parts have been working well and received extensive testing and use.
In order for this driver to work, the proper SPI drivers need to be loaded too; for MB8,1 these are spi_pxa2xx_platform and spi_pxa2xx_pci; for all others they are spi_pxa2xx_platform and intel_lpss_pci. For this reason enabling this driver in the config implies enabling the above drivers.
--- drivers/input/keyboard/Kconfig | 15 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/applespi.c | 1988 +++++++++++++++++++++++++++++ 3 files changed, 2004 insertions(+) create mode 100644 drivers/input/keyboard/applespi.c
drivers/input/keyboard/Kconfig +15 -0
@@ -70,6 +70,21 @@ config KEYBOARD_AMIGA config ATARI_KBD_CORE bool +config KEYBOARD_APPLESPI + tristate "Apple SPI keyboard and trackpad" + depends on ACPI && EFI + depends on SPI + depends on X86 || COMPILE_TEST + imply SPI_PXA2XX + imply SPI_PXA2XX_PCI + imply MFD_INTEL_LPSS_PCI + help + Say Y here if you are running Linux on any Apple MacBook8,1 or later, + or any MacBookPro13,* or MacBookPro14,*. + + To compile this driver as a module, choose M here: the + module will be called applespi. + config KEYBOARD_ATARI tristate "Atari keyboard" depends on ATARI
drivers/input/keyboard/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_KEYBOARD_ADP5520) += adp5520-keys.o obj-$(CONFIG_KEYBOARD_ADP5588) += adp5588-keys.o obj-$(CONFIG_KEYBOARD_ADP5589) += adp5589-keys.o obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o +obj-$(CONFIG_KEYBOARD_APPLESPI) += applespi.o obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o obj-$(CONFIG_KEYBOARD_BCM) += bcm-keypad.o
drivers/input/keyboard/applespi.c new file +1988 -0
1,988 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v3 4/4] Input: add Apple SPI keyboard and trackpad driver.
Quoted 7 lines · Ronald Tschalär
The keyboard and trackpad on recent MacBook's (since 8,1) and MacBookPro's (13,* and 14,*) are attached to an SPI controller instead of USB, as previously. The higher level protocol is not publicly documented and hence has been reverse engineered. As a consequence there are still a number of unknown fields and commands. However, the known parts have been working well and received extensive testing and use.
Quoted 7 lines
In order for this driver to work, the proper SPI drivers need to be loaded too; for MB8,1 these are
spi_pxa2xx_platformandspi_pxa2xx_pci; for all others they arespi_pxa2xx_platformandintel_lpss_pci. For this reason enabling this driver in the config implies enabling the above drivers.+// SPDX-License-Identifier: GPL-2.0
According to last changes this should be GPL-2.0-only
Quoted 9 lines
+ */
drivers/input/keyboard/applespi.c new file +8
-0+ +#include <linux/acpi.h> +#include <linux/crc16.h> +#include <linux/delay.h> +#include <linux/efi.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/ktime.h>
drivers/input/keyboard/applespi.c line 59
Quoted 10 lines
drivers/input/keyboard/applespi.c new file +9
-0+#include <linux/leds.h> +#include <linux/module.h> +#include <linux/spinlock.h> +#include <linux/spi/spi.h> +#include <linux/wait.h> +#include <linux/workqueue.h> + +#include <asm/barrier.h> +#include <asm-generic/unaligned.h>
generic?!
#include <asm/unaligned.h>
should work.
Quoted 14 lines
drivers/input/keyboard/applespi.c new file +14
-0+static const char *applespi_debug_facility (unsigned int log_mask) +{ +switch (log_mask) { +case DBG_CMD_TP_INI : +return "Touchpad Initialization" ; +case DBG_CMD_BL : +return "Backlight Command" ; +case DBG_CMD_CL : +return "Caps-Lock Command" ; +case DBG_RD_KEYB : +return "Keyboard Event" ; +case DBG_RD_TPAD : +return "Touchpad Event" ; +case DBG_RD_UNKN :
drivers/input/keyboard/applespi.c line 559
Quoted 10 lines
drivers/input/keyboard/applespi.c new file +9
-0+return "Unknown Event" ; +case DBG_RD_IRQ : +return "Interrupt Request" ; +case DBG_RD_CRC : +return "Corrupted packet" ; +case DBG_TP_DIM : +return "Touchpad Dimensions" ; +default : +return "-Unrecognized log mask-" ;
I don't think '-' surroundings are needed, but this is rather minor. Up to you.
Quoted 2 lines
(quoted diff) +2
-0+ } +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Greg Kroah-Hartman
maintainerRe: [PATCH v3 4/4] Input: add Apple SPI keyboard and trackpad driver.
Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Ronald Tschalär
The keyboard and trackpad on recent MacBook's (since 8,1) and MacBookPro's (13,* and 14,*) are attached to an SPI controller instead of USB, as previously. The higher level protocol is not publicly documented and hence has been reverse engineered. As a consequence there are still a number of unknown fields and commands. However, the known parts have been working well and received extensive testing and use.
In order for this driver to work, the proper SPI drivers need to be loaded too; for MB8,1 these are
spi_pxa2xx_platformandspi_pxa2xx_pci; for all others they arespi_pxa2xx_platformandintel_lpss_pci. For this reason enabling this driver in the config implies enabling the above drivers.
Quoted 3 lines
Quoted 1 line
+// SPDX-License-Identifier: GPL-2.0
According to last changes this should be GPL-2.0-only
What "last changes"? "GPL-2.0" is a totally valid SPDX identifier for the kernel. Don't buy into the "-only" prefix crud that the newer SPDX version adopted for crazy reasons. The in-kernel documentation lists the valid identifiers and the version of SPDX we are currently using.
thanks,
greg k-h
Steven Rostedt
reviewerRe: [PATCH v3 4/4] Input: add Apple SPI keyboard and trackpad driver.
Quoted 8 lines · On Wed, 27 Mar 2019 19:45:26 +0100 Greg Kroah-Hartman…
Quoted 3 lines
Quoted 1 line
+// SPDX-License-Identifier: GPL-2.0
According to last changes this should be GPL-2.0-only
What "last changes"? "GPL-2.0" is a totally valid SPDX identifier for the kernel. Don't buy into the "-only" prefix crud that the newer SPDX version adopted for crazy reasons. The in-kernel documentation lists the valid identifiers and the version of SPDX we are currently using.
According to: LICENSES/preferred/GPL-2.0
Quoted 5 lines
SPDX-URL: https://spdx.org/licenses/GPL-2.0.html
Usage-Guide:
To use this license in source code, put one of the following SPDX tag/value pairs into a comment according to the placement guidelines in the licensing rules documentation.
Quoted 8 lines
For 'GNU General Public License (GPL) version 2 only' use:
SPDX-License-Identifier: GPL-2.0
or
SPDX-License-Identifier: GPL-2.0-only
For 'GNU General Public License (GPL) version 2 or any later version' use:
SPDX-License-Identifier: GPL-2.0+
or
SPDX-License-Identifier: GPL-2.0-or-later
So, GPL-2.0 is the same as GPL-2.0-only. Changing it from one to the other doesn't make any difference.
-- Steve
Re: [PATCH v3 4/4] Input: add Apple SPI keyboard and trackpad driver.
In reply to Greg Kroah-HartmanQuoted 15 lines · Greg Kroah-Hartman
Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Ronald Tschalär
The keyboard and trackpad on recent MacBook's (since 8,1) and MacBookPro's (13,* and 14,*) are attached to an SPI controller instead of USB, as previously. The higher level protocol is not publicly documented and hence has been reverse engineered. As a consequence there are still a number of unknown fields and commands. However, the known parts have been working well and received extensive testing and use.
In order for this driver to work, the proper SPI drivers need to be loaded too; for MB8,1 these are
spi_pxa2xx_platformandspi_pxa2xx_pci; for all others they arespi_pxa2xx_platformandintel_lpss_pci. For this reason enabling this driver in the config implies enabling the above drivers.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
+// SPDX-License-Identifier: GPL-2.0
According to last changes this should be GPL-2.0-only
What "last changes"? "GPL-2.0" is a totally valid SPDX identifier for the kernel. Don't buy into the "-only" prefix crud that the newer SPDX version adopted for crazy reasons. The in-kernel documentation lists the valid identifiers and the version of SPDX we are currently using.
Thanks for this clarification.
// offtopic
Bartosz, so, it seems my first mail has been a correct one: in-kernel documentation clarifies things for kernel.
// offtopic
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 4/4] Input: add Apple SPI keyboard and trackpad driver.
In reply to Andy ShevchenkoQuoted 7 lines · Andy Shevchenko
Quoted 6 lines · Ronald Tschalär
The keyboard and trackpad on recent MacBook's (since 8,1) and MacBookPro's (13,* and 14,*) are attached to an SPI controller instead of USB, as previously. The higher level protocol is not publicly documented and hence has been reverse engineered. As a consequence there are still a number of unknown fields and commands. However, the known parts have been working well and received extensive testing and use.
[snip]
Quoted 8 lines
drivers/input/keyboard/applespi.c line 59
Quoted 3 lines
drivers/input/keyboard/applespi.c new file +2
-0+#include <asm/barrier.h> +#include <asm-generic/unaligned.h> generic?!
#include <
asm/unaligned.h>
should work.
Yes, you're right. I brought myself up-to-speed now on the difference between the two.
Quoted 23 lines
Quoted 22 lines
drivers/input/keyboard/applespi.c new file +22
-0+static const char *applespi_debug_facility (unsigned int log_mask) +{ +switch (log_mask) { +case DBG_CMD_TP_INI : +return "Touchpad Initialization" ; +case DBG_CMD_BL : +return "Backlight Command" ; +case DBG_CMD_CL : +return "Caps-Lock Command" ; +case DBG_RD_KEYB : +return "Keyboard Event" ; +case DBG_RD_TPAD : +return "Touchpad Event" ; +case DBG_RD_UNKN : +return "Unknown Event" ; +case DBG_RD_IRQ : +return "Interrupt Request" ; +case DBG_RD_CRC : +return "Corrupted packet" ; +case DBG_TP_DIM : +return "Touchpad Dimensions" ; +default :
Quoted 3 lines
drivers/input/keyboard/applespi.c line 559
Quoted 1 line
drivers/input/keyboard/applespi.c new file +1
-0+return "-Unrecognized log mask-" ;I don't think '-' surroundings are needed, but this is rather minor. Up to you.
I've used that to distinguish an error value from normal values; but that's not an idiom used in the kernel AFAICT, so I'll remove them.
Thanks.
Cheers,
Ronald