Skip to content

Commit 4a68af8

Browse files
committed
/dev/mem: Requirement templatification
This follows the example from [1]. [1] https://github.com/elisa-tech/linux/blob/linux_requirements_wip/kernel/trace/trace_events.c Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
1 parent fedf2ca commit 4a68af8

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

drivers/char/mem.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ static inline bool should_stop_iteration(void)
7676
}
7777

7878
/**
79+
* SPDX-Req-ID: drivers/char/mem.c:read_mem
80+
* SPDX-Req-Text:
7981
* read_mem - read from physical memory (/dev/mem).
8082
* @file: struct file associated with /dev/mem.
8183
* @buf: user-space buffer to copy data to.
@@ -123,6 +125,8 @@ static inline bool should_stop_iteration(void)
123125
* * %-EPERM - access to any of the required physical pages is not allowed
124126
* * %-ENOMEM - out of memory error for auxiliary kernel buffers supporting
125127
* the operation of copying content from the physical pages
128+
*
129+
* SPDX-Req-End
126130
*/
127131
static ssize_t read_mem(struct file *file, char __user *buf,
128132
size_t count, loff_t *ppos)
@@ -212,6 +216,8 @@ static ssize_t read_mem(struct file *file, char __user *buf,
212216
}
213217

214218
/**
219+
* SPDX-Req-ID: drivers/char/mem.c:write_mem
220+
* SPDX-Req-Text:
215221
* write_mem - write to physical memory (/dev/mem).
216222
* @file: struct file associated with /dev/mem.
217223
* @buf: user-space buffer containing the data to write.
@@ -258,6 +264,8 @@ static ssize_t read_mem(struct file *file, char __user *buf,
258264
* * %-EFAULT - the physical address range is not valid or no bytes could
259265
* be copied from user-space
260266
* * %-EPERM - access to any of the required pages is not allowed
267+
*
268+
* SPDX-Req-End
261269
*/
262270
static ssize_t write_mem(struct file *file, const char __user *buf,
263271
size_t count, loff_t *ppos)
@@ -416,6 +424,8 @@ static const struct vm_operations_struct mmap_mem_ops = {
416424
};
417425

418426
/**
427+
* SPDX-Req-ID: drivers/char/mem.c:mmap_mem
428+
* SPDX-Req-Text:
419429
* mmap_mem - map physical memory into user space (/dev/mem).
420430
* @file: file structure for the device.
421431
* @vma: virtual memory area structure describing the user mapping.
@@ -450,6 +460,8 @@ static const struct vm_operations_struct mmap_mem_ops = {
450460
* fails)
451461
* * %-EINVAL - requested physical range to be mapped is not valid
452462
* * %-EPERM - no permission to access the requested physical range
463+
*
464+
* SPDX-Req-End
453465
*/
454466
static int mmap_mem(struct file *file, struct vm_area_struct *vma)
455467
{
@@ -693,6 +705,8 @@ static loff_t null_lseek(struct file *file, loff_t offset, int orig)
693705
}
694706

695707
/**
708+
* SPDX-Req-ID: drivers/char/mem.c:memory_lseek
709+
* SPDX-Req-Text:
696710
* memory_lseek - change the file position.
697711
* @file: file structure for the device.
698712
* @offset: file offset to seek to.
@@ -733,6 +747,8 @@ static loff_t null_lseek(struct file *file, loff_t offset, int orig)
733747
* * %-EOVERFLOW - the new position value equals or exceeds
734748
* (unsigned long long) -MAX_ERRNO
735749
* * %-EINVAL - the orig parameter is invalid
750+
*
751+
* SPDX-Req-End
736752
*/
737753
static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
738754
{
@@ -761,6 +777,8 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
761777
}
762778

763779
/**
780+
* SPDX-Req-ID: drivers/char/mem.c:open_port
781+
* SPDX-Req-Text:
764782
* open_port - open the I/O port device (/dev/port).
765783
* @inode: inode of the device file.
766784
* @filp: file structure for the device.
@@ -788,6 +806,8 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
788806
* * 0 on success
789807
* * %-EPERM - caller lacks the required capability (CAP_SYS_RAWIO)
790808
* * any error returned by securty_locked_down()
809+
*
810+
* SPDX-Req-End
791811
*/
792812
static int open_port(struct inode *inode, struct file *filp)
793813
{
@@ -897,6 +917,8 @@ static const struct memdev {
897917
};
898918

899919
/**
920+
* SPDX-Req-ID: drivers/char/mem.c:memory_open
921+
* SPDX-Req-Text:
900922
* memory_open - set the filp f_op to the memory device fops and invoke open().
901923
* @inode: inode of the device file.
902924
* @filp: file structure for the device.
@@ -922,6 +944,8 @@ static const struct memdev {
922944
* associated with any device or the corresponding device has a NULL fops
923945
* pointer
924946
* * any error returned by the device specific open function pointer
947+
*
948+
* SPDX-Req-End
925949
*/
926950
static int memory_open(struct inode *inode, struct file *filp)
927951
{

0 commit comments

Comments
 (0)