diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-10-28 14:31:48 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2010-10-28 14:31:48 -0400 |
commit | 1bb3450ce5050bc677c1995a60a0ddfe9e33e7b6 (patch) | |
tree | bb4a0fcaaf4647cb791d1bcc00cde8fc9a52ba3d /drivers/hwmon | |
parent | 2ae61de90545fe3dadae8119181c430d89a8627b (diff) |
hwmon: (w83795) Delay reading pwm config registers
Wait until we need the pwm config register values, instead of
pre-reading them. This saves over 1 second on modprobe on my test
system.
Obviously this time is added when first accessing pwm config
attributes, however not everybody will use them, so it seems unfair
to slow down driver loading (and thus boot) for an optional feature.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/w83795.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c index 6464a52b134b..78a876f35fa3 100644 --- a/drivers/hwmon/w83795.c +++ b/drivers/hwmon/w83795.c | |||
@@ -372,6 +372,7 @@ struct w83795_data { | |||
372 | 372 | ||
373 | char valid; | 373 | char valid; |
374 | char valid_limits; | 374 | char valid_limits; |
375 | char valid_pwm_config; | ||
375 | }; | 376 | }; |
376 | 377 | ||
377 | /* | 378 | /* |
@@ -503,11 +504,17 @@ static void w83795_update_limits(struct i2c_client *client) | |||
503 | data->valid_limits = 1; | 504 | data->valid_limits = 1; |
504 | } | 505 | } |
505 | 506 | ||
506 | static void w83795_update_pwm_config(struct i2c_client *client) | 507 | static struct w83795_data *w83795_update_pwm_config(struct device *dev) |
507 | { | 508 | { |
509 | struct i2c_client *client = to_i2c_client(dev); | ||
508 | struct w83795_data *data = i2c_get_clientdata(client); | 510 | struct w83795_data *data = i2c_get_clientdata(client); |
509 | int i, tmp; | 511 | int i, tmp; |
510 | 512 | ||
513 | mutex_lock(&data->update_lock); | ||
514 | |||
515 | if (data->valid_pwm_config) | ||
516 | goto END; | ||
517 | |||
511 | /* Read temperature source selection */ | 518 | /* Read temperature source selection */ |
512 | for (i = 0; i < ARRAY_SIZE(data->temp_src); i++) | 519 | for (i = 0; i < ARRAY_SIZE(data->temp_src); i++) |
513 | data->temp_src[i] = w83795_read(client, W83795_REG_TSS(i)); | 520 | data->temp_src[i] = w83795_read(client, W83795_REG_TSS(i)); |
@@ -556,6 +563,12 @@ static void w83795_update_pwm_config(struct i2c_client *client) | |||
556 | for (i = 0; i < ARRAY_SIZE(data->setup_pwm); i++) | 563 | for (i = 0; i < ARRAY_SIZE(data->setup_pwm); i++) |
557 | data->setup_pwm[i] = | 564 | data->setup_pwm[i] = |
558 | w83795_read(client, W83795_REG_SETUP_PWM(i)); | 565 | w83795_read(client, W83795_REG_SETUP_PWM(i)); |
566 | |||
567 | data->valid_pwm_config = 1; | ||
568 | |||
569 | END: | ||
570 | mutex_unlock(&data->update_lock); | ||
571 | return data; | ||
559 | } | 572 | } |
560 | 573 | ||
561 | static struct w83795_data *w83795_update_device(struct device *dev) | 574 | static struct w83795_data *w83795_update_device(struct device *dev) |
@@ -775,13 +788,16 @@ store_fan_min(struct device *dev, struct device_attribute *attr, | |||
775 | static ssize_t | 788 | static ssize_t |
776 | show_pwm(struct device *dev, struct device_attribute *attr, char *buf) | 789 | show_pwm(struct device *dev, struct device_attribute *attr, char *buf) |
777 | { | 790 | { |
778 | struct w83795_data *data = w83795_update_device(dev); | 791 | struct w83795_data *data; |
779 | struct sensor_device_attribute_2 *sensor_attr = | 792 | struct sensor_device_attribute_2 *sensor_attr = |
780 | to_sensor_dev_attr_2(attr); | 793 | to_sensor_dev_attr_2(attr); |
781 | int nr = sensor_attr->nr; | 794 | int nr = sensor_attr->nr; |
782 | int index = sensor_attr->index; | 795 | int index = sensor_attr->index; |
783 | unsigned int val; | 796 | unsigned int val; |
784 | 797 | ||
798 | data = nr == PWM_OUTPUT ? w83795_update_device(dev) | ||
799 | : w83795_update_pwm_config(dev); | ||
800 | |||
785 | switch (nr) { | 801 | switch (nr) { |
786 | case PWM_STOP_TIME: | 802 | case PWM_STOP_TIME: |
787 | val = time_from_reg(data->pwm[index][nr]); | 803 | val = time_from_reg(data->pwm[index][nr]); |
@@ -835,8 +851,7 @@ show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf) | |||
835 | { | 851 | { |
836 | struct sensor_device_attribute_2 *sensor_attr = | 852 | struct sensor_device_attribute_2 *sensor_attr = |
837 | to_sensor_dev_attr_2(attr); | 853 | to_sensor_dev_attr_2(attr); |
838 | struct i2c_client *client = to_i2c_client(dev); | 854 | struct w83795_data *data = w83795_update_pwm_config(dev); |
839 | struct w83795_data *data = i2c_get_clientdata(client); | ||
840 | int index = sensor_attr->index; | 855 | int index = sensor_attr->index; |
841 | u8 tmp; | 856 | u8 tmp; |
842 | 857 | ||
@@ -864,7 +879,7 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
864 | const char *buf, size_t count) | 879 | const char *buf, size_t count) |
865 | { | 880 | { |
866 | struct i2c_client *client = to_i2c_client(dev); | 881 | struct i2c_client *client = to_i2c_client(dev); |
867 | struct w83795_data *data = i2c_get_clientdata(client); | 882 | struct w83795_data *data = w83795_update_pwm_config(dev); |
868 | struct sensor_device_attribute_2 *sensor_attr = | 883 | struct sensor_device_attribute_2 *sensor_attr = |
869 | to_sensor_dev_attr_2(attr); | 884 | to_sensor_dev_attr_2(attr); |
870 | int index = sensor_attr->index; | 885 | int index = sensor_attr->index; |
@@ -905,8 +920,7 @@ show_temp_src(struct device *dev, struct device_attribute *attr, char *buf) | |||
905 | { | 920 | { |
906 | struct sensor_device_attribute_2 *sensor_attr = | 921 | struct sensor_device_attribute_2 *sensor_attr = |
907 | to_sensor_dev_attr_2(attr); | 922 | to_sensor_dev_attr_2(attr); |
908 | struct i2c_client *client = to_i2c_client(dev); | 923 | struct w83795_data *data = w83795_update_pwm_config(dev); |
909 | struct w83795_data *data = i2c_get_clientdata(client); | ||
910 | int index = sensor_attr->index; | 924 | int index = sensor_attr->index; |
911 | u8 val = index / 2; | 925 | u8 val = index / 2; |
912 | u8 tmp = data->temp_src[val]; | 926 | u8 tmp = data->temp_src[val]; |
@@ -926,7 +940,7 @@ store_temp_src(struct device *dev, struct device_attribute *attr, | |||
926 | const char *buf, size_t count) | 940 | const char *buf, size_t count) |
927 | { | 941 | { |
928 | struct i2c_client *client = to_i2c_client(dev); | 942 | struct i2c_client *client = to_i2c_client(dev); |
929 | struct w83795_data *data = i2c_get_clientdata(client); | 943 | struct w83795_data *data = w83795_update_pwm_config(dev); |
930 | struct sensor_device_attribute_2 *sensor_attr = | 944 | struct sensor_device_attribute_2 *sensor_attr = |
931 | to_sensor_dev_attr_2(attr); | 945 | to_sensor_dev_attr_2(attr); |
932 | int index = sensor_attr->index; | 946 | int index = sensor_attr->index; |
@@ -957,8 +971,7 @@ static ssize_t | |||
957 | show_temp_pwm_enable(struct device *dev, struct device_attribute *attr, | 971 | show_temp_pwm_enable(struct device *dev, struct device_attribute *attr, |
958 | char *buf) | 972 | char *buf) |
959 | { | 973 | { |
960 | struct i2c_client *client = to_i2c_client(dev); | 974 | struct w83795_data *data = w83795_update_pwm_config(dev); |
961 | struct w83795_data *data = i2c_get_clientdata(client); | ||
962 | struct sensor_device_attribute_2 *sensor_attr = | 975 | struct sensor_device_attribute_2 *sensor_attr = |
963 | to_sensor_dev_attr_2(attr); | 976 | to_sensor_dev_attr_2(attr); |
964 | int nr = sensor_attr->nr; | 977 | int nr = sensor_attr->nr; |
@@ -986,7 +999,7 @@ store_temp_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
986 | const char *buf, size_t count) | 999 | const char *buf, size_t count) |
987 | { | 1000 | { |
988 | struct i2c_client *client = to_i2c_client(dev); | 1001 | struct i2c_client *client = to_i2c_client(dev); |
989 | struct w83795_data *data = i2c_get_clientdata(client); | 1002 | struct w83795_data *data = w83795_update_pwm_config(dev); |
990 | struct sensor_device_attribute_2 *sensor_attr = | 1003 | struct sensor_device_attribute_2 *sensor_attr = |
991 | to_sensor_dev_attr_2(attr); | 1004 | to_sensor_dev_attr_2(attr); |
992 | int nr = sensor_attr->nr; | 1005 | int nr = sensor_attr->nr; |
@@ -1023,8 +1036,7 @@ store_temp_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1023 | static ssize_t | 1036 | static ssize_t |
1024 | show_fanin(struct device *dev, struct device_attribute *attr, char *buf) | 1037 | show_fanin(struct device *dev, struct device_attribute *attr, char *buf) |
1025 | { | 1038 | { |
1026 | struct i2c_client *client = to_i2c_client(dev); | 1039 | struct w83795_data *data = w83795_update_pwm_config(dev); |
1027 | struct w83795_data *data = i2c_get_clientdata(client); | ||
1028 | struct sensor_device_attribute_2 *sensor_attr = | 1040 | struct sensor_device_attribute_2 *sensor_attr = |
1029 | to_sensor_dev_attr_2(attr); | 1041 | to_sensor_dev_attr_2(attr); |
1030 | int nr = sensor_attr->nr; | 1042 | int nr = sensor_attr->nr; |
@@ -1081,8 +1093,7 @@ store_fanin(struct device *dev, struct device_attribute *attr, | |||
1081 | static ssize_t | 1093 | static ssize_t |
1082 | show_temp_pwm(struct device *dev, struct device_attribute *attr, char *buf) | 1094 | show_temp_pwm(struct device *dev, struct device_attribute *attr, char *buf) |
1083 | { | 1095 | { |
1084 | struct i2c_client *client = to_i2c_client(dev); | 1096 | struct w83795_data *data = w83795_update_pwm_config(dev); |
1085 | struct w83795_data *data = i2c_get_clientdata(client); | ||
1086 | struct sensor_device_attribute_2 *sensor_attr = | 1097 | struct sensor_device_attribute_2 *sensor_attr = |
1087 | to_sensor_dev_attr_2(attr); | 1098 | to_sensor_dev_attr_2(attr); |
1088 | int nr = sensor_attr->nr; | 1099 | int nr = sensor_attr->nr; |
@@ -1143,8 +1154,7 @@ store_temp_pwm(struct device *dev, struct device_attribute *attr, | |||
1143 | static ssize_t | 1154 | static ssize_t |
1144 | show_sf4_pwm(struct device *dev, struct device_attribute *attr, char *buf) | 1155 | show_sf4_pwm(struct device *dev, struct device_attribute *attr, char *buf) |
1145 | { | 1156 | { |
1146 | struct i2c_client *client = to_i2c_client(dev); | 1157 | struct w83795_data *data = w83795_update_pwm_config(dev); |
1147 | struct w83795_data *data = i2c_get_clientdata(client); | ||
1148 | struct sensor_device_attribute_2 *sensor_attr = | 1158 | struct sensor_device_attribute_2 *sensor_attr = |
1149 | to_sensor_dev_attr_2(attr); | 1159 | to_sensor_dev_attr_2(attr); |
1150 | int nr = sensor_attr->nr; | 1160 | int nr = sensor_attr->nr; |
@@ -1179,8 +1189,7 @@ store_sf4_pwm(struct device *dev, struct device_attribute *attr, | |||
1179 | static ssize_t | 1189 | static ssize_t |
1180 | show_sf4_temp(struct device *dev, struct device_attribute *attr, char *buf) | 1190 | show_sf4_temp(struct device *dev, struct device_attribute *attr, char *buf) |
1181 | { | 1191 | { |
1182 | struct i2c_client *client = to_i2c_client(dev); | 1192 | struct w83795_data *data = w83795_update_pwm_config(dev); |
1183 | struct w83795_data *data = i2c_get_clientdata(client); | ||
1184 | struct sensor_device_attribute_2 *sensor_attr = | 1193 | struct sensor_device_attribute_2 *sensor_attr = |
1185 | to_sensor_dev_attr_2(attr); | 1194 | to_sensor_dev_attr_2(attr); |
1186 | int nr = sensor_attr->nr; | 1195 | int nr = sensor_attr->nr; |
@@ -1456,8 +1465,7 @@ show_sf_setup(struct device *dev, struct device_attribute *attr, char *buf) | |||
1456 | struct sensor_device_attribute_2 *sensor_attr = | 1465 | struct sensor_device_attribute_2 *sensor_attr = |
1457 | to_sensor_dev_attr_2(attr); | 1466 | to_sensor_dev_attr_2(attr); |
1458 | int nr = sensor_attr->nr; | 1467 | int nr = sensor_attr->nr; |
1459 | struct i2c_client *client = to_i2c_client(dev); | 1468 | struct w83795_data *data = w83795_update_pwm_config(dev); |
1460 | struct w83795_data *data = i2c_get_clientdata(client); | ||
1461 | u16 val = data->setup_pwm[nr]; | 1469 | u16 val = data->setup_pwm[nr]; |
1462 | 1470 | ||
1463 | switch (nr) { | 1471 | switch (nr) { |
@@ -2029,7 +2037,6 @@ static int w83795_probe(struct i2c_client *client, | |||
2029 | data->has_pwm = 8; | 2037 | data->has_pwm = 8; |
2030 | else | 2038 | else |
2031 | data->has_pwm = 2; | 2039 | data->has_pwm = 2; |
2032 | w83795_update_pwm_config(client); | ||
2033 | 2040 | ||
2034 | err = w83795_handle_files(dev, device_create_file); | 2041 | err = w83795_handle_files(dev, device_create_file); |
2035 | if (err) | 2042 | if (err) |