From patchwork Tue May 31 06:31:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143561 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 5D32860761 for ; Tue, 31 May 2016 06:35:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51449281C1 for ; Tue, 31 May 2016 06:35:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 460A128213; Tue, 31 May 2016 06:35:24 +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 DA9FE281C1 for ; Tue, 31 May 2016 06:35:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755387AbcEaGcT (ORCPT ); Tue, 31 May 2016 02:32:19 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34502 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755781AbcEaGcQ (ORCPT ); Tue, 31 May 2016 02:32:16 -0400 Received: by mail-pf0-f195.google.com with SMTP id c84so17239787pfc.1; Mon, 30 May 2016 23:32:16 -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=Ir46v7+SqA+KxtuRa8aDF0MIgAV5bOef/ucylQq0/sg=; b=G4ZJJ/K7XfLb4snWPp1KoF0o9YxE0k7OJTi9NqdLFPtbfYXZ3wNp7YRtzHINH5O65p /bQJbApDRx1lMceTbiHvdUJIpU7itAPEVwHb3FJZxdci6HxYLmUDEpbhwR7RAjY+V69+ aJOFEoxY6Ttral/corTNdXEs23mARS+ZnZrfLTZHp6X05K4UJVbt9vUOIWuuG4PsWvkp t5P2qb0C13gOTsEQekgNBSmhZF/N4XsVcLEz8A2+DFeY2ARjnYM4UQFQyPgBgdasMujD pxISKOOPVSL/vphqMHTj/oi61CRR3WPlPDi0QyaRROL5vUDFEbBssHLWx3a3vlE6D/3b m7Bg== 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=Ir46v7+SqA+KxtuRa8aDF0MIgAV5bOef/ucylQq0/sg=; b=CmN+tajAlw6FiNnU3enXHzJ6CWPi297tz/AmcpMQW5f9Q2o2JPmHCXowhZd7WFRt1a DU235jBC5z+i4hpRpARgZhaO7NV6W/LQiUIXvsfDsZBQMIBRl8nPgHY1nXJYiLOn8/9w 6kseFuTmV+vg83SFay3N1sKowrr6QhXH3qhtf3Q9t6Wbt6/qo4hUyc4C75BYuqpykna0 rlPWSFT9THcLlt3WWY/RFZlbKtC7YEKwSQEa9iay42SU/3viUDTQoY1xHyCRaLGotRcY qVdL08z8jW2ofP1LTFLaJAYpu727tY6ILfCKY1MT9Bi5UeRoUYKrGm4FdwMK0+jLiL1/ b5fA== X-Gm-Message-State: ALyK8tKlwXkoqHT/LkWI1zyzNpcW6olrthLgufwXdERLRE+XyE0/LFUzn2H3nRiGWKeCcg== X-Received: by 10.98.90.132 with SMTP id o126mr3181895pfb.146.1464676330544; Mon, 30 May 2016 23:32:10 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id b73sm34160045pfd.61.2016.05.30.23.32.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:32:09 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 04/15] thermal: sysfs: lock tz while on trip_point_temp properties Date: Mon, 30 May 2016 23:31:25 -0700 Message-Id: <1464676296-5610-5-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 tz.ops in user facing sysfs handler trip_point_temp_show() and trip_point_temp_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 b69036e..32f410f 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -151,7 +151,9 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, if (kstrtoint(buf, 10, &temperature)) return -EINVAL; + mutex_lock(&tz->lock); ret = tz->ops->set_trip_temp(tz, trip, temperature); + mutex_unlock(&tz->lock); if (ret) return ret; @@ -174,7 +176,9 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr, if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) != 1) return -EINVAL; + mutex_lock(&tz->lock); ret = tz->ops->get_trip_temp(tz, trip, &temperature); + mutex_unlock(&tz->lock); if (ret) return ret;