From patchwork Fri Sep 21 10:10:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10609665 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 B21A85A4 for ; Fri, 21 Sep 2018 10:10:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F6D72D73C for ; Fri, 21 Sep 2018 10:10:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91C242D7AF; Fri, 21 Sep 2018 10:10:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 23FA72D73C for ; Fri, 21 Sep 2018 10:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389642AbeIUP7B (ORCPT ); Fri, 21 Sep 2018 11:59:01 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:56138 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbeIUP7B (ORCPT ); Fri, 21 Sep 2018 11:59:01 -0400 Received: by mail-wm1-f68.google.com with SMTP id f21-v6so2436291wmc.5; Fri, 21 Sep 2018 03:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p0vxQJrW8p1Rec88UNy3atst5yfRwb5Gz6J6VEWXW1g=; b=IXpjSgMSsRFOr0yT84YLfMHz2TWtSajozPAlR2jJD7qxWsMdjujQhRZfeRuBZmx3q2 lYtf5bxBABjQe+pyip5fL/rqG9XWahG2vnn/j8NZyV7Z4ZX5wwxqKTa3j+UVwcCPZQoN Hx4CzeNhXeUjTGoI5HcVxcVciOlupDwAgXzVfJ7TY76gcaJbgWsheXT+uATDGVZorhlg ENEk9A9uKiek66NcbJJGHEwrajz0+ULXq1emw0rcgQoGLQH0PSvpJCSgfKI5TMC9QH1+ nDmywmgVQA1DOV/i3CUgREPesXU0nMEMktYpisd9+Sxm9n8HAGiLyFPpaoofizuVYIW6 0Jzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p0vxQJrW8p1Rec88UNy3atst5yfRwb5Gz6J6VEWXW1g=; b=FmK5C3PgBeWkeAjXwKsgx0QKdInfzKw7lZCjQSeb2Iyq4n+uwsQfLQZbH6Db5qvFaS 1VbK19lOW8b+F9IHzZl15FGyy2mGMIPzMGfX+e/C5aJ3uQiweCEsTGXAqPyw+qr4wGCT OnQUqFYa8uUzOtYk43DGEt/FoMgjfCsJwqsri24CIRoX2rbEXPiv3uSjnmSxusLp2RKX nKlU1VFetht69RqT0dwkt2ttEoonnq7F0V+dA0dpRKI/pjVPLwJURfIETUMg6Ry4U5aZ 8Ia9ZOcMi77rT0jGMwkcHmR4LO4PTDVaUI78xsmivnhOswuY2QJVuJScpehb8Z0zkyAh rCKw== X-Gm-Message-State: ABuFfogo+bBwda2PCA5AF3tZyDX0OjvlniXWIVQY1/WEnoVGj8sqR33B etKqCjWBR9hTQO8fnHzvYAg= X-Google-Smtp-Source: ACcGV62BJh3VzPWnZsOR/88SPM6F00DDKb9KqRN4wvfosx8Y/PF4atj89M6eaIUWp+WCpNvduGxBpQ== X-Received: by 2002:a1c:b404:: with SMTP id d4-v6mr6452893wmf.28.1537524650414; Fri, 21 Sep 2018 03:10:50 -0700 (PDT) Received: from localhost (pD9E515A3.dip0.t-ipconnect.de. [217.229.21.163]) by smtp.gmail.com with ESMTPSA id u1-v6sm19528013wrt.59.2018.09.21.03.10.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Sep 2018 03:10:49 -0700 (PDT) From: Thierry Reding To: Jean Delvare , Guenter Roeck Cc: Kamil Debski , Bartlomiej Zolnierkiewicz , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] hwmon: pwm-fan: Silence error on probe deferral Date: Fri, 21 Sep 2018 12:10:47 +0200 Message-Id: <20180921101048.11679-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Probe deferrals aren't actual errors, so silence the error message in case the PWM cannot yet be acquired. Signed-off-by: Thierry Reding --- drivers/hwmon/pwm-fan.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 7838af58f92d..936aaf76dd6e 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -221,8 +221,12 @@ static int pwm_fan_probe(struct platform_device *pdev) ctx->pwm = devm_of_pwm_get(&pdev->dev, pdev->dev.of_node, NULL); if (IS_ERR(ctx->pwm)) { - dev_err(&pdev->dev, "Could not get PWM\n"); - return PTR_ERR(ctx->pwm); + ret = PTR_ERR(ctx->pwm); + + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "Could not get PWM: %d\n", ret); + + return ret; } platform_set_drvdata(pdev, ctx); From patchwork Fri Sep 21 10:10:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10609667 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 240D014DA for ; Fri, 21 Sep 2018 10:11:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140732D7B1 for ; Fri, 21 Sep 2018 10:11:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07B792D7EB; Fri, 21 Sep 2018 10:11:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 9F14A2D7B1 for ; Fri, 21 Sep 2018 10:11:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725898AbeIUP7D (ORCPT ); Fri, 21 Sep 2018 11:59:03 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35199 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389630AbeIUP7C (ORCPT ); Fri, 21 Sep 2018 11:59:02 -0400 Received: by mail-wr1-f66.google.com with SMTP id j26-v6so12286468wre.2; Fri, 21 Sep 2018 03:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+k8VQnKn4mutcliPiNEY+rHvbFqnNR24naQdY6mjm90=; b=JgaB21sWBO6OpxFqgWMQavCm/A+X6hF2JaWSmFzpr9+DEbV3NPYZAo6KEEi1QV7S4l 3kiX+GyqwgTUmLIuqpuxQ47J+RiziJF5OCp8/F2FGB4oeau5V7GalasRrLeGfVmkoBFm 2JeTjYbXWjbB33uI/bN1KTeMHokqGRZ5iAg2bWcOP5PKuDKFEetg6zmHd8t/7WCzr7Be K+FKWD/D85Nyd7LiIs+XquKiRaJUY7MZLlcRsrpDuHsinvdIXXF4pb3LheT/HU3AmgK8 em5UWTQTL9HqHUPN39qPdFcO59XZxzSt+JoAvmHNUeZH1NLuPk2D6BeJ6aq3w00mnjB7 t73A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+k8VQnKn4mutcliPiNEY+rHvbFqnNR24naQdY6mjm90=; b=fwWJLvt5yMuIrS9VV5kSYkYarTYRxhjRsTZTaXYEjfzroBA1HwlVpoy8utMWg/mi+R 6swYLR1f3LUNgn0W4JYdMtRkLWJKCYXp3PU/7+gh/a6ir5kJ6QqtWeFjxI+NPegkZUkN HCS16PR0u5YklMuSqnsyD8GkAFGND3GnQnWDQN1pW+aEnBah0QkJBmkQxW7ddQRLRf3O oZtHhF35xxE1qKh1IvvdNMkUjDcBty3GNwumygM7CM0xM/1Ak4BnpiO9lz8oCxq1PLZC XUZk9mOI3VXPSvWzky6hCDpyqyCxmYfPpnpK4s1cFuxbF5M3OFbYSEgGhwpbQ1TG6Ok6 CV7w== X-Gm-Message-State: APzg51CoEq8YYoVUsP6lgM7n40jXUVYoSwuUOuDLkzPjKnhDLgDG7jTb R8epjFrbgpJXtuvOEd/YUEKgpXe6 X-Google-Smtp-Source: ANB0VdYFCd5AGIaBmfOSFeAXSVTGl/SCbnuZdUzCs9onEUmGa3tY41jBtKH3YnN7Vd4CyW57J1Ta2A== X-Received: by 2002:adf:e711:: with SMTP id c17-v6mr36970485wrm.143.1537524651799; Fri, 21 Sep 2018 03:10:51 -0700 (PDT) Received: from localhost (pD9E515A3.dip0.t-ipconnect.de. [217.229.21.163]) by smtp.gmail.com with ESMTPSA id j191-v6sm4618354wmb.37.2018.09.21.03.10.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Sep 2018 03:10:51 -0700 (PDT) From: Thierry Reding To: Jean Delvare , Guenter Roeck Cc: Kamil Debski , Bartlomiej Zolnierkiewicz , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] hwmon: pwm-fan: Set fan speed to 0 on suspend Date: Fri, 21 Sep 2018 12:10:48 +0200 Message-Id: <20180921101048.11679-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180921101048.11679-1-thierry.reding@gmail.com> References: <20180921101048.11679-1-thierry.reding@gmail.com> MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Technically this is not required because disabling the PWM should be enough. However, when support for atomic operations was implemented in the PWM subsystem, only actual changes to the PWM channel are applied during pwm_config(), which means that during after resume from suspend the old settings won't be applied. One possible solution is for the PWM driver to implement its own PM operations such that settings from before suspend get applied on resume. This has the disadvantage of completely ignoring any particular ordering requirements that PWM user drivers might have, so it is best to leave it up to the user drivers to apply the settings that they want at the appropriate time. Another way to solve this would be to read back the current state of the PWM at the time of resume. That way, in case the configuration was lost during suspend, applying the old settings in PWM user drivers would actually get them applied because they differ from the current settings. However, not all PWM drivers support reading the hardware state, and not all hardware may support it. The best workaround at this point seems to be to let PWM user drivers tell the PWM subsystem that the PWM is turned off by, in addition to disabling it, also setting the duty cycle to 0. This causes the resume operation to apply a configuration that is different from the current configuration, resulting in the proper state from before suspend getting restored. Signed-off-by: Thierry Reding --- drivers/hwmon/pwm-fan.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 936aaf76dd6e..7da6a160d45a 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -294,9 +294,19 @@ static int pwm_fan_remove(struct platform_device *pdev) static int pwm_fan_suspend(struct device *dev) { struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); + struct pwm_args args; + int ret; + + pwm_get_args(ctx->pwm, &args); + + if (ctx->pwm_value) { + ret = pwm_config(ctx->pwm, 0, args.period); + if (ret < 0) + return ret; - if (ctx->pwm_value) pwm_disable(ctx->pwm); + } + return 0; }