Skip to content

Commit a876ef7

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 a876ef7

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

drivers/char/mem.c

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

7878
/**
79+
* SPDX-Req-ID: drivers/char/mem.c:read_mem
80+
* SPDX-Req-HKey: TBD
81+
* SPDX-Req-Text:
7982
* read_mem - read from physical memory (/dev/mem).
8083
* @file: struct file associated with /dev/mem.
8184
* @buf: user-space buffer to copy data to.
@@ -123,6 +126,8 @@ static inline bool should_stop_iteration(void)
123126
* * %-EPERM - access to any of the required physical pages is not allowed
124127
* * %-ENOMEM - out of memory error for auxiliary kernel buffers supporting
125128
* the operation of copying content from the physical pages
129+
*
130+
* SPDX-Req-End
126131
*/
127132
static ssize_t read_mem(struct file *file, char __user *buf,
128133
size_t count, loff_t *ppos)
@@ -212,6 +217,9 @@ static ssize_t read_mem(struct file *file, char __user *buf,
212217
}
213218

214219
/**
220+
* SPDX-Req-ID: drivers/char/mem.c:write_mem
221+
* SPDX-Req-HKey: TBD
222+
* SPDX-Req-Text:
215223
* write_mem - write to physical memory (/dev/mem).
216224
* @file: struct file associated with /dev/mem.
217225
* @buf: user-space buffer containing the data to write.
@@ -258,6 +266,8 @@ static ssize_t read_mem(struct file *file, char __user *buf,
258266
* * %-EFAULT - the physical address range is not valid or no bytes could
259267
* be copied from user-space
260268
* * %-EPERM - access to any of the required pages is not allowed
269+
*
270+
* SPDX-Req-End
261271
*/
262272
static ssize_t write_mem(struct file *file, const char __user *buf,
263273
size_t count, loff_t *ppos)
@@ -416,6 +426,9 @@ static const struct vm_operations_struct mmap_mem_ops = {
416426
};
417427

418428
/**
429+
* SPDX-Req-ID: drivers/char/mem.c:mmap_mem
430+
* SPDX-Req-HKey: TBD
431+
* SPDX-Req-Text:
419432
* mmap_mem - map physical memory into user space (/dev/mem).
420433
* @file: file structure for the device.
421434
* @vma: virtual memory area structure describing the user mapping.
@@ -450,6 +463,8 @@ static const struct vm_operations_struct mmap_mem_ops = {
450463
* fails)
451464
* * %-EINVAL - requested physical range to be mapped is not valid
452465
* * %-EPERM - no permission to access the requested physical range
466+
*
467+
* SPDX-Req-End
453468
*/
454469
static int mmap_mem(struct file *file, struct vm_area_struct *vma)
455470
{
@@ -693,6 +708,9 @@ static loff_t null_lseek(struct file *file, loff_t offset, int orig)
693708
}
694709

695710
/**
711+
* SPDX-Req-ID: drivers/char/mem.c:memory_lseek
712+
* SPDX-Req-HKey: TBD
713+
* SPDX-Req-Text:
696714
* memory_lseek - change the file position.
697715
* @file: file structure for the device.
698716
* @offset: file offset to seek to.
@@ -733,6 +751,8 @@ static loff_t null_lseek(struct file *file, loff_t offset, int orig)
733751
* * %-EOVERFLOW - the new position value equals or exceeds
734752
* (unsigned long long) -MAX_ERRNO
735753
* * %-EINVAL - the orig parameter is invalid
754+
*
755+
* SPDX-Req-End
736756
*/
737757
static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
738758
{
@@ -761,6 +781,9 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
761781
}
762782

763783
/**
784+
* SPDX-Req-ID: drivers/char/mem.c:open_port
785+
* SPDX-Req-HKey: TBD
786+
* SPDX-Req-Text:
764787
* open_port - open the I/O port device (/dev/port).
765788
* @inode: inode of the device file.
766789
* @filp: file structure for the device.
@@ -788,6 +811,8 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
788811
* * 0 on success
789812
* * %-EPERM - caller lacks the required capability (CAP_SYS_RAWIO)
790813
* * any error returned by securty_locked_down()
814+
*
815+
* SPDX-Req-End
791816
*/
792817
static int open_port(struct inode *inode, struct file *filp)
793818
{
@@ -897,6 +922,9 @@ static const struct memdev {
897922
};
898923

899924
/**
925+
* SPDX-Req-ID: drivers/char/mem.c:memory_open
926+
* SPDX-Req-HKey: TBD
927+
* SPDX-Req-Text:
900928
* memory_open - set the filp f_op to the memory device fops and invoke open().
901929
* @inode: inode of the device file.
902930
* @filp: file structure for the device.
@@ -922,6 +950,8 @@ static const struct memdev {
922950
* associated with any device or the corresponding device has a NULL fops
923951
* pointer
924952
* * any error returned by the device specific open function pointer
953+
*
954+
* SPDX-Req-End
925955
*/
926956
static int memory_open(struct inode *inode, struct file *filp)
927957
{

0 commit comments

Comments
 (0)