From c7fe1a2685a88383d0a69df5358ac42650d5f327 Mon Sep 17 00:00:00 2001 From: Simo Piiroinen Date: Tue, 25 Apr 2017 20:43:55 +0300 Subject: [PATCH] [modesetting] Do not use "none" as usb function Use of "none" string as no-usb-function place holder causes journal spamming as kernels are likely to return EINVAL error when it is actually used. Substitute "none" with empty string when written to usb function control file. Signed-off-by: Simo Piiroinen --- src/usb_moded-modesetting.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/usb_moded-modesetting.c b/src/usb_moded-modesetting.c index 586e72f..31445ca 100644 --- a/src/usb_moded-modesetting.c +++ b/src/usb_moded-modesetting.c @@ -116,6 +116,16 @@ int write_to_file(const char *path, const char *text) if(!text || !path) return err; + /* There is usb-moded code and configuration files that use + * "none" as a place-holder for no-function. Attempting to + * write that into sysfs leads to journal spamming due to + * EINVAL error return. Substituting "none" with an empty + * string avoids that. */ + if( !strcmp(path, "/sys/class/android_usb/android0/functions") && + !strcmp(text, "none") ) { + text = ""; + } + #if LOG_ENABLE_DEBUG if(log_level >= LOG_DEBUG) {