From patchwork Wed Feb 1 14:49:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 6497 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0B7E723E16 for ; Wed, 1 Feb 2012 14:49:43 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id DF4B5A18501 for ; Wed, 1 Feb 2012 14:49:42 +0000 (UTC) Received: by bkar19 with SMTP id r19so1472194bka.11 for ; Wed, 01 Feb 2012 06:49:42 -0800 (PST) Received: by 10.205.130.12 with SMTP id hk12mr12712448bkc.56.1328107782564; Wed, 01 Feb 2012 06:49:42 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.204.130.220 with SMTP id u28cs212913bks; Wed, 1 Feb 2012 06:49:40 -0800 (PST) Received: by 10.180.78.130 with SMTP id b2mr3862940wix.1.1328107780026; Wed, 01 Feb 2012 06:49:40 -0800 (PST) Received: from cavan.codon.org.uk (cavan.codon.org.uk. [93.93.128.6]) by mx.google.com with ESMTPS id h17si12816726wee.17.2012.02.01.06.49.39 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Feb 2012 06:49:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of prvs=0378150d6d=mjg59@cavan.codon.org.uk designates 93.93.128.6 as permitted sender) client-ip=93.93.128.6; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of prvs=0378150d6d=mjg59@cavan.codon.org.uk designates 93.93.128.6 as permitted sender) smtp.mail=prvs=0378150d6d=mjg59@cavan.codon.org.uk Received: from mjg59 by cavan.codon.org.uk with local (Exim 4.72) (envelope-from ) id 1RsbV5-00086E-9R; Wed, 01 Feb 2012 14:49:31 +0000 Date: Wed, 1 Feb 2012 14:49:31 +0000 From: Matthew Garrett To: Amit Daniel Kachhap Cc: linux-pm@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, lenb@kernel.org, rui.zhang@intel.com, linaro-dev@lists.linaro.org, patches@linaro.org Subject: Re: [RFC PATCH 1/2] thermal: Add a new trip type to use cooling device instance number Message-ID: <20120201144931.GC30184@srcf.ucam.org> References: <1323789196-4942-1-git-send-email-amit.kachhap@linaro.org> <1323789196-4942-2-git-send-email-amit.kachhap@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1323789196-4942-2-git-send-email-amit.kachhap@linaro.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: mjg59@cavan.codon.org.uk X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false I'm not really a fan of this as it stands - the name isn't very intuitive and the code's pretty difficult to read. Would the following (incomplete and obviously untested) not have the effect you want? Then you register multiple trip points with the same cooling device but different private values, and the state set does whatever you want it to. Or am I misunderstanding the problem you're trying to solve? diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 220ce7e..817f2ba 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -50,6 +50,7 @@ struct thermal_cooling_device_instance { char attr_name[THERMAL_NAME_LENGTH]; struct device_attribute attr; struct list_head node; + unsigned long private; }; static DEFINE_IDR(thermal_tz_idr); @@ -909,7 +910,8 @@ static struct class thermal_class = { * @ops: standard thermal cooling devices callbacks. */ struct thermal_cooling_device *thermal_cooling_device_register( - char *type, void *devdata, const struct thermal_cooling_device_ops *ops) + char *type, void *devdata, const struct thermal_cooling_device_ops *ops, + unsigned long private) { struct thermal_cooling_device *cdev; struct thermal_zone_device *pos; @@ -936,6 +938,7 @@ struct thermal_cooling_device *thermal_cooling_device_register( cdev->ops = ops; cdev->device.class = &thermal_class; cdev->devdata = devdata; + cdev->private = private; dev_set_name(&cdev->device, "cooling_device%d", cdev->id); result = device_register(&cdev->device); if (result) { @@ -1079,11 +1082,14 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) continue; cdev = instance->cdev; - - if (temp >= trip_temp) - cdev->ops->set_cur_state(cdev, 1); - else - cdev->ops->set_cur_state(cdev, 0); + if (cdev->private) { + cdev->ops->set_cur_state(cdev, cdev->private); + } else { + if (temp >= trip_temp) + cdev->ops->set_cur_state(cdev, 1); + else + cdev->ops->set_cur_state(cdev, 0); + } } break; case THERMAL_TRIP_PASSIVE: diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 796f1ff..04aac09 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -148,7 +148,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, struct thermal_cooling_device *); void thermal_zone_device_update(struct thermal_zone_device *); struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, - const struct thermal_cooling_device_ops *); + const struct thermal_cooling_device_ops *, unsigned long private); void thermal_cooling_device_unregister(struct thermal_cooling_device *); #ifdef CONFIG_NET