From patchwork Tue May 31 06:31:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143567 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 24FBA60761 for ; Tue, 31 May 2016 06:35:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1918127D17 for ; Tue, 31 May 2016 06:35:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DE8E281C1; Tue, 31 May 2016 06:35:55 +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 8A3EA27D17 for ; Tue, 31 May 2016 06:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755495AbcEaGcO (ORCPT ); Tue, 31 May 2016 02:32:14 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:35729 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752684AbcEaGcM (ORCPT ); Tue, 31 May 2016 02:32:12 -0400 Received: by mail-pa0-f66.google.com with SMTP id gp3so17029126pac.2; Mon, 30 May 2016 23:32:12 -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=ELZwWS+5yM7xdMb+/nWnfHFjC+dfGR5snNSkhOprngI=; b=YXC7qL7/6Prk3yybtViPmYctN6PhxyBNpU+HDjm0LJrz/WQJO0RCqx7FiF2CGk5KsO FfKgVzxXtAZ1fxfXkLbAHG47AjDiz9GmpaP8HCdSPRN8E2yqXcBa68RxA1whs8ND83nA oxtTsqHDX1PcGvY6THOgGYx/U4DrZyGJmTtBXS3b5jqFt4w05RCRcGFjz2/y3O76MTQ3 SqYODuaME4EL9tsQYSSuJ6EXrIoVMahRMzMcJ6EOoozvPm4zD9Zq5tOwn+AYWltGWXoh 05/qJKlzcly0oi+iZCK7jeoS0167Kss3zAeVoGfULMuEhwXtlGfo4Tp+vK7oDMVblqPy VkSA== 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=ELZwWS+5yM7xdMb+/nWnfHFjC+dfGR5snNSkhOprngI=; b=XP/TKKceQ1+Wbt5JFhaWvhlb2E30bgwGltHCkPAWIeIgaEc6ReCfnaPvK0vKYynT0S ak4PoDN2UkJZ7VK6CJh8nP2s6aysmPJ/gLLZYcOE+l/SPVLmMabzJjmGsDcKAdJ0AeDG fT1dxhWdNrKc4O0pnldL2G3G8Qp7Tr6je5iRLjHbFY5hbwyqnLF5nNOvDyxThVSs7Ypz pdqW0ggewvOqc8U8C6EjHPW966cd1yns7xzgQIByN6YXPPTg/Fcq0DYZVAylWeR7ga13 TMDfB9wbHCTVe599ZywgEqPQA10YBU8PqJOC8i5yNcFwMl+n7JvXn8sa11xhKbf4PgaU t5Eg== X-Gm-Message-State: ALyK8tKcNYaKBuTzqo6c1q3p6F6vU/Yq4niy9VZRKdgts8qAUMdZf5R2ax5K5YBPYGG+EQ== X-Received: by 10.66.170.233 with SMTP id ap9mr52750434pac.158.1464676332202; Mon, 30 May 2016 23:32:12 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id i65sm20664489pfk.84.2016.05.30.23.32.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:32:11 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 05/15] thermal: sysfs: lock tz while on trip_point_hyst properties Date: Mon, 30 May 2016 23:31:26 -0700 Message-Id: <1464676296-5610-6-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_hyst_store() and trip_point_hyst_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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 32f410f..afb42a2 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -208,7 +208,9 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr, * here. The driver implementing 'set_trip_hyst' has to * take care of this. */ + mutex_lock(&tz->lock); ret = tz->ops->set_trip_hyst(tz, trip, temperature); + mutex_unlock(&tz->lock); return ret ? ret : count; } @@ -227,7 +229,9 @@ trip_point_hyst_show(struct device *dev, struct device_attribute *attr, if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) != 1) return -EINVAL; + mutex_lock(&tz->lock); ret = tz->ops->get_trip_hyst(tz, trip, &temperature); + mutex_unlock(&tz->lock); return ret ? ret : sprintf(buf, "%d\n", temperature); }