23 #include <linux/time.h>
25 #include <linux/slab.h>
26 #include <linux/string.h>
27 #include <linux/module.h>
31 #include <linux/utsname.h>
42 int snd_info_check_reserved_words(
const char *
str)
73 struct snd_info_private_data {
77 void *file_private_data;
80 static int snd_info_version_init(
void);
81 static int snd_info_version_done(
void);
119 len = buffer->
len - buffer->
size;
128 err = resize_info_buffer(buffer, buffer->
len +
PAGE_SIZE);
131 len = buffer->
len - buffer->
size;
152 #ifdef CONFIG_SND_OSSEMUL
163 static loff_t snd_info_entry_llseek(
struct file *
file, loff_t
offset,
int orig)
165 struct snd_info_private_data *
data;
173 entry->
c.
ops->llseek) {
174 offset = entry->
c.
ops->llseek(entry,
175 data->file_private_data,
187 offset += file->
f_pos;
199 if (size && offset > size)
208 static ssize_t snd_info_entry_read(
struct file *file,
char __user *buffer,
209 size_t count, loff_t * offset)
211 struct snd_info_private_data *
data;
221 if (pos < 0 || (
long) pos != pos || (
ssize_t) count < 0)
223 if ((
unsigned long) pos + (
unsigned long) count < (
unsigned long) pos)
231 if (pos >= buf->
size)
234 size =
min(count, size);
239 if (pos >= entry->
size)
241 if (entry->
c.
ops->read) {
243 size =
min(count, size);
244 size = entry->
c.
ops->read(entry,
245 data->file_private_data,
246 file, buffer, size, pos);
251 *offset = pos +
size;
255 static ssize_t snd_info_entry_write(
struct file *file,
const char __user *buffer,
256 size_t count, loff_t * offset)
258 struct snd_info_private_data *
data;
269 if (pos < 0 || (
long) pos != pos || (
ssize_t) count < 0)
271 if ((
unsigned long) pos + (
unsigned long) count < (
unsigned long) pos)
279 if (pos + count >= buf->
len) {
280 if (resize_info_buffer(buf, pos + count)) {
294 if (entry->
c.
ops->write && count > 0) {
295 size_t maxsize = entry->
size -
pos;
296 count =
min(count, maxsize);
297 size = entry->
c.
ops->write(entry,
298 data->file_private_data,
299 file, buffer, count, pos);
304 *offset = pos +
size;
308 static int snd_info_entry_open(
struct inode *
inode,
struct file *file)
311 struct snd_info_private_data *
data;
319 if (entry ==
NULL || ! entry->
p) {
323 if (!try_module_get(entry->
module)) {
351 buffer = kzalloc(
sizeof(*buffer),
GFP_KERNEL);
361 buffer = kzalloc(
sizeof(*buffer),
GFP_KERNEL);
372 if (entry->
c.
ops->open) {
373 if ((err = entry->
c.
ops->open(entry, mode,
374 &data->file_private_data)) < 0) {
385 if (entry->
c.
text.read) {
387 entry->
c.
text.read(entry, data->rbuffer);
395 kfree(data->rbuffer->buffer);
396 kfree(data->rbuffer);
399 kfree(data->wbuffer->buffer);
400 kfree(data->wbuffer);
405 module_put(entry->
module);
411 static int snd_info_entry_release(
struct inode *inode,
struct file *file)
414 struct snd_info_private_data *
data;
423 kfree(data->rbuffer->buffer);
424 kfree(data->rbuffer);
427 if (entry->
c.
text.write) {
428 entry->
c.
text.write(entry, data->wbuffer);
429 if (data->wbuffer->error) {
432 data->wbuffer->error);
435 kfree(data->wbuffer->buffer);
436 kfree(data->wbuffer);
440 if (entry->
c.
ops->release)
441 entry->
c.
ops->release(entry, mode,
442 data->file_private_data);
445 module_put(entry->
module);
450 static unsigned int snd_info_entry_poll(
struct file *file,
poll_table *
wait)
452 struct snd_info_private_data *
data;
463 if (entry->
c.
ops->poll)
464 return entry->
c.
ops->poll(entry,
465 data->file_private_data,
467 if (entry->
c.
ops->read)
469 if (entry->
c.
ops->write)
476 static long snd_info_entry_ioctl(
struct file *file,
unsigned int cmd,
479 struct snd_info_private_data *
data;
488 if (entry->
c.
ops->ioctl)
489 return entry->
c.
ops->ioctl(entry,
490 data->file_private_data,
497 static int snd_info_entry_mmap(
struct file *file,
struct vm_area_struct *vma)
499 struct inode *inode = file->
f_path.dentry->d_inode;
500 struct snd_info_private_data *
data;
509 if (entry->
c.
ops->mmap)
510 return entry->
c.
ops->mmap(entry,
511 data->file_private_data,
521 .llseek = snd_info_entry_llseek,
522 .read = snd_info_entry_read,
523 .write = snd_info_entry_write,
524 .poll = snd_info_entry_poll,
525 .unlocked_ioctl = snd_info_entry_ioctl,
526 .mmap = snd_info_entry_mmap,
527 .open = snd_info_entry_open,
528 .release = snd_info_entry_release,
531 int __init snd_info_init(
void)
539 #ifdef CONFIG_SND_OSSEMUL
545 if (snd_info_register(entry) < 0) {
546 snd_info_free_entry(entry);
549 snd_oss_root =
entry;
552 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
558 if (snd_info_register(entry) < 0) {
559 snd_info_free_entry(entry);
562 snd_seq_root =
entry;
565 snd_info_version_init();
567 snd_minor_info_oss_init();
572 int __exit snd_info_done(
void)
575 snd_minor_info_oss_done();
577 snd_info_version_done();
579 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
580 snd_info_free_entry(snd_seq_root);
582 #ifdef CONFIG_SND_OSSEMUL
583 snd_info_free_entry(snd_oss_root);
585 snd_remove_proc_entry(
NULL, snd_proc_root);
608 if ((entry = snd_info_create_module_entry(card->
module, str,
NULL)) ==
NULL)
611 if (snd_info_register(entry) < 0) {
612 snd_info_free_entry(entry);
623 int snd_info_card_register(
struct snd_card *card)
643 void snd_info_card_id_change(
struct snd_card *card)
661 void snd_info_card_disconnect(
struct snd_card *card)
679 int snd_info_card_free(
struct snd_card *card)
703 if (len <= 0 || buffer->
stop || buffer->
error)
718 while (c !=
'\n' && !buffer->
stop) {
741 const char *snd_info_get_str(
char *
dest,
const char *
src,
int len)
745 while (*src ==
' ' || *src ==
'\t')
747 if (*src ==
'"' || *src ==
'\'') {
749 while (--len > 0 && *src && *src != c) {
755 while (--len > 0 && *src && *src !=
' ' && *src !=
'\t') {
760 while (*src ==
' ' || *src ==
'\t')
794 INIT_LIST_HEAD(&entry->
list);
858 list_del_init(&entry->
list);
861 snd_remove_proc_entry(root, entry->
p);
868 snd_info_free_entry(entry);
875 return snd_info_register(entry);
898 int snd_card_proc_new(
struct snd_card *card,
const char *name,
902 .dev_free = snd_info_dev_free_entry,
903 .dev_register = snd_info_dev_register_entry,
909 entry = snd_info_create_card_entry(card, name, card->
proc_root);
913 snd_info_free_entry(entry);
935 snd_info_disconnect(entry);
968 p->
proc_fops = &snd_info_entry_operations;
989 "Advanced Linux Sound Architecture Driver Version k%s.\n",
993 static int __init snd_info_version_init(
void)
1000 entry->
c.
text.read = snd_info_version_read;
1001 if (snd_info_register(entry) < 0) {
1002 snd_info_free_entry(entry);
1005 snd_info_version_entry =
entry;
1009 static int __exit snd_info_version_done(
void)
1011 snd_info_free_entry(snd_info_version_entry);