Skip to content

Commit

Permalink
ipts: Move debugging settings into modparams
Browse files Browse the repository at this point in the history
Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
  • Loading branch information
StollD committed Nov 7, 2019
1 parent b7c60a6 commit ec34a39
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 35 deletions.
1 change: 1 addition & 0 deletions drivers/misc/ipts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#

obj-$(CONFIG_INTEL_IPTS)+= intel-ipts.o
intel-ipts-objs += ipts.o
intel-ipts-objs += ipts-companion.o
intel-ipts-objs += ipts-mei.o
intel-ipts-objs += ipts-hid.o
Expand Down
19 changes: 7 additions & 12 deletions drivers/misc/ipts/ipts-gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

#include "ipts.h"
#include "ipts-msg-handler.h"
#include "ipts-params.h"
#include "ipts-state.h"
#include "../mei/mei_dev.h"

static void gfx_processing_complete(void *data)
{
Expand Down Expand Up @@ -60,10 +62,6 @@ static void disconnect_gfx(struct ipts_info *ipts)
ipts_disconnect(ipts->gfx_info.gfx_handle);
}

#ifdef RUN_DBG_THREAD

#include "../mei/mei_dev.h"

static struct task_struct *dbg_thread;

// TODO: Document the meaning of the values (Arda Coskunses comment on Github)
Expand Down Expand Up @@ -107,8 +105,6 @@ static int ipts_dbg_thread(void *data)
return 0;
}

#endif

int ipts_open_gpu(struct ipts_info *ipts)
{
int ret = 0;
Expand All @@ -126,9 +122,9 @@ int ipts_open_gpu(struct ipts_info *ipts)
return ret;
}

#ifdef RUN_DBG_THREAD
dbg_thread = kthread_run(ipts_dbg_thread, (void *)ipts, "ipts_debug");
#endif
if (ipts_modparams.debug_thread)
dbg_thread = kthread_run(
ipts_dbg_thread, (void *)ipts, "ipts_debug");

return 0;
}
Expand All @@ -137,9 +133,8 @@ void ipts_close_gpu(struct ipts_info *ipts)
{
disconnect_gfx(ipts);

#ifdef RUN_DBG_THREAD
kthread_stop(dbg_thread);
#endif
if (ipts_modparams.debug_thread)
kthread_stop(dbg_thread);
}

struct ipts_mapbuffer *ipts_map_buffer(struct ipts_info *ipts,
Expand Down
11 changes: 11 additions & 0 deletions drivers/misc/ipts/ipts-params.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ struct ipts_params ipts_modparams = {
.ignore_config_fallback = false,
.ignore_companion = false,
.no_feedback = -1,

.debug = false,
.debug_thread = false,
};

IPTS_PARAM(ignore_fw_fallback, bool, 0400,
Expand All @@ -33,3 +36,11 @@ IPTS_PARAM(ignore_companion, bool, 0400,
IPTS_PARAM(no_feedback, int, 0644,
"Disable sending feedback to ME (can prevent crashes on Skylake). (-1=auto [default], 0=false, 1=true)"
);

IPTS_PARAM(debug, bool, 0400,
"Enable IPTS debugging output. (default: false)"
);
IPTS_PARAM(debug_thread, bool, 0400,
"Periodically print the ME status into the kernel log. (default: false)"
);

3 changes: 3 additions & 0 deletions drivers/misc/ipts/ipts-params.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ struct ipts_params {
bool ignore_config_fallback;
bool ignore_companion;
int no_feedback;

bool debug;
bool debug_thread;
};

extern struct ipts_params ipts_modparams;
Expand Down
62 changes: 62 additions & 0 deletions drivers/misc/ipts/ipts.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
*
* Intel Precise Touch & Stylus
* Copyright (c) 2016 Intel Corporation
*
*/

#include <linux/device.h>
#include <stdarg.h>

#include "ipts.h"
#include "ipts-params.h"

static void ipts_printk(const char *level, const struct device *dev,
struct va_format *vaf)
{
if (dev) {
dev_printk_emit(level[1] - '0', dev, "%s %s: %pV",
dev_driver_string(dev), dev_name(dev), vaf);
} else {
// checkpatch wants this to be prefixed with KERN_*, but
// since the level is passed as a parameter, ignore it
printk("%s(NULL device *): %pV", level, vaf);
}
}

void ipts_info(struct ipts_info *ipts, const char *fmt, ...)
{
va_list args;
struct va_format vaf;

if (!ipts_modparams.debug)
return;

va_start(args, fmt);

vaf.fmt = fmt;
vaf.va = &args;

ipts_printk(KERN_INFO, &ipts->cldev->dev, &vaf);

va_end(args);
}

void ipts_dbg(struct ipts_info *ipts, const char *fmt, ...)
{
va_list args;
struct va_format vaf;

if (!ipts_modparams.debug)
return;

va_start(args, fmt);

vaf.fmt = fmt;
vaf.va = &args;

ipts_printk(KERN_DEBUG, &ipts->cldev->dev, &vaf);

va_end(args);
}
30 changes: 7 additions & 23 deletions drivers/misc/ipts/ipts.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,6 @@
#include "ipts-mei-msgs.h"
#include "ipts-state.h"

// Enable IPTS debug
#define ENABLE_IPTS_DEBUG

#ifdef ENABLE_IPTS_DEBUG

#define ipts_info(ipts, format, arg...) \
dev_info(&ipts->cldev->dev, format, ##arg)

#define ipts_dbg(ipts, format, arg...) \
dev_info(&ipts->cldev->dev, format, ##arg)

// #define RUN_DBG_THREAD

#else

#define ipts_info(ipts, format, arg...) do {} while (0)
#define ipts_dbg(ipts, format, arg...) do {} while (0)

#endif

#define ipts_err(ipts, format, arg...) \
dev_err(&ipts->cldev->dev, format, ##arg)

#define HID_PARALLEL_DATA_BUFFERS TOUCH_SENSOR_MAX_DATA_BUFFERS

#define IPTS_MAX_RETRY 3
Expand Down Expand Up @@ -126,6 +103,13 @@ static int ipts_dbgfs_register(struct ipts_info *ipts, const char *name);
static void ipts_dbgfs_deregister(struct ipts_info *ipts);
#endif

void ipts_info(struct ipts_info *ipts, const char *fmt, ...);
void ipts_dbg(struct ipts_info *ipts, const char *fmt, ...);

// Because ipts_err is unconditional, this can stay a macro for now
#define ipts_err(ipts, format, arg...) \
dev_err(&ipts->cldev->dev, format, ##arg)

/*
* Inline functions
*/
Expand Down

0 comments on commit ec34a39

Please sign in to comment.