diff options
author | Juerg Haefliger <juergh@gmail.com> | 2007-10-02 00:20:28 -0400 |
---|---|---|
committer | Mark M. Hoffman <mhoffman@lightlink.com> | 2007-10-10 22:24:08 -0400 |
commit | 67e2f3285ecff8ceaa555e7614d1603b76e09b95 (patch) | |
tree | 1c8dd3a212e9a45aa367247293ca986fba797316 /drivers | |
parent | b237eb25d8e81c31ba561990445cfe4448c9de14 (diff) |
hwmon: (dme1737) group functions logically
Move functions to group them logically. Device and I2C functions go in separate
places. No functional changes (really!).
Signed-off-by: Juerg Haefliger <juergh at gmail.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/dme1737.c | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c index cef662c6af9d..63cee3b6f9bf 100644 --- a/drivers/hwmon/dme1737.c +++ b/drivers/hwmon/dme1737.c | |||
@@ -1697,58 +1697,11 @@ static inline void dme1737_sio_outb(int sio_cip, int reg, int val) | |||
1697 | outb(val, sio_cip + 1); | 1697 | outb(val, sio_cip + 1); |
1698 | } | 1698 | } |
1699 | 1699 | ||
1700 | static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data) | ||
1701 | { | ||
1702 | int err = 0, reg; | ||
1703 | u16 addr; | ||
1704 | |||
1705 | dme1737_sio_enter(sio_cip); | ||
1706 | |||
1707 | /* Check device ID | ||
1708 | * The DME1737 can return either 0x78 or 0x77 as its device ID. */ | ||
1709 | reg = dme1737_sio_inb(sio_cip, 0x20); | ||
1710 | if (!(reg == 0x77 || reg == 0x78)) { | ||
1711 | err = -ENODEV; | ||
1712 | goto exit; | ||
1713 | } | ||
1714 | |||
1715 | /* Select logical device A (runtime registers) */ | ||
1716 | dme1737_sio_outb(sio_cip, 0x07, 0x0a); | ||
1717 | |||
1718 | /* Get the base address of the runtime registers */ | ||
1719 | if (!(addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) | | ||
1720 | dme1737_sio_inb(sio_cip, 0x61))) { | ||
1721 | err = -ENODEV; | ||
1722 | goto exit; | ||
1723 | } | ||
1724 | |||
1725 | /* Read the runtime registers to determine which optional features | ||
1726 | * are enabled and available. Bits [3:2] of registers 0x43-0x46 are set | ||
1727 | * to '10' if the respective feature is enabled. */ | ||
1728 | if ((inb(addr + 0x43) & 0x0c) == 0x08) { /* fan6 */ | ||
1729 | data->has_fan |= (1 << 5); | ||
1730 | } | ||
1731 | if ((inb(addr + 0x44) & 0x0c) == 0x08) { /* pwm6 */ | ||
1732 | data->has_pwm |= (1 << 5); | ||
1733 | } | ||
1734 | if ((inb(addr + 0x45) & 0x0c) == 0x08) { /* fan5 */ | ||
1735 | data->has_fan |= (1 << 4); | ||
1736 | } | ||
1737 | if ((inb(addr + 0x46) & 0x0c) == 0x08) { /* pwm5 */ | ||
1738 | data->has_pwm |= (1 << 4); | ||
1739 | } | ||
1740 | |||
1741 | exit: | ||
1742 | dme1737_sio_exit(sio_cip); | ||
1743 | |||
1744 | return err; | ||
1745 | } | ||
1746 | |||
1747 | /* --------------------------------------------------------------------- | 1700 | /* --------------------------------------------------------------------- |
1748 | * Device detection, registration and initialization | 1701 | * Device detection, registration and initialization |
1749 | * --------------------------------------------------------------------- */ | 1702 | * --------------------------------------------------------------------- */ |
1750 | 1703 | ||
1751 | static struct i2c_driver dme1737_i2c_driver; | 1704 | static int dme1737_i2c_get_features(int, struct dme1737_data*); |
1752 | 1705 | ||
1753 | static void dme1737_chmod_file(struct device *dev, | 1706 | static void dme1737_chmod_file(struct device *dev, |
1754 | struct attribute *attr, mode_t mode) | 1707 | struct attribute *attr, mode_t mode) |
@@ -1967,6 +1920,59 @@ static int dme1737_init_device(struct device *dev) | |||
1967 | return 0; | 1920 | return 0; |
1968 | } | 1921 | } |
1969 | 1922 | ||
1923 | /* --------------------------------------------------------------------- | ||
1924 | * I2C device detection and registration | ||
1925 | * --------------------------------------------------------------------- */ | ||
1926 | |||
1927 | static struct i2c_driver dme1737_i2c_driver; | ||
1928 | |||
1929 | static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data) | ||
1930 | { | ||
1931 | int err = 0, reg; | ||
1932 | u16 addr; | ||
1933 | |||
1934 | dme1737_sio_enter(sio_cip); | ||
1935 | |||
1936 | /* Check device ID | ||
1937 | * The DME1737 can return either 0x78 or 0x77 as its device ID. */ | ||
1938 | reg = dme1737_sio_inb(sio_cip, 0x20); | ||
1939 | if (!(reg == 0x77 || reg == 0x78)) { | ||
1940 | err = -ENODEV; | ||
1941 | goto exit; | ||
1942 | } | ||
1943 | |||
1944 | /* Select logical device A (runtime registers) */ | ||
1945 | dme1737_sio_outb(sio_cip, 0x07, 0x0a); | ||
1946 | |||
1947 | /* Get the base address of the runtime registers */ | ||
1948 | if (!(addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) | | ||
1949 | dme1737_sio_inb(sio_cip, 0x61))) { | ||
1950 | err = -ENODEV; | ||
1951 | goto exit; | ||
1952 | } | ||
1953 | |||
1954 | /* Read the runtime registers to determine which optional features | ||
1955 | * are enabled and available. Bits [3:2] of registers 0x43-0x46 are set | ||
1956 | * to '10' if the respective feature is enabled. */ | ||
1957 | if ((inb(addr + 0x43) & 0x0c) == 0x08) { /* fan6 */ | ||
1958 | data->has_fan |= (1 << 5); | ||
1959 | } | ||
1960 | if ((inb(addr + 0x44) & 0x0c) == 0x08) { /* pwm6 */ | ||
1961 | data->has_pwm |= (1 << 5); | ||
1962 | } | ||
1963 | if ((inb(addr + 0x45) & 0x0c) == 0x08) { /* fan5 */ | ||
1964 | data->has_fan |= (1 << 4); | ||
1965 | } | ||
1966 | if ((inb(addr + 0x46) & 0x0c) == 0x08) { /* pwm5 */ | ||
1967 | data->has_pwm |= (1 << 4); | ||
1968 | } | ||
1969 | |||
1970 | exit: | ||
1971 | dme1737_sio_exit(sio_cip); | ||
1972 | |||
1973 | return err; | ||
1974 | } | ||
1975 | |||
1970 | static int dme1737_i2c_detect(struct i2c_adapter *adapter, int address, | 1976 | static int dme1737_i2c_detect(struct i2c_adapter *adapter, int address, |
1971 | int kind) | 1977 | int kind) |
1972 | { | 1978 | { |
@@ -2087,6 +2093,10 @@ static struct i2c_driver dme1737_i2c_driver = { | |||
2087 | .detach_client = dme1737_i2c_detach_client, | 2093 | .detach_client = dme1737_i2c_detach_client, |
2088 | }; | 2094 | }; |
2089 | 2095 | ||
2096 | /* --------------------------------------------------------------------- | ||
2097 | * Module initialization and cleanup | ||
2098 | * --------------------------------------------------------------------- */ | ||
2099 | |||
2090 | static int __init dme1737_init(void) | 2100 | static int __init dme1737_init(void) |
2091 | { | 2101 | { |
2092 | return i2c_add_driver(&dme1737_i2c_driver); | 2102 | return i2c_add_driver(&dme1737_i2c_driver); |