Skip to content
Permalink
Browse files
[modesetting] Log origin of sysfs writes in debug verbosity. JB#38433
When debugging configuration issues, it is sometimes hard to tell where the
various sysfs control writes are made from.

To ease debugging, log also call site when logging sysfs writes.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Apr 26, 2017
1 parent e1dc87e commit 7107bf5d4dfaef0b558e5205202e4faf3e2c0d65
Showing with 10 additions and 3 deletions.
  1. +5 −2 src/usb_moded-modesetting.c
  2. +5 −1 src/usb_moded-modesetting.h
@@ -105,7 +105,8 @@ static char *read_from_file(const char *path, size_t maxsize)
}
#endif /* LOG_ENABLE_DEBUG */

int write_to_file(const char *path, const char *text)
int write_to_file_real(const char *file, int line, const char *func,
const char *path, const char *text)
{
int err = -1;
int fd = -1;
@@ -130,7 +131,9 @@ int write_to_file(const char *path, const char *text)
if(log_level >= LOG_DEBUG)
{
char *prev = read_from_file(path, 0x1000);
log_debug("WRITE '%s' : '%s' --> '%s'", path, prev ?: "???", text);
log_debug("%s:%d: %s(): WRITE '%s' : '%s' --> '%s'",
file, line, func,
path, prev ?: "???", text);
free(prev);
}
#endif
@@ -22,7 +22,11 @@

#include "usb_moded-dyn-config.h"

int write_to_file(const char *path, const char *text);
int write_to_file_real(const char *file, int line, const char *func, const char *path, const char *text);

#define write_to_file(path,text)\
write_to_file_real(__FILE__,__LINE__,__FUNCTION__,(path),(text))

int set_mtp_mode(void);
int set_dynamic_mode(void);
void unset_dynamic_mode(void);

0 comments on commit 7107bf5

Please sign in to comment.