From patchwork Tue May 31 06:31:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143547 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 0876260761 for ; Tue, 31 May 2016 06:34:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0CEC27D17 for ; Tue, 31 May 2016 06:34:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E58D3281C1; Tue, 31 May 2016 06:34:08 +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 A37FD27D17 for ; Tue, 31 May 2016 06:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755691AbcEaGeH (ORCPT ); Tue, 31 May 2016 02:34:07 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:36108 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162133AbcEaGc3 (ORCPT ); Tue, 31 May 2016 02:32:29 -0400 Received: by mail-pa0-f68.google.com with SMTP id fg1so23807032pad.3; Mon, 30 May 2016 23:32:29 -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=xSpaPshoA3+rRGy3/2p1B2rynKGGicmpXLk1TM4QNWI=; b=0Yo4VcN/46j46S2Tt9VLKE34cM4b5Gx5isxyoQcYI7D03QyiAaY3fb6WBWH2Zk0HRf +7F0GHhtT+LmfjxCqe/D9jejwDwcZcMph9Q3qLmgITj22bKWBogAuTn9OHx79UvYFWwQ WQV8b0IhSqL6VPfDvizff5EWsuOlcPuTIFY32i8ETOcOrVAGoPEURGmzXsv4HqhnuPUp BOd5X5DvUL/AChhiThgZmUDCaOMND6ORpbz8QjbmFp8LoIS3w5XyZC3eYl3rrRyWIqvC PWA2ZJJUhbjDAlHu3t0XAwiSBMQUGAK/ecTmjktMOkSOnr3q4BPw/iXLtPF1aGinuDiT LR0w== 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=xSpaPshoA3+rRGy3/2p1B2rynKGGicmpXLk1TM4QNWI=; b=H/sUDTbgPSocCh4k+jTXJIIt4seUjCwvMpPQDAzFsZESAAfKrTlzgUMMg0ExG04ToA tL9g0IkxjP3dEaXhkOzpJ8rMQhpQys1fiugrcx5Q22ZOE2csr+bGEi9qLq5m0K3+H3rW UbLFNsIjMPD3tSxOPgPQHuaSW3Bw6NIh5w5u0e/rh1PcDazZO2T755TbkFBgw4PP4Tux m91oNczcSSAXtgwyDO+d+Sv6Kr4q4OARkVn13IGEFvyr+43Tg/AJcWHA7NMCwJbMYy0E 355/6w/2/bg0biLBP8wJtAxi87KEGSxD1gsvhubp/pGmL3byHsyMCKBtdTq44qSDcWws Mv8Q== X-Gm-Message-State: ALyK8tIEGjtaQo/lWp6okrMYuWbuIiDGav4Eejo4S+JAkCaSI6fpNEiLKiAmgRE00PRwUQ== X-Received: by 10.66.81.70 with SMTP id y6mr52369236pax.121.1464676347856; Mon, 30 May 2016 23:32:27 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id t77sm37212754pfa.71.2016.05.30.23.32.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:32:27 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 12/15] thermal: sysfs: lock cdev while accessing max_state Date: Mon, 30 May 2016 23:31:33 -0700 Message-Id: <1464676296-5610-13-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 handler thermal_cooling_device_max_state_show(). 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 044090a..3eaa081 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -699,7 +699,9 @@ thermal_cooling_device_max_state_show(struct device *dev, unsigned long state; int ret; + mutex_lock(&cdev->lock); ret = cdev->ops->get_max_state(cdev, &state); + mutex_unlock(&cdev->lock); if (ret) return ret; return sprintf(buf, "%ld\n", state);