From patchwork Thu Feb 26 06:01:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 45158 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 121452142A for ; Thu, 26 Feb 2015 06:01:59 +0000 (UTC) Received: by lbiw7 with SMTP id w7sf6186203lbi.0 for ; Wed, 25 Feb 2015 22:01:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=QHpbrQqsFky0R80vNVXrGqm9Ir08wmPRSAJKxDsFBiI=; b=UBV7IDtwa2dyMpCwFmZdCmk70ackU/rHNMQrwAaBOs9VccfmV9dWfkU24IkX/9r88i qDQZO6nv2E2ZnDegCAb6ZI9SH5NOFPGAXR2cooiTm/uP9LYnNp0szSZVdioWEvagNC76 zC1wadYVSSfxlfEUsf7jrL7rwefokJUX2v9xEMEPSnLeNoC2VOgDm+JLoKhN+91BQInn V8/KTftq307vRifDFP0xR5xva4P+3ecL7+MUmeL8TiIJxY59s48QnoZfhKsl3Gazc0HW HVAiAykBTrHfGoXgFugad8E/5yKjQQK2o6qNXfiRDKkaeBrcIBkfXy1BkXVa2veD9wtp JZ2A== X-Gm-Message-State: ALoCoQmrgn/xusVzmQukLklBJX9CUKU107dgVeOItNvEJGEqeofFcz6bl0yBvhXLNMWX4GXcnk9A X-Received: by 10.112.131.106 with SMTP id ol10mr1021277lbb.20.1424930518006; Wed, 25 Feb 2015 22:01:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.132 with SMTP id wq4ls242100lac.30.gmail; Wed, 25 Feb 2015 22:01:57 -0800 (PST) X-Received: by 10.152.88.99 with SMTP id bf3mr287121lab.37.1424930517726; Wed, 25 Feb 2015 22:01:57 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id po1si32390277lbb.87.2015.02.25.22.01.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 22:01:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbdu14 with SMTP id u14so8672371lbd.1 for ; Wed, 25 Feb 2015 22:01:57 -0800 (PST) X-Received: by 10.152.197.34 with SMTP id ir2mr5953560lac.36.1424930517629; Wed, 25 Feb 2015 22:01:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp3092577lbj; Wed, 25 Feb 2015 22:01:56 -0800 (PST) X-Received: by 10.68.224.233 with SMTP id rf9mr12316498pbc.22.1424930515829; Wed, 25 Feb 2015 22:01:55 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gv5si9525030pac.200.2015.02.25.22.01.55; Wed, 25 Feb 2015 22:01:55 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750938AbbBZGBw (ORCPT + 11 others); Thu, 26 Feb 2015 01:01:52 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:41396 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbbBZGBw (ORCPT ); Thu, 26 Feb 2015 01:01:52 -0500 Received: by padfb1 with SMTP id fb1so11332805pad.8 for ; Wed, 25 Feb 2015 22:01:51 -0800 (PST) X-Received: by 10.70.94.195 with SMTP id de3mr11727445pdb.59.1424930511748; Wed, 25 Feb 2015 22:01:51 -0800 (PST) Received: from localhost.localdomain ([180.150.157.4]) by mx.google.com with ESMTPSA id jj1sm43288747pac.17.2015.02.25.22.01.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 22:01:51 -0800 (PST) From: Leo Yan To: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH] thermal: fix the casting issue for long type Date: Thu, 26 Feb 2015 14:01:32 +0800 Message-Id: <1424930492-22658-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leo.yan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When enable the thermal on arm64 platform, it will report failure when call function *thermal_zone_bind_cooling_device()*. The failure is caused by casting. If dtb specify the minimum cooling state and maximum cooling state as THERMAL_NO_LIMIT, then variables "lower" and "upper" equal to 0x0000_0000_ffff_fffff after casting the value from "unsigned int" to "unsigned long". Finally in kernel if check the variables "lower" and "upper", it will never equal to (-1UL), or 0xffff_ffff_ffff_fffff. So change to use "unsigned int" type, this can be compatible for 32 bits and 64 bits system. Signed-off-by: Leo Yan --- drivers/thermal/of-thermal.c | 4 ++-- drivers/thermal/thermal_core.c | 6 +++--- include/linux/thermal.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 668fb1b..b50c4e1 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -49,8 +49,8 @@ struct __thermal_bind_params { struct device_node *cooling_device; unsigned int trip_id; unsigned int usage; - unsigned long min; - unsigned long max; + unsigned int min; + unsigned int max; }; /** diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 48491d1..04de575 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -923,7 +923,7 @@ thermal_cooling_device_trip_point_show(struct device *dev, int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, int trip, struct thermal_cooling_device *cdev, - unsigned long upper, unsigned long lower) + unsigned int upper, unsigned int lower) { struct thermal_instance *dev; struct thermal_instance *pos; @@ -952,8 +952,8 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, return ret; /* lower default 0, upper default max_state */ - lower = lower == THERMAL_NO_LIMIT ? 0 : lower; - upper = upper == THERMAL_NO_LIMIT ? max_state : upper; + lower = lower == (unsigned int)THERMAL_NO_LIMIT ? 0 : lower; + upper = upper == (unsigned int)THERMAL_NO_LIMIT ? max_state : upper; if (lower > upper || upper > max_state) return -EINVAL; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index fc52e30..a2afe04 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -321,7 +321,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *); int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, struct thermal_cooling_device *, - unsigned long, unsigned long); + unsigned int, unsigned int); int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, struct thermal_cooling_device *); void thermal_zone_device_update(struct thermal_zone_device *);