[patch] pc87360 de-macro and code shrink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



attached is a patch which:

1. adds an __ATTR_N macro to device.h,
which takes an extra _index arg, and initializes device_attibute's new 
.index member/

2. replaces lots of nested-macro-uses of these:

static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
    show_temp##offset##_input, NULL); \

with array initializers. like these:

static struct device_attribute dev_attr_temp_input[] =
  {
    __ATTR_N(temp1_input, S_IRUGO, show_temp_input, NULL, 0),
    __ATTR_N(temp2_input, S_IRUGO, show_temp_input, NULL, 1),
    __ATTR_N(temp3_input, S_IRUGO, show_temp_input, NULL, 2),
    __ATTR_N(temp4_input, S_IRUGO, show_temp_input, NULL, 3),
    __ATTR_N(temp5_input, S_IRUGO, show_temp_input, NULL, 4),
    __ATTR_N(temp6_input, S_IRUGO, show_temp_input, NULL, 5),
  };

3.  de-macros the functions called by the individual items.
the functions use devattr->index to determine which item theyre working on.


this is an interim version, and has ifdefs to support back and forth 
debugging:

grep define pc87360.c |grep ATTR_LOOP
#define FAN_ATTR_LOOP 0
#define PWM_ATTR_LOOP 0
#define VOLT_ATTR_LOOP 1
#define TEMP_ATTR_LOOP 0

using loops results in a large savings in obj code.

baseline:           -rw-rw-r--  1 jimc jimc 168326 Jul 27 23:10 
drivers/hwmon/pc87360.ko
VOLT_ATTR_LOOP      -rw-rw-r--  1 jimc jimc 135940 Jul 27 23:11 
drivers/hwmon/pc87360.ko
+ TEMP_ATTR_LOOP    -rw-rw-r--  1 jimc jimc 127441 Jul 27 23:16 
drivers/hwmon/pc87360.ko
+ FAN/PWM_ATTR_LOOP -rw-rw-r--  1 jimc jimc 121062 Jul 27 23:55 
drivers/hwmon/pc87360.ko


I have a couple of questions that Im hoping you can clarify for me;
its late, and I could sleep now, and see your responses when I wake.

line 887 starts the show_and_set_temp(offset)  macro,
which looks to be a duplicate of
#define show_and_set_therm(offset) on line 651,

or if theyre not duplicates (I havent looked carefully), its an 
unfortunate naming,
creating functions which are disambiguated only by the offset.

OTOH, they could be different cuz the physical units on the chip have 
different capabilities.
ATM code has some unused data, but probly not another 10k

Using loops to call device_create_file also simplifies some of the logic 
wrt data->innr, tempnr, fannr;
the if-variations are hidden/abstracted by 0..configd_max.   Of course, 
I could have oversimplified.


Ive done cursory testing: new code does this.

root at soekris:~# sensors
pc87366-isa-6620
Adapter: ISA adapter
avi0:      +3.01 V  (min =  +0.00 V, max =  +3.01 V)
VCORE:     +2.02 V  (min =  +0.00 V, max =  +3.01 V)
VCC:       +5.01 V  (min =  +0.00 V, max =  +6.03 V)
VPWR:     +14.01 V  (min =  +0.00 V, max = +60.56 V)
+12V:     +11.91 V  (min =  +0.00 V, max = +14.46 V)
-12V:     -12.28 V  (min = -60.61 V, max =  -2.76 V)
GND:       +0.00 V  (min =  +0.00 V, max =  +3.01 V)
Vsb:       +3.33 V  (min =  +0.00 V, max =  +6.03 V)
Vdd:       +2.91 V  (min =  +0.00 V, max =  +6.03 V)
Vbat:      +3.01 V  (min =  +0.00 V, max =  +3.01 V)
AVdd:      +3.31 V  (min =  +0.00 V, max =  +6.03 V)
Temp:       +107 C  (low  =   -55 C, high =  +127 C)
Critical:   +127 C

root at soekris:~#
root at soekris:~# cd /sys/bus/i2c/devices/0-6620/
alarms_temp   in2_max       in6_max       temp1_crit    temp4_input
bus           in2_min       in6_min       temp1_input   temp4_max
driver        in2_status    in6_status    temp1_max     temp4_min
in0_input     in3_input     in7_input     temp1_min     temp4_status
in0_max       in3_max       in7_max       temp1_status  temp5_crit
in0_min       in3_min       in7_min       temp2_crit    temp5_input
in0_status    in3_status    in7_status    temp2_input   temp5_max
in10_input    in4_input     in8_input     temp2_max     temp5_min
in10_max      in4_max       in8_max       temp2_min     temp5_status
in10_min      in4_min       in8_min       temp2_status  temp6_crit
in10_status   in4_status    in8_status    temp3_crit    temp6_input
in1_input     in5_input     in9_input     temp3_input   temp6_max
in1_max       in5_max       in9_max       temp3_max     temp6_min
in1_min       in5_min       in9_min       temp3_min     temp6_status
in1_status    in5_status    in9_status    temp3_status
in2_input     in6_input     name          temp4_crit

I have no fans on this board, and have never gotten temp readings I trust.
But the voltages look right :-)

thanks
jimc


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diff.linux.20050728.001755
Url: http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20050728/c827e00f/attachment.pl 


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux