<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">ChangeSet 1.1587.12.57, 2004/04/30 14:52:02-07:00, eike-hotplug@sf-tec.de

[PATCH] PCI Express Hotplug: some cleanups

Some coding style fixes and small cleanups for pciehp_core.c:
-wrap long lines
-kill spaces before opening braces of functions
-remove code duplication where both parts of an if statement do exactly the
 same
-kill some useless comments
-kill an unneeded initialisation


 drivers/pci/hotplug/pciehp_core.c |   66 +++++++++++++++++++-------------------
 1 files changed, 34 insertions(+), 32 deletions(-)


diff -Nru a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
--- a/drivers/pci/hotplug/pciehp_core.c	Mon May 17 17:00:12 2004
+++ b/drivers/pci/hotplug/pciehp_core.c	Mon May 17 17:00:12 2004
@@ -66,7 +66,7 @@
 
 #define PCIE_MODULE_NAME "pciehp"
 
-static int pcie_start_thread (void);
+static int pcie_start_thread(void);
 static int set_attention_status (struct hotplug_slot *slot, u8 value);
 static int enable_slot		(struct hotplug_slot *slot);
 static int disable_slot		(struct hotplug_slot *slot);
@@ -142,14 +142,19 @@
 		make_slot_name (new_slot-&gt;hotplug_slot-&gt;name, SLOT_NAME_SIZE, new_slot);
 		new_slot-&gt;hotplug_slot-&gt;ops = &amp;pciehp_hotplug_slot_ops;
 
-		new_slot-&gt;hpc_ops-&gt;get_power_status(new_slot, &amp;(new_slot-&gt;hotplug_slot-&gt;info-&gt;power_status));
-		new_slot-&gt;hpc_ops-&gt;get_attention_status(new_slot, &amp;(new_slot-&gt;hotplug_slot-&gt;info-&gt;attention_status));
-		new_slot-&gt;hpc_ops-&gt;get_latch_status(new_slot, &amp;(new_slot-&gt;hotplug_slot-&gt;info-&gt;latch_status));
-		new_slot-&gt;hpc_ops-&gt;get_adapter_status(new_slot, &amp;(new_slot-&gt;hotplug_slot-&gt;info-&gt;adapter_status));
+		new_slot-&gt;hpc_ops-&gt;get_power_status(new_slot,
+			&amp;(new_slot-&gt;hotplug_slot-&gt;info-&gt;power_status));
+		new_slot-&gt;hpc_ops-&gt;get_attention_status(new_slot,
+			&amp;(new_slot-&gt;hotplug_slot-&gt;info-&gt;attention_status));
+		new_slot-&gt;hpc_ops-&gt;get_latch_status(new_slot,
+			&amp;(new_slot-&gt;hotplug_slot-&gt;info-&gt;latch_status));
+		new_slot-&gt;hpc_ops-&gt;get_adapter_status(new_slot,
+			&amp;(new_slot-&gt;hotplug_slot-&gt;info-&gt;adapter_status));
 
 		dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n", 
-			new_slot-&gt;bus, new_slot-&gt;device, new_slot-&gt;hp_slot, new_slot-&gt;number, ctrl-&gt;slot_device_offset);
-		result = pci_hp_register (new_slot-&gt;hotplug_slot);
+			new_slot-&gt;bus, new_slot-&gt;device, new_slot-&gt;hp_slot,
+			new_slot-&gt;number, ctrl-&gt;slot_device_offset);
+		result = pci_hp_register(new_slot-&gt;hotplug_slot);
 		if (result) {
 			err ("pci_hp_register failed with error %d\n", result);
 			goto error_name;
@@ -178,7 +183,7 @@
 }
 
 
-static int cleanup_slots (struct controller * ctrl)
+static int cleanup_slots(struct controller * ctrl)
 {
 	struct slot *old_slot, *next_slot;
 
@@ -187,7 +192,7 @@
 
 	while (old_slot) {
 		next_slot = old_slot-&gt;next;
-		pci_hp_deregister (old_slot-&gt;hotplug_slot);
+		pci_hp_deregister(old_slot-&gt;hotplug_slot);
 		kfree(old_slot-&gt;hotplug_slot-&gt;info);
 		kfree(old_slot-&gt;hotplug_slot-&gt;name);
 		kfree(old_slot-&gt;hotplug_slot);
@@ -208,9 +213,11 @@
 	int rc;
 	int flags;			/* Not needed */
 
-	rc = pcie_get_ctlr_slot_config(ctrl, &amp;num_ctlr_slots, &amp;first_device_num, &amp;physical_slot_num, &amp;updown, &amp;flags);
+	rc = pcie_get_ctlr_slot_config(ctrl, &amp;num_ctlr_slots, &amp;first_device_num,
+			&amp;physical_slot_num, &amp;updown, &amp;flags);
 	if (rc) {
-		err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl-&gt;bus, ctrl-&gt;device);
+		err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n",
+				__FUNCTION__, ctrl-&gt;bus, ctrl-&gt;device);
 		return (-1);
 	}
 
