hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/dma/pxa_dma.c
....@@ -1,9 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2015 Robert Jarzmik <robert.jarzmik@free.fr>
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 */
85
96 #include <linux/err.h>
....@@ -132,7 +129,6 @@
132129 spinlock_t phy_lock; /* Phy association */
133130 #ifdef CONFIG_DEBUG_FS
134131 struct dentry *dbgfs_root;
135
- struct dentry *dbgfs_state;
136132 struct dentry **dbgfs_chan;
137133 #endif
138134 };
....@@ -179,7 +175,7 @@
179175 return 0x1000 + line * 4;
180176 }
181177
182
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
178
+static bool pxad_filter_fn(struct dma_chan *chan, void *param);
183179
184180 /*
185181 * Debug fs
....@@ -189,7 +185,7 @@
189185 #include <linux/uaccess.h>
190186 #include <linux/seq_file.h>
191187
192
-static int dbg_show_requester_chan(struct seq_file *s, void *p)
188
+static int requester_chan_show(struct seq_file *s, void *p)
193189 {
194190 struct pxad_phy *phy = s->private;
195191 int i;
....@@ -220,7 +216,7 @@
220216 #define PXA_DCSR_STR(flag) (dcsr & PXA_DCSR_##flag ? #flag" " : "")
221217 #define PXA_DCMD_STR(flag) (dcmd & PXA_DCMD_##flag ? #flag" " : "")
222218
223
-static int dbg_show_descriptors(struct seq_file *s, void *p)
219
+static int descriptors_show(struct seq_file *s, void *p)
224220 {
225221 struct pxad_phy *phy = s->private;
226222 int i, max_show = 20, burst, width;
....@@ -263,7 +259,7 @@
263259 return 0;
264260 }
265261
266
-static int dbg_show_chan_state(struct seq_file *s, void *p)
262
+static int chan_state_show(struct seq_file *s, void *p)
267263 {
268264 struct pxad_phy *phy = s->private;
269265 u32 dcsr, dcmd;
....@@ -306,7 +302,7 @@
306302 return 0;
307303 }
308304
309
-static int dbg_show_state(struct seq_file *s, void *p)
305
+static int state_show(struct seq_file *s, void *p)
310306 {
311307 struct pxad_device *pdev = s->private;
312308
....@@ -317,52 +313,27 @@
317313 return 0;
318314 }
319315
320
-#define DBGFS_FUNC_DECL(name) \
321
-static int dbg_open_##name(struct inode *inode, struct file *file) \
322
-{ \
323
- return single_open(file, dbg_show_##name, inode->i_private); \
324
-} \
325
-static const struct file_operations dbg_fops_##name = { \
326
- .open = dbg_open_##name, \
327
- .llseek = seq_lseek, \
328
- .read = seq_read, \
329
- .release = single_release, \
330
-}
331
-
332
-DBGFS_FUNC_DECL(state);
333
-DBGFS_FUNC_DECL(chan_state);
334
-DBGFS_FUNC_DECL(descriptors);
335
-DBGFS_FUNC_DECL(requester_chan);
316
+DEFINE_SHOW_ATTRIBUTE(state);
317
+DEFINE_SHOW_ATTRIBUTE(chan_state);
318
+DEFINE_SHOW_ATTRIBUTE(descriptors);
319
+DEFINE_SHOW_ATTRIBUTE(requester_chan);
336320
337321 static struct dentry *pxad_dbg_alloc_chan(struct pxad_device *pdev,
338322 int ch, struct dentry *chandir)
339323 {
340324 char chan_name[11];
341
- struct dentry *chan, *chan_state = NULL, *chan_descr = NULL;
342
- struct dentry *chan_reqs = NULL;
325
+ struct dentry *chan;
343326 void *dt;
344327
345328 scnprintf(chan_name, sizeof(chan_name), "%d", ch);
346329 chan = debugfs_create_dir(chan_name, chandir);
347330 dt = (void *)&pdev->phys[ch];
348331
349
- if (chan)
350
- chan_state = debugfs_create_file("state", 0400, chan, dt,
351
- &dbg_fops_chan_state);
352
- if (chan_state)
353
- chan_descr = debugfs_create_file("descriptors", 0400, chan, dt,
354
- &dbg_fops_descriptors);
355
- if (chan_descr)
356
- chan_reqs = debugfs_create_file("requesters", 0400, chan, dt,
357
- &dbg_fops_requester_chan);
358
- if (!chan_reqs)
359
- goto err_state;
332
+ debugfs_create_file("state", 0400, chan, dt, &chan_state_fops);
333
+ debugfs_create_file("descriptors", 0400, chan, dt, &descriptors_fops);
334
+ debugfs_create_file("requesters", 0400, chan, dt, &requester_chan_fops);
360335
361336 return chan;
362
-
363
-err_state:
364
- debugfs_remove_recursive(chan);
365
- return NULL;
366337 }
367338
368339 static void pxad_init_debugfs(struct pxad_device *pdev)
....@@ -370,40 +341,20 @@
370341 int i;
371342 struct dentry *chandir;
372343
373
- pdev->dbgfs_root = debugfs_create_dir(dev_name(pdev->slave.dev), NULL);
374
- if (IS_ERR(pdev->dbgfs_root) || !pdev->dbgfs_root)
375
- goto err_root;
376
-
377
- pdev->dbgfs_state = debugfs_create_file("state", 0400, pdev->dbgfs_root,
378
- pdev, &dbg_fops_state);
379
- if (!pdev->dbgfs_state)
380
- goto err_state;
381
-
382344 pdev->dbgfs_chan =
383
- kmalloc_array(pdev->nr_chans, sizeof(*pdev->dbgfs_state),
345
+ kmalloc_array(pdev->nr_chans, sizeof(struct dentry *),
384346 GFP_KERNEL);
385347 if (!pdev->dbgfs_chan)
386
- goto err_alloc;
348
+ return;
349
+
350
+ pdev->dbgfs_root = debugfs_create_dir(dev_name(pdev->slave.dev), NULL);
351
+
352
+ debugfs_create_file("state", 0400, pdev->dbgfs_root, pdev, &state_fops);
387353
388354 chandir = debugfs_create_dir("channels", pdev->dbgfs_root);
389
- if (!chandir)
390
- goto err_chandir;
391355
392
- for (i = 0; i < pdev->nr_chans; i++) {
356
+ for (i = 0; i < pdev->nr_chans; i++)
393357 pdev->dbgfs_chan[i] = pxad_dbg_alloc_chan(pdev, i, chandir);
394
- if (!pdev->dbgfs_chan[i])
395
- goto err_chans;
396
- }
397
-
398
- return;
399
-err_chans:
400
-err_chandir:
401
- kfree(pdev->dbgfs_chan);
402
-err_alloc:
403
-err_state:
404
- debugfs_remove_recursive(pdev->dbgfs_root);
405
-err_root:
406
- pr_err("pxad: debugfs is not available\n");
407358 }
408359
409360 static void pxad_cleanup_debugfs(struct pxad_device *pdev)
....@@ -1278,7 +1229,6 @@
12781229
12791230 pxad_cleanup_debugfs(pdev);
12801231 pxad_free_channels(&pdev->slave);
1281
- dma_async_device_unregister(&pdev->slave);
12821232 return 0;
12831233 }
12841234
....@@ -1299,14 +1249,14 @@
12991249 return -ENOMEM;
13001250
13011251 for (i = 0; i < nb_phy_chans; i++)
1302
- if (platform_get_irq(op, i) > 0)
1252
+ if (platform_get_irq_optional(op, i) > 0)
13031253 nr_irq++;
13041254
13051255 for (i = 0; i < nb_phy_chans; i++) {
13061256 phy = &pdev->phys[i];
13071257 phy->base = pdev->base;
13081258 phy->idx = i;
1309
- irq = platform_get_irq(op, i);
1259
+ irq = platform_get_irq_optional(op, i);
13101260 if ((nr_irq > 1) && (irq > 0))
13111261 ret = devm_request_irq(&op->dev, irq,
13121262 pxad_chan_handler,
....@@ -1389,7 +1339,7 @@
13891339 init_waitqueue_head(&c->wq_state);
13901340 }
13911341
1392
- return dma_async_device_register(&pdev->slave);
1342
+ return dmaenginem_async_device_register(&pdev->slave);
13931343 }
13941344
13951345 static int pxad_probe(struct platform_device *op)
....@@ -1426,7 +1376,7 @@
14261376 "#dma-requests set to default 32 as missing in OF: %d",
14271377 ret);
14281378 nb_requestors = 32;
1429
- };
1379
+ }
14301380 } else if (pdata && pdata->dma_channels) {
14311381 dma_channels = pdata->dma_channels;
14321382 nb_requestors = pdata->nb_requestors;
....@@ -1494,7 +1444,7 @@
14941444 .remove = pxad_remove,
14951445 };
14961446
1497
-bool pxad_filter_fn(struct dma_chan *chan, void *param)
1447
+static bool pxad_filter_fn(struct dma_chan *chan, void *param)
14981448 {
14991449 struct pxad_chan *c = to_pxad_chan(chan);
15001450 struct pxad_param *p = param;
....@@ -1507,7 +1457,6 @@
15071457
15081458 return true;
15091459 }
1510
-EXPORT_SYMBOL_GPL(pxad_filter_fn);
15111460
15121461 module_platform_driver(pxad_driver);
15131462