[PATCH] PPC64 iSeries add soem proc entries

Stephen Rothwell sfr at canb.auug.org.au
Thu Apr 22 17:36:32 EST 2004


Hi Andrew,

This patch just adds some proc entries for the virtual tape and cdrom
drivers to allow mapping between linux devices and OS/400 ones.  This
is expected by existing users and there is no other way to do this
translation.

Please apply to your tree and send upstream.

--
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
-------------- next part --------------
diff -ruN 2.6.6-rc2.viocd/drivers/cdrom/viocd.c 2.6.6-rc2.viocd.proc/drivers/cdrom/viocd.c
--- 2.6.6-rc2.viocd/drivers/cdrom/viocd.c	2004-04-22 02:14:07.000000000 +1000
+++ 2.6.6-rc2.viocd.proc/drivers/cdrom/viocd.c	2004-04-22 17:31:15.000000000 +1000
@@ -39,6 +39,8 @@
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/completion.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>

 #include <asm/bug.h>

@@ -152,6 +154,33 @@

 #define MAX_CD_REQ	1

+/* procfs support */
+static int proc_viocd_show(struct seq_file *m, void *v)
+{
+	int i;
+
+	for (i = 0; i < viocd_numdev; i++) {
+		seq_printf(m, "viocd device %d is iSeries resource %10.10s"
+				"type %4.4s, model %3.3s\n",
+				i, viocd_unitinfo[i].rsrcname,
+				viocd_unitinfo[i].type,
+				viocd_unitinfo[i].model);
+	}
+	return 0;
+}
+
+static int proc_viocd_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, proc_viocd_show, NULL);
+}
+
+static struct file_operations proc_viocd_operations = {
+	.open		= proc_viocd_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 static int viocd_blk_open(struct inode *inode, struct file *file)
 {
 	struct disk_info *di = inode->i_bdev->bd_disk->private_data;
@@ -541,6 +570,7 @@
 	struct gendisk *gendisk;
 	int deviceno;
 	int ret = 0;
+	struct proc_dir_entry *e;

 	if (viopath_hostLp == HvLpIndexInvalid) {
 		vio_set_hostlp();
@@ -629,6 +659,12 @@
 		add_disk(gendisk);
 	}

+	e = create_proc_entry("iSeries/viocd", S_IFREG|S_IRUGO, NULL);
+	if (e) {
+		e->owner = THIS_MODULE;
+		e->proc_fops = &proc_viocd_operations;
+	}
+
 	return 0;

 out_undo_vio:
@@ -643,6 +679,7 @@
 {
 	int deviceno;

+	remove_proc_entry("iSeries/viocd", NULL);
 	for (deviceno = 0; deviceno < viocd_numdev; deviceno++) {
 		struct disk_info *d = &viocd_diskinfo[deviceno];
 		if (unregister_cdrom(&d->viocd_info) != 0)
diff -ruN 2.6.6-rc2.viocd/drivers/char/viotape.c 2.6.6-rc2.viocd.proc/drivers/char/viotape.c
--- 2.6.6-rc2.viocd/drivers/char/viotape.c	2004-04-05 10:22:35.000000000 +1000
+++ 2.6.6-rc2.viocd.proc/drivers/char/viotape.c	2004-04-22 17:30:28.000000000 +1000
@@ -47,6 +47,8 @@
 #include <linux/devfs_fs_kernel.h>
 #include <linux/major.h>
 #include <linux/completion.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>

 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
@@ -56,7 +58,7 @@
 #include <asm/iSeries/HvCallEvent.h>
 #include <asm/iSeries/HvLpConfig.h>

-#define VIOTAPE_VERSION		"1.1"
+#define VIOTAPE_VERSION		"1.2"
 #define VIOTAPE_MAXREQ		1

 #define VIOTAPE_KERN_WARN	KERN_WARNING "viotape: "
@@ -269,6 +271,34 @@
 /* forward declaration to resolve interdependence */
 static int chg_state(int index, unsigned char new_state, struct file *file);

+/* procfs support */
+static int proc_viotape_show(struct seq_file *m, void *v)
+{
+	int i;
+
+	seq_printf(m, "viotape driver version " VIOTAPE_VERSION "\n");
+	for (i = 0; i < viotape_numdev; i++) {
+		seq_printf(m, "viotape device %d is iSeries resource %10.10s"
+				"type %4.4s, model %3.3s\n",
+				i, viotape_unitinfo[i].rsrcname,
+				viotape_unitinfo[i].type,
+				viotape_unitinfo[i].model);
+	}
+	return 0;
+}
+
+static int proc_viotape_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, proc_viotape_show, NULL);
+}
+
+static struct file_operations proc_viotape_operations = {
+	.open		= proc_viotape_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 /* Decode the device minor number into its parts */
 void get_dev_info(struct inode *ino, struct viot_devinfo_struct *devi)
 {
@@ -912,6 +942,7 @@
 	int ret;
 	char tapename[32];
 	int i;
+	struct proc_dir_entry *e;

 	op_struct_list = NULL;
 	if ((ret = add_op_structs(VIOTAPE_MAXREQ)) < 0) {
@@ -988,6 +1019,12 @@
 				viotape_unitinfo[i].model);
 	}

+	e = create_proc_entry("iSeries/viotape", S_IFREG|S_IRUGO, NULL);
+	if (e) {
+		e->owner = THIS_MODULE;
+		e->proc_fops = &proc_viotape_operations;
+	}
+
 	return 0;

 unreg_class:
@@ -1029,6 +1066,8 @@
 {
 	int i, ret;

+	remove_proc_entry("iSeries/viotape", NULL);
+
 	for (i = 0; i < viotape_numdev; ++i) {
 		devfs_remove("iseries/nvt%d", i);
 		devfs_remove("iseries/vt%d", i);


More information about the Linuxppc64-dev mailing list