Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Loongson: Cleanup cpu_hwmon.c

Fix the following checkpatch warnings and errors:

ERROR: do not initialise statics to 0
+static int csr_temp_enable = 0;

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(name, S_IRUGO, get_hwmon_name, NULL, 0);

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, get_cpu_temp, NULL, 1);

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, cpu_temp_label, NULL, 1);

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, get_cpu_temp, NULL, 2);

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, cpu_temp_label, NULL, 2);

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, get_cpu_temp, NULL, 3);

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, cpu_temp_label, NULL, 3);

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, get_cpu_temp, NULL, 4);

WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
+static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, cpu_temp_label, NULL, 4);

WARNING: Missing a blank line after declarations
+ int id = (to_sensor_dev_attr(attr))->index - 1;
+ return sprintf(buf, "CPU %d Temperature\n", id);

WARNING: Missing a blank line after declarations
+ int value = loongson3_cpu_temp(id);
+ return sprintf(buf, "%d\n", value);

ERROR: spaces required around that '=' (ctx:VxV)
+ for (i=0; i<nr_packages; i++)
^

ERROR: spaces required around that '<' (ctx:VxV)
+ for (i=0; i<nr_packages; i++)
^

ERROR: spaces required around that '=' (ctx:VxV)
+ for (i=0; i<nr_packages; i++)
^

ERROR: spaces required around that '<' (ctx:VxV)
+ for (i=0; i<nr_packages; i++)
^

ERROR: spaces required around that '=' (ctx:VxV)
+ for (i=0; i<nr_packages; i++) {
^

ERROR: spaces required around that '<' (ctx:VxV)
+ for (i=0; i<nr_packages; i++) {
^

WARNING: line over 80 characters
+ csr_temp_enable = csr_readl(LOONGSON_CSR_FEATURES) & LOONGSON_CSRF_TEMP;

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Zhi Li <lizhi01@loongson.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Tiezhu Yang and committed by
Thomas Bogendoerfer
f17d3f21 7a98c066

+18 -15
+18 -15
drivers/platform/mips/cpu_hwmon.c
··· 11 11 #include <loongson_hwmon.h> 12 12 #include <loongson_regs.h> 13 13 14 - static int csr_temp_enable = 0; 14 + static int csr_temp_enable; 15 15 16 16 /* 17 17 * Loongson-3 series cpu has two sensors inside, ··· 44 44 case PRID_REV_LOONGSON3A_R3_0: 45 45 case PRID_REV_LOONGSON3A_R3_1: 46 46 default: 47 - reg = (reg & 0xffff)*731/0x4000 - 273; 47 + reg = (reg & 0xffff) * 731 / 0x4000 - 273; 48 48 break; 49 49 } 50 50 ··· 57 57 58 58 static ssize_t get_hwmon_name(struct device *dev, 59 59 struct device_attribute *attr, char *buf); 60 - static SENSOR_DEVICE_ATTR(name, S_IRUGO, get_hwmon_name, NULL, 0); 60 + static SENSOR_DEVICE_ATTR(name, 0444, get_hwmon_name, NULL, 0); 61 61 62 62 static struct attribute *cpu_hwmon_attributes[] = { 63 63 &sensor_dev_attr_name.dev_attr.attr, ··· 81 81 static ssize_t cpu_temp_label(struct device *dev, 82 82 struct device_attribute *attr, char *buf); 83 83 84 - static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, get_cpu_temp, NULL, 1); 85 - static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, cpu_temp_label, NULL, 1); 86 - static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, get_cpu_temp, NULL, 2); 87 - static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, cpu_temp_label, NULL, 2); 88 - static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, get_cpu_temp, NULL, 3); 89 - static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, cpu_temp_label, NULL, 3); 90 - static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, get_cpu_temp, NULL, 4); 91 - static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, cpu_temp_label, NULL, 4); 84 + static SENSOR_DEVICE_ATTR(temp1_input, 0444, get_cpu_temp, NULL, 1); 85 + static SENSOR_DEVICE_ATTR(temp1_label, 0444, cpu_temp_label, NULL, 1); 86 + static SENSOR_DEVICE_ATTR(temp2_input, 0444, get_cpu_temp, NULL, 2); 87 + static SENSOR_DEVICE_ATTR(temp2_label, 0444, cpu_temp_label, NULL, 2); 88 + static SENSOR_DEVICE_ATTR(temp3_input, 0444, get_cpu_temp, NULL, 3); 89 + static SENSOR_DEVICE_ATTR(temp3_label, 0444, cpu_temp_label, NULL, 3); 90 + static SENSOR_DEVICE_ATTR(temp4_input, 0444, get_cpu_temp, NULL, 4); 91 + static SENSOR_DEVICE_ATTR(temp4_label, 0444, cpu_temp_label, NULL, 4); 92 92 93 93 static const struct attribute *hwmon_cputemp[4][3] = { 94 94 { ··· 117 117 struct device_attribute *attr, char *buf) 118 118 { 119 119 int id = (to_sensor_dev_attr(attr))->index - 1; 120 + 120 121 return sprintf(buf, "CPU %d Temperature\n", id); 121 122 } 122 123 ··· 126 125 { 127 126 int id = (to_sensor_dev_attr(attr))->index - 1; 128 127 int value = loongson3_cpu_temp(id); 128 + 129 129 return sprintf(buf, "%d\n", value); 130 130 } 131 131 ··· 134 132 { 135 133 int i, ret = 0; 136 134 137 - for (i=0; i<nr_packages; i++) 135 + for (i = 0; i < nr_packages; i++) 138 136 ret = sysfs_create_files(kobj, hwmon_cputemp[i]); 139 137 140 138 return ret; ··· 144 142 { 145 143 int i; 146 144 147 - for (i=0; i<nr_packages; i++) 145 + for (i = 0; i < nr_packages; i++) 148 146 sysfs_remove_files(kobj, hwmon_cputemp[i]); 149 147 } 150 148 ··· 155 153 { 156 154 int i, value, temp_max = 0; 157 155 158 - for (i=0; i<nr_packages; i++) { 156 + for (i = 0; i < nr_packages; i++) { 159 157 value = loongson3_cpu_temp(i); 160 158 if (value > temp_max) 161 159 temp_max = value; ··· 174 172 pr_info("Loongson Hwmon Enter...\n"); 175 173 176 174 if (cpu_has_csr()) 177 - csr_temp_enable = csr_readl(LOONGSON_CSR_FEATURES) & LOONGSON_CSRF_TEMP; 175 + csr_temp_enable = csr_readl(LOONGSON_CSR_FEATURES) & 176 + LOONGSON_CSRF_TEMP; 178 177 179 178 cpu_hwmon_dev = hwmon_device_register(NULL); 180 179 if (IS_ERR(cpu_hwmon_dev)) {