@@ -220,8 +227,8 @@
 	ctrl-&gt;slot_num_inc = updown; 	/* Not needed */		/* either -1 or 1 */
 
 	dbg("%s: bus(0x%x) num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n",
-		__FUNCTION__, ctrl-&gt;slot_bus, num_ctlr_slots, first_device_num, physical_slot_num, updown, 
-		ctrl-&gt;bus, ctrl-&gt;device);
+		__FUNCTION__, ctrl-&gt;slot_bus, num_ctlr_slots, first_device_num,
+		physical_slot_num, updown, ctrl-&gt;bus, ctrl-&gt;device);
 
 	return (0);
 }
@@ -385,14 +392,15 @@
 		goto err_out_unmap_mmio_region;
 	}
 	dbg("%s: ctrl-&gt;pci_bus %p\n", __FUNCTION__, ctrl-&gt;pci_bus);
-	memcpy (ctrl-&gt;pci_bus, pdev-&gt;bus, sizeof (*ctrl-&gt;pci_bus));
+	memcpy(ctrl-&gt;pci_bus, pdev-&gt;bus, sizeof(*ctrl-&gt;pci_bus));
 	ctrl-&gt;bus = pdev-&gt;bus-&gt;number;  /* ctrl bus */
 	ctrl-&gt;slot_bus = pdev-&gt;subordinate-&gt;number;  /* bus controlled by this HPC */
 
 	ctrl-&gt;device = PCI_SLOT(pdev-&gt;devfn);
 	ctrl-&gt;function = PCI_FUNC(pdev-&gt;devfn);
-	dbg("%s: ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", __FUNCTION__,
-		ctrl-&gt;bus, ctrl-&gt;device, ctrl-&gt;function, pdev-&gt;irq);
+	dbg("%s: ctrl bus=0x%x, device=%x, function=%x, irq=%x\n",
+		__FUNCTION__, ctrl-&gt;bus, ctrl-&gt;device,
+		ctrl-&gt;function, pdev-&gt;irq);
 
 	/*
 	 *	Save configuration headers for this and subordinate PCI buses
@@ -409,9 +417,11 @@
 	/* Store PCI Config Space for all devices on this bus */
 	dbg("%s: Before calling pciehp_save_config, ctrl-&gt;bus %x,ctrl-&gt;slot_bus %x\n", 
 		__FUNCTION__,ctrl-&gt;bus, ctrl-&gt;slot_bus);
-	rc = pciehp_save_config(ctrl, ctrl-&gt;slot_bus, num_ctlr_slots, first_device_num);
+	rc = pciehp_save_config(ctrl, ctrl-&gt;slot_bus, num_ctlr_slots,
+					first_device_num);
 	if (rc) {
-		err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc);
+		err("%s: unable to save PCI configuration data, error %d\n",
+				__FUNCTION__, rc);
 		goto err_out_free_ctrl_bus;
 	}
 
@@ -438,31 +448,23 @@
 	/*	Finish setting up the hot plug ctrl device */
 	ctrl-&gt;next_event = 0;
 
-	if (!pciehp_ctrl_list) {
-		pciehp_ctrl_list = ctrl;
-		ctrl-&gt;next = NULL;
-	} else {
-		ctrl-&gt;next = pciehp_ctrl_list;
-		pciehp_ctrl_list = ctrl;
-	}
+	pciehp_ctrl_list = ctrl;
+	ctrl-&gt;next = NULL;
 
-	/* Wait for exclusive access to hardware */
 	down(&amp;ctrl-&gt;crit_sect);
 
 	t_slot-&gt;hpc_ops-&gt;get_adapter_status(t_slot, &amp;value); /* Check if slot is occupied */
 	dbg("%s: adpater value %x\n", __FUNCTION__, value);
 	if (!value) {
-		rc = t_slot-&gt;hpc_ops-&gt;power_off_slot(t_slot); /* Power off slot if not occupied*/
+		rc = t_slot-&gt;hpc_ops-&gt;power_off_slot(t_slot);
 		if (rc) {
-			/* Done with exclusive hardware access */
 			up(&amp;ctrl-&gt;crit_sect);
 			goto err_out_free_ctrl_slot;
 		} else
 			/* Wait for the command to complete */
-			wait_for_ctrl_irq (ctrl);
+			wait_for_ctrl_irq(ctrl);
 	}
 
-	/* Done with exclusive hardware access */
 	up(&amp;ctrl-&gt;crit_sect);
 
 	return 0;
@@ -480,10 +482,10 @@
 }
 
 
-static int pcie_start_thread(void)
+static int __init pcie_start_thread(void)
 {
 	int loop;
-	int retval = 0;
+	int retval;
 	
 	dbg("Initialize + Start the notification/polling mechanism \n");
 
</pre></body></html>