diff options
| -rw-r--r-- | drivers/hwmon/w83791d.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c index de21142d106c..6b1cec9950ff 100644 --- a/drivers/hwmon/w83791d.c +++ b/drivers/hwmon/w83791d.c | |||
| @@ -160,6 +160,7 @@ static const u8 W83791D_REG_BEEP_CTRL[3] = { | |||
| 160 | 0xA3, /* BEEP Control Register 3 */ | 160 | 0xA3, /* BEEP Control Register 3 */ |
| 161 | }; | 161 | }; |
| 162 | 162 | ||
| 163 | #define W83791D_REG_GPIO 0x15 | ||
| 163 | #define W83791D_REG_CONFIG 0x40 | 164 | #define W83791D_REG_CONFIG 0x40 |
| 164 | #define W83791D_REG_VID_FANDIV 0x47 | 165 | #define W83791D_REG_VID_FANDIV 0x47 |
| 165 | #define W83791D_REG_DID_VID4 0x49 | 166 | #define W83791D_REG_DID_VID4 0x49 |
| @@ -908,8 +909,6 @@ static struct attribute *w83791d_attributes[] = { | |||
| 908 | FAN_UNIT_ATTRS(0), | 909 | FAN_UNIT_ATTRS(0), |
| 909 | FAN_UNIT_ATTRS(1), | 910 | FAN_UNIT_ATTRS(1), |
| 910 | FAN_UNIT_ATTRS(2), | 911 | FAN_UNIT_ATTRS(2), |
| 911 | FAN_UNIT_ATTRS(3), | ||
| 912 | FAN_UNIT_ATTRS(4), | ||
| 913 | TEMP_UNIT_ATTRS(0), | 912 | TEMP_UNIT_ATTRS(0), |
| 914 | TEMP_UNIT_ATTRS(1), | 913 | TEMP_UNIT_ATTRS(1), |
| 915 | TEMP_UNIT_ATTRS(2), | 914 | TEMP_UNIT_ATTRS(2), |
| @@ -925,6 +924,18 @@ static const struct attribute_group w83791d_group = { | |||
| 925 | .attrs = w83791d_attributes, | 924 | .attrs = w83791d_attributes, |
| 926 | }; | 925 | }; |
| 927 | 926 | ||
| 927 | /* Separate group of attributes for fan/pwm 4-5. Their pins can also be | ||
| 928 | in use for GPIO in which case their sysfs-interface should not be made | ||
| 929 | available */ | ||
| 930 | static struct attribute *w83791d_attributes_fanpwm45[] = { | ||
| 931 | FAN_UNIT_ATTRS(3), | ||
| 932 | FAN_UNIT_ATTRS(4), | ||
| 933 | NULL | ||
| 934 | }; | ||
| 935 | |||
| 936 | static const struct attribute_group w83791d_group_fanpwm45 = { | ||
| 937 | .attrs = w83791d_attributes_fanpwm45, | ||
| 938 | }; | ||
| 928 | 939 | ||
| 929 | static int w83791d_detect_subclients(struct i2c_client *client) | 940 | static int w83791d_detect_subclients(struct i2c_client *client) |
| 930 | { | 941 | { |
| @@ -1056,6 +1067,7 @@ static int w83791d_probe(struct i2c_client *client, | |||
| 1056 | struct w83791d_data *data; | 1067 | struct w83791d_data *data; |
| 1057 | struct device *dev = &client->dev; | 1068 | struct device *dev = &client->dev; |
| 1058 | int i, err; | 1069 | int i, err; |
| 1070 | u8 has_fanpwm45; | ||
| 1059 | 1071 | ||
| 1060 | #ifdef DEBUG | 1072 | #ifdef DEBUG |
| 1061 | int val1; | 1073 | int val1; |
| @@ -1090,15 +1102,27 @@ static int w83791d_probe(struct i2c_client *client, | |||
| 1090 | if ((err = sysfs_create_group(&client->dev.kobj, &w83791d_group))) | 1102 | if ((err = sysfs_create_group(&client->dev.kobj, &w83791d_group))) |
| 1091 | goto error3; | 1103 | goto error3; |
| 1092 | 1104 | ||
| 1105 | /* Check if pins of fan/pwm 4-5 are in use as GPIO */ | ||
| 1106 | has_fanpwm45 = w83791d_read(client, W83791D_REG_GPIO) & 0x10; | ||
| 1107 | if (has_fanpwm45) { | ||
| 1108 | err = sysfs_create_group(&client->dev.kobj, | ||
| 1109 | &w83791d_group_fanpwm45); | ||
| 1110 | if (err) | ||
| 1111 | goto error4; | ||
| 1112 | } | ||
| 1113 | |||
| 1093 | /* Everything is ready, now register the working device */ | 1114 | /* Everything is ready, now register the working device */ |
| 1094 | data->hwmon_dev = hwmon_device_register(dev); | 1115 | data->hwmon_dev = hwmon_device_register(dev); |
| 1095 | if (IS_ERR(data->hwmon_dev)) { | 1116 | if (IS_ERR(data->hwmon_dev)) { |
| 1096 | err = PTR_ERR(data->hwmon_dev); | 1117 | err = PTR_ERR(data->hwmon_dev); |
| 1097 | goto error4; | 1118 | goto error5; |
| 1098 | } | 1119 | } |
| 1099 | 1120 | ||
| 1100 | return 0; | 1121 | return 0; |
| 1101 | 1122 | ||
| 1123 | error5: | ||
| 1124 | if (has_fanpwm45) | ||
| 1125 | sysfs_remove_group(&client->dev.kobj, &w83791d_group_fanpwm45); | ||
| 1102 | error4: | 1126 | error4: |
| 1103 | sysfs_remove_group(&client->dev.kobj, &w83791d_group); | 1127 | sysfs_remove_group(&client->dev.kobj, &w83791d_group); |
| 1104 | error3: | 1128 | error3: |
