Thread (31 messages) 31 messages, 5 authors, 2012-12-27

RE: [PATCH 2/8] Thermal: Create zone level APIs

From: R, Durgadoss <hidden>
Date: 2012-12-20 06:04:20
Also in: lkml

Hi Joe,
-----Original Message-----
From: Joe Perches [mailto:joe@perches.com]
Sent: Tuesday, December 18, 2012 5:00 PM
To: R, Durgadoss
Cc: Zhang, Rui; linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org;
hongbo.zhang@linaro.org; wni@nvidia.com
Subject: Re: [PATCH 2/8] Thermal: Create zone level APIs

On Tue, 2012-12-18 at 14:59 +0530, Durgadoss R wrote:
quoted
This patch adds a new thermal_zone structure to
thermal.h. Also, adds zone level APIs to the thermal
framework.
[]
quoted
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
quoted
+#define GET_INDEX(tz, ptr, indx, type)			\
+	do {						\
+		int i;					\
+		indx = -EINVAL;				\
+		if (!tz || !ptr)			\
+			break;				\
+		mutex_lock(&type##_list_lock);		\
+		for (i = 0; i < tz->type##_indx; i++) {	\
+			if (tz->type##s[i] == ptr) {	\
+				indx = i;		\
+				break;			\
+			}				\
+		}					\
+		mutex_unlock(&type##_list_lock);	\
+	} while (0)
A statement expression macro returning int would be
more kernel style like and better to use.
Yes, makes sense. Will fix this in next rev.

Thanks,
Durga
(sorry about the whitespace, evolution 3.6 is crappy)

#define GET_INDEX(tx, ptr, type)				\
({								\
	int rtn = -EINVAL;					\
	do {							\
		int i;						\
		if (!tz || !ptr)				\
			break;					\
		mutex_lock(&type##_list_lock);			\
		for (i = 0; i < tz->type##_indx; i++) {		\
			if (tz->type##s[i] == ptr) {		\
				rtn = i;			\
				break;				\
			}					\
		}						\
		mutex_unlock(&type##_list_lock);		\
	} while (0);						\
	rtn;							\
})

quoted
+static void remove_sensor_from_zone(struct thermal_zone *tz,
+				struct thermal_sensor *ts)
+{
+	int j, indx;
+
+	GET_INDEX(tz, ts, indx, sensor);
This becomes

	indx = GET_INDEX(tx, ts, sensor);
quoted
+	if (indx < 0)
+		return;
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help