From 938d0071573c5f83da87cc607bebea1e5b4e52b6 Mon Sep 17 00:00:00 2001 From: Corentin Labbe Date: Thu, 15 Dec 2016 16:27:11 +0100 Subject: HID: intel-ish-hid: Remove unneeded linux/miscdevice.h include hid/intel-ish-hid does not use any miscdevice so this patch remove this unnecessary inclusion. Signed-off-by: Corentin Labbe Acked-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- drivers/hid/intel-ish-hid/ipc/pci-ish.c | 1 - drivers/hid/intel-ish-hid/ishtp/hbm.c | 1 - drivers/hid/intel-ish-hid/ishtp/init.c | 1 - 3 files changed, 3 deletions(-) (limited to 'drivers/hid/intel-ish-hid') diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c index 20d647d2dd2c..d20da39c696c 100644 --- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c +++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c @@ -24,7 +24,6 @@ #include #include #include -#include #define CREATE_TRACE_POINTS #include #include "ishtp-dev.h" diff --git a/drivers/hid/intel-ish-hid/ishtp/hbm.c b/drivers/hid/intel-ish-hid/ishtp/hbm.c index 59460b66e689..b7213608ce43 100644 --- a/drivers/hid/intel-ish-hid/ishtp/hbm.c +++ b/drivers/hid/intel-ish-hid/ishtp/hbm.c @@ -19,7 +19,6 @@ #include #include #include -#include #include "ishtp-dev.h" #include "hbm.h" #include "client.h" diff --git a/drivers/hid/intel-ish-hid/ishtp/init.c b/drivers/hid/intel-ish-hid/ishtp/init.c index ac364418e17c..d27e03526acd 100644 --- a/drivers/hid/intel-ish-hid/ishtp/init.c +++ b/drivers/hid/intel-ish-hid/ishtp/init.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "ishtp-dev.h" #include "hbm.h" #include "client.h" -- cgit From 0aae34fa314d7dedfe756ab81787df7944de0df6 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Thu, 22 Dec 2016 11:09:09 +0100 Subject: HID: intel-ish-hid: add printf attribute to print_log() Structure ishtp_device contains a logging function, print_log(), which formats some of its parameters using vsnprintf(). Add a __printf attribute to this function field (and to ish_event_tracer()) in order to detect at compile time issues related to the printf-like formatting. While at it, make format parameter a const pointer as print_log() is not supposed to modify it. Signed-off-by: Nicolas Iooss Acked-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- drivers/hid/intel-ish-hid/ipc/pci-ish.c | 3 ++- drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/hid/intel-ish-hid') diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c index 20d647d2dd2c..34c95de6885e 100644 --- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c +++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c @@ -47,7 +47,8 @@ MODULE_DEVICE_TABLE(pci, ish_pci_tbl); * * Callback to direct log messages to Linux trace buffers */ -static void ish_event_tracer(struct ishtp_device *dev, char *format, ...) +static __printf(2, 3) +void ish_event_tracer(struct ishtp_device *dev, const char *format, ...) { if (trace_ishtp_dump_enabled()) { va_list args; diff --git a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h index a94f9a8a96a0..6a6d927b78b0 100644 --- a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h +++ b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h @@ -238,7 +238,8 @@ struct ishtp_device { uint64_t ishtp_host_dma_rx_buf_phys; /* Dump to trace buffers if enabled*/ - void (*print_log)(struct ishtp_device *dev, char *format, ...); + __printf(2, 3) void (*print_log)(struct ishtp_device *dev, + const char *format, ...); /* Debug stats */ unsigned int ipc_rx_cnt; -- cgit From 5299a92a3b98b91b7230662b8b9b6c64bcf8cae6 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Thu, 22 Dec 2016 11:09:10 +0100 Subject: HID: intel-ish-hid: format 32-bit integers with %X In ishtp_hid_probe(), use %04X instead of %04hX to format __u32 values, in order to silent a format error reported by clang: drivers/hid/intel-ish-hid/ishtp-hid.c:212:3: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat] hid->vendor, hid->product); ^~~~~~~~~~~ drivers/hid/intel-ish-hid/ishtp-hid.c:212:16: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat] hid->vendor, hid->product); ^~~~~~~~~~~~ Signed-off-by: Nicolas Iooss Acked-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- drivers/hid/intel-ish-hid/ishtp-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/hid/intel-ish-hid') diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.c b/drivers/hid/intel-ish-hid/ishtp-hid.c index 277983aa1d90..cd23903ddcf1 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid.c @@ -208,7 +208,7 @@ int ishtp_hid_probe(unsigned int cur_hid_dev, hid->version = le16_to_cpu(ISH_HID_VERSION); hid->vendor = le16_to_cpu(ISH_HID_VENDOR); hid->product = le16_to_cpu(ISH_HID_PRODUCT); - snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX", "hid-ishtp", + snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", "hid-ishtp", hid->vendor, hid->product); rv = hid_add_device(hid); -- cgit From 291e9e3f6931eda50be839500c15b1135146aaf6 Mon Sep 17 00:00:00 2001 From: Even Xu Date: Fri, 3 Feb 2017 14:24:53 +0800 Subject: HID: intel-ish-hid: ipc: check FW status to distinguish ISH resume paths For ISH resume, there are two paths, they need different way to handle: one where ISH is not powered off, in that case a simple resume message is enough, in other case we need a reset sequence. We can use ISH FW status to distinguish those two cases and handle them properly. Signed-off-by: Even Xu Acked-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h | 8 +++++++ drivers/hid/intel-ish-hid/ipc/hw-ish.h | 12 ++++++++++ drivers/hid/intel-ish-hid/ipc/pci-ish.c | 34 ++++++++++++++++++++--------- 3 files changed, 44 insertions(+), 10 deletions(-) (limited to 'drivers/hid/intel-ish-hid') diff --git a/drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h b/drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h index ab68afcba2a2..a5897b9c0956 100644 --- a/drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h +++ b/drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h @@ -110,6 +110,14 @@ #define IPC_ILUP_OFFS (0) #define IPC_ILUP_BIT (1<> IPC_ISH_FWSTS_SHIFT) + /* * FW status bits (relevant) */ diff --git a/drivers/hid/intel-ish-hid/ipc/hw-ish.h b/drivers/hid/intel-ish-hid/ipc/hw-ish.h index 46615a03e78f..fd34307a7a70 100644 --- a/drivers/hid/intel-ish-hid/ipc/hw-ish.h +++ b/drivers/hid/intel-ish-hid/ipc/hw-ish.h @@ -61,6 +61,18 @@ struct ish_hw { void __iomem *mem_addr; }; +/* + * ISH FW status type + */ +enum { + FWSTS_AFTER_RESET = 0, + FWSTS_WAIT_FOR_HOST = 4, + FWSTS_START_KERNEL_DMA = 5, + FWSTS_FW_IS_RUNNING = 7, + FWSTS_SENSOR_APP_LOADED = 8, + FWSTS_SENSOR_APP_RUNNING = 15 +}; + #define to_ish_hw(dev) (struct ish_hw *)((dev)->hw) irqreturn_t ish_irq_handler(int irq, void *dev_id); diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c index 34c95de6885e..393f2e3d4679 100644 --- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c +++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c @@ -206,12 +206,15 @@ static void ish_remove(struct pci_dev *pdev) #ifdef CONFIG_PM static struct device *ish_resume_device; +/* 50ms to get resume response */ +#define WAIT_FOR_RESUME_ACK_MS 50 + /** * ish_resume_handler() - Work function to complete resume * @work: work struct * * The resume work function to complete resume function asynchronously. - * There are two types of platforms, one where ISH is not powered off, + * There are two resume paths, one where ISH is not powered off, * in that case a simple resume message is enough, others we need * a reset sequence. */ @@ -219,20 +222,31 @@ static void ish_resume_handler(struct work_struct *work) { struct pci_dev *pdev = to_pci_dev(ish_resume_device); struct ishtp_device *dev = pci_get_drvdata(pdev); + uint32_t fwsts; int ret; - ishtp_send_resume(dev); + /* Get ISH FW status */ + fwsts = IPC_GET_ISH_FWSTS(dev->ops->get_fw_status(dev)); - /* 50 ms to get resume response */ - if (dev->resume_flag) - ret = wait_event_interruptible_timeout(dev->resume_wait, - !dev->resume_flag, - msecs_to_jiffies(50)); + /* + * If currently, in ISH FW, sensor app is loaded or beyond that, + * it means ISH isn't powered off, in this case, send a resume message. + */ + if (fwsts >= FWSTS_SENSOR_APP_LOADED) { + ishtp_send_resume(dev); + + /* Waiting to get resume response */ + if (dev->resume_flag) + ret = wait_event_interruptible_timeout(dev->resume_wait, + !dev->resume_flag, + msecs_to_jiffies(WAIT_FOR_RESUME_ACK_MS)); + } /* - * If no resume response. This platform is not S0ix compatible - * So on resume full reboot of ISH processor will happen, so - * need to go through init sequence again + * If in ISH FW, sensor app isn't loaded yet, or no resume response. + * That means this platform is not S0ix compatible, or something is + * wrong with ISH FW. So on resume, full reboot of ISH processor will + * happen, so need to go through init sequence again. */ if (dev->resume_flag) ish_init(dev); -- cgit From 12be9f7b5861f14f010ae1ce3b343ae903d7a74d Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 11 Feb 2017 12:40:37 +0530 Subject: HID: intel-ish-hid: constify device_type structure Declare device_type structure as const as it is only stored in the type field of a device structure. This field is of type const, so add const to the declaration of device_type structure. File size before: drivers/hid/intel-ish-hid/ishtp/bus.o text data bss dec hex filename 4260 336 16 4612 1204 hid/intel-ish-hid/ishtp/bus.o File size after: drivers/hid/intel-ish-hid/ishtp/bus.o text data bss dec hex filename 4324 272 16 4612 1204 hid/intel-ish-hid/ishtp/bus.o Signed-off-by: Bhumika Goyal Acked-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- drivers/hid/intel-ish-hid/ishtp/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/hid/intel-ish-hid') diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index f4cbc744e657..5f382fedc2ab 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -358,7 +358,7 @@ static void ishtp_cl_dev_release(struct device *dev) kfree(to_ishtp_cl_device(dev)); } -static struct device_type ishtp_cl_device_type = { +static const struct device_type ishtp_cl_device_type = { .release = ishtp_cl_dev_release, }; -- cgit