[openib-general] [PATCH] remove some /proc files

Roland Dreier roland at topspin.com
Fri Sep 10 13:36:11 PDT 2004


This gets rid of everything in /proc that's also in sysfs (only the
PMA counters still need to be moved, and I'm waiting for the new MAD
API before I do that work).

 - R.

Index: infiniband/core/core_proc.c
===================================================================
--- infiniband/core/core_proc.c	(revision 759)
+++ infiniband/core/core_proc.c	(working copy)
@@ -54,7 +54,6 @@
 	int                    index;
 	char                   dev_dir_name[16];
 	struct proc_dir_entry *dev_dir;
-	struct proc_dir_entry *dev_info;
 	struct ib_port_proc   *port;
 };
 
@@ -62,343 +61,12 @@
 	struct ib_device      *device;
 	int                    port_num;
 	struct proc_dir_entry *port_dir;
-	struct proc_dir_entry *port_data;
-	struct proc_dir_entry *gid_table;
-	struct proc_dir_entry *pkey_table;
 	struct proc_dir_entry *counters;
 };
 
 static int index = 1;
 static struct proc_dir_entry *core_dir;
 
-static void *ib_dev_info_seq_start(struct seq_file *file,
-				   loff_t *pos)
-{
-	if (*pos)
-		return NULL;
-	else
-		return (void *) 1UL;
-}
-
-static void *ib_dev_info_seq_next(struct seq_file *file,
-				  void *iter_ptr,
-				  loff_t *pos)
-{
-	(*pos)++;
-	return NULL;
-}
-
-static void ib_dev_info_seq_stop(struct seq_file *file,
-				 void *iter_ptr)
-{
-	/* nothing for now */
-}
-
-static int ib_dev_info_seq_show(struct seq_file *file,
-				void *iter_ptr)
-{
-	struct ib_device_attr prop;
-	struct ib_device     *proc_device = file->private;
-
-	seq_printf(file, "name:          %s\n", proc_device->name);
-	seq_printf(file, "provider:      %s\n", proc_device->provider);
-
-	if (proc_device->query_device(proc_device, &prop))
-		return 0;
-
-	seq_printf(file, "node GUID:     %04x:%04x:%04x:%04x\n",
-		   be16_to_cpu(((u16 *) &prop.node_guid)[0]),
-		   be16_to_cpu(((u16 *) &prop.node_guid)[1]),
-		   be16_to_cpu(((u16 *) &prop.node_guid)[2]),
-		   be16_to_cpu(((u16 *) &prop.node_guid)[3]));
-	seq_printf(file, "ports:         %d\n", prop.phys_port_cnt);
-	seq_printf(file, "vendor ID:     0x%x\n", prop.vendor_id);
-	seq_printf(file, "device ID:     0x%x\n", prop.vendor_part_id);
-	seq_printf(file, "HW revision:   0x%x\n", prop.hw_ver);
-	seq_printf(file, "FW revision:   0x%" TS_U64_FMT "x\n", prop.fw_ver);
-
-	return 0;
-}
-
-static struct seq_operations dev_info_seq_ops = {
-	.start = ib_dev_info_seq_start,
-	.next  = ib_dev_info_seq_next,
-	.stop  = ib_dev_info_seq_stop,
-	.show  = ib_dev_info_seq_show
-};
-
-static int ib_dev_info_open(struct inode *inode,
-			    struct file *file)
-{
-	int ret;
-
-	ret = seq_open(file, &dev_info_seq_ops);
-	if (ret)
-		return ret;
-
-	((struct seq_file *) file->private_data)->private = PDE(inode)->data;
-
-	return 0;
-}
-
-static void *ib_port_info_seq_start(struct seq_file *file,
-				  loff_t *pos)
-{
-	if (*pos)
-		return NULL;
-	else
-		return (void *) 1UL;
-}
-
-static void *ib_port_info_seq_next(struct seq_file *file,
-				   void *iter_ptr,
-				   loff_t *pos)
-{
-	(*pos)++;
-	return NULL;
-}
-
-static void ib_port_info_seq_stop(struct seq_file *file,
-				  void *iter_ptr)
-{
-	/* nothing for now */
-}
-
-static int ib_port_info_seq_show(struct seq_file *file,
-				 void *iter_ptr)
-{
-	struct ib_port_attr  prop;
-	struct ib_port_proc *proc_port = file->private;
-
-	if (proc_port->device->query_port(proc_port->device,
-					  proc_port->port_num, &prop)) {
-		return 0;
-	}
-
-	seq_printf(file, "state:         ");
-	switch (prop.state) {
-	case IB_PORT_NOP:
-		seq_printf(file, "NOP\n");
-		break;
-	case IB_PORT_DOWN:
-		seq_printf(file, "DOWN\n");
-		break;
-	case IB_PORT_INIT:
-		seq_printf(file, "INITIALIZE\n");
-		break;
-	case IB_PORT_ARMED:
-		seq_printf(file, "ARMED\n");
-		break;
-	case IB_PORT_ACTIVE:
-		seq_printf(file, "ACTIVE\n");
-		break;
-	default:
-		seq_printf(file, "UNKNOWN\n");
-		break;
-	}
-
-	seq_printf(file, "LID:           0x%04x\n", prop.lid);
-	seq_printf(file, "LMC:           0x%04x\n", prop.lmc);
-	seq_printf(file, "SM LID:        0x%04x\n", prop.sm_lid);
-	seq_printf(file, "SM SL:         0x%04x\n", prop.sm_sl);
-	seq_printf(file, "Capabilities:  ");
-	if (prop.port_cap_flags) {
-		static const char *cap_name[] = {
-			[1]  = "IsSM",
-			[2]  = "IsNoticeSupported",
-			[3]  = "IsTrapSupported",
-			[5]  = "IsAutomaticMigrationSupported",
-			[6]  = "IsSLMappingSupported",
-			[7]  = "IsMKeyNVRAM",
-			[8]  = "IsPKeyNVRAM",
-			[9]  = "IsLEDInfoSupported",
-			[10] = "IsSMdisabled",
-			[11] = "IsSystemImageGUIDSupported",
-			[12] = "IsPKeySwitchExternalPortTrapSupported",
-			[16] = "IsCommunicationManagementSupported",
-			[17] = "IsSNMPTunnelingSupported",
-			[18] = "IsReinitSupported",
-			[19] = "IsDeviceManagementSupported",
-			[20] = "IsVendorClassSupported",
-			[21] = "IsDRNoticeSupported",
-			[22] = "IsCapabilityMaskNoticeSupported",
-			[23] = "IsBootManagementSupported"
-		};
-		int i;
-		int f = 0;
-
-		for (i = 0; i < ARRAY_SIZE(cap_name); ++i) {
-			if (prop.port_cap_flags & (1 << i)) {
-				if (f++) {
-					seq_puts(file, "               ");
-				}
-				if (cap_name[i]) {
-					seq_printf(file, "%s\n", cap_name[i]);
-				} else {
-					seq_printf(file, "RESERVED (%d)\n", i);
-				}
-			}
-		}
-	} else {
-		seq_puts(file, "NONE\n");
-	}
-
-
-	return 0;
-}
-
-static struct seq_operations port_data_seq_ops = {
-	.start = ib_port_info_seq_start,
-	.next  = ib_port_info_seq_next,
-	.stop  = ib_port_info_seq_stop,
-	.show  = ib_port_info_seq_show
-};
-
-static int ib_port_info_open(struct inode *inode,
-			     struct file *file)
-{
-	int ret;
-
-	ret = seq_open(file, &port_data_seq_ops);
-	if (ret)
-		return ret;
-
-	((struct seq_file *) file->private_data)->private = PDE(inode)->data;
-
-	return 0;
-}
-
-static void *ib_gid_table_seq_start(struct seq_file *file,
-				    loff_t *pos)
-{
-	if (*pos)
-		return NULL;
-	else
-		return (void *) 1UL;
-}
-
-static void *ib_gid_table_seq_next(struct seq_file *file,
-				   void *iter_ptr,
-				   loff_t *pos)
-{
-	(*pos)++;
-	return NULL;
-}
-
-static void ib_gid_table_seq_stop(struct seq_file *file,
-				  void *iter_ptr)
-{
-	/* nothing for now */
-}
-
-static int ib_gid_table_seq_show(struct seq_file *file,
-				 void *iter_ptr)
-{
-	int i, j;
-	struct ib_port_proc *proc_port = file->private;
-	static const tTS_IB_GID null_gid;
-	tTS_IB_GID gid;
-
-	for (i = 0; !ib_cached_gid_get(proc_port->device, proc_port->port_num, i, gid); ++i) {
-		if (memcmp(&null_gid[8], &gid[8], 8)) {
-			seq_printf(file, "[%3d] ", i);
-
-			for (j = 0; j < sizeof (tTS_IB_GID) / 2; ++j) {
-				if (j)
-					seq_putc(file, ':');
-				seq_printf(file, "%04x",
-					   be16_to_cpu(((u16 *) gid)[j]));
-			}
-			seq_putc(file, '\n');
-		}
-	}
-
-	return 0;
-}
-
-static struct seq_operations gid_table_seq_ops = {
-	.start = ib_gid_table_seq_start,
-	.next  = ib_gid_table_seq_next,
-	.stop  = ib_gid_table_seq_stop,
-	.show  = ib_gid_table_seq_show
-};
-
-static int ib_gid_table_open(struct inode *inode,
-			      struct file *file)
-{
-	int ret;
-
-	ret = seq_open(file, &gid_table_seq_ops);
-	if (ret)
-		return ret;
-
-	((struct seq_file *) file->private_data)->private = PDE(inode)->data;
-
-	return 0;
-}
-
-static void *ib_pkey_table_seq_start(struct seq_file *file,
-				     loff_t *pos)
-{
-	if (*pos) {
-		return NULL;
-	} else {
-		return (void *) 1UL;
-	}
-}
-
-static void *ib_pkey_table_seq_next(struct seq_file *file,
-				    void *iter_ptr,
-				    loff_t *pos)
-{
-	(*pos)++;
-	return NULL;
-}
-
-static void ib_pkey_table_seq_stop(struct seq_file *file,
-				   void *iter_ptr)
-{
-	/* nothing for now */
-}
-
-static int ib_pkey_table_seq_show(struct seq_file *file,
-				  void *iter_ptr)
-{
-	int i;
-	struct ib_port_proc *proc_port = file->private;
-	u16 pkey;
-
-	for (i = 0; !ib_cached_pkey_get(proc_port->device, proc_port->port_num, i, &pkey); ++i) {
-		if (pkey & 0x7fff) {
-			seq_printf(file, "[%3d] %04x\n", i, pkey);
-		}
-	}
-
-	return 0;
-}
-
-static struct seq_operations pkey_table_seq_ops = {
-	.start = ib_pkey_table_seq_start,
-	.next  = ib_pkey_table_seq_next,
-	.stop  = ib_pkey_table_seq_stop,
-	.show  = ib_pkey_table_seq_show
-};
-
-static int ib_pkey_table_open(
-	struct inode *inode,
-	struct file *file
-	) {
-	int ret;
-
-	ret = seq_open(file, &pkey_table_seq_ops);
-	if (ret) {
-		return ret;
-	}
-	((struct seq_file *) file->private_data)->private = PDE(inode)->data;
-
-	return 0;
-}
-
 static void *ib_counters_seq_start(struct seq_file *file,
 				   loff_t *pos)
 {
@@ -541,38 +209,6 @@
 	return seq_release(inode, file);
 }
 
