From patchwork Mon Mar 18 19:14:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858403 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B26836C2 for ; Mon, 18 Mar 2019 19:15:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D80428F2F for ; Mon, 18 Mar 2019 19:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 749E528F7A; Mon, 18 Mar 2019 19:15:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB9B42946D for ; Mon, 18 Mar 2019 19:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbfCRTPF (ORCPT ); Mon, 18 Mar 2019 15:15:05 -0400 Received: from mga18.intel.com ([134.134.136.126]:38402 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbfCRTPF (ORCPT ); Mon, 18 Mar 2019 15:15:05 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107024" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:04 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Hong Liu Subject: [PATCH v2 01/10] HID: intel-ish-hid: Add match callback to ishtp bus type Date: Mon, 18 Mar 2019 12:14:19 -0700 Message-Id: <20190318191428.6527-2-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hong Liu Currently we depend on the guid check in ishtp_cl_driver.probe to match the device and driver. However Linux device core first calls the match() callback to decide the matching of driver and device, and then does some preparation before calling the driver probe function. If we return error in the driver probe, it needs to tear down all the preparation work and retry with next driver. Adding the match callback can avoid the unnecessary entry into unmatched driver probe function for ishtp clients reported by FW. Signed-off-by: Hong Liu --- drivers/hid/intel-ish-hid/ishtp-hid-client.c | 5 +---- drivers/hid/intel-ish-hid/ishtp/bus.c | 21 ++++++++++++++++++++ drivers/hid/intel-ish-hid/ishtp/bus.h | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c index 58773a3b5150..b86290611a5f 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c @@ -803,10 +803,6 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device) if (!cl_device) return -ENODEV; - if (!guid_equal(&hid_ishtp_guid, - &cl_device->fw_client->props.protocol_name)) - return -ENODEV; - client_data = devm_kzalloc(&cl_device->dev, sizeof(*client_data), GFP_KERNEL); if (!client_data) @@ -937,6 +933,7 @@ static const struct dev_pm_ops hid_ishtp_pm_ops = { static struct ishtp_cl_driver hid_ishtp_cl_driver = { .name = "ish-hid", + .guid = &hid_ishtp_guid, .probe = hid_ishtp_cl_probe, .remove = hid_ishtp_cl_remove, .reset = hid_ishtp_cl_reset, diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index d5f4b6438d86..6348fee8aadc 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -219,6 +219,26 @@ static int ishtp_cl_device_probe(struct device *dev) return driver->probe(device); } +/** + * ishtp_cl_bus_match() - Bus match() callback + * @dev: the device structure + * @drv: the driver structure + * + * This is a bus match callback, called when a new ishtp_cl_device is + * registered during ishtp bus client enumeration. Use the guid_t in + * drv and dev to decide whether they match or not. + * + * Return: 1 if dev & drv matches, 0 otherwise. + */ +static int ishtp_cl_bus_match(struct device *dev, struct device_driver *drv) +{ + struct ishtp_cl_device *device = to_ishtp_cl_device(dev); + struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv); + + return guid_equal(driver->guid, + &device->fw_client->props.protocol_name); +} + /** * ishtp_cl_device_remove() - Bus remove() callback * @dev: the device structure @@ -372,6 +392,7 @@ static struct bus_type ishtp_cl_bus_type = { .name = "ishtp", .dev_groups = ishtp_cl_dev_groups, .probe = ishtp_cl_device_probe, + .match = ishtp_cl_bus_match, .remove = ishtp_cl_device_remove, .pm = &ishtp_cl_bus_dev_pm_ops, .uevent = ishtp_cl_uevent, diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.h b/drivers/hid/intel-ish-hid/ishtp/bus.h index 4cf7ad586c37..c96e7fb42f01 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.h +++ b/drivers/hid/intel-ish-hid/ishtp/bus.h @@ -64,6 +64,7 @@ struct ishtp_cl_device { struct ishtp_cl_driver { struct device_driver driver; const char *name; + const guid_t *guid; int (*probe)(struct ishtp_cl_device *dev); int (*remove)(struct ishtp_cl_device *dev); int (*reset)(struct ishtp_cl_device *dev); From patchwork Mon Mar 18 19:14:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7278213B5 for ; Mon, 18 Mar 2019 19:15:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58A3C28EBD for ; Mon, 18 Mar 2019 19:15:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CC6E290A3; Mon, 18 Mar 2019 19:15:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5011928EBD for ; Mon, 18 Mar 2019 19:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727701AbfCRTPm (ORCPT ); Mon, 18 Mar 2019 15:15:42 -0400 Received: from mga18.intel.com ([134.134.136.126]:38402 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727432AbfCRTPG (ORCPT ); Mon, 18 Mar 2019 15:15:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107025" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:04 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 02/10] HID: intel-ish-hid: Hide members of struct ishtp_cl_device Date: Mon, 18 Mar 2019 12:14:20 -0700 Message-Id: <20190318191428.6527-3-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ISH clients don't need to access any field of struct ishtp_cl_device. To avoid this create an interface functions instead where it is required. In the case of ishtp_cl_allocate(), modify the parameters so that the clients don't have to dereference. Clients can also use tracing, here a new interface is added to get the common trace function pointer, instead of direct call. The new interface functions defined in one external header file, named intel-ish-client-if.h. This is the only header files all ISHTP clients must include. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp-hid-client.c | 56 +++++++++++--------- drivers/hid/intel-ish-hid/ishtp-hid.c | 4 +- drivers/hid/intel-ish-hid/ishtp-hid.h | 2 +- drivers/hid/intel-ish-hid/ishtp/bus.c | 27 ++++++++++ drivers/hid/intel-ish-hid/ishtp/client.c | 4 +- drivers/hid/intel-ish-hid/ishtp/client.h | 2 +- include/linux/intel-ish-client-if.h | 18 +++++++ 7 files changed, 84 insertions(+), 29 deletions(-) create mode 100644 include/linux/intel-ish-client-if.h diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c index b86290611a5f..17d5bd4f52c1 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c @@ -15,6 +15,7 @@ #include #include +#include #include #include "ishtp/ishtp-dev.h" #include "ishtp/client.h" @@ -24,6 +25,8 @@ #define HID_CL_RX_RING_SIZE 32 #define HID_CL_TX_RING_SIZE 16 +#define cl_data_to_dev(client_data) ishtp_device(client_data->cl_device) + /** * report_bad_packets() - Report bad packets * @hid_ishtp_cl: Client instance to get stats @@ -39,7 +42,7 @@ static void report_bad_packet(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, struct hostif_msg *recv_msg = recv_buf; struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; - dev_err(&client_data->cl_device->dev, "[hid-ish]: BAD packet %02X\n" + dev_err(cl_data_to_dev(client_data), "[hid-ish]: BAD packet %02X\n" "total_bad=%u cur_pos=%u\n" "[%02X %02X %02X %02X]\n" "payload_len=%u\n" @@ -85,7 +88,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, do { if (cur_pos + sizeof(struct hostif_msg) > total_len) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: error, received %u which is less than data header %u\n", (unsigned int)data_len, (unsigned int)sizeof(struct hostif_msg_hdr)); @@ -124,12 +127,12 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, client_data->hid_dev_count = (unsigned int)*payload; if (!client_data->hid_devices) client_data->hid_devices = devm_kcalloc( - &client_data->cl_device->dev, + cl_data_to_dev(client_data), client_data->hid_dev_count, sizeof(struct device_info), GFP_KERNEL); if (!client_data->hid_devices) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "Mem alloc failed for hid device info\n"); wake_up_interruptible(&client_data->init_wait); break; @@ -137,7 +140,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, for (i = 0; i < client_data->hid_dev_count; ++i) { if (1 + sizeof(struct device_info) * i >= payload_len) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: [ENUM_DEVICES]: content size %zu is bigger than payload_len %zu\n", 1 + sizeof(struct device_info) * i, payload_len); @@ -172,7 +175,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, } if (!client_data->hid_descr[curr_hid_dev]) client_data->hid_descr[curr_hid_dev] = - devm_kmalloc(&client_data->cl_device->dev, + devm_kmalloc(cl_data_to_dev(client_data), payload_len, GFP_KERNEL); if (client_data->hid_descr[curr_hid_dev]) { memcpy(client_data->hid_descr[curr_hid_dev], @@ -197,7 +200,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, } if (!client_data->report_descr[curr_hid_dev]) client_data->report_descr[curr_hid_dev] = - devm_kmalloc(&client_data->cl_device->dev, + devm_kmalloc(cl_data_to_dev(client_data), payload_len, GFP_KERNEL); if (client_data->report_descr[curr_hid_dev]) { memcpy(client_data->report_descr[curr_hid_dev], @@ -516,12 +519,12 @@ static int ishtp_enum_enum_devices(struct ishtp_cl *hid_ishtp_cl) sizeof(struct hostif_msg)); } if (!client_data->enum_devices_done) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: timed out waiting for enum_devices\n"); return -ETIMEDOUT; } if (!client_data->hid_devices) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: failed to allocate HID dev structures\n"); return -ENOMEM; } @@ -564,13 +567,13 @@ static int ishtp_get_hid_descriptor(struct ishtp_cl *hid_ishtp_cl, int index) client_data->hid_descr_done, 3 * HZ); if (!client_data->hid_descr_done) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: timed out for hid_descr_done\n"); return -EIO; } if (!client_data->hid_descr[index]) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: allocation HID desc fail\n"); return -ENOMEM; } @@ -611,12 +614,12 @@ static int ishtp_get_report_descriptor(struct ishtp_cl *hid_ishtp_cl, client_data->report_descr_done, 3 * HZ); if (!client_data->report_descr_done) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: timed out for report descr\n"); return -EIO; } if (!client_data->report_descr[index]) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: failed to alloc report descr\n"); return -ENOMEM; } @@ -646,12 +649,12 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) int i; int rv; - dev_dbg(&client_data->cl_device->dev, "%s\n", __func__); + dev_dbg(cl_data_to_dev(client_data), "%s\n", __func__); hid_ishtp_trace(client_data, "%s reset flag: %d\n", __func__, reset); rv = ishtp_cl_link(hid_ishtp_cl, ISHTP_HOST_CLIENT_ID_ANY); if (rv) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "ishtp_cl_link failed\n"); return -ENOMEM; } @@ -666,7 +669,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) fw_client = ishtp_fw_cl_get_client(dev, &hid_ishtp_guid); if (!fw_client) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "ish client uuid not found\n"); return -ENOENT; } @@ -676,7 +679,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) rv = ishtp_cl_connect(hid_ishtp_cl); if (rv) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "client connect fail\n"); goto err_cl_unlink; } @@ -707,7 +710,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) if (!reset) { rv = ishtp_hid_probe(i, client_data); if (rv) { - dev_err(&client_data->cl_device->dev, + dev_err(cl_data_to_dev(client_data), "[hid-ish]: HID probe for #%u failed: %d\n", i, rv); goto err_cl_disconnect; @@ -763,7 +766,7 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work) hid_ishtp_cl_deinit(hid_ishtp_cl); - hid_ishtp_cl = ishtp_cl_allocate(cl_device->ishtp_dev); + hid_ishtp_cl = ishtp_cl_allocate(cl_device); if (!hid_ishtp_cl) return; @@ -777,15 +780,17 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work) rv = hid_ishtp_cl_init(hid_ishtp_cl, 1); if (!rv) break; - dev_err(&client_data->cl_device->dev, "Retry reset init\n"); + dev_err(cl_data_to_dev(client_data), "Retry reset init\n"); } if (rv) { - dev_err(&client_data->cl_device->dev, "Reset Failed\n"); + dev_err(cl_data_to_dev(client_data), "Reset Failed\n"); hid_ishtp_trace(client_data, "%s Failed hid_ishtp_cl %p\n", __func__, hid_ishtp_cl); } } +void (*hid_print_trace)(void *dev, const char *format, ...); + /** * hid_ishtp_cl_probe() - ISHTP client driver probe * @cl_device: ISHTP client device instance @@ -803,12 +808,13 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device) if (!cl_device) return -ENODEV; - client_data = devm_kzalloc(&cl_device->dev, sizeof(*client_data), + client_data = devm_kzalloc(ishtp_device(cl_device), + sizeof(*client_data), GFP_KERNEL); if (!client_data) return -ENOMEM; - hid_ishtp_cl = ishtp_cl_allocate(cl_device->ishtp_dev); + hid_ishtp_cl = ishtp_cl_allocate(cl_device); if (!hid_ishtp_cl) return -ENOMEM; @@ -822,6 +828,8 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device) INIT_WORK(&client_data->work, hid_ishtp_cl_reset_handler); + hid_print_trace = ishtp_trace_callback(cl_device); + rv = hid_ishtp_cl_init(hid_ishtp_cl, 0); if (rv) { ishtp_cl_free(hid_ishtp_cl); @@ -848,7 +856,7 @@ static int hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device) hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__, hid_ishtp_cl); - dev_dbg(&cl_device->dev, "%s\n", __func__); + dev_dbg(ishtp_device(cl_device), "%s\n", __func__); hid_ishtp_cl->state = ISHTP_CL_DISCONNECTING; ishtp_cl_disconnect(hid_ishtp_cl); ishtp_put_device(cl_device); diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.c b/drivers/hid/intel-ish-hid/ishtp-hid.c index 5c7e127b0483..95a5b87d9105 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid.c @@ -14,6 +14,7 @@ */ #include +#include #include #include "ishtp/client.h" #include "ishtp-hid.h" @@ -241,7 +242,8 @@ int ishtp_hid_probe(unsigned int cur_hid_dev, hid->ll_driver = &ishtp_hid_ll_driver; hid->bus = BUS_INTEL_ISHTP; - hid->dev.parent = &client_data->cl_device->dev; + hid->dev.parent = ishtp_device(client_data->cl_device); + hid->version = le16_to_cpu(ISH_HID_VERSION); hid->vendor = le16_to_cpu(client_data->hid_devices[cur_hid_dev].vid); hid->product = le16_to_cpu(client_data->hid_devices[cur_hid_dev].pid); diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.h b/drivers/hid/intel-ish-hid/ishtp-hid.h index 40663639e43b..8af44e855a49 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid.h +++ b/drivers/hid/intel-ish-hid/ishtp-hid.h @@ -24,7 +24,7 @@ #define IS_RESPONSE 0x80 /* Used to dump to Linux trace buffer, if enabled */ -#define hid_ishtp_trace(client, ...) \ +#define hid_ishtp_trace(client, ...) \ client->cl_device->ishtp_dev->print_log(\ client->cl_device->ishtp_dev, __VA_ARGS__) diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index 6348fee8aadc..308853eab91c 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -827,6 +827,33 @@ int ishtp_use_dma_transfer(void) return ishtp_use_dma; } +/** + * ishtp_device() - Return device pointer + * + * This interface is used to return device pointer from ishtp_cl_device + * instance. + * + * Return: device *. + */ +struct device *ishtp_device(struct ishtp_cl_device *device) +{ + return &device->dev; +} +EXPORT_SYMBOL(ishtp_device); + +/** + * ishtp_trace_callback() - Return trace callback + * + * This interface is used to return trace callback function pointer. + * + * Return: void *. + */ +void *ishtp_trace_callback(struct ishtp_cl_device *cl_device) +{ + return cl_device->ishtp_dev->print_log; +} +EXPORT_SYMBOL(ishtp_trace_callback); + /** * ishtp_bus_register() - Function to register bus * diff --git a/drivers/hid/intel-ish-hid/ishtp/client.c b/drivers/hid/intel-ish-hid/ishtp/client.c index faeccdb1475b..760e48a368a8 100644 --- a/drivers/hid/intel-ish-hid/ishtp/client.c +++ b/drivers/hid/intel-ish-hid/ishtp/client.c @@ -126,7 +126,7 @@ static void ishtp_cl_init(struct ishtp_cl *cl, struct ishtp_device *dev) * * Return: The allocated client instance or NULL on failure */ -struct ishtp_cl *ishtp_cl_allocate(struct ishtp_device *dev) +struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device) { struct ishtp_cl *cl; @@ -134,7 +134,7 @@ struct ishtp_cl *ishtp_cl_allocate(struct ishtp_device *dev) if (!cl) return NULL; - ishtp_cl_init(cl, dev); + ishtp_cl_init(cl, cl_device->ishtp_dev); return cl; } EXPORT_SYMBOL(ishtp_cl_allocate); diff --git a/drivers/hid/intel-ish-hid/ishtp/client.h b/drivers/hid/intel-ish-hid/ishtp/client.h index e0df3eb611e6..992625891a6c 100644 --- a/drivers/hid/intel-ish-hid/ishtp/client.h +++ b/drivers/hid/intel-ish-hid/ishtp/client.h @@ -170,7 +170,7 @@ static inline bool ishtp_cl_cmp_id(const struct ishtp_cl *cl1, } /* exported functions from ISHTP under client management scope */ -struct ishtp_cl *ishtp_cl_allocate(struct ishtp_device *dev); +struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); void ishtp_cl_free(struct ishtp_cl *cl); int ishtp_cl_link(struct ishtp_cl *cl, int id); void ishtp_cl_unlink(struct ishtp_cl *cl); diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h new file mode 100644 index 000000000000..11e285172735 --- /dev/null +++ b/include/linux/intel-ish-client-if.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Intel ISH client Interface definitions + * + * Copyright (c) 2019, Intel Corporation. + */ + +#ifndef _INTEL_ISH_CLIENT_IF_H_ +#define _INTEL_ISH_CLIENT_IF_H_ + +struct ishtp_cl_device; + +/* Get the device * from ishtp device instance */ +struct device *ishtp_device(struct ishtp_cl_device *cl_device); +/* Trace interface for clients */ +void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); + +#endif /* _INTEL_ISH_CLIENT_IF_H_ */ From patchwork Mon Mar 18 19:14:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858411 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 899CF17E9 for ; Mon, 18 Mar 2019 19:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71EF428DDF for ; Mon, 18 Mar 2019 19:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5929629404; Mon, 18 Mar 2019 19:15:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E32D129404 for ; Mon, 18 Mar 2019 19:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbfCRTPH (ORCPT ); Mon, 18 Mar 2019 15:15:07 -0400 Received: from mga18.intel.com ([134.134.136.126]:38405 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727468AbfCRTPG (ORCPT ); Mon, 18 Mar 2019 15:15:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107027" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:04 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 03/10] HID: intel-ish-hid: Simplify ishtp_cl_link() Date: Mon, 18 Mar 2019 12:14:21 -0700 Message-Id: <20190318191428.6527-4-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All callers will only use ISHTP_HOST_CLIENT_ID_ANY, so get rid of option to pass this additional id. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp-hid-client.c | 2 +- drivers/hid/intel-ish-hid/ishtp/client.c | 14 ++++---------- drivers/hid/intel-ish-hid/ishtp/client.h | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c index 17d5bd4f52c1..94a00ffeb09b 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c @@ -652,7 +652,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) dev_dbg(cl_data_to_dev(client_data), "%s\n", __func__); hid_ishtp_trace(client_data, "%s reset flag: %d\n", __func__, reset); - rv = ishtp_cl_link(hid_ishtp_cl, ISHTP_HOST_CLIENT_ID_ANY); + rv = ishtp_cl_link(hid_ishtp_cl); if (rv) { dev_err(cl_data_to_dev(client_data), "ishtp_cl_link failed\n"); diff --git a/drivers/hid/intel-ish-hid/ishtp/client.c b/drivers/hid/intel-ish-hid/ishtp/client.c index 760e48a368a8..657b46dcefa6 100644 --- a/drivers/hid/intel-ish-hid/ishtp/client.c +++ b/drivers/hid/intel-ish-hid/ishtp/client.c @@ -168,9 +168,6 @@ EXPORT_SYMBOL(ishtp_cl_free); /** * ishtp_cl_link() - Reserve a host id and link the client instance * @cl: client device instance - * @id: host client id to use. It can be ISHTP_HOST_CLIENT_ID_ANY if any - * id from the available can be used - * * * This allocates a single bit in the hostmap. This function will make sure * that not many client sessions are opened at the same time. Once allocated @@ -179,11 +176,11 @@ EXPORT_SYMBOL(ishtp_cl_free); * * Return: 0 or error code on failure */ -int ishtp_cl_link(struct ishtp_cl *cl, int id) +int ishtp_cl_link(struct ishtp_cl *cl) { struct ishtp_device *dev; - unsigned long flags, flags_cl; - int ret = 0; + unsigned long flags, flags_cl; + int id, ret = 0; if (WARN_ON(!cl || !cl->dev)) return -EINVAL; @@ -197,10 +194,7 @@ int ishtp_cl_link(struct ishtp_cl *cl, int id) goto unlock_dev; } - /* If Id is not assigned get one*/ - if (id == ISHTP_HOST_CLIENT_ID_ANY) - id = find_first_zero_bit(dev->host_clients_map, - ISHTP_CLIENTS_MAX); + id = find_first_zero_bit(dev->host_clients_map, ISHTP_CLIENTS_MAX); if (id >= ISHTP_CLIENTS_MAX) { spin_unlock_irqrestore(&dev->device_lock, flags); diff --git a/drivers/hid/intel-ish-hid/ishtp/client.h b/drivers/hid/intel-ish-hid/ishtp/client.h index 992625891a6c..afa8b1f521d0 100644 --- a/drivers/hid/intel-ish-hid/ishtp/client.h +++ b/drivers/hid/intel-ish-hid/ishtp/client.h @@ -172,7 +172,7 @@ static inline bool ishtp_cl_cmp_id(const struct ishtp_cl *cl1, /* exported functions from ISHTP under client management scope */ struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); void ishtp_cl_free(struct ishtp_cl *cl); -int ishtp_cl_link(struct ishtp_cl *cl, int id); +int ishtp_cl_link(struct ishtp_cl *cl); void ishtp_cl_unlink(struct ishtp_cl *cl); int ishtp_cl_disconnect(struct ishtp_cl *cl); int ishtp_cl_connect(struct ishtp_cl *cl); From patchwork Mon Mar 18 19:14:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E355B13B5 for ; Mon, 18 Mar 2019 19:15:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBDB829464 for ; Mon, 18 Mar 2019 19:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFDAE29433; Mon, 18 Mar 2019 19:15:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3750128DDF for ; Mon, 18 Mar 2019 19:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727207AbfCRTPg (ORCPT ); Mon, 18 Mar 2019 15:15:36 -0400 Received: from mga18.intel.com ([134.134.136.126]:38405 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727479AbfCRTPH (ORCPT ); Mon, 18 Mar 2019 15:15:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107028" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:04 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 04/10] HID: intel-ish-hid: Move driver registry functions Date: Mon, 18 Mar 2019 12:14:22 -0700 Message-Id: <20190318191428.6527-5-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the driver registry with the ishtp bus to the common interface file, which clients can include. Also rename __ishtp_cl_driver_register() to ishtp_cl_driver_register() and removed define for ishtp_cl_driver_register. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp-hid-client.c | 2 +- drivers/hid/intel-ish-hid/ishtp/bus.c | 8 +++--- drivers/hid/intel-ish-hid/ishtp/bus.h | 27 +------------------- include/linux/intel-ish-client-if.h | 25 ++++++++++++++++++ 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c index 94a00ffeb09b..4afb39713213 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c @@ -953,7 +953,7 @@ static int __init ish_hid_init(void) int rv; /* Register ISHTP client device driver with ISHTP Bus */ - rv = ishtp_cl_driver_register(&hid_ishtp_cl_driver); + rv = ishtp_cl_driver_register(&hid_ishtp_cl_driver, THIS_MODULE); return rv; diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index 308853eab91c..95a97534fcda 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -485,7 +485,7 @@ static void ishtp_bus_remove_device(struct ishtp_cl_device *device) } /** - * __ishtp_cl_driver_register() - Client driver register + * ishtp_cl_driver_register() - Client driver register * @driver: the client driver instance * @owner: Owner of this driver module * @@ -494,8 +494,8 @@ static void ishtp_bus_remove_device(struct ishtp_cl_device *device) * * Return: Return value of driver_register or -ENODEV if not ready */ -int __ishtp_cl_driver_register(struct ishtp_cl_driver *driver, - struct module *owner) +int ishtp_cl_driver_register(struct ishtp_cl_driver *driver, + struct module *owner) { int err; @@ -512,7 +512,7 @@ int __ishtp_cl_driver_register(struct ishtp_cl_driver *driver, return 0; } -EXPORT_SYMBOL(__ishtp_cl_driver_register); +EXPORT_SYMBOL(ishtp_cl_driver_register); /** * ishtp_cl_driver_unregister() - Client driver unregister diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.h b/drivers/hid/intel-ish-hid/ishtp/bus.h index c96e7fb42f01..4aed195719de 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.h +++ b/drivers/hid/intel-ish-hid/ishtp/bus.h @@ -17,6 +17,7 @@ #include #include +#include struct ishtp_cl; struct ishtp_cl_device; @@ -52,26 +53,6 @@ struct ishtp_cl_device { void (*event_cb)(struct ishtp_cl_device *device); }; -/** - * struct ishtp_cl_device - ISHTP device handle - * @driver: driver instance on a bus - * @name: Name of the device for probe - * @probe: driver callback for device probe - * @remove: driver callback on device removal - * - * Client drivers defines to get probed/removed for ISHTP client device. - */ -struct ishtp_cl_driver { - struct device_driver driver; - const char *name; - const guid_t *guid; - int (*probe)(struct ishtp_cl_device *dev); - int (*remove)(struct ishtp_cl_device *dev); - int (*reset)(struct ishtp_cl_device *dev); - const struct dev_pm_ops *pm; -}; - - int ishtp_bus_new_client(struct ishtp_device *dev); void ishtp_remove_all_clients(struct ishtp_device *dev); int ishtp_cl_device_bind(struct ishtp_cl *cl); @@ -105,12 +86,6 @@ void ishtp_get_device(struct ishtp_cl_device *); void ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data); void *ishtp_get_drvdata(struct ishtp_cl_device *cl_device); -int __ishtp_cl_driver_register(struct ishtp_cl_driver *driver, - struct module *owner); -#define ishtp_cl_driver_register(driver) \ - __ishtp_cl_driver_register(driver, THIS_MODULE) -void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver); - int ishtp_register_event_cb(struct ishtp_cl_device *device, void (*read_cb)(struct ishtp_cl_device *)); int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *cuuid); diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index 11e285172735..abc0b8122f07 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -10,6 +10,31 @@ struct ishtp_cl_device; +/** + * struct ishtp_cl_device - ISHTP device handle + * @driver: driver instance on a bus + * @name: Name of the device for probe + * @probe: driver callback for device probe + * @remove: driver callback on device removal + * + * Client drivers defines to get probed/removed for ISHTP client device. + */ +struct ishtp_cl_driver { + struct device_driver driver; + const char *name; + const guid_t *guid; + int (*probe)(struct ishtp_cl_device *dev); + int (*remove)(struct ishtp_cl_device *dev); + int (*reset)(struct ishtp_cl_device *dev); + const struct dev_pm_ops *pm; +}; + +int ishtp_cl_driver_register(struct ishtp_cl_driver *driver, + struct module *owner); +void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver); +int ishtp_register_event_cb(struct ishtp_cl_device *device, + void (*read_cb)(struct ishtp_cl_device *)); + /* Get the device * from ishtp device instance */ struct device *ishtp_device(struct ishtp_cl_device *cl_device); /* Trace interface for clients */ From patchwork Mon Mar 18 19:14:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858423 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFEF16C2 for ; Mon, 18 Mar 2019 19:16:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8ABA28E13 for ; Mon, 18 Mar 2019 19:16:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD33928E1A; Mon, 18 Mar 2019 19:16:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79A0C29464 for ; Mon, 18 Mar 2019 19:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbfCRTP5 (ORCPT ); Mon, 18 Mar 2019 15:15:57 -0400 Received: from mga17.intel.com ([192.55.52.151]:37070 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbfCRTPF (ORCPT ); Mon, 18 Mar 2019 15:15:05 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107029" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:04 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 05/10] HID: intel-ish-hid: Store ishtp_cl_device instance in device Date: Mon, 18 Mar 2019 12:14:23 -0700 Message-Id: <20190318191428.6527-6-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Store ishtp_cl_device pointer in device struct private data. In this way we can get ishtp_cl_device * from device struct pointer. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp/bus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index 95a97534fcda..2ca65864192f 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -466,6 +466,7 @@ static struct ishtp_cl_device *ishtp_bus_add_device(struct ishtp_device *dev, } ishtp_device_ready = true; + dev_set_drvdata(&device->dev, device); return device; } From patchwork Mon Mar 18 19:14:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13EF26C2 for ; Mon, 18 Mar 2019 19:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F174328ED8 for ; Mon, 18 Mar 2019 19:15:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5C3728E13; Mon, 18 Mar 2019 19:15:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65B6328ED8 for ; Mon, 18 Mar 2019 19:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727432AbfCRTPs (ORCPT ); Mon, 18 Mar 2019 15:15:48 -0400 Received: from mga17.intel.com ([192.55.52.151]:37070 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727028AbfCRTPF (ORCPT ); Mon, 18 Mar 2019 15:15:05 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107030" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:04 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 06/10] HID: intel-ish-hid: Move the common functions from client.h Date: Mon, 18 Mar 2019 12:14:24 -0700 Message-Id: <20190318191428.6527-7-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the interface functions in client.h to common include. These are already abstracted well to use as is. Also move any associated structures used by these functions. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp/client.h | 24 ----------- drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h | 26 ----------- include/linux/intel-ish-client-if.h | 48 +++++++++++++++++++++ 3 files changed, 48 insertions(+), 50 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp/client.h b/drivers/hid/intel-ish-hid/ishtp/client.h index afa8b1f521d0..6ed00947d6bc 100644 --- a/drivers/hid/intel-ish-hid/ishtp/client.h +++ b/drivers/hid/intel-ish-hid/ishtp/client.h @@ -19,15 +19,6 @@ #include #include "ishtp-dev.h" -/* Client state */ -enum cl_state { - ISHTP_CL_INITIALIZING = 0, - ISHTP_CL_CONNECTING, - ISHTP_CL_CONNECTED, - ISHTP_CL_DISCONNECTING, - ISHTP_CL_DISCONNECTED -}; - /* Tx and Rx ring size */ #define CL_DEF_RX_RING_SIZE 2 #define CL_DEF_TX_RING_SIZE 2 @@ -169,19 +160,4 @@ static inline bool ishtp_cl_cmp_id(const struct ishtp_cl *cl1, (cl1->fw_client_id == cl2->fw_client_id); } -/* exported functions from ISHTP under client management scope */ -struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); -void ishtp_cl_free(struct ishtp_cl *cl); -int ishtp_cl_link(struct ishtp_cl *cl); -void ishtp_cl_unlink(struct ishtp_cl *cl); -int ishtp_cl_disconnect(struct ishtp_cl *cl); -int ishtp_cl_connect(struct ishtp_cl *cl); -int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length); -int ishtp_cl_flush_queues(struct ishtp_cl *cl); - -/* exported functions from ISHTP client buffer management scope */ -int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); -bool ishtp_cl_tx_empty(struct ishtp_cl *cl); -struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); - #endif /* _ISHTP_CLIENT_H_ */ diff --git a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h index e54ce1ef27dd..e0a320e67a41 100644 --- a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h +++ b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h @@ -79,32 +79,6 @@ struct ishtp_fw_client { uint8_t client_id; }; -/** - * struct ishtp_msg_data - ISHTP message data struct - * @size: Size of data in the *data - * @data: Pointer to data - */ -struct ishtp_msg_data { - uint32_t size; - unsigned char *data; -}; - -/* - * struct ishtp_cl_rb - request block structure - * @list: Link to list members - * @cl: ISHTP client instance - * @buffer: message header - * @buf_idx: Index into buffer - * @read_time: unused at this time - */ -struct ishtp_cl_rb { - struct list_head list; - struct ishtp_cl *cl; - struct ishtp_msg_data buffer; - unsigned long buf_idx; - unsigned long read_time; -}; - /* * Control info for IPC messages ISHTP/IPC sending FIFO - * list with inline data buffer diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index abc0b8122f07..7ce172f656f8 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -9,6 +9,16 @@ #define _INTEL_ISH_CLIENT_IF_H_ struct ishtp_cl_device; +struct ishtp_cl; + +/* Client state */ +enum cl_state { + ISHTP_CL_INITIALIZING = 0, + ISHTP_CL_CONNECTING, + ISHTP_CL_CONNECTED, + ISHTP_CL_DISCONNECTING, + ISHTP_CL_DISCONNECTED +}; /** * struct ishtp_cl_device - ISHTP device handle @@ -29,6 +39,32 @@ struct ishtp_cl_driver { const struct dev_pm_ops *pm; }; +/** + * struct ishtp_msg_data - ISHTP message data struct + * @size: Size of data in the *data + * @data: Pointer to data + */ +struct ishtp_msg_data { + uint32_t size; + unsigned char *data; +}; + +/* + * struct ishtp_cl_rb - request block structure + * @list: Link to list members + * @cl: ISHTP client instance + * @buffer: message header + * @buf_idx: Index into buffer + * @read_time: unused at this time + */ +struct ishtp_cl_rb { + struct list_head list; + struct ishtp_cl *cl; + struct ishtp_msg_data buffer; + unsigned long buf_idx; + unsigned long read_time; +}; + int ishtp_cl_driver_register(struct ishtp_cl_driver *driver, struct module *owner); void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver); @@ -40,4 +76,16 @@ struct device *ishtp_device(struct ishtp_cl_device *cl_device); /* Trace interface for clients */ void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); +struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); +void ishtp_cl_free(struct ishtp_cl *cl); +int ishtp_cl_link(struct ishtp_cl *cl); +void ishtp_cl_unlink(struct ishtp_cl *cl); +int ishtp_cl_disconnect(struct ishtp_cl *cl); +int ishtp_cl_connect(struct ishtp_cl *cl); +int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length); +int ishtp_cl_flush_queues(struct ishtp_cl *cl); +int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); +bool ishtp_cl_tx_empty(struct ishtp_cl *cl); +struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); + #endif /* _INTEL_ISH_CLIENT_IF_H_ */ From patchwork Mon Mar 18 19:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37FDF6C2 for ; Mon, 18 Mar 2019 19:15:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2142328E1A for ; Mon, 18 Mar 2019 19:15:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 153D528DDF; Mon, 18 Mar 2019 19:15:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B33CD28E1A for ; Mon, 18 Mar 2019 19:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727470AbfCRTPG (ORCPT ); Mon, 18 Mar 2019 15:15:06 -0400 Received: from mga17.intel.com ([192.55.52.151]:37070 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbfCRTPG (ORCPT ); Mon, 18 Mar 2019 15:15:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107032" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:04 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 07/10] HID: intel-ish-hid: Add interface functions for struct ishtp_cl Date: Mon, 18 Mar 2019 12:14:25 -0700 Message-Id: <20190318191428.6527-8-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of directly accessing members of struct ishtp_cl, create interface functions to access them. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp/client.c | 42 ++++++++++++++++++++++++ include/linux/intel-ish-client-if.h | 7 ++++ 2 files changed, 49 insertions(+) diff --git a/drivers/hid/intel-ish-hid/ishtp/client.c b/drivers/hid/intel-ish-hid/ishtp/client.c index 657b46dcefa6..b7ac5e3b1e82 100644 --- a/drivers/hid/intel-ish-hid/ishtp/client.c +++ b/drivers/hid/intel-ish-hid/ishtp/client.c @@ -1063,3 +1063,45 @@ void recv_ishtp_cl_msg_dma(struct ishtp_device *dev, void *msg, eoi: return; } + +void *ishtp_get_client_data(struct ishtp_cl *cl) +{ + return cl->client_data; +} +EXPORT_SYMBOL(ishtp_get_client_data); + +void ishtp_set_client_data(struct ishtp_cl *cl, void *data) +{ + cl->client_data = data; +} +EXPORT_SYMBOL(ishtp_set_client_data); + +struct ishtp_device *ishtp_get_ishtp_device(struct ishtp_cl *cl) +{ + return cl->dev; +} +EXPORT_SYMBOL(ishtp_get_ishtp_device); + +void ishtp_set_tx_ring_size(struct ishtp_cl *cl, int size) +{ + cl->tx_ring_size = size; +} +EXPORT_SYMBOL(ishtp_set_tx_ring_size); + +void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size) +{ + cl->rx_ring_size = size; +} +EXPORT_SYMBOL(ishtp_set_rx_ring_size); + +void ishtp_set_connection_state(struct ishtp_cl *cl, int state) +{ + cl->state = state; +} +EXPORT_SYMBOL(ishtp_set_connection_state); + +void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id) +{ + cl->fw_client_id = fw_client_id; +} +EXPORT_SYMBOL(ishtp_cl_set_fw_client_id); diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index 7ce172f656f8..526e3048e09f 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -87,5 +87,12 @@ int ishtp_cl_flush_queues(struct ishtp_cl *cl); int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); bool ishtp_cl_tx_empty(struct ishtp_cl *cl); struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); +void *ishtp_get_client_data(struct ishtp_cl *cl); +void ishtp_set_client_data(struct ishtp_cl *cl, void *data); +struct ishtp_device *ishtp_get_ishtp_device(struct ishtp_cl *cl); +void ishtp_set_tx_ring_size(struct ishtp_cl *cl, int size); +void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size); +void ishtp_set_connection_state(struct ishtp_cl *cl, int state); +void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id); #endif /* _INTEL_ISH_CLIENT_IF_H_ */ From patchwork Mon Mar 18 19:14:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFDDB13B5 for ; Mon, 18 Mar 2019 19:15:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 970A828DDF for ; Mon, 18 Mar 2019 19:15:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AE4928EB9; Mon, 18 Mar 2019 19:15:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14DFA28DDF for ; Mon, 18 Mar 2019 19:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727487AbfCRTPH (ORCPT ); Mon, 18 Mar 2019 15:15:07 -0400 Received: from mga17.intel.com ([192.55.52.151]:37070 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727369AbfCRTPG (ORCPT ); Mon, 18 Mar 2019 15:15:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107034" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:05 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 08/10] HID: intel-ish-hid: Move functions related to bus and device Date: Mon, 18 Mar 2019 12:14:26 -0700 Message-Id: <20190318191428.6527-9-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move function idefinitions related to bus and device to common header file. Also create new function to get fw client id and move ish_hw_reset() from inline to exported function. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp/bus.c | 26 +++++++++++++++++++++ drivers/hid/intel-ish-hid/ishtp/bus.h | 11 --------- drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h | 5 ---- include/linux/intel-ish-client-if.h | 12 ++++++++++ 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index 2ca65864192f..66a485a41481 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -170,6 +170,19 @@ struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev, } EXPORT_SYMBOL(ishtp_fw_cl_get_client); +/** + * ishtp_get_fw_client_id() - Get fw client id + * + * This interface is used to reset HW get FW client id. + * + * Return: firmware client id. + */ +int ishtp_get_fw_client_id(struct ishtp_fw_client *fw_client) +{ + return fw_client->client_id; +} +EXPORT_SYMBOL(ishtp_get_fw_client_id); + /** * ishtp_fw_cl_by_id() - return index to fw_clients for client_id * @dev: the ishtp device structure @@ -855,6 +868,19 @@ void *ishtp_trace_callback(struct ishtp_cl_device *cl_device) } EXPORT_SYMBOL(ishtp_trace_callback); +/** + * ish_hw_reset() - Call HW reset IPC callback + * + * This interface is used to reset HW in case of error. + * + * Return: value from IPC hw_reset callback + */ +int ish_hw_reset(struct ishtp_device *dev) +{ + return dev->ops->hw_reset(dev); +} +EXPORT_SYMBOL(ish_hw_reset); + /** * ishtp_bus_register() - Function to register bus * diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.h b/drivers/hid/intel-ish-hid/ishtp/bus.h index 4aed195719de..93d516f5a853 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.h +++ b/drivers/hid/intel-ish-hid/ishtp/bus.h @@ -80,16 +80,5 @@ void ishtp_recv(struct ishtp_device *dev); void ishtp_reset_handler(struct ishtp_device *dev); void ishtp_reset_compl_handler(struct ishtp_device *dev); -void ishtp_put_device(struct ishtp_cl_device *); -void ishtp_get_device(struct ishtp_cl_device *); - -void ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data); -void *ishtp_get_drvdata(struct ishtp_cl_device *cl_device); - -int ishtp_register_event_cb(struct ishtp_cl_device *device, - void (*read_cb)(struct ishtp_cl_device *)); int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *cuuid); -struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev, - const guid_t *uuid); - #endif /* _LINUX_ISHTP_CL_BUS_H */ diff --git a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h index e0a320e67a41..3cfef084b9fc 100644 --- a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h +++ b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h @@ -238,11 +238,6 @@ static inline int ish_ipc_reset(struct ishtp_device *dev) return dev->ops->ipc_reset(dev); } -static inline int ish_hw_reset(struct ishtp_device *dev) -{ - return dev->ops->hw_reset(dev); -} - /* Exported function */ void ishtp_device_init(struct ishtp_device *dev); int ishtp_start(struct ishtp_device *dev); diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index 526e3048e09f..e98bfbb1e07e 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -9,7 +9,9 @@ #define _INTEL_ISH_CLIENT_IF_H_ struct ishtp_cl_device; +struct ishtp_device; struct ishtp_cl; +struct ishtp_fw_client; /* Client state */ enum cl_state { @@ -95,4 +97,14 @@ void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size); void ishtp_set_connection_state(struct ishtp_cl *cl, int state); void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id); +void ishtp_put_device(struct ishtp_cl_device *cl_dev); +void ishtp_get_device(struct ishtp_cl_device *cl_dev); +void ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data); +void *ishtp_get_drvdata(struct ishtp_cl_device *cl_device); +int ishtp_register_event_cb(struct ishtp_cl_device *device, + void (*read_cb)(struct ishtp_cl_device *)); +struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev, + const guid_t *uuid); +int ishtp_get_fw_client_id(struct ishtp_fw_client *fw_client); +int ish_hw_reset(struct ishtp_device *dev); #endif /* _INTEL_ISH_CLIENT_IF_H_ */ From patchwork Mon Mar 18 19:14:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858407 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 008C013B5 for ; Mon, 18 Mar 2019 19:15:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDC1F28EBD for ; Mon, 18 Mar 2019 19:15:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D244D28F7A; Mon, 18 Mar 2019 19:15:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1F6F29471 for ; Mon, 18 Mar 2019 19:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727480AbfCRTPH (ORCPT ); Mon, 18 Mar 2019 15:15:07 -0400 Received: from mga05.intel.com ([192.55.52.43]:54512 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726995AbfCRTPF (ORCPT ); Mon, 18 Mar 2019 15:15:05 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107036" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:05 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 09/10] HID: intel-ish-hid: Use the new interface functions in HID ish client Date: Mon, 18 Mar 2019 12:14:27 -0700 Message-Id: <20190318191428.6527-10-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Only include intel-ish-client-if.h, which has all interfaces required to implment ISHTP client. There is no longer any direct field access from core ISHTP only include files. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp-hid-client.c | 68 +++++++++----------- drivers/hid/intel-ish-hid/ishtp-hid.c | 2 - drivers/hid/intel-ish-hid/ishtp-hid.h | 6 +- 3 files changed, 35 insertions(+), 41 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c index 4afb39713213..56777a43e69c 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c @@ -17,8 +17,6 @@ #include #include #include -#include "ishtp/ishtp-dev.h" -#include "ishtp/client.h" #include "ishtp-hid.h" /* Rx ring buffer pool size */ @@ -40,7 +38,7 @@ static void report_bad_packet(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, size_t cur_pos, size_t payload_len) { struct hostif_msg *recv_msg = recv_buf; - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); dev_err(cl_data_to_dev(client_data), "[hid-ish]: BAD packet %02X\n" "total_bad=%u cur_pos=%u\n" @@ -77,7 +75,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, struct report_list *reports_list; char *reports; size_t report_len; - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); int curr_hid_dev = client_data->cur_hid_dev; struct ishtp_hid_data *hid_data = NULL; struct hid_device *hid = NULL; @@ -93,7 +91,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, (unsigned int)data_len, (unsigned int)sizeof(struct hostif_msg_hdr)); ++client_data->bad_recv_cnt; - ish_hw_reset(hid_ishtp_cl->dev); + ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl)); break; } @@ -106,7 +104,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, ++client_data->bad_recv_cnt; report_bad_packet(hid_ishtp_cl, recv_msg, cur_pos, payload_len); - ish_hw_reset(hid_ishtp_cl->dev); + ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl)); break; } @@ -121,7 +119,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, report_bad_packet(hid_ishtp_cl, recv_msg, cur_pos, payload_len); - ish_hw_reset(hid_ishtp_cl->dev); + ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl)); break; } client_data->hid_dev_count = (unsigned int)*payload; @@ -170,7 +168,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, report_bad_packet(hid_ishtp_cl, recv_msg, cur_pos, payload_len); - ish_hw_reset(hid_ishtp_cl->dev); + ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl)); break; } if (!client_data->hid_descr[curr_hid_dev]) @@ -195,7 +193,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, report_bad_packet(hid_ishtp_cl, recv_msg, cur_pos, payload_len); - ish_hw_reset(hid_ishtp_cl->dev); + ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl)); break; } if (!client_data->report_descr[curr_hid_dev]) @@ -313,7 +311,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, ++client_data->bad_recv_cnt; report_bad_packet(hid_ishtp_cl, recv_msg, cur_pos, payload_len); - ish_hw_reset(hid_ishtp_cl->dev); + ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl)); break; } @@ -493,7 +491,7 @@ int ishtp_hid_link_ready_wait(struct ishtp_cl_data *client_data) static int ishtp_enum_enum_devices(struct ishtp_cl *hid_ishtp_cl) { struct hostif_msg msg; - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); int retry_count; int rv; @@ -530,7 +528,7 @@ static int ishtp_enum_enum_devices(struct ishtp_cl *hid_ishtp_cl) } client_data->num_hid_devices = client_data->hid_dev_count; - dev_info(&hid_ishtp_cl->device->dev, + dev_info(ishtp_device(client_data->cl_device), "[hid-ish]: enum_devices_done OK, num_hid_devices=%d\n", client_data->num_hid_devices); @@ -549,7 +547,7 @@ static int ishtp_enum_enum_devices(struct ishtp_cl *hid_ishtp_cl) static int ishtp_get_hid_descriptor(struct ishtp_cl *hid_ishtp_cl, int index) { struct hostif_msg msg; - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); int rv; /* Get HID descriptor */ @@ -596,7 +594,7 @@ static int ishtp_get_report_descriptor(struct ishtp_cl *hid_ishtp_cl, int index) { struct hostif_msg msg; - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); int rv; /* Get report descriptor */ @@ -644,7 +642,7 @@ static int ishtp_get_report_descriptor(struct ishtp_cl *hid_ishtp_cl, static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) { struct ishtp_device *dev; - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); struct ishtp_fw_client *fw_client; int i; int rv; @@ -661,11 +659,11 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) client_data->init_done = 0; - dev = hid_ishtp_cl->dev; + dev = ishtp_get_ishtp_device(hid_ishtp_cl); /* Connect to FW client */ - hid_ishtp_cl->rx_ring_size = HID_CL_RX_RING_SIZE; - hid_ishtp_cl->tx_ring_size = HID_CL_TX_RING_SIZE; + ishtp_set_tx_ring_size(hid_ishtp_cl, HID_CL_TX_RING_SIZE); + ishtp_set_rx_ring_size(hid_ishtp_cl, HID_CL_RX_RING_SIZE); fw_client = ishtp_fw_cl_get_client(dev, &hid_ishtp_guid); if (!fw_client) { @@ -673,9 +671,9 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) "ish client uuid not found\n"); return -ENOENT; } - - hid_ishtp_cl->fw_client_id = fw_client->client_id; - hid_ishtp_cl->state = ISHTP_CL_CONNECTING; + ishtp_cl_set_fw_client_id(hid_ishtp_cl, + ishtp_get_fw_client_id(fw_client)); + ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_CONNECTING); rv = ishtp_cl_connect(hid_ishtp_cl); if (rv) { @@ -687,7 +685,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) hid_ishtp_trace(client_data, "%s client connected\n", __func__); /* Register read callback */ - ishtp_register_event_cb(hid_ishtp_cl->device, ish_cl_event_cb); + ishtp_register_event_cb(client_data->cl_device, ish_cl_event_cb); rv = ishtp_enum_enum_devices(hid_ishtp_cl); if (rv) @@ -725,7 +723,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) return 0; err_cl_disconnect: - hid_ishtp_cl->state = ISHTP_CL_DISCONNECTING; + ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_DISCONNECTING); ishtp_cl_disconnect(hid_ishtp_cl); err_cl_unlink: ishtp_cl_unlink(hid_ishtp_cl); @@ -762,7 +760,7 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work) hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__, hid_ishtp_cl); - dev_dbg(&cl_device->dev, "%s\n", __func__); + dev_dbg(ishtp_device(client_data->cl_device), "%s\n", __func__); hid_ishtp_cl_deinit(hid_ishtp_cl); @@ -771,7 +769,7 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work) return; ishtp_set_drvdata(cl_device, hid_ishtp_cl); - hid_ishtp_cl->client_data = client_data; + ishtp_set_client_data(hid_ishtp_cl, client_data); client_data->hid_ishtp_cl = hid_ishtp_cl; client_data->num_hid_devices = 0; @@ -789,7 +787,7 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work) } } -void (*hid_print_trace)(void *dev, const char *format, ...); +void (*hid_print_trace)(void *unused, const char *format, ...); /** * hid_ishtp_cl_probe() - ISHTP client driver probe @@ -819,7 +817,7 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device) return -ENOMEM; ishtp_set_drvdata(cl_device, hid_ishtp_cl); - hid_ishtp_cl->client_data = client_data; + ishtp_set_client_data(hid_ishtp_cl, client_data); client_data->hid_ishtp_cl = hid_ishtp_cl; client_data->cl_device = cl_device; @@ -851,13 +849,13 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device) static int hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device) { struct ishtp_cl *hid_ishtp_cl = ishtp_get_drvdata(cl_device); - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__, hid_ishtp_cl); dev_dbg(ishtp_device(cl_device), "%s\n", __func__); - hid_ishtp_cl->state = ISHTP_CL_DISCONNECTING; + ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_DISCONNECTING); ishtp_cl_disconnect(hid_ishtp_cl); ishtp_put_device(cl_device); ishtp_hid_remove(client_data); @@ -881,7 +879,7 @@ static int hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device) static int hid_ishtp_cl_reset(struct ishtp_cl_device *cl_device) { struct ishtp_cl *hid_ishtp_cl = ishtp_get_drvdata(cl_device); - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__, hid_ishtp_cl); @@ -891,8 +889,6 @@ static int hid_ishtp_cl_reset(struct ishtp_cl_device *cl_device) return 0; } -#define to_ishtp_cl_device(d) container_of(d, struct ishtp_cl_device, dev) - /** * hid_ishtp_cl_suspend() - ISHTP client driver suspend * @device: device instance @@ -903,9 +899,9 @@ static int hid_ishtp_cl_reset(struct ishtp_cl_device *cl_device) */ static int hid_ishtp_cl_suspend(struct device *device) { - struct ishtp_cl_device *cl_device = to_ishtp_cl_device(device); + struct ishtp_cl_device *cl_device = dev_get_drvdata(device); struct ishtp_cl *hid_ishtp_cl = ishtp_get_drvdata(cl_device); - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__, hid_ishtp_cl); @@ -924,9 +920,9 @@ static int hid_ishtp_cl_suspend(struct device *device) */ static int hid_ishtp_cl_resume(struct device *device) { - struct ishtp_cl_device *cl_device = to_ishtp_cl_device(device); + struct ishtp_cl_device *cl_device = dev_get_drvdata(device); struct ishtp_cl *hid_ishtp_cl = ishtp_get_drvdata(cl_device); - struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data; + struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__, hid_ishtp_cl); diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.c b/drivers/hid/intel-ish-hid/ishtp-hid.c index 95a5b87d9105..62c03561adaa 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid.c @@ -16,7 +16,6 @@ #include #include #include -#include "ishtp/client.h" #include "ishtp-hid.h" /** @@ -154,7 +153,6 @@ static void ishtp_hid_request(struct hid_device *hid, struct hid_report *rep, static int ishtp_wait_for_response(struct hid_device *hid) { struct ishtp_hid_data *hid_data = hid->driver_data; - struct ishtp_cl_data *client_data = hid_data->client_data; int rv; hid_ishtp_trace(client_data, "%s hid %p\n", __func__, hid); diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.h b/drivers/hid/intel-ish-hid/ishtp-hid.h index 8af44e855a49..e27d3d6c1920 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid.h +++ b/drivers/hid/intel-ish-hid/ishtp-hid.h @@ -24,9 +24,9 @@ #define IS_RESPONSE 0x80 /* Used to dump to Linux trace buffer, if enabled */ -#define hid_ishtp_trace(client, ...) \ - client->cl_device->ishtp_dev->print_log(\ - client->cl_device->ishtp_dev, __VA_ARGS__) +extern void (*hid_print_trace)(void *unused, const char *format, ...); +#define hid_ishtp_trace(client, ...) \ + (hid_print_trace)(NULL, __VA_ARGS__) /* ISH Transport protocol (ISHTP in short) GUID */ static const guid_t hid_ishtp_guid = From patchwork Mon Mar 18 19:14:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 10858409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 675106C2 for ; Mon, 18 Mar 2019 19:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DDD928E13 for ; Mon, 18 Mar 2019 19:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DD8B28DDF; Mon, 18 Mar 2019 19:15:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C254128EB9 for ; Mon, 18 Mar 2019 19:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726728AbfCRTP3 (ORCPT ); Mon, 18 Mar 2019 15:15:29 -0400 Received: from mga05.intel.com ([192.55.52.43]:54512 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727485AbfCRTPH (ORCPT ); Mon, 18 Mar 2019 15:15:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 12:15:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,494,1544515200"; d="scan'208";a="156107038" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2019 12:15:05 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 10/10] HID: intel-ish-hid: Add interface function for PCI device pointer Date: Mon, 18 Mar 2019 12:14:28 -0700 Message-Id: <20190318191428.6527-11-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> References: <20190318191428.6527-1-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of directly accessing PCI device poitner via struct ishtp_cl, create interface function for same. This is required for DMA transfer. Signed-off-by: Srinivas Pandruvada --- drivers/hid/intel-ish-hid/ishtp/bus.c | 13 +++++++++++++ include/linux/intel-ish-client-if.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index 66a485a41481..fb8ca12955b4 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -855,6 +855,19 @@ struct device *ishtp_device(struct ishtp_cl_device *device) } EXPORT_SYMBOL(ishtp_device); +/** + * ishtp_get_pci_device() - Return PCI device dev pointer + * This interface is used to return PCI device pointer + * from ishtp_cl_device instance. + * + * Return: device *. + */ +struct device *ishtp_get_pci_device(struct ishtp_cl_device *device) +{ + return device->ishtp_dev->devc; +} +EXPORT_SYMBOL(ishtp_get_pci_device); + /** * ishtp_trace_callback() - Return trace callback * diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index e98bfbb1e07e..16255c2ca2f4 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -77,6 +77,8 @@ int ishtp_register_event_cb(struct ishtp_cl_device *device, struct device *ishtp_device(struct ishtp_cl_device *cl_device); /* Trace interface for clients */ void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); +/* Get device pointer of PCI device for DMA acces */ +struct device *ishtp_get_pci_device(struct ishtp_cl_device *cl_device); struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); void ishtp_cl_free(struct ishtp_cl *cl);