Navigation Menu

Skip to content

Commit

Permalink
[modesetting] Log origin of sysfs writes in debug verbosity. JB#38433
Browse files Browse the repository at this point in the history
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 7107bf5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/usb_moded-modesetting.c
Expand Up @@ -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;
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/usb_moded-modesetting.h
Expand Up @@ -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);
Expand Down

0 comments on commit 7107bf5

Please sign in to comment.