-static struct file_operations dev_info_ops = {
-	.owner   = THIS_MODULE,
-	.open    = ib_dev_info_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = ib_proc_file_release
-};
-
-static struct file_operations port_data_ops = {
-	.owner   = THIS_MODULE,
-	.open    = ib_port_info_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = ib_proc_file_release
-};
-
-static struct file_operations gid_table_ops = {
-	.owner   = THIS_MODULE,
-	.open    = ib_gid_table_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = ib_proc_file_release
-};
-
-static struct file_operations pkey_table_ops = {
-	.owner   = THIS_MODULE,
-	.open    = ib_pkey_table_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = ib_proc_file_release
-};
-
 static struct file_operations counters_ops = {
 	.owner   = THIS_MODULE,
 	.open    = ib_counters_open,
@@ -606,65 +242,29 @@
 		goto out_free;
 	}
 
-	core_proc->dev_info = create_proc_entry("info", S_IRUGO, core_proc->dev_dir);
-	if (!core_proc->dev_info) {
-		goto out_topdir;
-	}
-	core_proc->dev_info->proc_fops = &dev_info_ops;
-	core_proc->dev_info->data      = device;
-
 	core_proc->port = kmalloc((priv->end_port + 1) * sizeof (struct ib_port_proc),
 				  GFP_KERNEL);
