@@ -48,7 +48,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
48
48
static ssize_t get_enable (struct device * dev , struct device_attribute * da , char * buf );
49
49
static ssize_t set_enable (struct device * dev , struct device_attribute * da ,
50
50
const char * buf , size_t count );
51
- static ssize_t get_sys_temp (struct device * dev , struct device_attribute * da , char * buf );
52
51
extern int accton_i2c_cpld_read (unsigned short cpld_addr , u8 reg );
53
52
extern int accton_i2c_cpld_write (unsigned short cpld_addr , u8 reg , u8 value );
54
53
@@ -150,12 +149,6 @@ enum sysfs_fan_attributes {
150
149
&sensor_dev_attr_pwm##index.dev_attr.attr, \
151
150
&sensor_dev_attr_pwm##index##_enable.dev_attr.attr
152
151
153
- #define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR () \
154
- static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE)
155
-
156
- #define DECLARE_FAN_SYSTEM_TEMP_ATTR () &sensor_dev_attr_sys_temp.dev_attr.attr
157
-
158
-
159
152
#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR (index ) \
160
153
static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT)
161
154
#define DECLARE_FAN_PRESENT_ATTR (index ) &sensor_dev_attr_fan##index##_present.dev_attr.attr
@@ -200,8 +193,6 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5);
200
193
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR (6 );
201
194
/* 1 fan duty cycle attribute in this platform */
202
195
DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR (1 );
203
- /* System temperature for fancontrol */
204
- DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR ();
205
196
206
197
static struct attribute * as7326_56x_fan_attributes [] = {
207
198
/* fan related attributes */
@@ -230,7 +221,6 @@ static struct attribute *as7326_56x_fan_attributes[] = {
230
221
DECLARE_FAN_DIRECTION_ATTR (5 ),
231
222
DECLARE_FAN_DIRECTION_ATTR (6 ),
232
223
DECLARE_FAN_DUTY_CYCLE_ATTR (1 ),
233
- DECLARE_FAN_SYSTEM_TEMP_ATTR (),
234
224
NULL
235
225
};
236
226
@@ -451,55 +441,55 @@ static int get_temp_file_path(
451
441
}
452
442
453
443
/*File read the dev file at user space.*/
454
- static int read_devfile_temp1_input (
455
- struct device * dev ,
456
- int bus_nr ,
457
- unsigned short addr ,
458
- struct device * hwmon_dev ,
459
- int * miniCelsius )
460
- {
461
- struct file * sfd ;
462
- char buffer [96 ];
463
- char devfile [96 ];
464
- int rc , status ;
465
- int rdlen , value ;
466
- mm_segment_t old_fs ;
467
-
468
- rc = 0 ;
469
- get_temp_file_path (bus_nr , addr , hwmon_dev , devfile , sizeof (devfile ));
470
- sfd = filp_open (devfile , O_RDONLY , 0 );
471
- if (IS_ERR (sfd )) {
472
- pr_err ("Failed to open file(%s)#%d\r\n" , devfile , __LINE__ );
473
- return - ENOENT ;
474
- }
475
- dev_dbg (dev , "Found device:%s\n" ,devfile );
476
-
477
- if (!(sfd -> f_op ) || !(sfd -> f_op -> read ) ) {
478
- pr_err ("file %s cann't readable ?\n" ,devfile );
479
- return - ENOENT ;
480
- }
481
-
482
- old_fs = get_fs ();
483
- set_fs (KERNEL_DS );
484
- rdlen = sfd -> f_op -> read (sfd , buffer , sizeof (buffer ), & sfd -> f_pos );
485
- if (rdlen == 0 ) {
486
- pr_err ( "File(%s) empty!\n" , devfile );
487
- rc = - EIO ;
488
- goto exit ;
489
- }
490
- status = sscanf (buffer , "%d" , & value );
491
- if (status != 1 ) {
492
- rc = - EIO ;
493
- goto exit ;
494
- }
495
- * miniCelsius = value ;
496
- dev_dbg (dev ,"found sensors: %d @i2c %d-%04x\n" , value , bus_nr , addr );
497
-
498
- exit :
499
- set_fs (old_fs );
500
- filp_close (sfd , 0 );
501
- return rc ;
502
- }
444
+ // static int read_devfile_temp1_input(
445
+ // struct device *dev,
446
+ // int bus_nr,
447
+ // unsigned short addr,
448
+ // struct device *hwmon_dev,
449
+ // int *miniCelsius)
450
+ // {
451
+ // struct file *sfd;
452
+ // char buffer[96];
453
+ // char devfile[96];
454
+ // int rc, status;
455
+ // int rdlen, value;
456
+ // mm_segment_t old_fs;
457
+
458
+ // rc = 0;
459
+ // get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile));
460
+ // sfd = filp_open(devfile, O_RDONLY, 0);
461
+ // if (IS_ERR(sfd)) {
462
+ // pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__);
463
+ // return -ENOENT;
464
+ // }
465
+ // dev_dbg(dev, "Found device:%s\n",devfile);
466
+
467
+ // if(!(sfd->f_op) || !(sfd->f_op->read) ) {
468
+ // pr_err("file %s cann't readable ?\n",devfile);
469
+ // return -ENOENT;
470
+ // }
471
+
472
+ // old_fs = get_fs();
473
+ // set_fs(KERNEL_DS);
474
+ // rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos);
475
+ // if (rdlen == 0) {
476
+ // pr_err( "File(%s) empty!\n", devfile);
477
+ // rc = -EIO;
478
+ // goto exit;
479
+ // }
480
+ // status = sscanf(buffer, "%d", &value);
481
+ // if (status != 1) {
482
+ // rc = -EIO;
483
+ // goto exit;
484
+ // }
485
+ // *miniCelsius = value;
486
+ // dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr);
487
+
488
+ // exit:
489
+ // set_fs(old_fs);
490
+ // filp_close(sfd, 0);
491
+ // return rc;
492
+ // }
503
493
504
494
static u8 is_lm75_data_due (struct i2c_client * client )
505
495
{
@@ -535,79 +525,79 @@ static bool lm75_addr_mached(unsigned short addr)
535
525
return 0 ;
536
526
}
537
527
538
- static int _find_lm75_device (struct device * dev , void * data )
539
- {
540
- struct device_driver * driver ;
541
- struct as7326_56x_fan_data * prv = data ;
542
- char * driver_name = THERMAL_SENSORS_DRIVER ;
543
-
544
- driver = dev -> driver ;
545
- if (driver && driver -> name &&
546
- strcmp (driver -> name , driver_name ) == 0 )
547
- {
548
- struct i2c_client * client ;
549
- client = to_i2c_client (dev );
550
- if (client )
551
- {
552
- /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/
553
- struct i2c_adapter * adap = client -> adapter ;
554
- int miniCelsius = 0 ;
555
-
556
- if (! lm75_addr_mached (client -> addr ))
557
- {
558
- return 0 ;
559
- }
560
-
561
- if (!adap ) {
562
- return - ENXIO ;
563
- }
564
-
565
- /* If the data is not updated, read them from devfile
566
- to drive them updateing data from chip.*/
567
- if (is_lm75_data_due (client ))
568
- {
569
- struct device * hwmon_dev ;
570
-
571
- hwmon_dev = get_hwmon_dev (client );
572
- if (0 == read_devfile_temp1_input (dev , adap -> nr ,
573
- client -> addr , hwmon_dev , & miniCelsius ))
574
- {
575
- prv -> system_temp += miniCelsius ;
576
- prv -> sensors_found ++ ;
577
- }
578
-
579
- }
580
- else
581
- {
582
- get_lm75_temp (client , & miniCelsius );
583
- prv -> system_temp += miniCelsius ;
584
- prv -> sensors_found ++ ;
585
-
586
- }
587
- }
588
- }
589
- return 0 ;
590
- }
528
+ // static int _find_lm75_device(struct device *dev, void *data)
529
+ // {
530
+ // struct device_driver *driver;
531
+ // struct as7326_56x_fan_data *prv = data;
532
+ // char *driver_name = THERMAL_SENSORS_DRIVER;
533
+
534
+ // driver = dev->driver;
535
+ // if (driver && driver->name &&
536
+ // strcmp(driver->name, driver_name) == 0)
537
+ // {
538
+ // struct i2c_client *client;
539
+ // client = to_i2c_client(dev);
540
+ // if (client)
541
+ // {
542
+ // /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/
543
+ // struct i2c_adapter *adap = client->adapter;
544
+ // int miniCelsius = 0;
545
+
546
+ // if (! lm75_addr_mached(client->addr))
547
+ // {
548
+ // return 0;
549
+ // }
550
+
551
+ // if (!adap) {
552
+ // return -ENXIO;
553
+ // }
554
+
555
+ // /* If the data is not updated, read them from devfile
556
+ // to drive them updateing data from chip.*/
557
+ // if (is_lm75_data_due(client))
558
+ // {
559
+ // struct device *hwmon_dev;
560
+
561
+ // hwmon_dev = get_hwmon_dev(client);
562
+ // if(0 == read_devfile_temp1_input(dev, adap->nr,
563
+ // client->addr, hwmon_dev, &miniCelsius))
564
+ // {
565
+ // prv->system_temp += miniCelsius;
566
+ // prv->sensors_found++;
567
+ // }
568
+
569
+ // }
570
+ // else
571
+ // {
572
+ // get_lm75_temp(client, &miniCelsius);
573
+ // prv->system_temp += miniCelsius;
574
+ // prv->sensors_found++;
575
+
576
+ // }
577
+ // }
578
+ // }
579
+ // return 0;
580
+ // }
591
581
592
582
/*Find all lm75 devices and return sum of temperatures.*/
593
- static ssize_t get_sys_temp (struct device * dev , struct device_attribute * da ,
594
- char * buf )
595
- {
596
- ssize_t ret = 0 ;
597
- struct as7326_56x_fan_data * data = as7326_56x_fan_update_device (dev );
598
-
599
- data -> system_temp = 0 ;
600
- data -> sensors_found = 0 ;
601
- i2c_for_each_dev (data , _find_lm75_device );
602
- if (NUM_THERMAL_SENSORS != data -> sensors_found )
603
- {
604
- dev_dbg (dev ,"only %d of %d temps are found\n" ,
605
- data -> sensors_found , NUM_THERMAL_SENSORS );
606
- data -> system_temp = INT_MAX ;
607
- }
608
- ret = sprintf (buf , "%d\n" ,data -> system_temp );
609
- return ret ;
610
- }
583
+ // static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da,
584
+ // char *buf)
585
+ // {
586
+ // ssize_t ret = 0;
587
+ // struct as7326_56x_fan_data *data = as7326_56x_fan_update_device(dev);
588
+
589
+ // data->system_temp=0;
590
+ // data->sensors_found=0;
591
+ // i2c_for_each_dev(data, _find_lm75_device);
592
+ // if (NUM_THERMAL_SENSORS != data->sensors_found)
593
+ // {
594
+ // dev_dbg(dev,"only %d of %d temps are found\n",
595
+ // data->sensors_found, NUM_THERMAL_SENSORS);
596
+ // data->system_temp = INT_MAX;
597
+ // }
598
+ // ret = sprintf(buf, "%d\n",data->system_temp);
599
+ // return ret;
600
+ // }
611
601
612
602
static ssize_t fan_show_value (struct device * dev , struct device_attribute * da ,
613
603
char * buf )
0 commit comments