1111#include <loongson_hwmon.h>
1212#include <loongson_regs.h>
1313
14- static int csr_temp_enable = 0 ;
14+ static int csr_temp_enable ;
1515
1616/*
1717 * Loongson-3 series cpu has two sensors inside,
@@ -44,7 +44,7 @@ int loongson3_cpu_temp(int cpu)
4444 case PRID_REV_LOONGSON3A_R3_0 :
4545 case PRID_REV_LOONGSON3A_R3_1 :
4646 default :
47- reg = (reg & 0xffff )* 731 / 0x4000 - 273 ;
47+ reg = (reg & 0xffff ) * 731 / 0x4000 - 273 ;
4848 break ;
4949 }
5050
@@ -57,7 +57,7 @@ static struct device *cpu_hwmon_dev;
5757
5858static ssize_t get_hwmon_name (struct device * dev ,
5959 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 ) ;
6161
6262static struct attribute * cpu_hwmon_attributes [] = {
6363 & sensor_dev_attr_name .dev_attr .attr ,
@@ -81,14 +81,14 @@ static ssize_t get_cpu_temp(struct device *dev,
8181static ssize_t cpu_temp_label (struct device * dev ,
8282 struct device_attribute * attr , char * buf );
8383
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 ) ;
9292
9393static const struct attribute * hwmon_cputemp [4 ][3 ] = {
9494 {
@@ -117,6 +117,7 @@ static ssize_t cpu_temp_label(struct device *dev,
117117 struct device_attribute * attr , char * buf )
118118{
119119 int id = (to_sensor_dev_attr (attr ))-> index - 1 ;
120+
120121 return sprintf (buf , "CPU %d Temperature\n" , id );
121122}
122123
@@ -125,14 +126,15 @@ static ssize_t get_cpu_temp(struct device *dev,
125126{
126127 int id = (to_sensor_dev_attr (attr ))-> index - 1 ;
127128 int value = loongson3_cpu_temp (id );
129+
128130 return sprintf (buf , "%d\n" , value );
129131}
130132
131133static int create_sysfs_cputemp_files (struct kobject * kobj )
132134{
133135 int i , ret = 0 ;
134136
135- for (i = 0 ; i < nr_packages ; i ++ )
137+ for (i = 0 ; i < nr_packages ; i ++ )
136138 ret = sysfs_create_files (kobj , hwmon_cputemp [i ]);
137139
138140 return ret ;
@@ -142,7 +144,7 @@ static void remove_sysfs_cputemp_files(struct kobject *kobj)
142144{
143145 int i ;
144146
145- for (i = 0 ; i < nr_packages ; i ++ )
147+ for (i = 0 ; i < nr_packages ; i ++ )
146148 sysfs_remove_files (kobj , hwmon_cputemp [i ]);
147149}
148150
@@ -153,7 +155,7 @@ static void do_thermal_timer(struct work_struct *work)
153155{
154156 int i , value , temp_max = 0 ;
155157
156- for (i = 0 ; i < nr_packages ; i ++ ) {
158+ for (i = 0 ; i < nr_packages ; i ++ ) {
157159 value = loongson3_cpu_temp (i );
158160 if (value > temp_max )
159161 temp_max = value ;
@@ -172,7 +174,8 @@ static int __init loongson_hwmon_init(void)
172174 pr_info ("Loongson Hwmon Enter...\n" );
173175
174176 if (cpu_has_csr ())
175- csr_temp_enable = csr_readl (LOONGSON_CSR_FEATURES ) & LOONGSON_CSRF_TEMP ;
177+ csr_temp_enable = csr_readl (LOONGSON_CSR_FEATURES ) &
178+ LOONGSON_CSRF_TEMP ;
176179
177180 cpu_hwmon_dev = hwmon_device_register (NULL );
178181 if (IS_ERR (cpu_hwmon_dev )) {
0 commit comments