From patchwork Tue May 31 06:31:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143559 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 8333660761 for ; Tue, 31 May 2016 06:35:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7787F281C1 for ; Tue, 31 May 2016 06:35:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C52528213; Tue, 31 May 2016 06:35:19 +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 02456281C1 for ; Tue, 31 May 2016 06:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755763AbcEaGex (ORCPT ); Tue, 31 May 2016 02:34:53 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36094 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755781AbcEaGcX (ORCPT ); Tue, 31 May 2016 02:32:23 -0400 Received: by mail-pf0-f193.google.com with SMTP id 62so12185404pfd.3; Mon, 30 May 2016 23:32:22 -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=pKVjP+iTJE74gFClYLoIEIKU88SYPxjsrLd72EigYHo=; b=rJUfpmCN/s1DPHJQIkzsp36fsJbzvb0FsHWQ+H1yCoBNXdX9EYpVWQbhDDPG4EUocj ujEGPjzNZxtjrdfD7bFtN3SGtzmUnoGHeDsAQdtYJ/vA8Z0COLbZycMLeEjYybYI7551 4xB2bO0mGv3SBdP3LMtZdMN6ayRCIdT5GCmV0iwjXFX0MYcHlFiEcDxT6jnl+QlJZHmh yoyX5/lO5w99VP6s6HCD86Fl6pIJ5GMxMH/y1hR4156ZLaeKYUvFdjXZBYLVpcAHbrmG EBVZWFs/teihMLncyw/qKaIBk0ddlGc6WcKtoRdRWTI4DczRMZ9RA+Qg4OHotO3Su212 GTcQ== 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=pKVjP+iTJE74gFClYLoIEIKU88SYPxjsrLd72EigYHo=; b=Jm/uCJOhVH/vMZSJgXJ/oA62UiLSzj4PP+pMgjPkRHxQpjciLCitxd3R0w0YYDphAP 6Bw0OpVyi01BqbfFVJWcghkDTo21pI5kOc/yhg8zs/HDqTN01rVH8txi7o9NZe7iHuVz FruZqlqO8PYDHupIAEVbMQpoWEJXLh/xAxUO/fynPqF2MIR+CHxahVoAcKYs+axZSqMY n2rcZgaZtOvcWqlQs7UfkfIgH1I40+2y3W80/s1quCkklSfbOB6Q/BD84V4Kk05fLChi SKLB0Y3UhuX5+onC2braokDA2/itZcJNPbX3VEpNPp0UmVJ9w5VzLCRmA2qynjRq/PcH yoFg== X-Gm-Message-State: ALyK8tJZVrRXV8dF7NQpvJXh163sdri5TxLwdCplZxp1eTDRN5naQSKgPq4ZwOa9BoJaFw== X-Received: by 10.98.68.203 with SMTP id m72mr14642047pfi.135.1464676342371; Mon, 30 May 2016 23:32:22 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id p1sm51807179paz.8.2016.05.30.23.32.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:32:21 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 08/15] thermal: sysfs: improve locking of emul_temp_store() Date: Mon, 30 May 2016 23:31:29 -0700 Message-Id: <1464676296-5610-9-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 emul_temp_store locks only for setting temperature, but it must lock also for calls to tz.ops. 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 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 234eb18..32ffadf 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -340,13 +340,12 @@ emul_temp_store(struct device *dev, struct device_attribute *attr, if (kstrtoint(buf, 10, &temperature)) return -EINVAL; - if (!tz->ops->set_emul_temp) { - mutex_lock(&tz->lock); + mutex_lock(&tz->lock); + if (!tz->ops->set_emul_temp) tz->emul_temperature = temperature; - mutex_unlock(&tz->lock); - } else { + else ret = tz->ops->set_emul_temp(tz, temperature); - } + mutex_unlock(&tz->lock); if (!ret) thermal_zone_device_update(tz);