mirror of https://gitee.com/openkylin/linux.git
ALSA: Update the documentation for changes of proc files
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
02f4865fa4
commit
c56a3b1847
|
@ -5518,34 +5518,41 @@ struct _snd_pcm_runtime {
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</informalexample>
|
</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>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The callback is much more complicated than the text-file
|
The read/write callbacks of raw mode are more direct than the text mode.
|
||||||
version. You need to use a low-level I/O functions such as
|
You need to use a low-level I/O functions such as
|
||||||
<function>copy_from/to_user()</function> to transfer the
|
<function>copy_from/to_user()</function> to transfer the
|
||||||
data.
|
data.
|
||||||
|
|
||||||
<informalexample>
|
<informalexample>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![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,
|
void *file_private_data,
|
||||||
struct file *file,
|
struct file *file,
|
||||||
char *buf,
|
char *buf,
|
||||||
unsigned long count,
|
size_t count,
|
||||||
unsigned long pos)
|
loff_t pos)
|
||||||
{
|
{
|
||||||
long size = count;
|
if (copy_to_user(buf, local_data + pos, count))
|
||||||
if (pos + size > local_max_size)
|
|
||||||
size = local_max_size - pos;
|
|
||||||
if (copy_to_user(buf, local_data + pos, size))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return size;
|
return count;
|
||||||
}
|
}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</informalexample>
|
</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>
|
</para>
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
Loading…
Reference in New Issue