summaryrefslogtreecommitdiff
path: root/sound/drivers/opl4/opl4_proc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-11-21 17:22:21 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-11-21 17:22:21 -0800
commit4843f6873f7c4835e62f2c73ba0fd538e57a2f22 (patch)
treeee620501a1ffbad9a83141e3a70154e1fe641040 /sound/drivers/opl4/opl4_proc.c
downloadlinux-master.tar.gz
linux-master.zip
Merge tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctlgraftedHEADmaster
Pull sysctl fix from Joel Granados: "Fix sysctl jiffy / milliseconds conversion: - Writing a previously read value "X" shall keep the same "X" value - Remove truncation that was causing incorrect saturation of valid timeouts" * tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl: sysctl: Do jiffy / ms conversion in ulong space
Diffstat (limited to 'sound/drivers/opl4/opl4_proc.c')
-rw-r--r--sound/drivers/opl4/opl4_proc.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/sound/drivers/opl4/opl4_proc.c b/sound/drivers/opl4/opl4_proc.c
new file mode 100644
index 000000000..fd0ba4704
--- /dev/null
+++ b/sound/drivers/opl4/opl4_proc.c
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Functions for the OPL4 proc file
+ * Copyright (c) 2003 by Clemens Ladisch <clemens@ladisch.de>
+ */
+
+#include "opl4_local.h"
+#include <linux/vmalloc.h>
+#include <linux/export.h>
+#include <sound/info.h>
+
+static int snd_opl4_mem_proc_open(struct snd_info_entry *entry,
+ unsigned short mode, void **file_private_data)
+{
+ struct snd_opl4 *opl4 = entry->private_data;
+
+ guard(mutex)(&opl4->access_mutex);
+ if (opl4->memory_access)
+ return -EBUSY;
+ opl4->memory_access++;
+ return 0;
+}
+
+static int snd_opl4_mem_proc_release(struct snd_info_entry *entry,
+ unsigned short mode, void *file_private_data)
+{
+ struct snd_opl4 *opl4 = entry->private_data;
+
+ guard(mutex)(&opl4->access_mutex);
+ opl4->memory_access--;
+ return 0;
+}
+
+static ssize_t snd_opl4_mem_proc_read(struct snd_info_entry *entry,
+ void *file_private_data,
+ struct file *file, char __user *_buf,
+ size_t count, loff_t pos)
+{
+ struct snd_opl4 *opl4 = entry->private_data;
+ char* buf;
+
+ buf = vmalloc(count);
+ if (!buf)
+ return -ENOMEM;
+ snd_opl4_read_memory(opl4, buf, pos, count);
+ if (copy_to_user(_buf, buf, count)) {
+ vfree(buf);
+ return -EFAULT;
+ }
+ vfree(buf);
+ return count;
+}
+
+static ssize_t snd_opl4_mem_proc_write(struct snd_info_entry *entry,
+ void *file_private_data,
+ struct file *file,
+ const char __user *_buf,
+ size_t count, loff_t pos)
+{
+ struct snd_opl4 *opl4 = entry->private_data;
+ char *buf;
+
+ buf = vmalloc(count);
+ if (!buf)
+ return -ENOMEM;
+ if (copy_from_user(buf, _buf, count)) {
+ vfree(buf);
+ return -EFAULT;
+ }
+ snd_opl4_write_memory(opl4, buf, pos, count);
+ vfree(buf);
+ return count;
+}
+
+static const struct snd_info_entry_ops snd_opl4_mem_proc_ops = {
+ .open = snd_opl4_mem_proc_open,
+ .release = snd_opl4_mem_proc_release,
+ .read = snd_opl4_mem_proc_read,
+ .write = snd_opl4_mem_proc_write,
+};
+
+int snd_opl4_create_proc(struct snd_opl4 *opl4)
+{
+ struct snd_info_entry *entry;
+
+ entry = snd_info_create_card_entry(opl4->card, "opl4-mem", opl4->card->proc_root);
+ if (entry) {
+ if (opl4->hardware < OPL3_HW_OPL4_ML) {
+ /* OPL4 can access 4 MB external ROM/SRAM */
+ entry->mode |= 0200;
+ entry->size = 4 * 1024 * 1024;
+ } else {
+ /* OPL4-ML has 1 MB internal ROM */
+ entry->size = 1 * 1024 * 1024;
+ }
+ entry->content = SNDRV_INFO_CONTENT_DATA;
+ entry->c.ops = &snd_opl4_mem_proc_ops;
+ entry->module = THIS_MODULE;
+ entry->private_data = opl4;
+ }
+ opl4->proc_entry = entry;
+ return 0;
+}
+
+void snd_opl4_free_proc(struct snd_opl4 *opl4)
+{
+ snd_info_free_entry(opl4->proc_entry);
+}