Commit f3271f65 authored by Jan Engelhardt's avatar Jan Engelhardt Committed by Jonathan Corbet

Fixes to the seq_file document

On Friday 2008-03-28 19:20, Jonathan Corbet wrote:
>commit 9756ccfda31b4c4544aa010aacf71b6672d668e8
>Date:   Fri Mar 28 11:19:56 2008 -0600
>
>    Add the seq_file documentation

patch on top:

  - add const qualifiers
  - remove void* casts
  - use proper specifier (%Ld is not valid)
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarJan Engelhardt <jengelh@computergmbh.de>
parent ef40203a
...@@ -107,8 +107,8 @@ complete. Here's the example version: ...@@ -107,8 +107,8 @@ complete. Here's the example version:
static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos) static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
{ {
loff_t *spos = (loff_t *) v; loff_t *spos = v;
*pos = ++(*spos); *pos = ++*spos;
return spos; return spos;
} }
...@@ -127,8 +127,8 @@ something goes wrong. The example module's show() function is: ...@@ -127,8 +127,8 @@ something goes wrong. The example module's show() function is:
static int ct_seq_show(struct seq_file *s, void *v) static int ct_seq_show(struct seq_file *s, void *v)
{ {
loff_t *spos = (loff_t *) v; loff_t *spos = v;
seq_printf(s, "%Ld\n", *spos); seq_printf(s, "%lld\n", (long long)*spos);
return 0; return 0;
} }
...@@ -136,7 +136,7 @@ We will look at seq_printf() in a moment. But first, the definition of the ...@@ -136,7 +136,7 @@ We will look at seq_printf() in a moment. But first, the definition of the
seq_file iterator is finished by creating a seq_operations structure with seq_file iterator is finished by creating a seq_operations structure with
the four functions we have just defined: the four functions we have just defined:
static struct seq_operations ct_seq_ops = { static const struct seq_operations ct_seq_ops = {
.start = ct_seq_start, .start = ct_seq_start,
.next = ct_seq_next, .next = ct_seq_next,
.stop = ct_seq_stop, .stop = ct_seq_stop,
...@@ -204,7 +204,7 @@ line, as in the example module: ...@@ -204,7 +204,7 @@ line, as in the example module:
static int ct_open(struct inode *inode, struct file *file) static int ct_open(struct inode *inode, struct file *file)
{ {
return seq_open(file, &ct_seq_ops); return seq_open(file, &ct_seq_ops);
}; }
Here, the call to seq_open() takes the seq_operations structure we created Here, the call to seq_open() takes the seq_operations structure we created
before, and gets set up to iterate through the virtual file. before, and gets set up to iterate through the virtual file.
...@@ -219,7 +219,7 @@ The other operations of interest - read(), llseek(), and release() - are ...@@ -219,7 +219,7 @@ The other operations of interest - read(), llseek(), and release() - are
all implemented by the seq_file code itself. So a virtual file's all implemented by the seq_file code itself. So a virtual file's
file_operations structure will look like: file_operations structure will look like:
static struct file_operations ct_file_ops = { static const struct file_operations ct_file_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = ct_open, .open = ct_open,
.read = seq_read, .read = seq_read,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment