forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/misc/genwqe/card_dev.c
....@@ -1,4 +1,5 @@
1
-/**
1
+// SPDX-License-Identifier: GPL-2.0-only
2
+/*
23 * IBM Accelerator Family 'GenWQE'
34 *
45 * (C) Copyright IBM Corp. 2013
....@@ -7,15 +8,6 @@
78 * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
89 * Author: Michael Jung <mijung@gmx.net>
910 * Author: Michael Ruettger <michael@ibmra.de>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License (version 2 only)
13
- * as published by the Free Software Foundation.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
1911 */
2012
2113 /*
....@@ -95,7 +87,7 @@
9587 * @cfile: Descriptor of opened file
9688 * @u_addr: User virtual address
9789 * @size: Size of buffer
98
- * @dma_addr: DMA address to be updated
90
+ * @virt_addr: Virtual address to be updated
9991 *
10092 * Return: Pointer to the corresponding mapping NULL if not found
10193 */
....@@ -152,6 +144,7 @@
152144 * @u_addr: user virtual address
153145 * @size: size of buffer
154146 * @dma_addr: DMA address to be updated
147
+ * @virt_addr: Virtual address to be updated
155148 * Return: Pointer to the corresponding mapping NULL if not found
156149 */
157150 static struct dma_mapping *__genwqe_search_mapping(struct genwqe_file *cfile,
....@@ -257,6 +250,8 @@
257250
258251 /**
259252 * genwqe_kill_fasync() - Send signal to all processes with open GenWQE files
253
+ * @cd: GenWQE device information
254
+ * @sig: Signal to send out
260255 *
261256 * E.g. genwqe_send_signal(cd, SIGIO);
262257 */
....@@ -388,6 +383,7 @@
388383
389384 /**
390385 * genwqe_vma_close() - Called each time when vma is unmapped
386
+ * @vma: VMA area to close
391387 *
392388 * Free memory which got allocated by GenWQE mmap().
393389 */
....@@ -424,6 +420,8 @@
424420
425421 /**
426422 * genwqe_mmap() - Provide contignous buffers to userspace
423
+ * @filp: File pointer (unused)
424
+ * @vma: VMA area to map
427425 *
428426 * We use mmap() to allocate contignous buffers used for DMA
429427 * transfers. After the buffer is allocated we remap it to user-space
....@@ -492,16 +490,15 @@
492490 return rc;
493491 }
494492
493
+#define FLASH_BLOCK 0x40000 /* we use 256k blocks */
494
+
495495 /**
496496 * do_flash_update() - Excute flash update (write image or CVPD)
497
- * @cd: genwqe device
497
+ * @cfile: Descriptor of opened file
498498 * @load: details about image load
499499 *
500500 * Return: 0 if successful
501501 */
502
-
503
-#define FLASH_BLOCK 0x40000 /* we use 256k blocks */
504
-
505502 static int do_flash_update(struct genwqe_file *cfile,
506503 struct genwqe_bitstream *load)
507504 {
....@@ -828,6 +825,8 @@
828825
829826 /**
830827 * ddcb_cmd_cleanup() - Remove dynamically created fixup entries
828
+ * @cfile: Descriptor of opened file
829
+ * @req: DDCB work request
831830 *
832831 * Only if there are any. Pinnings are not removed.
833832 */
....@@ -852,6 +851,8 @@
852851
853852 /**
854853 * ddcb_cmd_fixups() - Establish DMA fixups/sglists for user memory references
854
+ * @cfile: Descriptor of opened file
855
+ * @req: DDCB work request
855856 *
856857 * Before the DDCB gets executed we need to handle the fixups. We
857858 * replace the user-space addresses with DMA addresses or do
....@@ -982,6 +983,8 @@
982983
983984 /**
984985 * genwqe_execute_ddcb() - Execute DDCB using userspace address fixups
986
+ * @cfile: Descriptor of opened file
987
+ * @cmd: Command identifier (passed from user)
985988 *
986989 * The code will build up the translation tables or lookup the
987990 * contignous memory allocation table to find the right translations
....@@ -1223,34 +1226,13 @@
12231226 return rc;
12241227 }
12251228
1226
-#if defined(CONFIG_COMPAT)
1227
-/**
1228
- * genwqe_compat_ioctl() - Compatibility ioctl
1229
- *
1230
- * Called whenever a 32-bit process running under a 64-bit kernel
1231
- * performs an ioctl on /dev/genwqe<n>_card.
1232
- *
1233
- * @filp: file pointer.
1234
- * @cmd: command.
1235
- * @arg: user argument.
1236
- * Return: zero on success or negative number on failure.
1237
- */
1238
-static long genwqe_compat_ioctl(struct file *filp, unsigned int cmd,
1239
- unsigned long arg)
1240
-{
1241
- return genwqe_ioctl(filp, cmd, arg);
1242
-}
1243
-#endif /* defined(CONFIG_COMPAT) */
1244
-
12451229 static const struct file_operations genwqe_fops = {
12461230 .owner = THIS_MODULE,
12471231 .open = genwqe_open,
12481232 .fasync = genwqe_fasync,
12491233 .mmap = genwqe_mmap,
12501234 .unlocked_ioctl = genwqe_ioctl,
1251
-#if defined(CONFIG_COMPAT)
1252
- .compat_ioctl = genwqe_compat_ioctl,
1253
-#endif
1235
+ .compat_ioctl = compat_ptr_ioctl,
12541236 .release = genwqe_release,
12551237 };
12561238
....@@ -1309,14 +1291,10 @@
13091291 goto err_cdev;
13101292 }
13111293
1312
- rc = genwqe_init_debugfs(cd);
1313
- if (rc != 0)
1314
- goto err_debugfs;
1294
+ genwqe_init_debugfs(cd);
13151295
13161296 return 0;
13171297
1318
- err_debugfs:
1319
- device_destroy(cd->class_genwqe, cd->devnum_genwqe);
13201298 err_cdev:
13211299 cdev_del(&cd->cdev_genwqe);
13221300 err_add:
....@@ -1372,6 +1350,7 @@
13721350
13731351 /**
13741352 * genwqe_device_remove() - Remove genwqe's char device
1353
+ * @cd: GenWQE device information
13751354 *
13761355 * This function must be called after the client devices are removed
13771356 * because it will free the major/minor number range for the genwqe