[PATCH] [4/4 try 2] x86_64: mce_amd readability cleanup

shin, jacob jacob.shin at amd.com
Mon May 22 16:53:55 CEST 2006


Change some spacing and variable names to make the code
more readable.

Signed-off-by: Jacob Shin <jacob.shin at amd.com>

---

 mce_amd.c |  100 ++++++++++++++++++++++++++++++++------------------------------
 1 file changed, 52 insertions(+), 48 deletions(-)

Index: linux/arch/x86_64/kernel/mce_amd.c
===================================================================
--- linux.orig/arch/x86_64/kernel/mce_amd.c
+++ linux/arch/x86_64/kernel/mce_amd.c
@@ -30,19 +30,22 @@
 #include <asm/percpu.h>
 #include <asm/idle.h>
 
-#define PFX "mce_threshold: "
-#define VERSION "version 1.1.0"
-#define NR_BANKS 6
-#define NR_BLOCKS 9
-#define THRESHOLD_MAX 0xFFF
-#define INT_TYPE_APIC 0x00020000
-#define MASK_VALID_HI 0x80000000
-#define MASK_LVTOFF_HI 0x00F00000
-#define MASK_COUNT_EN_HI 0x00080000
-#define MASK_INT_TYPE_HI 0x00060000
-#define MASK_OVERFLOW_HI 0x00010000
+#define PFX               "mce_threshold: "
+#define VERSION           "version 1.1.1"
+
+#define NR_BANKS          6
+#define NR_BLOCKS         9
+#define THRESHOLD_MAX     0xFFF
+#define INT_TYPE_APIC     0x00020000
+
+#define MASK_VALID_HI     0x80000000
+#define MASK_LVTOFF_HI    0x00F00000
+#define MASK_COUNT_EN_HI  0x00080000
+#define MASK_INT_TYPE_HI  0x00060000
+#define MASK_OVERFLOW_HI  0x00010000
 #define MASK_ERR_COUNT_HI 0x00000FFF
 #define MASK_BLKPTR_LO    0xFF000000
+
 #define MCG_XBLK_ADDR     0xC0000400
 
 struct threshold_block {
@@ -221,7 +224,7 @@ asmlinkage void mce_threshold_interrupt(
 			        : (address += MCG_XBLK_ADDR))               &&
 			 (++block < NR_BLOCKS));
 	}
-      out:
+out:
 	irq_exit();
 }
 
