diff options
author | Takashi Iwai <tiwai@suse.de> | 2010-05-20 11:58:57 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-05-20 11:58:57 +0200 |
commit | 3374cd1abd478f767aaedf2c21d109596ff0fe72 (patch) | |
tree | 46b00a571ba5d86373bd9054fdccc5dc6e28e42f /Documentation/DocBook | |
parent | e40152ee1e1c7a63f4777791863215e3faa37a86 (diff) | |
parent | 670ff6abd6caff406b217f8a828d6c03656535d8 (diff) | |
download | op-kernel-dev-3374cd1abd478f767aaedf2c21d109596ff0fe72.zip op-kernel-dev-3374cd1abd478f767aaedf2c21d109596ff0fe72.tar.gz |
Merge branch 'topic/core-cleanup' into for-linus
Diffstat (limited to 'Documentation/DocBook')
-rw-r--r-- | Documentation/DocBook/writing-an-alsa-driver.tmpl | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl index 0d0f7b4..0ba149d 100644 --- a/Documentation/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl @@ -5518,34 +5518,41 @@ struct _snd_pcm_runtime { ]]> </programlisting> </informalexample> + + For the raw data, <structfield>size</structfield> field must be + set properly. This specifies the maximum size of the proc file access. </para> <para> - The callback is much more complicated than the text-file - version. You need to use a low-level I/O functions such as + The read/write callbacks of raw mode are more direct than the text mode. + You need to use a low-level I/O functions such as <function>copy_from/to_user()</function> to transfer the data. <informalexample> <programlisting> <![CDATA[ - static long my_file_io_read(struct snd_info_entry *entry, + static ssize_t my_file_io_read(struct snd_info_entry *entry, void *file_private_data, struct file *file, char *buf, - unsigned long count, - unsigned long pos) + size_t count, + loff_t pos) { - long size = count; - if (pos + size > local_max_size) - size = local_max_size - pos; - if (copy_to_user(buf, local_data + pos, size)) + if (copy_to_user(buf, local_data + pos, count)) return -EFAULT; - return size; + return count; } ]]> </programlisting> </informalexample> + + If the size of the info entry has been set up properly, + <structfield>count</structfield> and <structfield>pos</structfield> are + guaranteed to fit within 0 and the given size. + You don't have to check the range in the callbacks unless any + other condition is required. + </para> </chapter> |