Skip to content

Commit

Permalink
/dev/port: don't compile file operations without CONFIG_DEVPORT
Browse files Browse the repository at this point in the history
(cherry picked from commit f0a816f)

In the future inb() and friends will not be available when compiling
with CONFIG_HAS_IOPORT=n so we must only try to access them here if
CONFIG_DEVPORT is set which depends on HAS_IOPORT.

Co-developed-by: Arnd Bergmann <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Niklas Schnelle <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
[mpe: Cherry picked from the char-misc tree to prevent build errors]
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
niklas88 authored and mpe committed Apr 18, 2024
1 parent f318c8b commit 1edb154
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ static int mmap_mem(struct file *file, struct vm_area_struct *vma)
return 0;
}

#ifdef CONFIG_DEVPORT
static ssize_t read_port(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
Expand Down Expand Up @@ -424,6 +425,7 @@ static ssize_t write_port(struct file *file, const char __user *buf,
*ppos = i;
return tmp-buf;
}
#endif

static ssize_t read_null(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
Expand Down Expand Up @@ -653,12 +655,14 @@ static const struct file_operations null_fops = {
.uring_cmd = uring_cmd_null,
};

static const struct file_operations __maybe_unused port_fops = {
#ifdef CONFIG_DEVPORT
static const struct file_operations port_fops = {
.llseek = memory_lseek,
.read = read_port,
.write = write_port,
.open = open_port,
};
#endif

static const struct file_operations zero_fops = {
.llseek = zero_lseek,
Expand Down

0 comments on commit 1edb154

Please sign in to comment.