From patchwork Tue May 31 06:31:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143551 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 41BA360761 for ; Tue, 31 May 2016 06:34:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 356B727D17 for ; Tue, 31 May 2016 06:34:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A4DB281C1; Tue, 31 May 2016 06:34:36 +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 B56AE27D17 for ; Tue, 31 May 2016 06:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162103AbcEaGcY (ORCPT ); Tue, 31 May 2016 02:32:24 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:35778 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755564AbcEaGcV (ORCPT ); Tue, 31 May 2016 02:32:21 -0400 Received: by mail-pa0-f67.google.com with SMTP id gp3so17029468pac.2; Mon, 30 May 2016 23:32:21 -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=ryrxtIMejJMgRzgxhES7i57V/5YapVZBu0Qd5aN1IWg=; b=a5BWUaKvjZ1LgTZ6VUlOiwWZyeBMsmh//G1rdIJgV63O4QfD05GbC0DPg0kPdldgyM rklpVuPUiFAe7i8rfo/j6gXvva4J0mqk2CBIJdx4P276BsxCZSoD43fCxEOxfY2cAP3V rLGiAiDOqK5iH9GChUDApfKECm75PuXMF2g39XJaOZJocmHvj9pmaXKCnz2ixD8aOZFq jqavHWokBO0GqUtn2asWlov526CgN6OwzaMedrHK/vbpEgFP8OnuEiyJRz7AxfwhWLT3 IYilJApJdCxQtKiX9MTKCGcyasbVer4y97GsabBzsCJFQSXdl7BS4Ho2yjED9mri4fUG uBvQ== 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=ryrxtIMejJMgRzgxhES7i57V/5YapVZBu0Qd5aN1IWg=; b=lPGZ7nAbGCXFP6NMetfecqCHNC7UruRgZSgoB/r6xY/vp4tOlqevMPhahZGKLyR84k DhZxXuuERitlfs2leP63UnrImHX6abwKS2nFAwuHxOlw6mS9RJdVWgOe8le6MfQsFHGZ 0o/6KDWqcnBgcOPH60EAZBluHev7vVFerKcC0rh9FgZeNP7UbcWf53YZKFJ9Njyd2qPi QcjIiT28Z9VumffRufhw7nLni+/TRGNjxi0ka29riN4PKL0c7YuNmRJhazD/tNVLnc59 dgVqE0ZVLAAv5mJ5LjisHNQt8a7C21XM9oV+19a1PGDizZyj+FSa//eaiZV6aJ8mF5ko hxQA== X-Gm-Message-State: ALyK8tJd3wxSGedazu58fy9TIrBrTkqeWJfEkfpZcAyNgu7eU99mB+HKvmbhBbjmJfNxpQ== X-Received: by 10.66.123.69 with SMTP id ly5mr10919291pab.57.1464676340628; Mon, 30 May 2016 23:32:20 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id f21sm779617pfk.20.2016.05.30.23.32.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:32:20 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 07/15] thermal: sysfs: lock tz while on policy properties Date: Mon, 30 May 2016 23:31:28 -0700 Message-Id: <1464676296-5610-8-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 policy_show(). policy_store() is already locked by the thermal core. 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index dcaeb17..234eb18 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -311,8 +311,14 @@ static ssize_t policy_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct thermal_zone_device *tz = to_thermal_zone(dev); + char *name; - return sprintf(buf, "%s\n", tz->governor->name); + /* locking the zone because governor->name does not change */ + mutex_lock(&tz->lock); + name = tz->governor->name; + mutex_unlock(&tz->lock); + + return sprintf(buf, "%s\n", name); } static ssize_t