Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 267267
b: refs/heads/master
c: 9af0794
h: refs/heads/master
i:
  267265: dd0213c
  267263: ed20d5e
v: v3
  • Loading branch information
Hans de Goede authored and Guenter Roeck committed Oct 24, 2011
1 parent cf8a430 commit 5a85f1e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 45 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5584014256f704e1031d10d0bd291bc52fab5c40
refs/heads/master: 9af0794c63ab1fbced7aa6f9d918ee0f7e7c45e5
108 changes: 64 additions & 44 deletions trunk/drivers/hwmon/f71882fg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,54 @@ static void f71882fg_remove_sysfs_files(struct platform_device *pdev,
device_remove_file(&pdev->dev, &attr[i].dev_attr);
}

static int __devinit f71882fg_create_fan_sysfs_files(
struct platform_device *pdev, int idx, bool pwm_auto_point)
{
struct f71882fg_data *data = platform_get_drvdata(pdev);
int err;

err = f71882fg_create_sysfs_files(pdev, &fxxxx_fan_attr[idx][0],
ARRAY_SIZE(fxxxx_fan_attr[0]));
if (err)
return err;

if (f71882fg_fan_has_beep[data->type]) {
err = f71882fg_create_sysfs_files(pdev,
&fxxxx_fan_beep_attr[idx],
1);
if (err)
return err;
}

if (!pwm_auto_point)
return 0; /* All done */

switch (data->type) {
case f71862fg:
err = f71882fg_create_sysfs_files(pdev,
&f71862fg_auto_pwm_attr[idx][0],
ARRAY_SIZE(f71862fg_auto_pwm_attr[0]));
break;
case f71808e:
case f71869:
err = f71882fg_create_sysfs_files(pdev,
&f71869_auto_pwm_attr[idx][0],
ARRAY_SIZE(f71869_auto_pwm_attr[0]));
break;
case f8000:
err = f71882fg_create_sysfs_files(pdev,
&f8000_auto_pwm_attr[idx][0],
ARRAY_SIZE(f8000_auto_pwm_attr[0]));
break;
default:
err = f71882fg_create_sysfs_files(pdev,
&fxxxx_auto_pwm_attr[idx][0],
ARRAY_SIZE(fxxxx_auto_pwm_attr[0]));
}

return err;
}

static int __devinit f71882fg_probe(struct platform_device *pdev)
{
struct f71882fg_data *data;
Expand Down Expand Up @@ -2247,6 +2295,8 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
}

if (start_reg & 0x02) {
bool pwm_auto_point = true;

switch (data->type) {
case f71808e:
case f71808a:
Expand Down Expand Up @@ -2298,18 +2348,6 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
goto exit_unregister_sysfs;
}

err = f71882fg_create_sysfs_files(pdev, &fxxxx_fan_attr[0][0],
ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans);
if (err)
goto exit_unregister_sysfs;

if (f71882fg_fan_has_beep[data->type]) {
err = f71882fg_create_sysfs_files(pdev,
fxxxx_fan_beep_attr, nr_fans);
if (err)
goto exit_unregister_sysfs;
}

switch (data->type) {
case f71808e:
case f71808a:
Expand All @@ -2331,59 +2369,41 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
"Auto pwm controlled by raw digital "
"data, disabling pwm auto_point "
"sysfs attributes\n");
goto no_pwm_auto_point;
pwm_auto_point = false;
}
break;
default:
break;
}

switch (data->type) {
case f71808a:
err = f71882fg_create_sysfs_files(pdev,
&fxxxx_auto_pwm_attr[0][0],
ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans);
for (i = 0; i < nr_fans; i++) {
err = f71882fg_create_fan_sysfs_files(pdev, i,
pwm_auto_point);
if (err)
goto exit_unregister_sysfs;

dev_info(&pdev->dev, "Fan: %d is in %s mode\n", i + 1,
(data->pwm_enable & (1 << 2 * i)) ?
"duty-cycle" : "RPM");
}

/* Some types have 1 extra fan with limited functionality */
switch (data->type) {
case f71808a:
err = f71882fg_create_sysfs_files(pdev,
f71808a_fan3_attr,
ARRAY_SIZE(f71808a_fan3_attr));
break;
case f71862fg:
err = f71882fg_create_sysfs_files(pdev,
&f71862fg_auto_pwm_attr[0][0],
ARRAY_SIZE(f71862fg_auto_pwm_attr[0]) *
nr_fans);
break;
case f71808e:
case f71869:
err = f71882fg_create_sysfs_files(pdev,
&f71869_auto_pwm_attr[0][0],
ARRAY_SIZE(f71869_auto_pwm_attr[0]) * nr_fans);
break;
case f8000:
err = f71882fg_create_sysfs_files(pdev,
f8000_fan_attr,
ARRAY_SIZE(f8000_fan_attr));
if (err)
goto exit_unregister_sysfs;
err = f71882fg_create_sysfs_files(pdev,
&f8000_auto_pwm_attr[0][0],
ARRAY_SIZE(f8000_auto_pwm_attr[0]) * nr_fans);
break;
default:
err = f71882fg_create_sysfs_files(pdev,
&fxxxx_auto_pwm_attr[0][0],
ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans);
break;
}
if (err)
goto exit_unregister_sysfs;

no_pwm_auto_point:
for (i = 0; i < nr_fans; i++)
dev_info(&pdev->dev, "Fan: %d is in %s mode\n", i + 1,
(data->pwm_enable & (1 << 2 * i)) ?
"duty-cycle" : "RPM");
}

data->hwmon_dev = hwmon_device_register(&pdev->dev);
Expand Down

0 comments on commit 5a85f1e

Please sign in to comment.