From patchwork Tue May 31 06:31:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143545 X-Patchwork-Delegate: rui.zhang@intel.com 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 13BCF60761 for ; Tue, 31 May 2016 06:34:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07F5A27D17 for ; Tue, 31 May 2016 06:34:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0C4D281C1; Tue, 31 May 2016 06:34: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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 57EE427D17 for ; Tue, 31 May 2016 06:34:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755592AbcEaGdt (ORCPT ); Tue, 31 May 2016 02:33:49 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36142 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162141AbcEaGca (ORCPT ); Tue, 31 May 2016 02:32:30 -0400 Received: by mail-pf0-f193.google.com with SMTP id 62so12185710pfd.3; Mon, 30 May 2016 23:32:30 -0700 (PDT) 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=KbUYsu2ClMGrJx2Mt5H/pXV9JfKjatxXKaGYzc+PGbA=; b=lVX4i/z/qlno9xxi7WhQzX0WNQIAK2k0WdMJ08tMNH0nijonainuAID0GKJCsolmj9 KXyoNzcU6EuqqdLTcMyni4P7uQJc2eMUz8/TESOPJ/T4Qs1/Mdx3YdGb7saAcIIRERQl CSt1EnDX1CAR0shTD2k2BOHn/3dlx6ZBmrMZPg7b6TjsvapH1BT1Q/hjZdWaJ6URT5AW G98TR0P2VrSxcri4jFPTmOm+urtVSVx+XkslGug7CYefoHD/eLmVvAes0F2HjAf42qBO PpBeltno+pmJiFLtBDgT4azNrTTNSK3LZh3u6sPl+m0oe3vL3tHlqluwHEXHqrPymeyF 3diw== 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=KbUYsu2ClMGrJx2Mt5H/pXV9JfKjatxXKaGYzc+PGbA=; b=eOH4x3miCxJNXvnFqgsi/bUrhzidFac1D14ucu8uQJwgwirQQmKCEImJtTm/612Zl8 KXmqM7/4T4xk5ixeei3JgsYp2mCGS/S0KJ1nDMGFB/wzGqvEmRrHosz+anxsAbKdd0CH jPnlaarXXenriojwVigHPB11FBhY4uSyiRWrjgFnGcV/8tkSGiI/qVi0pgSHED/T3u5L o7aP2F8OnrpneFSwnLcu1qJicrlIVh6m2lFLSaOtNDvT41Yi9RIT/I4JRy+DbC0+AyHM EB7WkacEdA3PButprV3RulcCR91AIrM4AdYiaik/R1MaA1YL0ZwEh9tljyhjh3mI5d6B +3qw== X-Gm-Message-State: ALyK8tIpjkz64PNAg9ACW7mn3g2zPt+E07XJAEf2P96TXH0bb1mxiYTkj9rMAhZB8TMOeQ== X-Received: by 10.98.86.151 with SMTP id h23mr39768896pfj.16.1464676349664; Mon, 30 May 2016 23:32:29 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id x88sm36117706pfa.47.2016.05.30.23.32.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:32:28 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 13/15] thermal: sysfs: lock cdev while accessing cur_state Date: Mon, 30 May 2016 23:31:34 -0700 Message-Id: <1464676296-5610-14-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464676296-5610-1-git-send-email-edubezval@gmail.com> References: <1464676296-5610-1-git-send-email-edubezval@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Serialized calls to cdev->ops in user facing sysfs handlers thermal_cooling_device_cur_state_show() and thermal_cooling_device_cur_state_store(). Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin --- drivers/thermal/thermal_sysfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 3eaa081..ab78e08 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -715,7 +715,9 @@ thermal_cooling_device_cur_state_show(struct device *dev, unsigned long state; int ret; + mutex_lock(&cdev->lock); ret = cdev->ops->get_cur_state(cdev, &state); + mutex_unlock(&cdev->lock); if (ret) return ret; return sprintf(buf, "%ld\n", state); @@ -736,7 +738,9 @@ thermal_cooling_device_cur_state_store(struct device *dev, if ((long)state < 0) return -EINVAL; + mutex_lock(&cdev->lock); result = cdev->ops->set_cur_state(cdev, state); + mutex_unlock(&cdev->lock); if (result) return result; return count;