From patchwork Sun Oct 20 17:00:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayman Bagabas X-Patchwork-Id: 11201039 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9FC71390 for ; Sun, 20 Oct 2019 17:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95C7D218BA for ; Sun, 20 Oct 2019 17:00:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HOyNo4Wv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726556AbfJTRA3 (ORCPT ); Sun, 20 Oct 2019 13:00:29 -0400 Received: from mail-vk1-f196.google.com ([209.85.221.196]:43737 "EHLO mail-vk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbfJTRA2 (ORCPT ); Sun, 20 Oct 2019 13:00:28 -0400 Received: by mail-vk1-f196.google.com with SMTP id i21so199316vka.10; Sun, 20 Oct 2019 10:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=7xTKcAHDsuXP3J9ZHHpeh3KHfStzUnhUUmFI7W4D55s=; b=HOyNo4WvAqisv+1p12J+bckQ+w3fyRj4Za0GVf9Gai7P9M2/MFs5LZI3bIHD4ycpEG YJu+xDgmwAjqKsfyEdEnXTw/fc23VDLNfZcvIKjrzytnKIh3yrFLVeCBT41bow7TdaXJ mRQ0lK3VRFXFZtJ0/a3W1bUlRJ7u+Woz3PYxOPoZSRPlATyCkLWqPMsceE3AeIKHJRdX qpucNtbVSJhjMpPopBwNJUgKxc4SlI/4kMkQGuteVJKnEXs+dPOGBFUDgdvh4V/tFxpV 2TbOoZGFHX1yWnNYSjkTSehMPe1tJHn5Kn43kMQG8RBUMOei7xC1kZhgT5w4kh00Gd0L KL0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=7xTKcAHDsuXP3J9ZHHpeh3KHfStzUnhUUmFI7W4D55s=; b=HGo8WQV18fEvFm8CjJuD++3nF6+Ci1z9kcdI8EwD+0+wr5e6IeuHUNUFUst3O7IGz7 c15bd9F8Z+xeG0SdcBUCoQZoOD3wJTsRsSSagdfQruK73Fe7duSFcCjiAKjeXvCrx6vQ l9dRd3off06Vg7IKm9vmsi6hL/ShsOTeJ+QSPucM0SuRe7Yyd3XeoJOcYFboGNUHQtvF y+fg0nkeqHE50NjgnjvPW5bOcmx8dt92xXXdRYvLxeguelJZgTjJ51raaNqOcwO8ZVIK zePn+scD1r9bESO036u7rbpohyvLI/yr688imdGzR/ZUR5vnrvDMJaCSdLjtp3t/TzkJ 7+gw== X-Gm-Message-State: APjAAAUUD+fe288f2N8IzyMX+JAoVwLMhJuw61uGyvBzv6zhT7mP667A YzZuhcn7k8Pcut8NXO3aBg== X-Google-Smtp-Source: APXvYqx8dy1VdnoJuEUxEP2aZNFtgDDh3RRXasgijwFdpUtwC5iTSuTjGxbRQehlW5ONyG9g40ukhQ== X-Received: by 2002:a1f:a48a:: with SMTP id n132mr10687027vke.68.1571590827355; Sun, 20 Oct 2019 10:00:27 -0700 (PDT) Received: from localhost.localdomain ([2601:901:202:18cc:820:670:dd1:f572]) by smtp.gmail.com with ESMTPSA id n126sm612962vke.51.2019.10.20.10.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 10:00:26 -0700 (PDT) From: Ayman Bagabas To: Darren Hart , Andy Shevchenko , Ayman Bagabas , Takashi Iwai , Mattias Jacobsson <2pi@mok.nu>, kbuild test robot , Dan Carpenter , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] platform/x86: huawei-wmi: Stricter battery thresholds set Date: Sun, 20 Oct 2019 13:00:07 -0400 Message-Id: <20191020170020.26251-1-ayman.bagabas@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Check if battery thresholds are within 0 and 100. Fixes: 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging thresholds") Signed-off-by: Ayman Bagabas --- drivers/platform/x86/huawei-wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: c4b9850b3676869ac0def5885d781d17f64b3a86 diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c index 5837d1b8693d..26041d44286a 100644 --- a/drivers/platform/x86/huawei-wmi.c +++ b/drivers/platform/x86/huawei-wmi.c @@ -345,7 +345,7 @@ static int huawei_wmi_battery_set(int start, int end) union hwmi_arg arg; int err; - if (start < 0 || end > 100) + if (start < 0 || end < 0 || start > 100 || end > 100) return -EINVAL; arg.cmd = BATTERY_THRESH_SET; From patchwork Sun Oct 20 17:00:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayman Bagabas X-Patchwork-Id: 11201041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB46F1390 for ; Sun, 20 Oct 2019 17:00:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 992F3218BA for ; Sun, 20 Oct 2019 17:00:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f5m+2UYd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726647AbfJTRAk (ORCPT ); Sun, 20 Oct 2019 13:00:40 -0400 Received: from mail-vs1-f65.google.com ([209.85.217.65]:45042 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbfJTRAk (ORCPT ); Sun, 20 Oct 2019 13:00:40 -0400 Received: by mail-vs1-f65.google.com with SMTP id w195so7311314vsw.11; Sun, 20 Oct 2019 10:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=jChDDBy/9+W5GZtGAP1vvb6UndWx2h0r7qmx1nXdLZQ=; b=f5m+2UYdDT6A2PtBNADex63H4WOtWOUoUWxFm9ldPVKHU1Rkv1uKwyyioIjWge5b6e ESZ1z9tFKDZzDF93ukQQ231EJLmEdYjpFigFvj8lkIlxWC7Im3rm6FFLk0/ogVM33to1 ybD3ugPl55Vj0+6pv2orTMu2IJOpCkxybZHixG3QfI1ZwfAhr5SnAjb7vx0MglhnWHF6 WZRq9MiGO8tZlhVZeiwa1thERdtOi8DW2z7H12r/R12wYrHLNXCu9VNt/ctDocYBtJlQ WVGNh+pC/WrnpxXW8L1zKeLn3vurOkyec0AdjnraqaFhZbBeAHrfze/Vrsm8cXwxV6yc APxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jChDDBy/9+W5GZtGAP1vvb6UndWx2h0r7qmx1nXdLZQ=; b=HypjIO0uYqNMzahVR0/XqQBrA7Qv9NWikBD5XOGAlWE9STTlv3+3q47Dr3aBbwjfIr D5l92IXpHisAahU0grDRBMd5UNz2es19RCLd4W1YP4togSLs3XcAgcZRA4pLNTiYmUAQ IRN7FOlcdSDynWpFu0zQwqrfOpBeGID/qWqN1RRpDwrj3xdbzti/mZyLN3sFpsd2XiYn wFTghRFTwkAezDK1VRQFJqeXyPA6k9F8U83tPl3LGJJYydsDJiRBD+hOUFcnkZ+4RPAk XCL9Ahm9J4+C5mFzYKf0YF+DpOQ5/L3H1E18r4Q1w8gQ3Mg2TUp/nX63ATcoJtQo5ZDM /zxw== X-Gm-Message-State: APjAAAUHw6AOVjnRPUP7hMZFKYobEy9S/tYvINBqh1dxVCAduqgjD9s2 FPwV1XwLLijOFTPezAyKbg== X-Google-Smtp-Source: APXvYqx5TQEy2L3c9lr8dqAHe47qFy3qlGAAz9XIOKD7z90IRbBeOqDpRXCrqnWOfmJhl3du3H0gkw== X-Received: by 2002:a67:8841:: with SMTP id k62mr11423664vsd.101.1571590839137; Sun, 20 Oct 2019 10:00:39 -0700 (PDT) Received: from localhost.localdomain ([2601:901:202:18cc:820:670:dd1:f572]) by smtp.gmail.com with ESMTPSA id n126sm612962vke.51.2019.10.20.10.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 10:00:38 -0700 (PDT) From: Ayman Bagabas To: Darren Hart , Andy Shevchenko , Ayman Bagabas , Mattias Jacobsson <2pi@mok.nu>, Takashi Iwai , Dan Carpenter , kbuild test robot , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] platform/x86: huawei-wmi: No need to check for battery name Date: Sun, 20 Oct 2019 13:00:08 -0400 Message-Id: <20191020170020.26251-2-ayman.bagabas@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191020170020.26251-1-ayman.bagabas@gmail.com> References: <20191020170020.26251-1-ayman.bagabas@gmail.com> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org No need to check for battery name, we already check if the WMI function is available in huawei_wmi_battery_setup. Fixes: 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging thresholds") Signed-off-by: Ayman Bagabas --- drivers/platform/x86/huawei-wmi.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c index 26041d44286a..7373a65a61d3 100644 --- a/drivers/platform/x86/huawei-wmi.c +++ b/drivers/platform/x86/huawei-wmi.c @@ -471,10 +471,6 @@ static DEVICE_ATTR_RW(charge_control_thresholds); static int huawei_wmi_battery_add(struct power_supply *battery) { - /* Huawei laptops come with one battery only */ - if (strcmp(battery->desc->name, "BAT") != 1) - return -ENODEV; - device_create_file(&battery->dev, &dev_attr_charge_control_start_threshold); device_create_file(&battery->dev, &dev_attr_charge_control_end_threshold); From patchwork Sun Oct 20 17:00:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayman Bagabas X-Patchwork-Id: 11201043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 576921599 for ; Sun, 20 Oct 2019 17:00:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35CA621897 for ; Sun, 20 Oct 2019 17:00:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LqpjWLD8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726645AbfJTRAw (ORCPT ); Sun, 20 Oct 2019 13:00:52 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:45227 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbfJTRAw (ORCPT ); Sun, 20 Oct 2019 13:00:52 -0400 Received: by mail-vs1-f66.google.com with SMTP id e19so7309836vsb.12; Sun, 20 Oct 2019 10:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Z3rFbdU+SplPcjhPOqnh6Ex901p18xA+QjA1SeUaWkw=; b=LqpjWLD8LLWxBJgS4hvN2oCSEiU5rjiaPgS+Dzz8QcV2skMzKalLhWugfPSCZYlugw 9B4RIMV3npSVJ7O/DXNuErQT2KlGOcBxmnDfX/Fsi/3r2J/jkekCmsdFMB1GhAwl69xa bVvr3nobbXQ5A2f49tCEO9Eiqbu8XIKbBfHgIR/TZ/3A/vZheBpk3eObUrgSOOkN/Gaj jNJ6I31J8AzzayGDeOaRYg7jpEhJlVKer1Actg1Q9aZW7BDspap01pZcqklx5OePC8RY tRF2v62tLIdfZey4bg7eAVw6xcv+VHfwoQy8SrruzC5UK3s7yNB2bAo1ZB0eAbTnq0cn krdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z3rFbdU+SplPcjhPOqnh6Ex901p18xA+QjA1SeUaWkw=; b=Ir4r3DXwCbQa+q22D17GiAz8qttr+1gBhN7lbs9aqVjmWCzYLo1JoGXN77KKjZJ+HT 5IkY0gAPlP3dXtMTI4N2ve4Ug8fJqR0uQKnl5Rx7dcxpdJ4nvoj+B8A+NZ72h07k3eLl nB+NebHikt9Irf4QAuStt++VWCnuIxVWLnhyQgktYrvygKc3EpGAjK7yXxD2ih704mzB 0M8zQvcku540I79QxP7xU2Gax2VIKN1xrsFqUyTAzTW9Et96C7EExP4mE+ec9u1/Z064 TKt2FImLjy14HBIOKpu04IHzh4wlnIgUjt3bIUa6VJjmcq3H93+3sM5GVAlTLMSdKDZr ovsg== X-Gm-Message-State: APjAAAWpYJWNy2h1ES3hsoY/ZxicYrXB6WisOx7qhfl/60wPBD/ElyQE KtSqCf24ZEw+rzb2+yrSQw== X-Google-Smtp-Source: APXvYqyrs6R30s8uibpzuM+64Scem0970K4MY9fjtJ05Zk0lFUy1F+qOyu6EY9rlWKrHNWV80Hct2w== X-Received: by 2002:a67:e3da:: with SMTP id k26mr10838781vsm.81.1571590850153; Sun, 20 Oct 2019 10:00:50 -0700 (PDT) Received: from localhost.localdomain ([2601:901:202:18cc:820:670:dd1:f572]) by smtp.gmail.com with ESMTPSA id n126sm612962vke.51.2019.10.20.10.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 10:00:49 -0700 (PDT) From: Ayman Bagabas To: Darren Hart , Andy Shevchenko , Ayman Bagabas , Takashi Iwai , Mattias Jacobsson <2pi@mok.nu>, kbuild test robot , Dan Carpenter , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] platform/x86: huawei-wmi: Remove unnecessary battery mutex Date: Sun, 20 Oct 2019 13:00:09 -0400 Message-Id: <20191020170020.26251-3-ayman.bagabas@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191020170020.26251-1-ayman.bagabas@gmail.com> References: <20191020170020.26251-1-ayman.bagabas@gmail.com> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org battery_lock mutex is never used and not needed. Fixes: 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging thresholds") Signed-off-by: Ayman Bagabas --- drivers/platform/x86/huawei-wmi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c index 7373a65a61d3..a2d846c4a7ee 100644 --- a/drivers/platform/x86/huawei-wmi.c +++ b/drivers/platform/x86/huawei-wmi.c @@ -67,7 +67,6 @@ struct huawei_wmi { struct led_classdev cdev; struct device *dev; - struct mutex battery_lock; struct mutex wmi_lock; }; @@ -807,7 +806,6 @@ static int huawei_wmi_probe(struct platform_device *pdev) if (wmi_has_guid(HWMI_METHOD_GUID)) { mutex_init(&huawei_wmi->wmi_lock); - mutex_init(&huawei_wmi->battery_lock); huawei_wmi_leds_setup(&pdev->dev); huawei_wmi_fn_lock_setup(&pdev->dev);