From patchwork Tue Oct 17 18:21:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10012703 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69E8D60211 for ; Tue, 17 Oct 2017 18:24:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61FE0289CB for ; Tue, 17 Oct 2017 18:24:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 542F2289D2; Tue, 17 Oct 2017 18:24: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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 0C35F289CB for ; Tue, 17 Oct 2017 18:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933046AbdJQSXw (ORCPT ); Tue, 17 Oct 2017 14:23:52 -0400 Received: from esa7.dell-outbound.iphmx.com ([68.232.153.96]:19818 "EHLO esa7.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758221AbdJQSWM (ORCPT ); Tue, 17 Oct 2017 14:22:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1508264101; x=1539800101; h=from:to:cc:subject:date:message-id; bh=MXj+FOzqZ1aFOfNR4seXrlaeMXEyDaYHAAFgGpAfkqw=; b=yMeO5mmyXLRfZYKRT3Xdbn2m1M2XDjSjlYxaAJ4UQ2Us0gtpmwMy+zQp Cihk4ZSkixmqzzeeOIEU9ipufGAwpEpVtxTHdeEoCJaj+OvtRH+7d7H2E p4/HICwqr5uKw9Qhb7wH9wrSFxPQPCQNWH2Ha64JplDru+ZjewY7keTaO M=; Received: from esa1.dell-outbound2.iphmx.com ([68.232.153.201]) by esa7.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2017 13:14:57 -0500 Received: from ausxipps306.us.dell.com ([143.166.148.156]) by esa1.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Oct 2017 00:21:15 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.43,391,1503378000"; d="scan'208";a="161471198" X-DLP: DLP_GlobalPCIDSS From: Mario Limonciello To: dvhart@infradead.org, Andy Shevchenko Cc: LKML , platform-driver-x86@vger.kernel.org, Andy Lutomirski , quasisec@google.com, pali.rohar@gmail.com, rjw@rjwysocki.net, mjg59@google.com, hch@lst.de, Greg KH , Alan Cox , Mario Limonciello Subject: [PATCH v9 13/17] platform/x86: wmi: Add sysfs attribute for required_buffer_size Date: Tue, 17 Oct 2017 13:21:57 -0500 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Method type WMI objects need to be able to describe the size of the interface that they will expect to use. Export this information to sysfs and allow vendor drivers to set it. Signed-off-by: Mario Limonciello Reviewed-by: Edward O'Callaghan --- drivers/platform/x86/wmi.c | 31 +++++++++++++++++++++++++++++++ include/linux/wmi.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index bcb41c1c7f52..63d01f98bf4c 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -72,6 +72,7 @@ struct wmi_block { struct acpi_device *acpi_device; wmi_notify_handler handler; void *handler_data; + u64 req_buf_size; bool read_takes_no_args; }; @@ -188,6 +189,26 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) /* * Exported WMI functions */ + +/** + * set_required_buffer_size - Sets the buffer size needed for performing IOCTL + * @wdev: A wmi bus device from a driver + * @instance: Instance index + * + * Allocates memory needed for buffer, stores the buffer size in that memory + */ +int set_required_buffer_size(struct wmi_device *wdev, u8 instance, u64 length) +{ + struct wmi_block *wblock; + + wblock = container_of(wdev, struct wmi_block, dev); + if (!wblock) + return -ENODEV; + wblock->req_buf_size = length; + return 0; +} +EXPORT_SYMBOL_GPL(set_required_buffer_size); + /** * wmi_evaluate_method - Evaluate a WMI method * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba @@ -718,8 +739,18 @@ static struct attribute *wmi_data_attrs[] = { }; ATTRIBUTE_GROUPS(wmi_data); +static ssize_t required_buffer_size_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct wmi_block *wblock = dev_to_wblock(dev); + + return sprintf(buf, "%lld\n", wblock->req_buf_size); +} +static DEVICE_ATTR_RO(required_buffer_size); + static struct attribute *wmi_method_attrs[] = { &dev_attr_object_id.attr, + &dev_attr_required_buffer_size.attr, NULL, }; ATTRIBUTE_GROUPS(wmi_method); diff --git a/include/linux/wmi.h b/include/linux/wmi.h index ddee427e0721..a9a72a4c5ed8 100644 --- a/include/linux/wmi.h +++ b/include/linux/wmi.h @@ -36,6 +36,9 @@ extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev, extern union acpi_object *wmidev_block_query(struct wmi_device *wdev, u8 instance); +extern int set_required_buffer_size(struct wmi_device *wdev, u8 instance, + u64 length); + struct wmi_device_id { const char *guid_string; };