Thread (16 messages) 16 messages, 3 authors, 2015-04-08

Re: [PATCH 4/4] hwmon: (ibmpowernv) pretty print labels

From: Guenter Roeck <linux@roeck-us.net>
Date: 2015-04-03 15:49:55

On 04/01/2015 03:15 AM, Cédric Le Goater wrote:
quoted hunk ↗ jump to hunk
The new OPAL device tree adds a few properties which can be used to add
extra information on the sensor label.

Signed-off-by: Cédric Le Goater <redacted>
---
  drivers/hwmon/ibmpowernv.c |   22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index be6fe559b52a..3e753c215b40 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -113,9 +113,31 @@ static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
  static void __init make_sensor_label(struct device_node *np,
  		    struct sensor_data *sdata, const char *label)
  {
+	u32 id;
  	size_t n;

  	n = snprintf(sdata->label, sizeof(sdata->label), "%s", label);
+
+	/*
+	 * Core temp pretty print
+	 */
+	if (!of_property_read_u32(np, "ibm,pir", &id)) {
+		int i;
+
+		for_each_possible_cpu(i)
+			if (paca[i].hw_cpu_id == id)
+				break;
+
+		n += snprintf(sdata->label + n, sizeof(sdata->label) - n,
+			      " %d-%d", i, i+7);
If ibm,pir points to a bad/invalid CPU id you just print an invalid value.
Is that what you want ? Also, what relevance does 'i' have for the user ?
It is the index into the paca array, sure, but what is its relevance
outside this code, especially in the context of you printing both i and i+7 ?

Guenter
+	}
+
+	/*
+	 * Membuffer pretty print
+	 */
+	if (!of_property_read_u32(np, "ibm,chip-id", &id))
+		n += snprintf(sdata->label + n, sizeof(sdata->label) - n,
+			      " %d", id & 0xffff);
  }

  static int get_sensor_index_attr(const char *name, u32 *index,
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help