Skip to contentSkip to conversation

: Use single_open instead of manual manipulations.

PATCH Applied Pavel Emelyanov 3 participants 6 messages Feb 18, 2008 – Mar 26, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Use single_open instead of manual manipulations.

The code opening proc entry for each device makes the same thing, as the single_open does, so remove the unneeded code.

---

drivers/net/ibmveth.c +3 -39
index 57772be..bb31e09 100644
@@ -1259,26 +1259,7 @@ static void ibmveth_proc_unregister_driver(void)
 	remove_proc_entry(IBMVETH_PROC_DIR, init_net.proc_net);
 }
 
-static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos)
-{
-	if (*pos == 0) {
-		return (void *)1;
-	} else {
-		return NULL;
-	}
-}
-
-static void *ibmveth_seq_next(struct seq_file *seq, void *v, loff_t *pos)
-{
-	++*pos;
-	return NULL;
-}
-
-static void ibmveth_seq_stop(struct seq_file *seq, void *v)
-{
-}
-
-static int ibmveth_seq_show(struct seq_file *seq, void *v)
+static int ibmveth_show(struct seq_file *seq, void *v)
 {
 	struct ibmveth_adapter *adapter = seq->private;
 	char *current_mac = ((char*) &adapter->netdev->dev_addr);
@@ -1302,27 +1283,10 @@ static int ibmveth_seq_show(struct seq_file *seq, void *v)
 
 	return 0;
 }
-static struct seq_operations ibmveth_seq_ops = {
-	.start = ibmveth_seq_start,
-	.next  = ibmveth_seq_next,
-	.stop  = ibmveth_seq_stop,
-	.show  = ibmveth_seq_show,
-};
 
 static int ibmveth_proc_open(struct inode *inode, struct file *file)
 {
-	struct seq_file *seq;
-	struct proc_dir_entry *proc;
-	int rc;
-
-	rc = seq_open(file, &ibmveth_seq_ops);
-	if (!rc) {
-		/* recover the pointer buried in proc_dir_entry data */
-		seq = file->private_data;
-		proc = PDE(inode);
-		seq->private = proc->data;
-	}
-	return rc;
+	return single_open(file, ibmveth_show, PDE(inode)->data);
 }
 
 static const struct file_operations ibmveth_proc_fops = {
@@ -1330,7 +1294,7 @@ static const struct file_operations ibmveth_proc_fops = {
 	.open    = ibmveth_proc_open,
 	.read    = seq_read,
 	.llseek  = seq_lseek,
-	.release = seq_release,
+	.release = single_release,
 };
 
 static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
#2 lore raw
Quoted 9 lines · Jeff Garzik
Quoted 5 lines · Pavel Emelyanov

The code opening proc entry for each device makes the same thing, as the single_open does, so remove the unneeded code.

ACK from ibmveth maintainer?

There's no such in MAINTAINERS file. Git log since 2.6.22 shows Brian King as main contributor, he is in Cc and no reply from him.

Acked-by
#3 lore raw
Quoted 6 lines · Pavel Emelyanov
Quoted 5 lines · Jeff Garzik
Quoted 4 lines · Pavel Emelyanov

The code opening proc entry for each device makes the same thing, as the single_open does, so remove the unneeded code.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

ACK from ibmveth maintainer?

There's no such in MAINTAINERS file. Git log since 2.6.22 shows Brian King as main contributor, he is in Cc and no reply from him.

Signature · 3 lines
Brian King
Linux on Power Virtualization
IBM Linux Technology Center
#4 lore raw
Quoted 7 lines · Brian King
Quoted 6 lines · Pavel Emelyanov
Quoted 5 lines · Jeff Garzik
Quoted 4 lines · Pavel Emelyanov

The code opening proc entry for each device makes the same thing, as the single_open does, so remove the unneeded code.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

ACK from ibmveth maintainer?

There's no such in MAINTAINERS file. Git log since 2.6.22 shows Brian King as main contributor, he is in Cc and no reply from him.

Jeff, what are your plans about this patch?

Thanks,
Pavel