diff options
author | Hans de Goede <hdegoede@redhat.com> | 2009-06-15 12:39:51 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-06-15 12:39:51 -0400 |
commit | 996cadb2bf3787adcf4e164e1b351966c9e787f6 (patch) | |
tree | ee8fb6f578d80bf85f6dfd05459a5bdd88c8a6e5 /drivers/hwmon/f71882fg.c | |
parent | 3fc7838a20cdd9aab0077f355b8c44135cd4b6bd (diff) |
hwmon: (f71882fg) Sanity check f8000 pwm settings
We depend up on the pwm_enable register (0x96) not containing any reserved
settings in various places. We were already checking to make sure there
were no reserved settings in the register for the f71862fg, this patch adds
the same checking for the f8000, while at it it also moves the code to
a more apropriate place so we don't need to check if the fan/pwm part
of the IC is enabled twice.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/f71882fg.c')
-rw-r--r-- | drivers/hwmon/f71882fg.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index eb324e604105..a65eac836174 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c | |||
@@ -1735,19 +1735,6 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1735 | goto exit_free; | 1735 | goto exit_free; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); | ||
1739 | /* If it is a 71862 and the fan / pwm part is enabled sanity check | ||
1740 | the pwm settings */ | ||
1741 | if (data->type == f71862fg && (start_reg & 0x02)) { | ||
1742 | if ((data->pwm_enable & 0x15) != 0x15) { | ||
1743 | dev_err(&pdev->dev, | ||
1744 | "Invalid (reserved) pwm settings: 0x%02x\n", | ||
1745 | (unsigned int)data->pwm_enable); | ||
1746 | err = -ENODEV; | ||
1747 | goto exit_free; | ||
1748 | } | ||
1749 | } | ||
1750 | |||
1751 | /* Register sysfs interface files */ | 1738 | /* Register sysfs interface files */ |
1752 | err = device_create_file(&pdev->dev, &dev_attr_name); | 1739 | err = device_create_file(&pdev->dev, &dev_attr_name); |
1753 | if (err) | 1740 | if (err) |
@@ -1778,6 +1765,29 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1778 | } | 1765 | } |
1779 | 1766 | ||
1780 | if (start_reg & 0x02) { | 1767 | if (start_reg & 0x02) { |
1768 | data->pwm_enable = | ||
1769 | f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); | ||
1770 | |||
1771 | /* Sanity check the pwm settings */ | ||
1772 | switch (data->type) { | ||
1773 | case f71862fg: | ||
1774 | err = (data->pwm_enable & 0x15) != 0x15; | ||
1775 | break; | ||
1776 | case f71882fg: | ||
1777 | err = 0; | ||
1778 | break; | ||
1779 | case f8000: | ||
1780 | err = data->pwm_enable & 0x20; | ||
1781 | break; | ||
1782 | } | ||
1783 | if (err) { | ||
1784 | dev_err(&pdev->dev, | ||
1785 | "Invalid (reserved) pwm settings: 0x%02x\n", | ||
1786 | (unsigned int)data->pwm_enable); | ||
1787 | err = -ENODEV; | ||
1788 | goto exit_unregister_sysfs; | ||
1789 | } | ||
1790 | |||
1781 | err = f71882fg_create_sysfs_files(pdev, fxxxx_fan_attr, | 1791 | err = f71882fg_create_sysfs_files(pdev, fxxxx_fan_attr, |
1782 | ARRAY_SIZE(fxxxx_fan_attr)); | 1792 | ARRAY_SIZE(fxxxx_fan_attr)); |
1783 | if (err) | 1793 | if (err) |