@@ -230,7 +233,7 @@ asmlinkage void mce_threshold_interrupt(
  */
 
 struct threshold_attr {
-        struct attribute attr;
+	struct attribute attr;
 	ssize_t(*show) (struct threshold_block *, char *);
 	ssize_t(*store) (struct threshold_block *, const char *, size_t count);
 };
@@ -249,11 +252,11 @@ static void affinity_restore(cpumask_t o
 	set_cpus_allowed(current, oldmask);
 }
 
-#define SHOW_FIELDS(name) \
-        static ssize_t show_ ## name(struct threshold_block * b, char *buf) \
-        { \
-                return sprintf(buf, "%lx\n", (unsigned long) b->name); \
-        }
+#define SHOW_FIELDS(name)                                           \
+static ssize_t show_ ## name(struct threshold_block * b, char *buf) \
+{                                                                   \
+        return sprintf(buf, "%lx\n", (unsigned long) b->name);      \
+}
 SHOW_FIELDS(interrupt_enable)
 SHOW_FIELDS(threshold_limit)
 
@@ -324,13 +327,13 @@ static ssize_t store_error_count(struct 
         .store = _store,                                      \
 };
 
-#define ATTR_FIELDS(name) \
-        static struct threshold_attr name = \
+#define RW_ATTR_FIELDS(name)                                    \
+static struct threshold_attr name =                             \
         THRESHOLD_ATTR(name, 0644, show_## name, store_## name)
 
-ATTR_FIELDS(interrupt_enable);
-ATTR_FIELDS(threshold_limit);
-ATTR_FIELDS(error_count);
+RW_ATTR_FIELDS(interrupt_enable);
+RW_ATTR_FIELDS(threshold_limit);
+RW_ATTR_FIELDS(error_count);
 
 static struct attribute *default_attrs[] = {
 	&interrupt_enable.attr,
@@ -340,7 +343,7 @@ static struct attribute *default_attrs[]
 };
 
 #define to_block(k) container_of(k, struct threshold_block, kobj)
-#define to_attr(a) container_of(a,struct threshold_attr,attr)
+#define to_attr(a) container_of(a, struct threshold_attr, attr)
 
 static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
 {
@@ -459,11 +462,11 @@ static __cpuinit int threshold_create_ba
 #ifdef CONFIG_SMP
 	if (cpu_core_id[cpu] && shared_bank[bank]) {	/* symlink */
 		char name[16];
-		unsigned lcpu = first_cpu(cpu_core_map[cpu]);
-		if (cpu_core_id[lcpu])
+		unsigned first_core = first_cpu(cpu_core_map[cpu]);
+		if (cpu_core_id[first_core])
 			goto out;	/* first core not up yet */
 
-		b = per_cpu(threshold_banks, lcpu)[bank];
+		b = per_cpu(threshold_banks, first_core)[bank];
 		if (!b)
 			goto out;
 		sprintf(name, "threshold_bank%i", bank);
@@ -508,7 +511,7 @@ static __cpuinit int threshold_create_ba
 out_free:
 	per_cpu(threshold_banks, cpu)[bank] = NULL;
 	kfree(b);
-      out:
+out:
 	up(&threshold_lock);
 	return err;
 }
@@ -516,7 +519,7 @@ out_free:
 /* create dir/files for all valid threshold banks */
 static __cpuinit int threshold_create_device(unsigned int cpu)
 {
-	int bank;
+	unsigned int bank;
 	int err = 0;
 
 	for (bank = 0; bank < NR_BANKS; ++bank) {
@@ -526,7 +529,7 @@ static __cpuinit int threshold_create_de
 		if (err)
 			goto out;
 	}
-      out:
+out:
 	return err;
 }
 
@@ -557,7 +560,8 @@ static __cpuinit void deallocate_thresho
 	per_cpu(threshold_banks, cpu)[bank]->blocks = NULL;
 }
 
-static __cpuinit void threshold_remove_bank(unsigned int cpu, int bank)
+static __cpuinit void threshold_remove_bank(unsigned int cpu, 
+					    unsigned int bank)
 {
 	struct threshold_bank *b;
 	char name[16];
@@ -585,7 +589,7 @@ static __cpuinit void threshold_remove_b
 
 static __cpuinit void threshold_remove_device(unsigned int cpu)
 {
-	int bank;
+	unsigned int bank;
 
 	for (bank = 0; bank < NR_BANKS; ++bank) {
 		if (!(per_cpu(bank_map, cpu) & 1 << bank))
@@ -597,20 +601,20 @@ static __cpuinit void threshold_remove_d
 /* link all existing siblings when first core comes up */
 static __cpuinit int threshold_create_symlinks(unsigned int cpu)
 {
-	int bank, err = 0;
-	unsigned int lcpu = 0;
+	int err = 0;
+	unsigned int bank, sibling = 0;
 
 	if (cpu_core_id[cpu])
 		return 0;
-	for_each_cpu_mask(lcpu, cpu_core_map[cpu]) {
-		if (lcpu == cpu)
+	for_each_cpu_mask(sibling, cpu_core_map[cpu]) {
+		if (sibling == cpu)
 			continue;
 		for (bank = 0; bank < NR_BANKS; ++bank) {
 			if (!(per_cpu(bank_map, cpu) & 1 << bank))
 				continue;
 			if (!shared_bank[bank])
 				continue;
-			err = threshold_create_bank(lcpu, bank);
+			err = threshold_create_bank(sibling, bank);
 		}
 	}
 	return err;
@@ -619,19 +623,19 @@ static __cpuinit int threshold_create_sy
 /* remove all symlinks before first core dies. */
 static __cpuinit void threshold_remove_symlinks(unsigned int cpu)
 {
-	int bank;
-	unsigned int lcpu = 0;
+	unsigned int bank;
+	unsigned int sibling = 0;
 	if (cpu_core_id[cpu])
 		return;
-	for_each_cpu_mask(lcpu, cpu_core_map[cpu]) {
-		if (lcpu == cpu)
+	for_each_cpu_mask(sibling, cpu_core_map[cpu]) {
+		if (sibling == cpu)
 			continue;
 		for (bank = 0; bank < NR_BANKS; ++bank) {
 			if (!(per_cpu(bank_map, cpu) & 1 << bank))
 				continue;
 			if (!shared_bank[bank])
 				continue;
-			threshold_remove_bank(lcpu, bank);
+			threshold_remove_bank(sibling, bank);
 		}
 	}
 }
@@ -649,7 +653,7 @@ static void threshold_remove_device(unsi
 
 /* get notified when a cpu comes on/off */
 static int threshold_cpu_callback(struct notifier_block *nfb,
-					    unsigned long action, void *hcpu)
+				  unsigned long action, void *hcpu)
 {
 	/* cpu was unsigned int to begin with */
 	unsigned int cpu = (unsigned long)hcpu;
@@ -674,7 +678,7 @@ static int threshold_cpu_callback(struct
 	default:
 		break;
 	}
-      out:
+out:
 	return NOTIFY_OK;
 }
 
@@ -685,17 +689,17 @@ static struct notifier_block threshold_c
 static __init int threshold_init_device(void)
 {
 	int err;
-	int lcpu = 0;
+	int cpu = 0;
 
 	/* to hit CPUs online before the notifier is up */
-	for_each_online_cpu(lcpu) {
-		err = threshold_create_device(lcpu);
+	for_each_online_cpu(cpu) {
+		err = threshold_create_device(cpu);
 		if (err)
 			goto out;
 	}
 	register_cpu_notifier(&threshold_cpu_notifier);
 
-      out:
+out:
 	return err;
 }
 




More information about the discuss mailing list