From patchwork Mon Jan 25 18:29:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Azael Avalos X-Patchwork-Id: 8113881 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9CD8C9F440 for ; Mon, 25 Jan 2016 18:30:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C04BA20279 for ; Mon, 25 Jan 2016 18:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF4312025A for ; Mon, 25 Jan 2016 18:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758054AbcAYS3k (ORCPT ); Mon, 25 Jan 2016 13:29:40 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:34185 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758002AbcAYS3a (ORCPT ); Mon, 25 Jan 2016 13:29:30 -0500 Received: by mail-oi0-f68.google.com with SMTP id x140so7716761oif.1; Mon, 25 Jan 2016 10:29:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NGzobHdL5XWbvmtqmQCHiPE+6WQfq8rgqBfi6c4R9yw=; b=RyVnGrj8L7UZGCbag9z3r6ubD4vjS9JSxmzqEASr9mStgKemR1/zfzs2zROnx6ISw1 IEvzHuzK5+/v6y84hpK8m2oogzI+8JVB2ndDEpdj1o3IwN04MhbM9nidRNrzd8ZURZId pGjJ3I2VAdV1xz2YD2UQfjs2Y228B8mYf+WabiQ8qOJimJ4LRmfE3oYjfYukC6AUjpdV kDC7jD4aI2Yuj76JgHZmT+xLmAm0n6DzfMkknR8VBQSGFrjuqeobb80V8a3jq1lYXDa8 958J3C/xA9797/X6ZLOVbdwSdtDACmKJOJOh0oHuvL7KgzL7fYRsKK47Y0b1nO6tTXIw MYcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NGzobHdL5XWbvmtqmQCHiPE+6WQfq8rgqBfi6c4R9yw=; b=Uoto3bwkyYbBHuPso7MoAMJwIl3g0FGqJSDEtQbFhgYEcnASKESx4os6aP9bb41cRP gwlOfExopAQVjOHfJvaQdnUF218am9DQhPrMTOzO0Fc0qb3OJgYu3eaCCNlUvompas/q gtZLTdhUlua5bbREIQaTh+55g0GH0B9bsm3JvPYywVrbBgY7L6lzeldyrOI+lqbQdtNB ZWHeE4VEf7lkus/pTN+naju5UWwggwEawOHfRCf96EuUPPrg9f6mWcZ7C8K3g6vF5A/c 3qQ5HQyZU2xbpmMzWwAFof9BklR+m+QJhXz/nFd+g4/iy5nC0ra1sOspma4KTno8BlU4 qoSg== X-Gm-Message-State: AG10YOS4DkqJsERGfplNgaFr/Ht9Egi945EiJpxROHGV59tvBHr5UBtxhQ8X7jFH+l+t1g== X-Received: by 10.202.239.212 with SMTP id n203mr14039135oih.77.1453746570174; Mon, 25 Jan 2016 10:29:30 -0800 (PST) Received: from Shakuras.scurra.org ([148.210.108.137]) by smtp.gmail.com with ESMTPSA id w6sm11023833obx.9.2016.01.25.10.29.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Jan 2016 10:29:29 -0800 (PST) From: Azael Avalos To: Darren Hart , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Azael Avalos Subject: [PATCH 2/2] toshiba_acpi: Add sysfs entries for the Cooling Method feature Date: Mon, 25 Jan 2016 11:29:11 -0700 Message-Id: <1453746551-17496-3-git-send-email-coproscefalo@gmail.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1453746551-17496-1-git-send-email-coproscefalo@gmail.com> References: <1453746551-17496-1-git-send-email-coproscefalo@gmail.com> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the sysfs entry Signed-off-by: Azael Avalos --- drivers/platform/x86/toshiba_acpi.c | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index c6f92ec..5ace1e0 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -2289,6 +2289,54 @@ static ssize_t usb_three_store(struct device *dev, } static DEVICE_ATTR_RW(usb_three); +static ssize_t cooling_method_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); + int state; + int ret; + + ret = toshiba_cooling_method_get(toshiba, &state); + if (ret < 0) + return ret; + + return sprintf(buf, "%d %d\n", state, toshiba->max_cooling_method); +} + +static ssize_t cooling_method_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); + int state; + int ret; + + ret = kstrtoint(buf, 0, &state); + if (ret) + return ret; + + /* + * Check for supported values + * Depending on the laptop model, some only support these two: + * 0 - Maximum Performance + * 1 - Battery Optimized + * + * While some others support all three methods: + * 0 - Maximum Performance + * 1 - Performance + * 2 - Battery Optimized + */ + if (state < 0 || state > toshiba->max_cooling_method) + return -EINVAL; + + ret = toshiba_cooling_method_set(toshiba, state); + if (ret) + return ret; + + return count; +} +static DEVICE_ATTR_RW(cooling_method); + static struct attribute *toshiba_attributes[] = { &dev_attr_version.attr, &dev_attr_fan.attr, @@ -2305,6 +2353,7 @@ static struct attribute *toshiba_attributes[] = { &dev_attr_kbd_function_keys.attr, &dev_attr_panel_power_on.attr, &dev_attr_usb_three.attr, + &dev_attr_cooling_method.attr, NULL, }; @@ -2339,6 +2388,8 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj, exists = (drv->panel_power_on_supported) ? true : false; else if (attr == &dev_attr_usb_three.attr) exists = (drv->usb_three_supported) ? true : false; + else if (attr == &dev_attr_cooling_method.attr) + exists = (drv->cooling_method_supported) ? true : false; return exists ? attr->mode : 0; }