aboutsummaryrefslogtreecommitdiffstats
path: root/f2.patch
blob: 47c6b064b81e40fdeb40ddd477508c220bf755a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
 samples/firmware_class/firmware_sample_firmware_class.c |   44 ++++++----------
 1 file changed, 18 insertions(+), 26 deletions(-)

--- a/samples/firmware_class/firmware_sample_firmware_class.c
+++ b/samples/firmware_class/firmware_sample_firmware_class.c
@@ -23,16 +23,8 @@ MODULE_AUTHOR("Manuel Estrada Sainz");
 MODULE_DESCRIPTION("Hackish sample for using firmware class directly");
 MODULE_LICENSE("GPL");
 
-static inline struct class_device *to_class_dev(struct kobject *obj)
-{
-	return container_of(obj, struct class_device, kobj);
-}
-
-static inline
-struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
-{
-	return container_of(_attr, struct class_device_attribute, attr);
-}
+#define to_dev(obj) container_of(obj, struct device, kobj)
+#define to_class_dev_attr(_attr) container_of(_attr, struct class_device_attribute, attr)
 
 struct firmware_priv {
 	char fw_id[FIRMWARE_NAME_MAX];
@@ -40,16 +32,18 @@ struct firmware_priv {
 	u32 abort:1;
 };
 
-static ssize_t firmware_loading_show(struct class_device *class_dev, char *buf)
+static ssize_t firmware_loading_show(struct device *dev,
+				     struct device_attribute *attr, char *buf)
 {
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	struct firmware_priv *fw_priv = dev_get_drvdata(dev);
 	return sprintf(buf, "%d\n", fw_priv->loading);
 }
 
-static ssize_t firmware_loading_store(struct class_device *class_dev,
+static ssize_t firmware_loading_store(struct device *dev,
+				      struct device_attribute *attr,
 				      const char *buf, size_t count)
 {
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	struct firmware_priv *fw_priv = dev_get_drvdata(dev);
 	int prev_loading = fw_priv->loading;
 
 	fw_priv->loading = simple_strtol(buf, NULL, 10);
@@ -71,15 +65,15 @@ static ssize_t firmware_loading_store(st
 
 	return count;
 }
-static CLASS_DEVICE_ATTR(loading, 0644,
-			 firmware_loading_show, firmware_loading_store);
+static DEVICE_ATTR(loading, 0644,
+		   firmware_loading_show, firmware_loading_store);
 
 static ssize_t firmware_data_read(struct kobject *kobj,
 				  struct bin_attribute *bin_attr,
 				  char *buffer, loff_t offset, size_t count)
 {
-	struct class_device *class_dev = to_class_dev(kobj);
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	struct device *dev = to_dev(kobj);
+	struct firmware_priv *fw_priv = dev_get_drvdata(dev);
 
 	/* read from the devices firmware memory */
 
@@ -89,8 +83,8 @@ static ssize_t firmware_data_write(struc
 				   struct bin_attribute *bin_attr,
 				   char *buffer, loff_t offset, size_t count)
 {
-	struct class_device *class_dev = to_class_dev(kobj);
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	struct device *dev = to_dev(kobj);
+	struct firmware_priv *fw_priv = dev_get_drvdata(dev);
 
 	/* write to the devices firmware memory */
 
@@ -102,9 +96,8 @@ static struct bin_attribute firmware_att
 	.read = firmware_data_read,
 	.write = firmware_data_write,
 };
-static int fw_setup_class_device(struct class_device *class_dev,
-				 const char *fw_name,
-				 struct device *device)
+static int fw_setup_device(struct device *dev, const char *fw_name,
+			   struct device *parent)
 {
 	int retval;
 	struct firmware_priv *fw_priv;
@@ -115,7 +108,7 @@ static int fw_setup_class_device(struct 
 		goto out;
 	}
 
-	memset(class_dev, 0, sizeof(*class_dev));
+	memset(dev, 0, sizeof(*dev));
 
 	strncpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX);
 	fw_priv->fw_id[FIRMWARE_NAME_MAX-1] = '\0';
@@ -183,8 +176,7 @@ static int __init firmware_sample_init(v
 	if (!class_dev)
 		return -ENOMEM;
 
-	error = fw_setup_class_device(class_dev, "my_firmware_image",
-				      &my_device);
+	error = fw_setup_device(class_dev, "my_firmware_image", &my_device);
 	if (error) {
 		kfree(class_dev);
 		return error;