-	if (!core_proc->port) {
-		goto out_info;
-	}
+	if (!core_proc->port)
+		goto out_topdir;
 
 	for (p = priv->start_port; p <= priv->end_port; ++p) {
 		core_proc->port[p].device     = device;
 		core_proc->port[p].port_num   = p;
 		core_proc->port[p].port_dir   = NULL;
-		core_proc->port[p].port_data  = NULL;
-		core_proc->port[p].gid_table  = NULL;
-		core_proc->port[p].pkey_table = NULL;
 		core_proc->port[p].counters   = NULL;
 	}
 
 	for (p = priv->start_port; p <= priv->end_port; ++p) {
 		snprintf(port_name, sizeof port_name, "port%d", p);
 		core_proc->port[p].port_dir = proc_mkdir(port_name, core_proc->dev_dir);
-		if (!core_proc->port[p].port_dir) {
+		if (!core_proc->port[p].port_dir)
 			goto out_port;
-		}
 
-		core_proc->port[p].port_data = create_proc_entry("info", S_IRUGO,
-								 core_proc->port[p].port_dir);
-		if (!core_proc->port[p].port_data) {
-			goto out_port;
-		}
-		core_proc->port[p].port_data->proc_fops = &port_data_ops;
-		core_proc->port[p].port_data->data      = &core_proc->port[p];
-
-		core_proc->port[p].gid_table = create_proc_entry("gid_table", S_IRUGO,
-								 core_proc->port[p].port_dir);
-		if (!core_proc->port[p].gid_table) {
-			goto out_port;
-		}
-		core_proc->port[p].gid_table->proc_fops = &gid_table_ops;
-		core_proc->port[p].gid_table->data      = &core_proc->port[p];
-
-		core_proc->port[p].pkey_table = create_proc_entry("pkey_table", S_IRUGO,
-								  core_proc->port[p].port_dir);
-		if (!core_proc->port[p].pkey_table) {
-			goto out_port;
-		}
-		core_proc->port[p].pkey_table->proc_fops = &pkey_table_ops;
-		core_proc->port[p].pkey_table->data      = &core_proc->port[p];
-
 		core_proc->port[p].counters = create_proc_entry("counters", S_IRUGO,
 								core_proc->port[p].port_dir);
-		if (!core_proc->port[p].counters) {
+		if (!core_proc->port[p].counters)
 			goto out_port;
-		}
+
 		core_proc->port[p].counters->proc_fops = &counters_ops;
 		core_proc->port[p].counters->data      = &core_proc->port[p];
 	}
