forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/drivers/staging/greybus/loopback.c
....@@ -25,11 +25,8 @@
2525 #include <linux/workqueue.h>
2626 #include <linux/atomic.h>
2727 #include <linux/pm_runtime.h>
28
-
28
+#include <linux/greybus.h>
2929 #include <asm/div64.h>
30
-
31
-#include "greybus.h"
32
-#include "connection.h"
3330
3431 #define NSEC_PER_DAY 86400000000000ULL
3532
....@@ -47,8 +44,6 @@
4744
4845 /* We need to take a lock in atomic context */
4946 spinlock_t lock;
50
- struct list_head list;
51
- struct list_head list_op_async;
5247 wait_queue_head_t wq;
5348 };
5449
....@@ -68,7 +63,6 @@
6863 struct kfifo kfifo_lat;
6964 struct mutex mutex;
7065 struct task_struct *task;
71
- struct list_head entry;
7266 struct device *dev;
7367 wait_queue_head_t wq;
7468 wait_queue_head_t wq_completion;
....@@ -97,7 +91,6 @@
9791 u32 timeout_min;
9892 u32 timeout_max;
9993 u32 outstanding_operations_max;
100
- u32 lbid;
10194 u64 elapsed_nsecs;
10295 u32 apbridge_latency_ts;
10396 u32 gbphy_latency_ts;
....@@ -142,10 +135,10 @@
142135 char *buf) \
143136 { \
144137 struct gb_loopback *gb = dev_get_drvdata(dev); \
145
- /* Report 0 for min and max if no transfer successed */ \
138
+ /* Report 0 for min and max if no transfer succeeded */ \
146139 if (!gb->requests_completed) \
147140 return sprintf(buf, "0\n"); \
148
- return sprintf(buf, "%"#type"\n", gb->name.field); \
141
+ return sprintf(buf, "%" #type "\n", gb->name.field); \
149142 } \
150143 static DEVICE_ATTR_RO(name##_##field)
151144
....@@ -180,7 +173,7 @@
180173 char *buf) \
181174 { \
182175 struct gb_loopback *gb = dev_get_drvdata(dev); \
183
- return sprintf(buf, "%"#type"\n", gb->field); \
176
+ return sprintf(buf, "%" #type "\n", gb->field); \
184177 } \
185178 static ssize_t field##_store(struct device *dev, \
186179 struct device_attribute *attr, \
....@@ -216,7 +209,7 @@
216209 char *buf) \
217210 { \
218211 struct gb_loopback *gb = dev_get_drvdata(dev); \
219
- return sprintf(buf, "%"#type"\n", gb->field); \
212
+ return sprintf(buf, "%" #type "\n", gb->field); \
220213 } \
221214 static ssize_t field##_store(struct device *dev, \
222215 struct device_attribute *attr, \
....@@ -886,7 +879,7 @@
886879 gb->type = 0;
887880 gb->send_count = 0;
888881 sysfs_notify(&gb->dev->kobj, NULL,
889
- "iteration_count");
882
+ "iteration_count");
890883 dev_dbg(&bundle->dev, "load test complete\n");
891884 } else {
892885 dev_dbg(&bundle->dev,
....@@ -974,57 +967,7 @@
974967 return gb_loopback_dbgfs_latency_show_common(s, &gb->kfifo_lat,
975968 &gb->mutex);
976969 }
977
-
978
-static int gb_loopback_latency_open(struct inode *inode, struct file *file)
979
-{
980
- return single_open(file, gb_loopback_dbgfs_latency_show,
981
- inode->i_private);
982
-}
983
-
984
-static const struct file_operations gb_loopback_debugfs_latency_ops = {
985
- .open = gb_loopback_latency_open,
986
- .read = seq_read,
987
- .llseek = seq_lseek,
988
- .release = single_release,
989
-};
990
-
991
-static int gb_loopback_bus_id_compare(void *priv, struct list_head *lha,
992
- struct list_head *lhb)
993
-{
994
- struct gb_loopback *a = list_entry(lha, struct gb_loopback, entry);
995
- struct gb_loopback *b = list_entry(lhb, struct gb_loopback, entry);
996
- struct gb_connection *ca = a->connection;
997
- struct gb_connection *cb = b->connection;
998
-
999
- if (ca->bundle->intf->interface_id < cb->bundle->intf->interface_id)
1000
- return -1;
1001
- if (cb->bundle->intf->interface_id < ca->bundle->intf->interface_id)
1002
- return 1;
1003
- if (ca->bundle->id < cb->bundle->id)
1004
- return -1;
1005
- if (cb->bundle->id < ca->bundle->id)
1006
- return 1;
1007
- if (ca->intf_cport_id < cb->intf_cport_id)
1008
- return -1;
1009
- else if (cb->intf_cport_id < ca->intf_cport_id)
1010
- return 1;
1011
-
1012
- return 0;
1013
-}
1014
-
1015
-static void gb_loopback_insert_id(struct gb_loopback *gb)
1016
-{
1017
- struct gb_loopback *gb_list;
1018
- u32 new_lbid = 0;
1019
-
1020
- /* perform an insertion sort */
1021
- list_add_tail(&gb->entry, &gb_dev.list);
1022
- list_sort(NULL, &gb_dev.list, gb_loopback_bus_id_compare);
1023
- list_for_each_entry(gb_list, &gb_dev.list, entry) {
1024
- gb_list->lbid = 1 << new_lbid;
1025
- new_lbid++;
1026
- }
1027
-}
970
+DEFINE_SHOW_ATTRIBUTE(gb_loopback_dbgfs_latency);
1028971
1029972 #define DEBUGFS_NAMELEN 32
1030973
....@@ -1084,7 +1027,7 @@
10841027 snprintf(name, sizeof(name), "raw_latency_%s",
10851028 dev_name(&connection->bundle->dev));
10861029 gb->file = debugfs_create_file(name, S_IFREG | 0444, gb_dev.root, gb,
1087
- &gb_loopback_debugfs_latency_ops);
1030
+ &gb_loopback_dbgfs_latency_fops);
10881031
10891032 gb->id = ida_simple_get(&loopback_ida, 0, 0, GFP_KERNEL);
10901033 if (gb->id < 0) {
....@@ -1108,7 +1051,7 @@
11081051
11091052 /* Allocate kfifo */
11101053 if (kfifo_alloc(&gb->kfifo_lat, kfifo_depth * sizeof(u32),
1111
- GFP_KERNEL)) {
1054
+ GFP_KERNEL)) {
11121055 retval = -ENOMEM;
11131056 goto out_conn;
11141057 }
....@@ -1121,7 +1064,6 @@
11211064 }
11221065
11231066 spin_lock_irqsave(&gb_dev.lock, flags);
1124
- gb_loopback_insert_id(gb);
11251067 gb_dev.count++;
11261068 spin_unlock_irqrestore(&gb_dev.lock, flags);
11271069
....@@ -1177,7 +1119,6 @@
11771119
11781120 spin_lock_irqsave(&gb_dev.lock, flags);
11791121 gb_dev.count--;
1180
- list_del(&gb->entry);
11811122 spin_unlock_irqrestore(&gb_dev.lock, flags);
11821123
11831124 device_unregister(gb->dev);
....@@ -1204,8 +1145,6 @@
12041145 {
12051146 int retval;
12061147
1207
- INIT_LIST_HEAD(&gb_dev.list);
1208
- INIT_LIST_HEAD(&gb_dev.list_op_async);
12091148 spin_lock_init(&gb_dev.lock);
12101149 gb_dev.root = debugfs_create_dir("gb_loopback", NULL);
12111150