Re: [PATCH 1/2] HID: hid-lg4ff: Use Private Data

From
Jiri Slaby <hidden>
Date
2012-04-02 16:32:12
Also in
lkml
Reply to
Simon Wood, 2012-04-02
On 04/02/2012 04:54 PM, Simon Wood wrote:
Use private data in hid-lg4ff to store device properties.

This code was writen by Michal, he asked me to check it and forward
it on to the list.
So this patch is missing proper From: header.
quoted hunk ↗ jump to hunk
Signed-off-by: Michal Maly <redacted>
Signed-off-by: Simon Wood <redacted>
---
 drivers/hid/hid-lg4ff.c |   96 +++++++++++++++++++++-------------------------
 1 files changed, 44 insertions(+), 52 deletions(-)
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 1145292..c3146e0 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -285,18 +280,20 @@ static void hid_lg4ff_switch_native(struct hid_device *hid, const struct lg4ff_n
 /* Read current range and display it in terminal */
 static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct lg4ff_device_entry *uninitialized_var(entry);
-	struct list_head *h;
 	struct hid_device *hid = to_hid_device(dev);
+	struct lg4ff_device_entry *uninitialized_var(entry);
+	struct lg_drv_data *uninitialized_var(drv_data);
You don't need uninitialized_var bloat anymroe, right?

Here and at the other places too...
quoted hunk ↗ jump to hunk
 	size_t count;
 
-	list_for_each(h, &device_list.list) {
-		entry = list_entry(h, struct lg4ff_device_entry, list);
-		if (strcmp(entry->device_id, (&hid->dev)->kobj.name) == 0)
-			break;
+	drv_data = hid_get_drvdata(hid);
+	if (!drv_data) {
+		hid_err(hid, "Private driver data not found!\n");
+		return 0;
 	}
-	if (h == &device_list.list) {
-		dbg_hid("Device not found!");
+
+	entry = drv_data->device_props;
+	if (!entry) {
+		hid_err(hid, "Device properties not found!\n");
 		return 0;
 	}
 
-- 
js
suse labs
Thread (12 messages) 12 messages, 4 authors, last reply 2012-04-03
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help