@@ -675,21 +275,8 @@
 
  out_port:
 	for (p = priv->start_port; p <= priv->end_port; ++p) {
-		if (core_proc->port[p].port_data) {
-			remove_proc_entry("info", core_proc->port[p].port_dir);
-		}
-
-		if (core_proc->port[p].gid_table) {
-			remove_proc_entry("gid_table", core_proc->port[p].port_dir);
-		}
-
-		if (core_proc->port[p].pkey_table) {
-			remove_proc_entry("pkey_table", core_proc->port[p].port_dir);
-		}
-
-		if (core_proc->port[p].counters) {
+		if (core_proc->port[p].counters)
 			remove_proc_entry("counters", core_proc->port[p].port_dir);
-		}
 
 		if (core_proc->port[p].port_dir) {
 			snprintf(port_name, sizeof port_name, "port%d", p);
@@ -697,9 +284,6 @@
 		}
 	}
 
- out_info:
-	remove_proc_entry("info", core_proc->dev_dir);
-
  out_topdir:
 	remove_proc_entry(core_proc->dev_dir_name, core_dir);
 
@@ -717,14 +301,10 @@
 
 	for (p = priv->start_port; p <= priv->end_port; ++p) {
 		remove_proc_entry("counters", core_proc->port[p].port_dir);
-		remove_proc_entry("pkey_table", core_proc->port[p].port_dir);
-		remove_proc_entry("gid_table", core_proc->port[p].port_dir);
-		remove_proc_entry("info", core_proc->port[p].port_dir);
 		snprintf(port_name, sizeof port_name, "port%d", p);
 		remove_proc_entry(port_name, core_proc->dev_dir);
 	}
 
-	remove_proc_entry("info", core_proc->dev_dir);
 	remove_proc_entry(core_proc->dev_dir_name, core_dir);
 
 	kfree(priv->proc);



More information about the general mailing list