Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
dc9f9ccd
Commit
dc9f9ccd
authored
Oct 19, 2004
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Plain Diff
Merge kroah.com:/home/greg/linux/BK/bleed-2.6
into kroah.com:/home/greg/linux/BK/i2c-2.6
parents
2a136606
251d166e
Changes
61
Hide whitespace changes
Inline
Side-by-side
Showing
61 changed files
with
651 additions
and
322 deletions
+651
-322
Documentation/i2c/i2c-stub
Documentation/i2c/i2c-stub
+33
-0
Documentation/i2c/sysfs-interface
Documentation/i2c/sysfs-interface
+5
-2
Documentation/i2c/writing-clients
Documentation/i2c/writing-clients
+14
-12
drivers/i2c/algos/i2c-algo-ite.c
drivers/i2c/algos/i2c-algo-ite.c
+0
-8
drivers/i2c/busses/Kconfig
drivers/i2c/busses/Kconfig
+13
-0
drivers/i2c/busses/Makefile
drivers/i2c/busses/Makefile
+1
-0
drivers/i2c/busses/i2c-ali1535.c
drivers/i2c/busses/i2c-ali1535.c
+2
-0
drivers/i2c/busses/i2c-ali1563.c
drivers/i2c/busses/i2c-ali1563.c
+2
-0
drivers/i2c/busses/i2c-ali15x3.c
drivers/i2c/busses/i2c-ali15x3.c
+2
-0
drivers/i2c/busses/i2c-amd756.c
drivers/i2c/busses/i2c-amd756.c
+2
-0
drivers/i2c/busses/i2c-amd8111.c
drivers/i2c/busses/i2c-amd8111.c
+2
-0
drivers/i2c/busses/i2c-elektor.c
drivers/i2c/busses/i2c-elektor.c
+4
-4
drivers/i2c/busses/i2c-hydra.c
drivers/i2c/busses/i2c-hydra.c
+2
-0
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-i801.c
+2
-0
drivers/i2c/busses/i2c-i810.c
drivers/i2c/busses/i2c-i810.c
+3
-1
drivers/i2c/busses/i2c-mpc.c
drivers/i2c/busses/i2c-mpc.c
+4
-3
drivers/i2c/busses/i2c-nforce2.c
drivers/i2c/busses/i2c-nforce2.c
+3
-0
drivers/i2c/busses/i2c-piix4.c
drivers/i2c/busses/i2c-piix4.c
+2
-0
drivers/i2c/busses/i2c-prosavage.c
drivers/i2c/busses/i2c-prosavage.c
+5
-3
drivers/i2c/busses/i2c-savage4.c
drivers/i2c/busses/i2c-savage4.c
+3
-1
drivers/i2c/busses/i2c-sis5595.c
drivers/i2c/busses/i2c-sis5595.c
+2
-0
drivers/i2c/busses/i2c-sis630.c
drivers/i2c/busses/i2c-sis630.c
+2
-0
drivers/i2c/busses/i2c-sis96x.c
drivers/i2c/busses/i2c-sis96x.c
+2
-0
drivers/i2c/busses/i2c-stub.c
drivers/i2c/busses/i2c-stub.c
+125
-0
drivers/i2c/busses/i2c-via.c
drivers/i2c/busses/i2c-via.c
+2
-0
drivers/i2c/busses/i2c-viapro.c
drivers/i2c/busses/i2c-viapro.c
+2
-0
drivers/i2c/busses/i2c-voodoo3.c
drivers/i2c/busses/i2c-voodoo3.c
+3
-1
drivers/i2c/busses/scx200_acb.c
drivers/i2c/busses/scx200_acb.c
+7
-6
drivers/i2c/chips/adm1021.c
drivers/i2c/chips/adm1021.c
+1
-1
drivers/i2c/chips/adm1025.c
drivers/i2c/chips/adm1025.c
+9
-7
drivers/i2c/chips/adm1031.c
drivers/i2c/chips/adm1031.c
+24
-24
drivers/i2c/chips/asb100.c
drivers/i2c/chips/asb100.c
+9
-9
drivers/i2c/chips/ds1621.c
drivers/i2c/chips/ds1621.c
+1
-1
drivers/i2c/chips/eeprom.c
drivers/i2c/chips/eeprom.c
+1
-1
drivers/i2c/chips/fscher.c
drivers/i2c/chips/fscher.c
+1
-1
drivers/i2c/chips/gl518sm.c
drivers/i2c/chips/gl518sm.c
+5
-3
drivers/i2c/chips/it87.c
drivers/i2c/chips/it87.c
+18
-18
drivers/i2c/chips/lm75.c
drivers/i2c/chips/lm75.c
+1
-1
drivers/i2c/chips/lm77.c
drivers/i2c/chips/lm77.c
+1
-1
drivers/i2c/chips/lm78.c
drivers/i2c/chips/lm78.c
+13
-27
drivers/i2c/chips/lm80.c
drivers/i2c/chips/lm80.c
+4
-3
drivers/i2c/chips/lm83.c
drivers/i2c/chips/lm83.c
+12
-10
drivers/i2c/chips/lm85.c
drivers/i2c/chips/lm85.c
+28
-25
drivers/i2c/chips/lm90.c
drivers/i2c/chips/lm90.c
+25
-18
drivers/i2c/chips/max1619.c
drivers/i2c/chips/max1619.c
+3
-2
drivers/i2c/chips/pcf8574.c
drivers/i2c/chips/pcf8574.c
+1
-1
drivers/i2c/chips/pcf8591.c
drivers/i2c/chips/pcf8591.c
+1
-1
drivers/i2c/chips/smsc47m1.c
drivers/i2c/chips/smsc47m1.c
+25
-25
drivers/i2c/chips/via686a.c
drivers/i2c/chips/via686a.c
+15
-15
drivers/i2c/chips/w83627hf.c
drivers/i2c/chips/w83627hf.c
+11
-11
drivers/i2c/chips/w83781d.c
drivers/i2c/chips/w83781d.c
+46
-30
drivers/w1/Makefile
drivers/w1/Makefile
+4
-0
drivers/w1/dscore.c
drivers/w1/dscore.c
+10
-3
drivers/w1/w1.c
drivers/w1/w1.c
+22
-7
drivers/w1/w1.h
drivers/w1/w1.h
+2
-0
drivers/w1/w1_family.c
drivers/w1/w1_family.c
+9
-2
drivers/w1/w1_int.c
drivers/w1/w1_int.c
+13
-4
drivers/w1/w1_int.h
drivers/w1/w1_int.h
+1
-1
drivers/w1/w1_netlink.c
drivers/w1/w1_netlink.c
+8
-0
drivers/w1/w1_therm.c
drivers/w1/w1_therm.c
+43
-28
include/linux/i2c-vid.h
include/linux/i2c-vid.h
+35
-1
No files found.
Documentation/i2c/i2c-stub
0 → 100644
View file @
dc9f9ccd
MODULE: i2c-stub
DESCRIPTION:
This module is a very simple fake I2C/SMBus driver. It implements three
types of SMBus commands: write quick, (r/w) byte data, and (r/w) word data.
No hardware is needed nor associated with this module. It will accept write
quick commands to all addresses; it will respond to the other commands (also
to all addresses) by reading from or writing to an array in memory. It will
also spam the kernel logs for every command it handles.
The typical use-case is like this:
1. load this module
2. use i2cset (from lm_sensors project) to pre-load some data
3. load the target sensors chip driver module
4. observe its behavior in the kernel log
CAVEATS:
There are independent arrays for byte/data and word/data commands. Depending
on if/how a target driver mixes them, you'll need to be careful.
If your target driver polls some byte or word waiting for it to change, the
stub could lock it up. Use i2cset to unlock it.
If the hardware for your driver has banked registers (e.g. Winbond sensors
chips) this module will not work well - although it could be extended to
support that pretty easily.
If you spam it hard enough, printk can be lossy. This module really wants
something like relayfs.
Documentation/i2c/sysfs-interface
View file @
dc9f9ccd
...
@@ -135,12 +135,15 @@ fan[1-3]_div Fan divisor.
...
@@ -135,12 +135,15 @@ fan[1-3]_div Fan divisor.
Note that this is actually an internal clock divisor, which
Note that this is actually an internal clock divisor, which
affects the measurable speed range, not the read value.
affects the measurable speed range, not the read value.
fan[1-3]_pwm Pulse width modulation fan control.
*******
* PWM *
*******
pwm[1-3] Pulse width modulation fan control.
Integer value in the range 0 to 255
Integer value in the range 0 to 255
Read/Write
Read/Write
255 is max or 100%.
255 is max or 100%.
fan[1-3]_pwm
_enable
pwm[1-3]
_enable
Switch PWM on and off.
Switch PWM on and off.
Not always present even if fan*_pwm is.
Not always present even if fan*_pwm is.
0 to turn off
0 to turn off
...
...
Documentation/i2c/writing-clients
View file @
dc9f9ccd
...
@@ -24,22 +24,24 @@ all clients from it. Remember, a driver structure contains general access
...
@@ -24,22 +24,24 @@ all clients from it. Remember, a driver structure contains general access
routines, a client structure specific information like the actual I2C
routines, a client structure specific information like the actual I2C
address.
address.
static struct i2c_driver foo_driver = {
static struct i2c_driver foo_driver = {
.owner
= THIS_MODULE,
.owner
= THIS_MODULE,
.name
= "Foo version 2.3 driver",
.name
= "Foo version 2.3 driver",
.id = I2C_DRIVERID_FOO, /* usually from i2c-id.h
*/
.id = I2C_DRIVERID_FOO, /* from i2c-id.h, optional
*/
.flags
= I2C_DF_NOTIFY,
.flags
= I2C_DF_NOTIFY,
.attach_adapter
= &foo_attach_adapter,
.attach_adapter
= &foo_attach_adapter,
.detach_client
= &foo_detach_client,
.detach_client
= &foo_detach_client,
.command
= &foo_command /* may be NULL */
.command
= &foo_command /* may be NULL */
}
}
The name can be chosen freely, and may be upto 40 characters long. Please
The name can be chosen freely, and may be upto 40 characters long. Please
use something descriptive here.
use something descriptive here.
The id should be a unique ID. The range 0xf000 to 0xffff is reserved for
If used, the id should be a unique ID. The range 0xf000 to 0xffff is
local use, and you can use one of those until you start distributing the
reserved for local use, and you can use one of those until you start
driver. Before you do that, contact the i2c authors to get your own ID(s).
distributing the driver, at which time you should contact the i2c authors
to get your own ID(s). Note that most of the time you don't need an ID
at all so you can just omit it.
Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This
Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This
means that your driver will be notified when new adapters are found.
means that your driver will be notified when new adapters are found.
...
...
drivers/i2c/algos/i2c-algo-ite.c
View file @
dc9f9ccd
...
@@ -107,14 +107,6 @@ static int wait_for_bb(struct i2c_algo_iic_data *adap)
...
@@ -107,14 +107,6 @@ static int wait_for_bb(struct i2c_algo_iic_data *adap)
return
(
timeout
<=
0
);
return
(
timeout
<=
0
);
}
}
/*
* Puts this process to sleep for a period equal to timeout
*/
static
inline
void
iic_sleep
(
unsigned
long
timeout
)
{
schedule_timeout
(
timeout
*
HZ
);
}
/* After we issue a transaction on the IIC bus, this function
/* After we issue a transaction on the IIC bus, this function
* is called. It puts this process to sleep until we get an interrupt from
* is called. It puts this process to sleep until we get an interrupt from
* from the controller telling us that the transaction we requested in complete.
* from the controller telling us that the transaction we requested in complete.
...
...
drivers/i2c/busses/Kconfig
View file @
dc9f9ccd
...
@@ -376,6 +376,19 @@ config I2C_SIS96X
...
@@ -376,6 +376,19 @@ config I2C_SIS96X
This driver can also be built as a module. If so, the module
This driver can also be built as a module. If so, the module
will be called i2c-sis96x.
will be called i2c-sis96x.
config I2C_STUB
tristate "I2C/SMBus Test Stub"
depends on I2C && EXPERIMENTAL && 'm'
default 'n'
help
This module may be useful to developers of SMBus client drivers,
especially for certain kinds of sensor chips.
If you do build this module, be sure to read the notes and warnings
in Documentation/i2c/i2c-stub.
If you don't know what to do here, definitely say N.
config I2C_VIA
config I2C_VIA
tristate "VIA 82C586B"
tristate "VIA 82C586B"
depends on I2C && PCI && EXPERIMENTAL
depends on I2C && PCI && EXPERIMENTAL
...
...
drivers/i2c/busses/Makefile
View file @
dc9f9ccd
...
@@ -30,6 +30,7 @@ obj-$(CONFIG_I2C_SAVAGE4) += i2c-savage4.o
...
@@ -30,6 +30,7 @@ obj-$(CONFIG_I2C_SAVAGE4) += i2c-savage4.o
obj-$(CONFIG_I2C_SIS5595)
+=
i2c-sis5595.o
obj-$(CONFIG_I2C_SIS5595)
+=
i2c-sis5595.o
obj-$(CONFIG_I2C_SIS630)
+=
i2c-sis630.o
obj-$(CONFIG_I2C_SIS630)
+=
i2c-sis630.o
obj-$(CONFIG_I2C_SIS96X)
+=
i2c-sis96x.o
obj-$(CONFIG_I2C_SIS96X)
+=
i2c-sis96x.o
obj-$(CONFIG_I2C_STUB)
+=
i2c-stub.o
obj-$(CONFIG_I2C_VIA)
+=
i2c-via.o
obj-$(CONFIG_I2C_VIA)
+=
i2c-via.o
obj-$(CONFIG_I2C_VIAPRO)
+=
i2c-viapro.o
obj-$(CONFIG_I2C_VIAPRO)
+=
i2c-viapro.o
obj-$(CONFIG_I2C_VOODOO3)
+=
i2c-voodoo3.o
obj-$(CONFIG_I2C_VOODOO3)
+=
i2c-voodoo3.o
...
...
drivers/i2c/busses/i2c-ali1535.c
View file @
dc9f9ccd
...
@@ -496,6 +496,8 @@ static struct pci_device_id ali1535_ids[] = {
...
@@ -496,6 +496,8 @@ static struct pci_device_id ali1535_ids[] = {
{
},
{
},
};
};
MODULE_DEVICE_TABLE
(
pci
,
ali1535_ids
);
static
int
__devinit
ali1535_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
ali1535_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
if
(
ali1535_setup
(
dev
))
{
if
(
ali1535_setup
(
dev
))
{
...
...
drivers/i2c/busses/i2c-ali1563.c
View file @
dc9f9ccd
...
@@ -394,6 +394,8 @@ static struct pci_device_id __devinitdata ali1563_id_table[] = {
...
@@ -394,6 +394,8 @@ static struct pci_device_id __devinitdata ali1563_id_table[] = {
{},
{},
};
};
MODULE_DEVICE_TABLE
(
pci
,
ali1563_id_table
);
static
struct
pci_driver
ali1563_pci_driver
=
{
static
struct
pci_driver
ali1563_pci_driver
=
{
.
name
=
"ali1563_i2c"
,
.
name
=
"ali1563_i2c"
,
.
id_table
=
ali1563_id_table
,
.
id_table
=
ali1563_id_table
,
...
...
drivers/i2c/busses/i2c-ali15x3.c
View file @
dc9f9ccd
...
@@ -486,6 +486,8 @@ static struct pci_device_id ali15x3_ids[] = {
...
@@ -486,6 +486,8 @@ static struct pci_device_id ali15x3_ids[] = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
ali15x3_ids
);
static
int
__devinit
ali15x3_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
ali15x3_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
if
(
ali15x3_setup
(
dev
))
{
if
(
ali15x3_setup
(
dev
))
{
...
...
drivers/i2c/busses/i2c-amd756.c
View file @
dc9f9ccd
...
@@ -320,6 +320,8 @@ static struct pci_device_id amd756_ids[] = {
...
@@ -320,6 +320,8 @@ static struct pci_device_id amd756_ids[] = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
amd756_ids
);
static
int
__devinit
amd756_probe
(
struct
pci_dev
*
pdev
,
static
int
__devinit
amd756_probe
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
id
)
const
struct
pci_device_id
*
id
)
{
{
...
...
drivers/i2c/busses/i2c-amd8111.c
View file @
dc9f9ccd
...
@@ -336,6 +336,8 @@ static struct pci_device_id amd8111_ids[] = {
...
@@ -336,6 +336,8 @@ static struct pci_device_id amd8111_ids[] = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
amd8111_ids
);
static
int
__devinit
amd8111_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
amd8111_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
struct
amd_smbus
*
smbus
;
struct
amd_smbus
*
smbus
;
...
...
drivers/i2c/busses/i2c-elektor.c
View file @
dc9f9ccd
...
@@ -180,11 +180,10 @@ static int __init i2c_pcfisa_init(void)
...
@@ -180,11 +180,10 @@ static int __init i2c_pcfisa_init(void)
/* check to see we have memory mapped PCF8584 connected to the
/* check to see we have memory mapped PCF8584 connected to the
Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
if
(
base
==
0
)
{
if
(
base
==
0
)
{
struct
pci_dev
*
cy693_dev
;
struct
pci_dev
*
cy693_dev
=
cy693_dev
=
pci_get_device
(
PCI_VENDOR_ID_CONTAQ
,
pci_find_device
(
PCI_VENDOR_ID_CONTAQ
,
PCI_DEVICE_ID_CONTAQ_82C693
,
NULL
);
PCI_DEVICE_ID_CONTAQ_82C693
,
NULL
);
if
(
cy693_dev
)
{
if
(
cy693_dev
)
{
char
config
;
char
config
;
/* yeap, we've found cypress, let's check config */
/* yeap, we've found cypress, let's check config */
...
@@ -215,6 +214,7 @@ static int __init i2c_pcfisa_init(void)
...
@@ -215,6 +214,7 @@ static int __init i2c_pcfisa_init(void)
printk
(
KERN_INFO
"i2c-elektor: found API UP2000 like board, will probe PCF8584 later.
\n
"
);
printk
(
KERN_INFO
"i2c-elektor: found API UP2000 like board, will probe PCF8584 later.
\n
"
);
}
}
}
}
pci_dev_put
(
cy693_dev
);
}
}
}
}
#endif
#endif
...
...
drivers/i2c/busses/i2c-hydra.c
View file @
dc9f9ccd
...
@@ -120,6 +120,8 @@ static struct pci_device_id hydra_ids[] = {
...
@@ -120,6 +120,8 @@ static struct pci_device_id hydra_ids[] = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
hydra_ids
);
static
int
__devinit
hydra_probe
(
struct
pci_dev
*
dev
,
static
int
__devinit
hydra_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
const
struct
pci_device_id
*
id
)
{
{
...
...
drivers/i2c/busses/i2c-i801.c
View file @
dc9f9ccd
...
@@ -599,6 +599,8 @@ static struct pci_device_id i801_ids[] = {
...
@@ -599,6 +599,8 @@ static struct pci_device_id i801_ids[] = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
i801_ids
);
static
int
__devinit
i801_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
i801_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
...
...
drivers/i2c/busses/i2c-i810.c
View file @
dc9f9ccd
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
#define CYCLE_DELAY 10
#define CYCLE_DELAY 10
#define TIMEOUT (HZ / 2)
#define TIMEOUT (HZ / 2)
static
void
*
ioaddr
;
static
void
__iomem
*
ioaddr
;
/* The i810 GPIO registers have individual masks for each bit
/* The i810 GPIO registers have individual masks for each bit
so we never have to read before writing. Nice. */
so we never have to read before writing. Nice. */
...
@@ -201,6 +201,8 @@ static struct pci_device_id i810_ids[] __devinitdata = {
...
@@ -201,6 +201,8 @@ static struct pci_device_id i810_ids[] __devinitdata = {
{
0
,
},
{
0
,
},
};
};
MODULE_DEVICE_TABLE
(
pci
,
i810_ids
);
static
int
__devinit
i810_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
i810_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
int
retval
;
int
retval
;
...
...
drivers/i2c/busses/i2c-mpc.c
View file @
dc9f9ccd
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include <asm/ocp.h>
#include <asm/ocp.h>
#include <linux/i2c.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#define MPC_I2C_ADDR 0x00
#define MPC_I2C_ADDR 0x00
#define MPC_I2C_FDR 0x04
#define MPC_I2C_FDR 0x04
...
@@ -91,9 +92,9 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
...
@@ -91,9 +92,9 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
x
=
readb
(
i2c
->
base
+
MPC_I2C_SR
);
x
=
readb
(
i2c
->
base
+
MPC_I2C_SR
);
writeb
(
0
,
i2c
->
base
+
MPC_I2C_SR
);
writeb
(
0
,
i2c
->
base
+
MPC_I2C_SR
);
}
else
{
}
else
{
set_current_state
(
TASK_INTERRUPTIBLE
);
add_wait_queue
(
&
i2c
->
queue
,
&
wait
);
add_wait_queue
(
&
i2c
->
queue
,
&
wait
);
while
(
!
(
i2c
->
interrupt
&
CSR_MIF
))
{
while
(
!
(
i2c
->
interrupt
&
CSR_MIF
))
{
set_current_state
(
TASK_INTERRUPTIBLE
);
if
(
signal_pending
(
current
))
{
if
(
signal_pending
(
current
))
{
pr_debug
(
"I2C: Interrupted
\n
"
);
pr_debug
(
"I2C: Interrupted
\n
"
);
result
=
-
EINTR
;
result
=
-
EINTR
;
...
@@ -104,9 +105,9 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
...
@@ -104,9 +105,9 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
result
=
-
EIO
;
result
=
-
EIO
;
break
;
break
;
}
}
schedule_timeout
(
timeout
);
msleep_interruptible
(
jiffies_to_msecs
(
timeout
)
);
}
}
current
->
state
=
TASK_RUNNING
;
set_current_state
(
TASK_RUNNING
)
;
remove_wait_queue
(
&
i2c
->
queue
,
&
wait
);
remove_wait_queue
(
&
i2c
->
queue
,
&
wait
);
x
=
i2c
->
interrupt
;
x
=
i2c
->
interrupt
;
i2c
->
interrupt
=
0
;
i2c
->
interrupt
=
0
;
...
...
drivers/i2c/busses/i2c-nforce2.c
View file @
dc9f9ccd
...
@@ -298,6 +298,9 @@ static struct pci_device_id nforce2_ids[] = {
...
@@ -298,6 +298,9 @@ static struct pci_device_id nforce2_ids[] = {
};
};
MODULE_DEVICE_TABLE
(
pci
,
nforce2_ids
);
static
int
__devinit
nforce2_probe_smb
(
struct
pci_dev
*
dev
,
int
reg
,
static
int
__devinit
nforce2_probe_smb
(
struct
pci_dev
*
dev
,
int
reg
,
struct
nforce2_smbus
*
smbus
,
char
*
name
)
struct
nforce2_smbus
*
smbus
,
char
*
name
)
{
{
...
...
drivers/i2c/busses/i2c-piix4.c
View file @
dc9f9ccd
...
@@ -459,6 +459,8 @@ static struct pci_device_id piix4_ids[] = {
...
@@ -459,6 +459,8 @@ static struct pci_device_id piix4_ids[] = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
piix4_ids
);
static
int
__devinit
piix4_probe
(
struct
pci_dev
*
dev
,
static
int
__devinit
piix4_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
const
struct
pci_device_id
*
id
)
{
{
...
...
drivers/i2c/busses/i2c-prosavage.c
View file @
dc9f9ccd
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
#define MAX_BUSSES 2
#define MAX_BUSSES 2
struct
s_i2c_bus
{
struct
s_i2c_bus
{
void
*
mmvga
;
void
__iomem
*
mmvga
;
int
i2c_reg
;
int
i2c_reg
;
int
adap_ok
;
int
adap_ok
;
struct
i2c_adapter
adap
;
struct
i2c_adapter
adap
;
...
@@ -76,7 +76,7 @@ struct s_i2c_bus {
...
@@ -76,7 +76,7 @@ struct s_i2c_bus {
};
};
struct
s_i2c_chip
{
struct
s_i2c_chip
{
void
*
mmio
;
void
__iomem
*
mmio
;
struct
s_i2c_bus
i2c_bus
[
MAX_BUSSES
];
struct
s_i2c_bus
i2c_bus
[
MAX_BUSSES
];
};
};
...
@@ -181,7 +181,7 @@ static int bit_s3via_getsda(void *bus)
...
@@ -181,7 +181,7 @@ static int bit_s3via_getsda(void *bus)
/*
/*
* adapter initialisation
* adapter initialisation
*/
*/
static
int
i2c_register_bus
(
struct
pci_dev
*
dev
,
struct
s_i2c_bus
*
p
,
u8
*
mmvga
,
u32
i2c_reg
)
static
int
i2c_register_bus
(
struct
pci_dev
*
dev
,
struct
s_i2c_bus
*
p
,
void
__iomem
*
mmvga
,
u32
i2c_reg
)
{
{
int
ret
;
int
ret
;
p
->
adap
.
owner
=
THIS_MODULE
;
p
->
adap
.
owner
=
THIS_MODULE
;
...
@@ -313,6 +313,8 @@ static struct pci_device_id prosavage_pci_tbl[] = {
...
@@ -313,6 +313,8 @@ static struct pci_device_id prosavage_pci_tbl[] = {
{
0
,
},
{
0
,
},
};
};
MODULE_DEVICE_TABLE
(
pci
,
prosavage_pci_tbl
);
static
struct
pci_driver
prosavage_driver
=
{
static
struct
pci_driver
prosavage_driver
=
{
.
name
=
"prosavage_smbus"
,
.
name
=
"prosavage_smbus"
,
.
id_table
=
prosavage_pci_tbl
,
.
id_table
=
prosavage_pci_tbl
,
...
...
drivers/i2c/busses/i2c-savage4.c
View file @
dc9f9ccd
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
#define TIMEOUT (HZ / 2)
#define TIMEOUT (HZ / 2)
static
void
*
ioaddr
;
static
void
__iomem
*
ioaddr
;
/* The sav GPIO registers don't have individual masks for each bit
/* The sav GPIO registers don't have individual masks for each bit
so we always have to read before writing. */
so we always have to read before writing. */
...
@@ -157,6 +157,8 @@ static struct pci_device_id savage4_ids[] __devinitdata = {
...
@@ -157,6 +157,8 @@ static struct pci_device_id savage4_ids[] __devinitdata = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
savage4_ids
);
static
int
__devinit
savage4_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
savage4_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
int
retval
;
int
retval
;
...
...
drivers/i2c/busses/i2c-sis5595.c
View file @
dc9f9ccd
...
@@ -371,6 +371,8 @@ static struct pci_device_id sis5595_ids[] __devinitdata = {
...
@@ -371,6 +371,8 @@ static struct pci_device_id sis5595_ids[] __devinitdata = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
sis5595_ids
);
static
int
__devinit
sis5595_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
sis5595_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
if
(
sis5595_setup
(
dev
))
{
if
(
sis5595_setup
(
dev
))
{
...
...
drivers/i2c/busses/i2c-sis630.c
View file @
dc9f9ccd
...
@@ -468,6 +468,8 @@ static struct pci_device_id sis630_ids[] __devinitdata = {
...
@@ -468,6 +468,8 @@ static struct pci_device_id sis630_ids[] __devinitdata = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
sis630_ids
);
static
int
__devinit
sis630_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
sis630_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
if
(
sis630_setup
(
dev
))
{
if
(
sis630_setup
(
dev
))
{
...
...
drivers/i2c/busses/i2c-sis96x.c
View file @
dc9f9ccd
...
@@ -278,6 +278,8 @@ static struct pci_device_id sis96x_ids[] = {
...
@@ -278,6 +278,8 @@ static struct pci_device_id sis96x_ids[] = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
sis96x_ids
);
static
int
__devinit
sis96x_probe
(
struct
pci_dev
*
dev
,
static
int
__devinit
sis96x_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
const
struct
pci_device_id
*
id
)
{
{
...
...
drivers/i2c/busses/i2c-stub.c
0 → 100644
View file @
dc9f9ccd
/*
i2c-stub.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (c) 2004 Mark M. Hoffman <mhoffman@lightlink.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define DEBUG 1
#include <linux/config.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/i2c.h>
static
u8
stub_bytes
[
256
];
static
u16
stub_words
[
256
];
/* Return -1 on error. */
static
s32
stub_xfer
(
struct
i2c_adapter
*
adap
,
u16
addr
,
unsigned
short
flags
,
char
read_write
,
u8
command
,
int
size
,
union
i2c_smbus_data
*
data
)
{
s32
ret
;
switch
(
size
)
{
case
I2C_SMBUS_QUICK
:
dev_dbg
(
&
adap
->
dev
,
"smbus quick - addr 0x%02x
\n
"
,
addr
);
ret
=
0
;
break
;
case
I2C_SMBUS_BYTE_DATA
:
if
(
read_write
==
I2C_SMBUS_WRITE
)
{
stub_bytes
[
command
]
=
data
->
byte
;
dev_dbg
(
&
adap
->
dev
,
"smbus byte data - addr 0x%02x, "
"wrote 0x%02x at 0x%02x.
\n
"
,
addr
,
data
->
byte
,
command
);
}
else
{
data
->
byte
=
stub_bytes
[
command
];
dev_dbg
(
&
adap
->
dev
,
"smbus byte data - addr 0x%02x, "
"read 0x%02x at 0x%02x.
\n
"
,
addr
,
data
->
byte
,
command
);
}
ret
=
0
;
break
;
case
I2C_SMBUS_WORD_DATA
:
if
(
read_write
==
I2C_SMBUS_WRITE
)
{
stub_words
[
command
]
=
data
->
word
;
dev_dbg
(
&
adap
->
dev
,
"smbus word data - addr 0x%02x, "
"wrote 0x%04x at 0x%02x.
\n
"
,
addr
,
data
->
word
,
command
);
}
else
{
data
->
word
=
stub_words
[
command
];
dev_dbg
(
&
adap
->
dev
,
"smbus word data - addr 0x%02x, "
"read 0x%04x at 0x%02x.
\n
"
,
addr
,
data
->
word
,
command
);
}
ret
=
0
;
break
;
default:
dev_dbg
(
&
adap
->
dev
,
"Unsupported I2C/SMBus command
\n
"
);
ret
=
-
1
;
break
;
}
/* switch (size) */
return
ret
;
}
static
u32
stub_func
(
struct
i2c_adapter
*
adapter
)
{
return
I2C_FUNC_SMBUS_QUICK
|
I2C_FUNC_SMBUS_BYTE_DATA
|
I2C_FUNC_SMBUS_WORD_DATA
;
}
static
struct
i2c_algorithm
smbus_algorithm
=
{
.
name
=
"Non-I2C SMBus adapter"
,
.
id
=
I2C_ALGO_SMBUS
,
.
functionality
=
stub_func
,
.
smbus_xfer
=
stub_xfer
,
};
static
struct
i2c_adapter
stub_adapter
=
{
.
owner
=
THIS_MODULE
,
.
class
=
I2C_CLASS_HWMON
,
.
algo
=
&
smbus_algorithm
,
.
name
=
"SMBus stub driver"
,
};
static
int
__init
i2c_stub_init
(
void
)
{
printk
(
KERN_INFO
"i2c-stub loaded
\n
"
);
return
i2c_add_adapter
(
&
stub_adapter
);
}
static
void
__exit
i2c_stub_exit
(
void
)
{
i2c_del_adapter
(
&
stub_adapter
);
}
MODULE_AUTHOR
(
"Mark M. Hoffman <mhoffman@lightlink.com>"
);
MODULE_DESCRIPTION
(
"I2C stub driver"
);
MODULE_LICENSE
(
"GPL"
);
module_init
(
i2c_stub_init
);
module_exit
(
i2c_stub_exit
);
drivers/i2c/busses/i2c-via.c
View file @
dc9f9ccd
...
@@ -99,6 +99,8 @@ static struct pci_device_id vt586b_ids[] __devinitdata = {
...
@@ -99,6 +99,8 @@ static struct pci_device_id vt586b_ids[] __devinitdata = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
vt586b_ids
);
static
int
__devinit
vt586b_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
vt586b_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
u16
base
;
u16
base
;
...
...
drivers/i2c/busses/i2c-viapro.c
View file @
dc9f9ccd
...
@@ -454,6 +454,8 @@ static struct pci_device_id vt596_ids[] = {
...
@@ -454,6 +454,8 @@ static struct pci_device_id vt596_ids[] = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
vt596_ids
);
static
struct
pci_driver
vt596_driver
=
{
static
struct
pci_driver
vt596_driver
=
{
.
name
=
"vt596_smbus"
,
.
name
=
"vt596_smbus"
,
.
id_table
=
vt596_ids
,
.
id_table
=
vt596_ids
,
...
...
drivers/i2c/busses/i2c-voodoo3.c
View file @
dc9f9ccd
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
#define TIMEOUT (HZ / 2)
#define TIMEOUT (HZ / 2)
static
void
*
ioaddr
;
static
void
__iomem
*
ioaddr
;
/* The voo GPIO registers don't have individual masks for each bit
/* The voo GPIO registers don't have individual masks for each bit
so we always have to read before writing. */
so we always have to read before writing. */
...
@@ -195,6 +195,8 @@ static struct pci_device_id voodoo3_ids[] __devinitdata = {
...
@@ -195,6 +195,8 @@ static struct pci_device_id voodoo3_ids[] __devinitdata = {
{
0
,
}
{
0
,
}
};
};
MODULE_DEVICE_TABLE
(
pci
,
voodoo3_ids
);
static
int
__devinit
voodoo3_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
static
int
__devinit
voodoo3_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
{
int
retval
;
int
retval
;
...
...
drivers/i2c/busses/scx200_acb.c
View file @
dc9f9ccd
...
@@ -503,6 +503,12 @@ static int __init scx200_acb_create(int base, int index)
...
@@ -503,6 +503,12 @@ static int __init scx200_acb_create(int base, int index)
return
rc
;
return
rc
;
}
}
static
struct
pci_device_id
scx200
[]
=
{
{
PCI_DEVICE
(
PCI_VENDOR_ID_NS
,
PCI_DEVICE_ID_NS_SCx200_BRIDGE
)
},
{
PCI_DEVICE
(
PCI_VENDOR_ID_NS
,
PCI_DEVICE_ID_NS_SC1100_BRIDGE
)
},
{
},
};
static
int
__init
scx200_acb_init
(
void
)
static
int
__init
scx200_acb_init
(
void
)
{
{
int
i
;
int
i
;
...
@@ -511,12 +517,7 @@ static int __init scx200_acb_init(void)
...
@@ -511,12 +517,7 @@ static int __init scx200_acb_init(void)
pr_debug
(
NAME
": NatSemi SCx200 ACCESS.bus Driver
\n
"
);
pr_debug
(
NAME
": NatSemi SCx200 ACCESS.bus Driver
\n
"
);
/* Verify that this really is a SCx200 processor */
/* Verify that this really is a SCx200 processor */
if
(
pci_find_device
(
PCI_VENDOR_ID_NS
,
if
(
pci_dev_present
(
scx200
)
==
0
)
PCI_DEVICE_ID_NS_SCx200_BRIDGE
,
NULL
)
==
NULL
&&
pci_find_device
(
PCI_VENDOR_ID_NS
,
PCI_DEVICE_ID_NS_SC1100_BRIDGE
,
NULL
)
==
NULL
)
return
-
ENODEV
;
return
-
ENODEV
;
rc
=
-
ENXIO
;
rc
=
-
ENXIO
;
...
...
drivers/i2c/chips/adm1021.c
View file @
dc9f9ccd
...
@@ -148,7 +148,7 @@ static struct i2c_driver adm1021_driver = {
...
@@ -148,7 +148,7 @@ static struct i2c_driver adm1021_driver = {
.
detach_client
=
adm1021_detach_client
,
.
detach_client
=
adm1021_detach_client
,
};
};
static
int
adm1021_id
=
0
;
static
int
adm1021_id
;
#define show(value) \
#define show(value) \
static ssize_t show_##value(struct device *dev, char *buf) \
static ssize_t show_##value(struct device *dev, char *buf) \
...
...
drivers/i2c/chips/adm1025.c
View file @
dc9f9ccd
...
@@ -153,7 +153,7 @@ struct adm1025_data {
...
@@ -153,7 +153,7 @@ struct adm1025_data {
* Internal variables
* Internal variables
*/
*/
static
int
adm1025_id
=
0
;
static
int
adm1025_id
;
/*
/*
* Sysfs stuff
* Sysfs stuff
...
@@ -212,8 +212,8 @@ static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \
...
@@ -212,8 +212,8 @@ static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct adm1025_data *data = i2c_get_clientdata(client); \
struct adm1025_data *data = i2c_get_clientdata(client); \
data->in_min[offset] = IN_TO_REG(simple_strtol(buf, NULL, 10),
\
long val = simple_strtol(buf, NULL, 10);
\
in_scale[offset]); \
data->in_min[offset] = IN_TO_REG(val,
in_scale[offset]); \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \
data->in_min[offset]); \
data->in_min[offset]); \
return count; \
return count; \
...
@@ -223,8 +223,8 @@ static ssize_t set_in##offset##_max(struct device *dev, const char *buf, \
...
@@ -223,8 +223,8 @@ static ssize_t set_in##offset##_max(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct adm1025_data *data = i2c_get_clientdata(client); \
struct adm1025_data *data = i2c_get_clientdata(client); \
data->in_max[offset] = IN_TO_REG(simple_strtol(buf, NULL, 10),
\
long val = simple_strtol(buf, NULL, 10);
\
in_scale[offset]); \
data->in_max[offset] = IN_TO_REG(val,
in_scale[offset]); \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \
data->in_max[offset]); \
data->in_max[offset]); \
return count; \
return count; \
...
@@ -246,7 +246,8 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
...
@@ -246,7 +246,8 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct adm1025_data *data = i2c_get_clientdata(client); \
struct adm1025_data *data = i2c_get_clientdata(client); \
data->temp_min[offset-1] = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
long val = simple_strtol(buf, NULL, 10); \
data->temp_min[offset-1] = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \
data->temp_min[offset-1]); \
data->temp_min[offset-1]); \
return count; \
return count; \
...
@@ -256,7 +257,8 @@ static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \
...
@@ -256,7 +257,8 @@ static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct adm1025_data *data = i2c_get_clientdata(client); \
struct adm1025_data *data = i2c_get_clientdata(client); \
data->temp_max[offset-1] = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
long val = simple_strtol(buf, NULL, 10); \
data->temp_max[offset-1] = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \
data->temp_max[offset-1]); \
data->temp_max[offset-1]); \
return count; \
return count; \
...
...
drivers/i2c/chips/adm1031.c
View file @
dc9f9ccd
...
@@ -298,12 +298,12 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
...
@@ -298,12 +298,12 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
#define fan_auto_channel_offset(offset) \
#define fan_auto_channel_offset(offset) \
static ssize_t show_fan_auto_channel_##offset (struct device *dev, char *buf) \
static ssize_t show_fan_auto_channel_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan_auto_channel(dev, buf,
0x##
offset - 1); \
return show_fan_auto_channel(dev, buf, offset - 1); \
} \
} \
static ssize_t set_fan_auto_channel_##offset (struct device *dev, \
static ssize_t set_fan_auto_channel_##offset (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_auto_channel(dev, buf, count,
0x##
offset - 1); \
return set_fan_auto_channel(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(auto_fan##offset##_channel, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(auto_fan##offset##_channel, S_IRUGO | S_IWUSR, \
show_fan_auto_channel_##offset, \
show_fan_auto_channel_##offset, \
...
@@ -365,25 +365,25 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
...
@@ -365,25 +365,25 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
#define auto_temp_reg(offset) \
#define auto_temp_reg(offset) \
static ssize_t show_auto_temp_##offset##_off (struct device *dev, char *buf) \
static ssize_t show_auto_temp_##offset##_off (struct device *dev, char *buf) \
{ \
{ \
return show_auto_temp_off(dev, buf,
0x##
offset - 1); \
return show_auto_temp_off(dev, buf, offset - 1); \
} \
} \
static ssize_t show_auto_temp_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_auto_temp_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_auto_temp_min(dev, buf,
0x##
offset - 1); \
return show_auto_temp_min(dev, buf, offset - 1); \
} \
} \
static ssize_t show_auto_temp_##offset##_max (struct device *dev, char *buf) \
static ssize_t show_auto_temp_##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_auto_temp_max(dev, buf,
0x##
offset - 1); \
return show_auto_temp_max(dev, buf, offset - 1); \
} \
} \
static ssize_t set_auto_temp_##offset##_min (struct device *dev, \
static ssize_t set_auto_temp_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_auto_temp_min(dev, buf, count,
0x##
offset - 1); \
return set_auto_temp_min(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_auto_temp_##offset##_max (struct device *dev, \
static ssize_t set_auto_temp_##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_auto_temp_max(dev, buf, count,
0x##
offset - 1); \
return set_auto_temp_max(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(auto_temp##offset##_off, S_IRUGO, \
static DEVICE_ATTR(auto_temp##offset##_off, S_IRUGO, \
show_auto_temp_##offset##_off, NULL); \
show_auto_temp_##offset##_off, NULL); \
...
@@ -429,14 +429,14 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
...
@@ -429,14 +429,14 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
#define pwm_reg(offset) \
#define pwm_reg(offset) \
static ssize_t show_pwm_##offset (struct device *dev, char *buf) \
static ssize_t show_pwm_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_pwm(dev, buf,
0x##
offset - 1); \
return show_pwm(dev, buf, offset - 1); \
} \
} \
static ssize_t set_pwm_##offset (struct device *dev, \
static ssize_t set_pwm_##offset (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_pwm(dev, buf, count,
0x##
offset - 1); \
return set_pwm(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(
fan##offset##_pwm, S_IRUGO | S_IWUSR,
\
static DEVICE_ATTR(
pwm##offset, S_IRUGO | S_IWUSR,
\
show_pwm_##offset, set_pwm_##offset)
show_pwm_##offset, set_pwm_##offset)
pwm_reg
(
1
);
pwm_reg
(
1
);
...
@@ -565,25 +565,25 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
...
@@ -565,25 +565,25 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
#define fan_offset(offset) \
#define fan_offset(offset) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan(dev, buf,
0x##
offset - 1); \
return show_fan(dev, buf, offset - 1); \
} \
} \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_fan_min(dev, buf,
0x##
offset - 1); \
return show_fan_min(dev, buf, offset - 1); \
} \
} \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
{ \
{ \
return show_fan_div(dev, buf,
0x##
offset - 1); \
return show_fan_div(dev, buf, offset - 1); \
} \
} \
static ssize_t set_fan_##offset##_min (struct device *dev, \
static ssize_t set_fan_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_min(dev, buf, count,
0x##
offset - 1); \
return set_fan_min(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_fan_##offset##_div (struct device *dev, \
static ssize_t set_fan_##offset##_div (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_div(dev, buf, count,
0x##
offset - 1); \
return set_fan_div(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, \
NULL); \
NULL); \
...
@@ -675,34 +675,34 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
...
@@ -675,34 +675,34 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
#define temp_reg(offset) \
#define temp_reg(offset) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_temp(dev, buf,
0x##
offset - 1); \
return show_temp(dev, buf, offset - 1); \
} \
} \
static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_temp_min(dev, buf,
0x##
offset - 1); \
return show_temp_min(dev, buf, offset - 1); \
} \
} \
static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \
static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_temp_max(dev, buf,
0x##
offset - 1); \
return show_temp_max(dev, buf, offset - 1); \
} \
} \
static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf) \
static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf) \
{ \
{ \
return show_temp_crit(dev, buf,
0x##
offset - 1); \
return show_temp_crit(dev, buf, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_min (struct device *dev, \
static ssize_t set_temp_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_min(dev, buf, count,
0x##
offset - 1); \
return set_temp_min(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_max (struct device *dev, \
static ssize_t set_temp_##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_max(dev, buf, count,
0x##
offset - 1); \
return set_temp_max(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_crit (struct device *dev, \
static ssize_t set_temp_##offset##_crit (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_crit(dev, buf, count,
0x##
offset - 1); \
return set_temp_crit(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, \
NULL); \
NULL); \
...
@@ -799,7 +799,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -799,7 +799,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan1_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan1_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan1_div
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan1_div
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan1_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan1_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan1_pwm
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_auto_fan1_channel
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_auto_fan1_channel
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp1_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp1_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp1_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp1_min
);
...
@@ -826,7 +826,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -826,7 +826,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan2_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan2_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan2_div
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan2_div
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan2_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan2_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan2_pwm
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm2
);
device_create_file
(
&
new_client
->
dev
,
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_auto_fan2_channel
);
&
dev_attr_auto_fan2_channel
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp3_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp3_input
);
...
...
drivers/i2c/chips/asb100.c
View file @
dc9f9ccd
...
@@ -266,29 +266,29 @@ set_in_reg(MAX, max)
...
@@ -266,29 +266,29 @@ set_in_reg(MAX, max)
static ssize_t \
static ssize_t \
show_in##offset (struct device *dev, char *buf) \
show_in##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in(dev, buf,
0x##
offset); \
return show_in(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
show_in##offset, NULL); \
show_in##offset, NULL); \
static ssize_t \
static ssize_t \
show_in##offset##_min (struct device *dev, char *buf) \
show_in##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_in_min(dev, buf,
0x##
offset); \
return show_in_min(dev, buf, offset); \
} \
} \
static ssize_t \
static ssize_t \
show_in##offset##_max (struct device *dev, char *buf) \
show_in##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_in_max(dev, buf,
0x##
offset); \
return show_in_max(dev, buf, offset); \
} \
} \
static ssize_t set_in##offset##_min (struct device *dev, \
static ssize_t set_in##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_min(dev, buf, count,
0x##
offset); \
return set_in_min(dev, buf, count, offset); \
} \
} \
static ssize_t set_in##offset##_max (struct device *dev, \
static ssize_t set_in##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_max(dev, buf, count,
0x##
offset); \
return set_in_max(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
show_in##offset##_min, set_in##offset##_min); \
show_in##offset##_min, set_in##offset##_min); \
...
@@ -591,12 +591,12 @@ static ssize_t set_pwm_enable1(struct device *dev, const char *buf,
...
@@ -591,12 +591,12 @@ static ssize_t set_pwm_enable1(struct device *dev, const char *buf,
return
count
;
return
count
;
}
}
static
DEVICE_ATTR
(
fan1_pwm
,
S_IRUGO
|
S_IWUSR
,
show_pwm1
,
set_pwm1
);
static
DEVICE_ATTR
(
pwm1
,
S_IRUGO
|
S_IWUSR
,
show_pwm1
,
set_pwm1
);
static
DEVICE_ATTR
(
fan1_pwm
_enable
,
S_IRUGO
|
S_IWUSR
,
static
DEVICE_ATTR
(
pwm1
_enable
,
S_IRUGO
|
S_IWUSR
,
show_pwm_enable1
,
set_pwm_enable1
);
show_pwm_enable1
,
set_pwm_enable1
);
#define device_create_file_pwm1(client) do { \
#define device_create_file_pwm1(client) do { \
device_create_file(&new_client->dev, &dev_attr_
fan1_pwm
); \
device_create_file(&new_client->dev, &dev_attr_
pwm1
); \
device_create_file(&new_client->dev, &dev_attr_
fan1_pwm
_enable); \
device_create_file(&new_client->dev, &dev_attr_
pwm1
_enable); \
} while (0)
} while (0)
/* This function is called when:
/* This function is called when:
...
...
drivers/i2c/chips/ds1621.c
View file @
dc9f9ccd
...
@@ -96,7 +96,7 @@ static struct i2c_driver ds1621_driver = {
...
@@ -96,7 +96,7 @@ static struct i2c_driver ds1621_driver = {
.
detach_client
=
ds1621_detach_client
,
.
detach_client
=
ds1621_detach_client
,
};
};
static
int
ds1621_id
=
0
;
static
int
ds1621_id
;
/* All registers are word-sized, except for the configuration register.
/* All registers are word-sized, except for the configuration register.
DS1621 uses a high-byte first convention, which is exactly opposite to
DS1621 uses a high-byte first convention, which is exactly opposite to
...
...
drivers/i2c/chips/eeprom.c
View file @
dc9f9ccd
...
@@ -86,7 +86,7 @@ static struct i2c_driver eeprom_driver = {
...
@@ -86,7 +86,7 @@ static struct i2c_driver eeprom_driver = {
.
detach_client
=
eeprom_detach_client
,
.
detach_client
=
eeprom_detach_client
,
};
};
static
int
eeprom_id
=
0
;
static
int
eeprom_id
;
static
void
eeprom_update_client
(
struct
i2c_client
*
client
,
u8
slice
)
static
void
eeprom_update_client
(
struct
i2c_client
*
client
,
u8
slice
)
{
{
...
...
drivers/i2c/chips/fscher.c
View file @
dc9f9ccd
...
@@ -156,7 +156,7 @@ struct fscher_data {
...
@@ -156,7 +156,7 @@ struct fscher_data {
* Internal variables
* Internal variables
*/
*/
static
int
fscher_id
=
0
;
static
int
fscher_id
;
/*
/*
* Sysfs stuff
* Sysfs stuff
...
...
drivers/i2c/chips/gl518sm.c
View file @
dc9f9ccd
...
@@ -164,7 +164,7 @@ static struct i2c_driver gl518_driver = {
...
@@ -164,7 +164,7 @@ static struct i2c_driver gl518_driver = {
* Internal variables
* Internal variables
*/
*/
static
int
gl518_id
=
0
;
static
int
gl518_id
;
/*
/*
* Sysfs stuff
* Sysfs stuff
...
@@ -217,7 +217,8 @@ static ssize_t set_##suffix(struct device *dev, const char *buf, \
...
@@ -217,7 +217,8 @@ static ssize_t set_##suffix(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct gl518_data *data = i2c_get_clientdata(client); \
struct gl518_data *data = i2c_get_clientdata(client); \
data->value = type##_TO_REG(simple_strtol(buf, NULL, 10)); \
long val = simple_strtol(buf, NULL, 10); \
data->value = type##_TO_REG(val); \
gl518_write_value(client, reg, data->value); \
gl518_write_value(client, reg, data->value); \
return count; \
return count; \
}
}
...
@@ -229,7 +230,8 @@ static ssize_t set_##suffix(struct device *dev, const char *buf, \
...
@@ -229,7 +230,8 @@ static ssize_t set_##suffix(struct device *dev, const char *buf, \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct gl518_data *data = i2c_get_clientdata(client); \
struct gl518_data *data = i2c_get_clientdata(client); \
int regvalue = gl518_read_value(client, reg); \
int regvalue = gl518_read_value(client, reg); \
data->value = type##_TO_REG(simple_strtoul(buf, NULL, 10)); \
unsigned long val = simple_strtoul(buf, NULL, 10); \
data->value = type##_TO_REG(val); \
regvalue = (regvalue & ~mask) | (data->value << shift); \
regvalue = (regvalue & ~mask) | (data->value << shift); \
gl518_write_value(client, reg, regvalue); \
gl518_write_value(client, reg, regvalue); \
return count; \
return count; \
...
...
drivers/i2c/chips/it87.c
View file @
dc9f9ccd
...
@@ -226,7 +226,7 @@ static struct i2c_driver it87_driver = {
...
@@ -226,7 +226,7 @@ static struct i2c_driver it87_driver = {
.
detach_client
=
it87_detach_client
,
.
detach_client
=
it87_detach_client
,
};
};
static
int
it87_id
=
0
;
static
int
it87_id
;
static
ssize_t
show_in
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
static
ssize_t
show_in
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
{
{
...
@@ -273,7 +273,7 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
...
@@ -273,7 +273,7 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
static ssize_t \
static ssize_t \
show_in##offset (struct device *dev, char *buf) \
show_in##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in(dev, buf,
0x##
offset); \
return show_in(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
...
@@ -281,22 +281,22 @@ static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
...
@@ -281,22 +281,22 @@ static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
static ssize_t \
static ssize_t \
show_in##offset##_min (struct device *dev, char *buf) \
show_in##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_in_min(dev, buf,
0x##offset);
\
return show_in_min(dev, buf,
offset);
\
} \
} \
static ssize_t \
static ssize_t \
show_in##offset##_max (struct device *dev, char *buf) \
show_in##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_in_max(dev, buf,
0x##offset);
\
return show_in_max(dev, buf,
offset);
\
} \
} \
static ssize_t set_in##offset##_min (struct device *dev, \
static ssize_t set_in##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_min(dev, buf, count,
0x##
offset); \
return set_in_min(dev, buf, count, offset); \
} \
} \
static ssize_t set_in##offset##_max (struct device *dev, \
static ssize_t set_in##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_max(dev, buf, count,
0x##
offset); \
return set_in_max(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
show_in##offset##_min, set_in##offset##_min); \
show_in##offset##_min, set_in##offset##_min); \
...
@@ -360,27 +360,27 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
...
@@ -360,27 +360,27 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
#define show_temp_offset(offset) \
#define show_temp_offset(offset) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_temp(dev, buf,
0x##offset - 1);
\
return show_temp(dev, buf,
offset - 1);
\
} \
} \
static ssize_t \
static ssize_t \
show_temp_##offset##_max (struct device *dev, char *buf) \
show_temp_##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_temp_max(dev, buf,
0x##
offset - 1); \
return show_temp_max(dev, buf, offset - 1); \
} \
} \
static ssize_t \
static ssize_t \
show_temp_##offset##_min (struct device *dev, char *buf) \
show_temp_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_temp_min(dev, buf,
0x##
offset - 1); \
return show_temp_min(dev, buf, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_max (struct device *dev, \
static ssize_t set_temp_##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_max(dev, buf, count,
0x##
offset - 1); \
return set_temp_max(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_min (struct device *dev, \
static ssize_t set_temp_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_min(dev, buf, count,
0x##
offset - 1); \
return set_temp_min(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
...
@@ -423,12 +423,12 @@ static ssize_t set_sensor(struct device *dev, const char *buf,
...
@@ -423,12 +423,12 @@ static ssize_t set_sensor(struct device *dev, const char *buf,
#define show_sensor_offset(offset) \
#define show_sensor_offset(offset) \
static ssize_t show_sensor_##offset (struct device *dev, char *buf) \
static ssize_t show_sensor_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_sensor(dev, buf,
0x##
offset - 1); \
return show_sensor(dev, buf, offset - 1); \
} \
} \
static ssize_t set_sensor_##offset (struct device *dev, \
static ssize_t set_sensor_##offset (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_sensor(dev, buf, count,
0x##offset - 1);
\
return set_sensor(dev, buf, count,
offset - 1);
\
} \
} \
static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
show_sensor_##offset, set_sensor_##offset);
show_sensor_##offset, set_sensor_##offset);
...
@@ -505,25 +505,25 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
...
@@ -505,25 +505,25 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
#define show_fan_offset(offset) \
#define show_fan_offset(offset) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan(dev, buf,
0x##offset - 1);
\
return show_fan(dev, buf,
offset - 1);
\
} \
} \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_fan_min(dev, buf,
0x##
offset - 1); \
return show_fan_min(dev, buf, offset - 1); \
} \
} \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
{ \
{ \
return show_fan_div(dev, buf,
0x##
offset - 1); \
return show_fan_div(dev, buf, offset - 1); \
} \
} \
static ssize_t set_fan_##offset##_min (struct device *dev, \
static ssize_t set_fan_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_min(dev, buf, count,
0x##
offset - 1); \
return set_fan_min(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_fan_##offset##_div (struct device *dev, \
static ssize_t set_fan_##offset##_div (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_div(dev, buf, count,
0x##
offset - 1); \
return set_fan_div(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
...
...
drivers/i2c/chips/lm75.c
View file @
dc9f9ccd
...
@@ -74,7 +74,7 @@ static struct i2c_driver lm75_driver = {
...
@@ -74,7 +74,7 @@ static struct i2c_driver lm75_driver = {
.
detach_client
=
lm75_detach_client
,
.
detach_client
=
lm75_detach_client
,
};
};
static
int
lm75_id
=
0
;
static
int
lm75_id
;
#define show(value) \
#define show(value) \
static ssize_t show_##value(struct device *dev, char *buf) \
static ssize_t show_##value(struct device *dev, char *buf) \
...
...
drivers/i2c/chips/lm77.c
View file @
dc9f9ccd
...
@@ -83,7 +83,7 @@ static struct i2c_driver lm77_driver = {
...
@@ -83,7 +83,7 @@ static struct i2c_driver lm77_driver = {
.
detach_client
=
lm77_detach_client
,
.
detach_client
=
lm77_detach_client
,
};
};
static
int
lm77_id
=
0
;
static
int
lm77_id
;
/* straight from the datasheet */
/* straight from the datasheet */
#define LM77_TEMP_MIN (-55000)
#define LM77_TEMP_MIN (-55000)
...
...
drivers/i2c/chips/lm78.c
View file @
dc9f9ccd
...
@@ -229,29 +229,29 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
...
@@ -229,29 +229,29 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
static ssize_t \
static ssize_t \
show_in##offset (struct device *dev, char *buf) \
show_in##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in(dev, buf,
0x##
offset); \
return show_in(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
show_in##offset, NULL); \
show_in##offset, NULL); \
static ssize_t \
static ssize_t \
show_in##offset##_min (struct device *dev, char *buf) \
show_in##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_in_min(dev, buf,
0x##offset);
\
return show_in_min(dev, buf,
offset);
\
} \
} \
static ssize_t \
static ssize_t \
show_in##offset##_max (struct device *dev, char *buf) \
show_in##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_in_max(dev, buf,
0x##offset);
\
return show_in_max(dev, buf,
offset);
\
} \
} \
static ssize_t set_in##offset##_min (struct device *dev, \
static ssize_t set_in##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_min(dev, buf, count,
0x##
offset); \
return set_in_min(dev, buf, count, offset); \
} \
} \
static ssize_t set_in##offset##_max (struct device *dev, \
static ssize_t set_in##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_max(dev, buf, count,
0x##
offset); \
return set_in_max(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
show_in##offset##_min, set_in##offset##_min); \
show_in##offset##_min, set_in##offset##_min); \
...
@@ -375,20 +375,20 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
...
@@ -375,20 +375,20 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
#define show_fan_offset(offset) \
#define show_fan_offset(offset) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan(dev, buf,
0x##offset - 1);
\
return show_fan(dev, buf,
offset - 1);
\
} \
} \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_fan_min(dev, buf,
0x##
offset - 1); \
return show_fan_min(dev, buf, offset - 1); \
} \
} \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
{ \
{ \
return show_fan_div(dev, buf,
0x##
offset - 1); \
return show_fan_div(dev, buf, offset - 1); \
} \
} \
static ssize_t set_fan_##offset##_min (struct device *dev, \
static ssize_t set_fan_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_min(dev, buf, count,
0x##
offset - 1); \
return set_fan_min(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
...
@@ -692,26 +692,12 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
...
@@ -692,26 +692,12 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
/* Called when we have found a new LM78. It should set limits, etc. */
/* Called when we have found a new LM78. It should set limits, etc. */
static
void
lm78_init_client
(
struct
i2c_client
*
client
)
static
void
lm78_init_client
(
struct
i2c_client
*
client
)
{
{
struct
lm78_data
*
data
=
i2c_get_clientdata
(
client
);
u8
config
=
lm78_read_value
(
client
,
LM78_REG_CONFIG
);
int
vid
;
/* Reset all except Watchdog values and last conversion values
This sets fan-divs to 2, among others */
lm78_write_value
(
client
,
LM78_REG_CONFIG
,
0x80
);
vid
=
lm78_read_value
(
client
,
LM78_REG_VID_FANDIV
)
&
0x0f
;
if
(
data
->
type
==
lm79
)
vid
|=
(
lm78_read_value
(
client
,
LM78_REG_CHIPID
)
&
0x01
)
<<
4
;
else
vid
|=
0x10
;
vid
=
VID_FROM_REG
(
vid
);
/* Start monitoring */
/* Start monitoring */
lm78_write_value
(
client
,
LM78_REG_CONFIG
,
if
(
!
(
config
&
0x01
))
(
lm78_read_value
(
client
,
LM78_REG_CONFIG
)
&
0xf7
)
lm78_write_value
(
client
,
LM78_REG_CONFIG
,
|
0x01
);
(
config
&
0xf7
)
|
0x01
);
}
}
static
struct
lm78_data
*
lm78_update_device
(
struct
device
*
dev
)
static
struct
lm78_data
*
lm78_update_device
(
struct
device
*
dev
)
...
...
drivers/i2c/chips/lm80.c
View file @
dc9f9ccd
...
@@ -145,7 +145,7 @@ static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value);
...
@@ -145,7 +145,7 @@ static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value);
* Internal variables
* Internal variables
*/
*/
static
int
lm80_id
=
0
;
static
int
lm80_id
;
/*
/*
* Driver data (common to all clients)
* Driver data (common to all clients)
...
@@ -262,14 +262,15 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
...
@@ -262,14 +262,15 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
lm80_data
*
data
=
i2c_get_clientdata
(
client
);
struct
lm80_data
*
data
=
i2c_get_clientdata
(
client
);
unsigned
long
min
;
unsigned
long
min
,
val
;
u8
reg
;
u8
reg
;
/* Save fan_min */
/* Save fan_min */
min
=
FAN_FROM_REG
(
data
->
fan_min
[
nr
],
min
=
FAN_FROM_REG
(
data
->
fan_min
[
nr
],
DIV_FROM_REG
(
data
->
fan_div
[
nr
]));
DIV_FROM_REG
(
data
->
fan_div
[
nr
]));
data
->
fan_div
[
nr
]
=
DIV_TO_REG
(
simple_strtoul
(
buf
,
NULL
,
10
));
val
=
simple_strtoul
(
buf
,
NULL
,
10
);
data
->
fan_div
[
nr
]
=
DIV_TO_REG
(
val
);
reg
=
(
lm80_read_value
(
client
,
LM80_REG_FANDIV
)
&
~
(
3
<<
(
2
*
(
nr
+
1
))))
reg
=
(
lm80_read_value
(
client
,
LM80_REG_FANDIV
)
&
~
(
3
<<
(
2
*
(
nr
+
1
))))
|
(
data
->
fan_div
[
nr
]
<<
(
2
*
(
nr
+
1
)));
|
(
data
->
fan_div
[
nr
]
<<
(
2
*
(
nr
+
1
)));
...
...
drivers/i2c/chips/lm83.c
View file @
dc9f9ccd
...
@@ -80,13 +80,14 @@ SENSORS_INSMOD_1(lm83);
...
@@ -80,13 +80,14 @@ SENSORS_INSMOD_1(lm83);
/*
/*
* Conversions and various macros
* Conversions and various macros
* The LM83 uses signed 8-bit values.
* The LM83 uses signed 8-bit values
with LSB = 1 degree Celcius
.
*/
*/
#define TEMP_FROM_REG(val) (((val) > 127 ? (val) - 0x100 : (val)) * 1000)
#define TEMP_FROM_REG(val) ((val) * 1000)
#define TEMP_TO_REG(val) ((val) <= -50000 ? -50 + 0x100 : (val) >= 127000 ? 127 : \
#define TEMP_TO_REG(val) ((val) <= -128000 ? -128 : \
(val) > -500 ? ((val)+500) / 1000 : \
(val) >= 127000 ? 127 : \
((val)-500) / 1000 + 0x100)
(val) < 0 ? ((val) - 500) / 1000 : \
((val) + 500) / 1000)
static
const
u8
LM83_REG_R_TEMP
[]
=
{
static
const
u8
LM83_REG_R_TEMP
[]
=
{
LM83_REG_R_LOCAL_TEMP
,
LM83_REG_R_LOCAL_TEMP
,
...
@@ -142,9 +143,9 @@ struct lm83_data {
...
@@ -142,9 +143,9 @@ struct lm83_data {
unsigned
long
last_updated
;
/* in jiffies */
unsigned
long
last_updated
;
/* in jiffies */
/* registers values */
/* registers values */
u
8
temp_input
[
4
];
s
8
temp_input
[
4
];
u
8
temp_high
[
4
];
s
8
temp_high
[
4
];
u
8
temp_crit
;
s
8
temp_crit
;
u16
alarms
;
/* bitvector, combined */
u16
alarms
;
/* bitvector, combined */
};
};
...
@@ -152,7 +153,7 @@ struct lm83_data {
...
@@ -152,7 +153,7 @@ struct lm83_data {
* Internal variables
* Internal variables
*/
*/
static
int
lm83_id
=
0
;
static
int
lm83_id
;
/*
/*
* Sysfs stuff
* Sysfs stuff
...
@@ -180,7 +181,8 @@ static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \
...
@@ -180,7 +181,8 @@ static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct lm83_data *data = i2c_get_clientdata(client); \
struct lm83_data *data = i2c_get_clientdata(client); \
data->value = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
long val = simple_strtol(buf, NULL, 10); \
data->value = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, reg, data->value); \
i2c_smbus_write_byte_data(client, reg, data->value); \
return count; \
return count; \
}
}
...
...
drivers/i2c/chips/lm85.c
View file @
dc9f9ccd
...
@@ -405,7 +405,7 @@ static struct i2c_driver lm85_driver = {
...
@@ -405,7 +405,7 @@ static struct i2c_driver lm85_driver = {
};
};
/* Unique ID assigned to each LM85 detected */
/* Unique ID assigned to each LM85 detected */
static
int
lm85_id
=
0
;
static
int
lm85_id
;
/* 4 Fans */
/* 4 Fans */
...
@@ -437,16 +437,16 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
...
@@ -437,16 +437,16 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
#define show_fan_offset(offset) \
#define show_fan_offset(offset) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan(dev, buf,
0x##offset - 1);
\
return show_fan(dev, buf,
offset - 1);
\
} \
} \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_fan_min(dev, buf,
0x##
offset - 1); \
return show_fan_min(dev, buf, offset - 1); \
} \
} \
static ssize_t set_fan_##offset##_min (struct device *dev, \
static ssize_t set_fan_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_min(dev, buf, count,
0x##
offset - 1); \
return set_fan_min(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
...
@@ -527,20 +527,21 @@ static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
...
@@ -527,20 +527,21 @@ static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
#define show_pwm_reg(offset) \
#define show_pwm_reg(offset) \
static ssize_t show_pwm_##offset (struct device *dev, char *buf) \
static ssize_t show_pwm_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_pwm(dev, buf,
0x##offset - 1);
\
return show_pwm(dev, buf,
offset - 1);
\
} \
} \
static ssize_t set_pwm_##offset (struct device *dev, \
static ssize_t set_pwm_##offset (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_pwm(dev, buf, count,
0x##offset - 1);
\
return set_pwm(dev, buf, count,
offset - 1);
\
} \
} \
static ssize_t show_pwm_enable##offset (struct device *dev, char *buf) \
static ssize_t show_pwm_enable##offset (struct device *dev, char *buf) \
{ \
{ \
return show_pwm_enable(dev, buf,
0x##
offset - 1); \
return show_pwm_enable(dev, buf, offset - 1); \
} \
} \
static DEVICE_ATTR(
fan##offset##_pwm
, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(
pwm##offset
, S_IRUGO | S_IWUSR, \
show_pwm_##offset, set_pwm_##offset); \
show_pwm_##offset, set_pwm_##offset); \
static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO, show_pwm_enable##offset, NULL);
static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO, \
show_pwm_enable##offset, NULL);
show_pwm_reg
(
1
);
show_pwm_reg
(
1
);
show_pwm_reg
(
2
);
show_pwm_reg
(
2
);
...
@@ -594,25 +595,25 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
...
@@ -594,25 +595,25 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
#define show_in_reg(offset) \
#define show_in_reg(offset) \
static ssize_t show_in_##offset (struct device *dev, char *buf) \
static ssize_t show_in_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in(dev, buf,
0x##
offset); \
return show_in(dev, buf, offset); \
} \
} \
static ssize_t show_in_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_in_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_in_min(dev, buf,
0x##offset);
\
return show_in_min(dev, buf,
offset);
\
} \
} \
static ssize_t show_in_##offset##_max (struct device *dev, char *buf) \
static ssize_t show_in_##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_in_max(dev, buf,
0x##offset);
\
return show_in_max(dev, buf,
offset);
\
} \
} \
static ssize_t set_in_##offset##_min (struct device *dev, \
static ssize_t set_in_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_min(dev, buf, count,
0x##
offset); \
return set_in_min(dev, buf, count, offset); \
} \
} \
static ssize_t set_in_##offset##_max (struct device *dev, \
static ssize_t set_in_##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_max(dev, buf, count,
0x##
offset); \
return set_in_max(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in_##offset, NULL); \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in_##offset, NULL); \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
...
@@ -674,25 +675,25 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
...
@@ -674,25 +675,25 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
#define show_temp_reg(offset) \
#define show_temp_reg(offset) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_temp(dev, buf,
0x##offset - 1);
\
return show_temp(dev, buf,
offset - 1);
\
} \
} \
static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_temp_min(dev, buf,
0x##
offset - 1); \
return show_temp_min(dev, buf, offset - 1); \
} \
} \
static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \
static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_temp_max(dev, buf,
0x##
offset - 1); \
return show_temp_max(dev, buf, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_min (struct device *dev, \
static ssize_t set_temp_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_min(dev, buf, count,
0x##
offset - 1); \
return set_temp_min(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_max (struct device *dev, \
static ssize_t set_temp_##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_max(dev, buf, count,
0x##
offset - 1); \
return set_temp_max(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
...
@@ -707,6 +708,8 @@ show_temp_reg(3);
...
@@ -707,6 +708,8 @@ show_temp_reg(3);
int
lm85_attach_adapter
(
struct
i2c_adapter
*
adapter
)
int
lm85_attach_adapter
(
struct
i2c_adapter
*
adapter
)
{
{
if
(
!
(
adapter
->
class
&
I2C_CLASS_HWMON
))
return
0
;
return
i2c_detect
(
adapter
,
&
addr_data
,
lm85_detect
);
return
i2c_detect
(
adapter
,
&
addr_data
,
lm85_detect
);
}
}
...
@@ -843,12 +846,12 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
...
@@ -843,12 +846,12 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan2_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan2_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan3_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan3_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan4_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan4_min
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan1_pwm
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan2_pwm
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan3_pwm
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm3
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan1_pwm
_enable
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm1
_enable
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan2_pwm
_enable
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm2
_enable
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan3_pwm
_enable
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm3
_enable
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in0_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in0_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in1_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in1_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in2_input
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in2_input
);
...
...
drivers/i2c/chips/lm90.c
View file @
dc9f9ccd
...
@@ -127,19 +127,24 @@ SENSORS_INSMOD_5(lm90, adm1032, lm99, lm86, max6657);
...
@@ -127,19 +127,24 @@ SENSORS_INSMOD_5(lm90, adm1032, lm99, lm86, max6657);
/*
/*
* Conversions and various macros
* Conversions and various macros
* The LM90 uses signed 8-bit values for the local temperatures,
* For local temperatures and limits, critical limits and the hysteresis
* and signed 11-bit values for the remote temperatures (except
* value, the LM90 uses signed 8-bit values with LSB = 1 degree Celcius.
* T_CRIT). Note that TEMP2_TO_REG does not round values, but
* For remote temperatures and limits, it uses signed 11-bit values with
* stick to the nearest lower value instead. Fixing it is just
* LSB = 0.125 degree Celcius, left-justified in 16-bit registers.
* not worth it.
*/
*/
#define TEMP1_FROM_REG(val) ((val & 0x80 ? val-0x100 : val) * 1000)
#define TEMP1_FROM_REG(val) ((val) * 1000)
#define TEMP1_TO_REG(val) ((val < 0 ? val+0x100*1000 : val) / 1000)
#define TEMP1_TO_REG(val) ((val) <= -128000 ? -128 : \
#define TEMP2_FROM_REG(val) (((val & 0x8000 ? val-0x10000 : val) >> 5) * 125)
(val) >= 127000 ? 127 : \
#define TEMP2_TO_REG(val) ((((val / 125) << 5) + (val < 0 ? 0x10000 : 0)) & 0xFFE0)
(val) < 0 ? ((val) - 500) / 1000 : \
#define HYST_FROM_REG(val) (val * 1000)
((val) + 500) / 1000)
#define HYST_TO_REG(val) (val <= 0 ? 0 : val >= 31000 ? 31 : val / 1000)
#define TEMP2_FROM_REG(val) ((val) / 32 * 125)
#define TEMP2_TO_REG(val) ((val) <= -128000 ? 0x8000 : \
(val) >= 127875 ? 0x7FE0 : \
(val) < 0 ? ((val) - 62) / 125 * 32 : \
((val) + 62) / 125 * 32)
#define HYST_TO_REG(val) ((val) <= 0 ? 0 : (val) >= 30500 ? 31 : \
((val) + 500) / 1000)
/*
/*
* Functions declaration
* Functions declaration
...
@@ -176,9 +181,9 @@ struct lm90_data {
...
@@ -176,9 +181,9 @@ struct lm90_data {
unsigned
long
last_updated
;
/* in jiffies */
unsigned
long
last_updated
;
/* in jiffies */
/* registers values */
/* registers values */
u
8
temp_input1
,
temp_low1
,
temp_high1
;
/* local */
s
8
temp_input1
,
temp_low1
,
temp_high1
;
/* local */
u
16
temp_input2
,
temp_low2
,
temp_high2
;
/* remote, combined */
s
16
temp_input2
,
temp_low2
,
temp_high2
;
/* remote, combined */
u
8
temp_crit1
,
temp_crit2
;
s
8
temp_crit1
,
temp_crit2
;
u8
temp_hyst
;
u8
temp_hyst
;
u16
alarms
;
/* bitvector, combined */
u16
alarms
;
/* bitvector, combined */
};
};
...
@@ -187,7 +192,7 @@ struct lm90_data {
...
@@ -187,7 +192,7 @@ struct lm90_data {
* Internal variables
* Internal variables
*/
*/
static
int
lm90_id
=
0
;
static
int
lm90_id
;
/*
/*
* Sysfs stuff
* Sysfs stuff
...
@@ -214,7 +219,8 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
...
@@ -214,7 +219,8 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct lm90_data *data = i2c_get_clientdata(client); \
struct lm90_data *data = i2c_get_clientdata(client); \
data->value = TEMP1_TO_REG(simple_strtol(buf, NULL, 10)); \
long val = simple_strtol(buf, NULL, 10); \
data->value = TEMP1_TO_REG(val); \
i2c_smbus_write_byte_data(client, reg, data->value); \
i2c_smbus_write_byte_data(client, reg, data->value); \
return count; \
return count; \
}
}
...
@@ -224,7 +230,8 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
...
@@ -224,7 +230,8 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct lm90_data *data = i2c_get_clientdata(client); \
struct lm90_data *data = i2c_get_clientdata(client); \
data->value = TEMP2_TO_REG(simple_strtol(buf, NULL, 10)); \
long val = simple_strtol(buf, NULL, 10); \
data->value = TEMP2_TO_REG(val); \
i2c_smbus_write_byte_data(client, regh, data->value >> 8); \
i2c_smbus_write_byte_data(client, regh, data->value >> 8); \
i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \
i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \
return count; \
return count; \
...
@@ -241,7 +248,7 @@ static ssize_t show_##value(struct device *dev, char *buf) \
...
@@ -241,7 +248,7 @@ static ssize_t show_##value(struct device *dev, char *buf) \
{ \
{ \
struct lm90_data *data = lm90_update_device(dev); \
struct lm90_data *data = lm90_update_device(dev); \
return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \
return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \
-
HYST
_FROM_REG(data->temp_hyst)); \
-
TEMP1
_FROM_REG(data->temp_hyst)); \
}
}
show_temp_hyst
(
temp_hyst1
,
temp_crit1
);
show_temp_hyst
(
temp_hyst1
,
temp_crit1
);
show_temp_hyst
(
temp_hyst2
,
temp_crit2
);
show_temp_hyst
(
temp_hyst2
,
temp_crit2
);
...
...
drivers/i2c/chips/max1619.c
View file @
dc9f9ccd
...
@@ -120,7 +120,7 @@ struct max1619_data {
...
@@ -120,7 +120,7 @@ struct max1619_data {
* Internal variables
* Internal variables
*/
*/
static
int
max1619_id
=
0
;
static
int
max1619_id
;
/*
/*
* Sysfs stuff
* Sysfs stuff
...
@@ -145,7 +145,8 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
...
@@ -145,7 +145,8 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct i2c_client *client = to_i2c_client(dev); \
struct max1619_data *data = i2c_get_clientdata(client); \
struct max1619_data *data = i2c_get_clientdata(client); \
data->value = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
long val = simple_strtol(buf, NULL, 10); \
data->value = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, reg, data->value); \
i2c_smbus_write_byte_data(client, reg, data->value); \
return count; \
return count; \
}
}
...
...
drivers/i2c/chips/pcf8574.c
View file @
dc9f9ccd
...
@@ -77,7 +77,7 @@ static struct i2c_driver pcf8574_driver = {
...
@@ -77,7 +77,7 @@ static struct i2c_driver pcf8574_driver = {
.
detach_client
=
pcf8574_detach_client
,
.
detach_client
=
pcf8574_detach_client
,
};
};
static
int
pcf8574_id
=
0
;
static
int
pcf8574_id
;
/* following are the sysfs callback functions */
/* following are the sysfs callback functions */
static
ssize_t
show_read
(
struct
device
*
dev
,
char
*
buf
)
static
ssize_t
show_read
(
struct
device
*
dev
,
char
*
buf
)
...
...
drivers/i2c/chips/pcf8591.c
View file @
dc9f9ccd
...
@@ -99,7 +99,7 @@ static struct i2c_driver pcf8591_driver = {
...
@@ -99,7 +99,7 @@ static struct i2c_driver pcf8591_driver = {
.
detach_client
=
pcf8591_detach_client
,
.
detach_client
=
pcf8591_detach_client
,
};
};
static
int
pcf8591_id
=
0
;
static
int
pcf8591_id
;
/* following are the sysfs callback functions */
/* following are the sysfs callback functions */
#define show_in_channel(channel) \
#define show_in_channel(channel) \
...
...
drivers/i2c/chips/smsc47m1.c
View file @
dc9f9ccd
...
@@ -182,13 +182,13 @@ static ssize_t get_fan_div(struct device *dev, char *buf, int nr)
...
@@ -182,13 +182,13 @@ static ssize_t get_fan_div(struct device *dev, char *buf, int nr)
return
sprintf
(
buf
,
"%d
\n
"
,
DIV_FROM_REG
(
data
->
fan_div
[
nr
]));
return
sprintf
(
buf
,
"%d
\n
"
,
DIV_FROM_REG
(
data
->
fan_div
[
nr
]));
}
}
static
ssize_t
get_
fan_
pwm
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
static
ssize_t
get_pwm
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
{
{
struct
smsc47m1_data
*
data
=
smsc47m1_update_device
(
dev
,
0
);
struct
smsc47m1_data
*
data
=
smsc47m1_update_device
(
dev
,
0
);
return
sprintf
(
buf
,
"%d
\n
"
,
PWM_FROM_REG
(
data
->
pwm
[
nr
]));
return
sprintf
(
buf
,
"%d
\n
"
,
PWM_FROM_REG
(
data
->
pwm
[
nr
]));
}
}
static
ssize_t
get_
fan_
pwm_en
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
static
ssize_t
get_pwm_en
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
{
{
struct
smsc47m1_data
*
data
=
smsc47m1_update_device
(
dev
,
0
);
struct
smsc47m1_data
*
data
=
smsc47m1_update_device
(
dev
,
0
);
return
sprintf
(
buf
,
"%d
\n
"
,
PWM_EN_FROM_REG
(
data
->
pwm
[
nr
]));
return
sprintf
(
buf
,
"%d
\n
"
,
PWM_EN_FROM_REG
(
data
->
pwm
[
nr
]));
...
@@ -256,7 +256,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
...
@@ -256,7 +256,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
return
count
;
return
count
;
}
}
static
ssize_t
set_
fan_
pwm
(
struct
device
*
dev
,
const
char
*
buf
,
static
ssize_t
set_pwm
(
struct
device
*
dev
,
const
char
*
buf
,
size_t
count
,
int
nr
)
size_t
count
,
int
nr
)
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
...
@@ -275,7 +275,7 @@ static ssize_t set_fan_pwm(struct device *dev, const char *buf,
...
@@ -275,7 +275,7 @@ static ssize_t set_fan_pwm(struct device *dev, const char *buf,
return
count
;
return
count
;
}
}
static
ssize_t
set_
fan_
pwm_en
(
struct
device
*
dev
,
const
char
*
buf
,
static
ssize_t
set_pwm_en
(
struct
device
*
dev
,
const
char
*
buf
,
size_t
count
,
int
nr
)
size_t
count
,
int
nr
)
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
...
@@ -298,43 +298,43 @@ static ssize_t set_fan_pwm_en(struct device *dev, const char *buf,
...
@@ -298,43 +298,43 @@ static ssize_t set_fan_pwm_en(struct device *dev, const char *buf,
#define fan_present(offset) \
#define fan_present(offset) \
static ssize_t get_fan##offset (struct device *dev, char *buf) \
static ssize_t get_fan##offset (struct device *dev, char *buf) \
{ \
{ \
return get_fan(dev, buf,
0x##offset - 1);
\
return get_fan(dev, buf,
offset - 1);
\
} \
} \
static ssize_t get_fan##offset##_min (struct device *dev, char *buf) \
static ssize_t get_fan##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return get_fan_min(dev, buf,
0x##
offset - 1); \
return get_fan_min(dev, buf, offset - 1); \
} \
} \
static ssize_t set_fan##offset##_min (struct device *dev, \
static ssize_t set_fan##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_min(dev, buf, count,
0x##
offset - 1); \
return set_fan_min(dev, buf, count, offset - 1); \
} \
} \
static ssize_t get_fan##offset##_div (struct device *dev, char *buf) \
static ssize_t get_fan##offset##_div (struct device *dev, char *buf) \
{ \
{ \
return get_fan_div(dev, buf,
0x##
offset - 1); \
return get_fan_div(dev, buf, offset - 1); \
} \
} \
static ssize_t set_fan##offset##_div (struct device *dev, \
static ssize_t set_fan##offset##_div (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_div(dev, buf, count,
0x##
offset - 1); \
return set_fan_div(dev, buf, count, offset - 1); \
} \
} \
static ssize_t get_
fan##offset##_pwm (struct device *dev, char *buf)
\
static ssize_t get_
pwm##offset (struct device *dev, char *buf)
\
{ \
{ \
return get_
fan_pwm(dev, buf, 0x##offset - 1);
\
return get_
pwm(dev, buf, offset - 1);
\
} \
} \
static ssize_t set_
fan##offset##_pwm (struct device *dev,
\
static ssize_t set_
pwm##offset (struct device *dev,
\
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_
fan_pwm(dev, buf, count, 0x##offset - 1);
\
return set_
pwm(dev, buf, count, offset - 1);
\
} \
} \
static ssize_t get_
fan##offset##_pwm
_en (struct device *dev, char *buf) \
static ssize_t get_
pwm##offset##
_en (struct device *dev, char *buf) \
{ \
{ \
return get_
fan_pwm_en(dev, buf, 0x##offset - 1);
\
return get_
pwm_en(dev, buf, offset - 1);
\
} \
} \
static ssize_t set_
fan##offset##_pwm
_en (struct device *dev, \
static ssize_t set_
pwm##offset##
_en (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_
fan_pwm_en(dev, buf, count, 0x##offset - 1);
\
return set_
pwm_en(dev, buf, count, offset - 1);
\
} \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, get_fan##offset, \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, get_fan##offset, \
NULL); \
NULL); \
...
@@ -342,10 +342,10 @@ static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
...
@@ -342,10 +342,10 @@ static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
get_fan##offset##_min, set_fan##offset##_min); \
get_fan##offset##_min, set_fan##offset##_min); \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
get_fan##offset##_div, set_fan##offset##_div); \
get_fan##offset##_div, set_fan##offset##_div); \
static DEVICE_ATTR(
fan##offset##_pwm, S_IRUGO | S_IWUSR,
\
static DEVICE_ATTR(
pwm##offset, S_IRUGO | S_IWUSR,
\
get_
fan##offset##_pwm, set_fan##offset##_pwm);
\
get_
pwm##offset, set_pwm##offset);
\
static DEVICE_ATTR(
fan##offset##_pwm
_enable, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(
pwm##offset##
_enable, S_IRUGO | S_IWUSR, \
get_
fan##offset##_pwm_en, set_fan##offset##_pwm
_en);
get_
pwm##offset##_en, set_pwm##offset##
_en);
fan_present
(
1
);
fan_present
(
1
);
fan_present
(
2
);
fan_present
(
2
);
...
@@ -462,15 +462,15 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -462,15 +462,15 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
if
((
smsc47m1_read_value
(
new_client
,
SMSC47M1_REG_PPIN
(
0
))
&
0x05
)
if
((
smsc47m1_read_value
(
new_client
,
SMSC47M1_REG_PPIN
(
0
))
&
0x05
)
==
0x04
)
{
==
0x04
)
{
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan1_pwm
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan1_pwm
_enable
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm1
_enable
);
}
else
}
else
dev_dbg
(
&
new_client
->
dev
,
"PWM 1 not enabled by hardware, "
dev_dbg
(
&
new_client
->
dev
,
"PWM 1 not enabled by hardware, "
"skipping
\n
"
);
"skipping
\n
"
);
if
((
smsc47m1_read_value
(
new_client
,
SMSC47M1_REG_PPIN
(
1
))
&
0x05
)
if
((
smsc47m1_read_value
(
new_client
,
SMSC47M1_REG_PPIN
(
1
))
&
0x05
)
==
0x04
)
{
==
0x04
)
{
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan2_pwm
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
fan2_pwm
_enable
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_
pwm2
_enable
);
}
else
}
else
dev_dbg
(
&
new_client
->
dev
,
"PWM 2 not enabled by hardware, "
dev_dbg
(
&
new_client
->
dev
,
"PWM 2 not enabled by hardware, "
"skipping
\n
"
);
"skipping
\n
"
);
...
...
drivers/i2c/chips/via686a.c
View file @
dc9f9ccd
...
@@ -383,27 +383,27 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
...
@@ -383,27 +383,27 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
static ssize_t \
static ssize_t \
show_in##offset (struct device *dev, char *buf) \
show_in##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in(dev, buf,
0x##
offset); \
return show_in(dev, buf, offset); \
} \
} \
static ssize_t \
static ssize_t \
show_in##offset##_min (struct device *dev, char *buf) \
show_in##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_in_min(dev, buf,
0x##
offset); \
return show_in_min(dev, buf, offset); \
} \
} \
static ssize_t \
static ssize_t \
show_in##offset##_max (struct device *dev, char *buf) \
show_in##offset##_max (struct device *dev, char *buf) \
{ \
{ \
return show_in_max(dev, buf,
0x##
offset); \
return show_in_max(dev, buf, offset); \
} \
} \
static ssize_t set_in##offset##_min (struct device *dev, \
static ssize_t set_in##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_min(dev, buf, count,
0x##
offset); \
return set_in_min(dev, buf, count, offset); \
} \
} \
static ssize_t set_in##offset##_max (struct device *dev, \
static ssize_t set_in##offset##_max (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_in_max(dev, buf, count,
0x##
offset); \
return set_in_max(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);\
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);\
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
...
@@ -451,27 +451,27 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf,
...
@@ -451,27 +451,27 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf,
#define show_temp_offset(offset) \
#define show_temp_offset(offset) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_temp(dev, buf,
0x##offset - 1);
\
return show_temp(dev, buf,
offset - 1);
\
} \
} \
static ssize_t \
static ssize_t \
show_temp_##offset##_over (struct device *dev, char *buf) \
show_temp_##offset##_over (struct device *dev, char *buf) \
{ \
{ \
return show_temp_over(dev, buf,
0x##
offset - 1); \
return show_temp_over(dev, buf, offset - 1); \
} \
} \
static ssize_t \
static ssize_t \
show_temp_##offset##_hyst (struct device *dev, char *buf) \
show_temp_##offset##_hyst (struct device *dev, char *buf) \
{ \
{ \
return show_temp_hyst(dev, buf,
0x##
offset - 1); \
return show_temp_hyst(dev, buf, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_over (struct device *dev, \
static ssize_t set_temp_##offset##_over (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_over(dev, buf, count,
0x##
offset - 1); \
return set_temp_over(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_temp_##offset##_hyst (struct device *dev, \
static ssize_t set_temp_##offset##_hyst (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_temp_hyst(dev, buf, count,
0x##
offset - 1); \
return set_temp_hyst(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);\
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);\
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
...
@@ -522,25 +522,25 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
...
@@ -522,25 +522,25 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
#define show_fan_offset(offset) \
#define show_fan_offset(offset) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan(dev, buf,
0x##offset - 1);
\
return show_fan(dev, buf,
offset - 1);
\
} \
} \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
{ \
{ \
return show_fan_min(dev, buf,
0x##
offset - 1); \
return show_fan_min(dev, buf, offset - 1); \
} \
} \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
{ \
{ \
return show_fan_div(dev, buf,
0x##
offset - 1); \
return show_fan_div(dev, buf, offset - 1); \
} \
} \
static ssize_t set_fan_##offset##_min (struct device *dev, \
static ssize_t set_fan_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_min(dev, buf, count,
0x##
offset - 1); \
return set_fan_min(dev, buf, count, offset - 1); \
} \
} \
static ssize_t set_fan_##offset##_div (struct device *dev, \
static ssize_t set_fan_##offset##_div (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return set_fan_div(dev, buf, count,
0x##
offset - 1); \
return set_fan_div(dev, buf, count, offset - 1); \
} \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
...
...
drivers/i2c/chips/w83627hf.c
View file @
dc9f9ccd
...
@@ -369,20 +369,20 @@ store_in_reg(MAX, max)
...
@@ -369,20 +369,20 @@ store_in_reg(MAX, max)
static ssize_t \
static ssize_t \
show_regs_in_##offset (struct device *dev, char *buf) \
show_regs_in_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in(dev, buf,
0x##
offset); \
return show_in(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
#define sysfs_in_reg_offset(reg, offset) \
#define sysfs_in_reg_offset(reg, offset) \
static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in_##reg (dev, buf,
0x##
offset); \
return show_in_##reg (dev, buf, offset); \
} \
} \
static ssize_t \
static ssize_t \
store_regs_in_##reg##offset (struct device *dev, \
store_regs_in_##reg##offset (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return store_in_##reg (dev, buf, count,
0x##
offset); \
return store_in_##reg (dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, \
static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, \
show_regs_in_##reg##offset, store_regs_in_##reg##offset);
show_regs_in_##reg##offset, store_regs_in_##reg##offset);
...
@@ -521,19 +521,19 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
...
@@ -521,19 +521,19 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
#define sysfs_fan_offset(offset) \
#define sysfs_fan_offset(offset) \
static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \
static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan(dev, buf,
0x##
offset); \
return show_fan(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
#define sysfs_fan_min_offset(offset) \
#define sysfs_fan_min_offset(offset) \
static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan_min(dev, buf,
0x##
offset); \
return show_fan_min(dev, buf, offset); \
} \
} \
static ssize_t \
static ssize_t \
store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \
store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \
{ \
{ \
return store_fan_min(dev, buf, count,
0x##
offset); \
return store_fan_min(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
show_regs_fan_min##offset, store_regs_fan_min##offset);
show_regs_fan_min##offset, store_regs_fan_min##offset);
...
@@ -595,20 +595,20 @@ store_temp_reg(HYST, max_hyst);
...
@@ -595,20 +595,20 @@ store_temp_reg(HYST, max_hyst);
static ssize_t \
static ssize_t \
show_regs_temp_##offset (struct device *dev, char *buf) \
show_regs_temp_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_temp(dev, buf,
0x##
offset); \
return show_temp(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
#define sysfs_temp_reg_offset(reg, offset) \
#define sysfs_temp_reg_offset(reg, offset) \
static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
{ \
{ \
return show_temp_##reg (dev, buf,
0x##
offset); \
return show_temp_##reg (dev, buf, offset); \
} \
} \
static ssize_t \
static ssize_t \
store_regs_temp_##reg##offset (struct device *dev, \
store_regs_temp_##reg##offset (struct device *dev, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
return store_temp_##reg (dev, buf, count,
0x##
offset); \
return store_temp_##reg (dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);
show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);
...
@@ -845,7 +845,7 @@ store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \
...
@@ -845,7 +845,7 @@ store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \
{ \
{ \
return store_pwm_reg(dev, buf, count, offset); \
return store_pwm_reg(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(
fan##offset##_pwm
, S_IRUGO | S_IWUSR, \
static DEVICE_ATTR(
pwm##offset
, S_IRUGO | S_IWUSR, \
show_regs_pwm_##offset, store_regs_pwm_##offset);
show_regs_pwm_##offset, store_regs_pwm_##offset);
sysfs_pwm
(
1
);
sysfs_pwm
(
1
);
...
@@ -854,7 +854,7 @@ sysfs_pwm(3);
...
@@ -854,7 +854,7 @@ sysfs_pwm(3);
#define device_create_file_pwm(client, offset) \
#define device_create_file_pwm(client, offset) \
do { \
do { \
device_create_file(&client->dev, &dev_attr_
fan##offset##_pwm
); \
device_create_file(&client->dev, &dev_attr_
pwm##offset
); \
} while (0)
} while (0)
static
ssize_t
static
ssize_t
...
...
drivers/i2c/chips/w83781d.c
View file @
dc9f9ccd
...
@@ -318,18 +318,18 @@ store_in_reg(MAX, max);
...
@@ -318,18 +318,18 @@ store_in_reg(MAX, max);
static ssize_t \
static ssize_t \
show_regs_in_##offset (struct device *dev, char *buf) \
show_regs_in_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in(dev, buf,
0x##
offset); \
return show_in(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
#define sysfs_in_reg_offset(reg, offset) \
#define sysfs_in_reg_offset(reg, offset) \
static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
{ \
{ \
return show_in_##reg (dev, buf,
0x##
offset); \
return show_in_##reg (dev, buf, offset); \
} \
} \
static ssize_t store_regs_in_##reg##offset (struct device *dev, const char *buf, size_t count) \
static ssize_t store_regs_in_##reg##offset (struct device *dev, const char *buf, size_t count) \
{ \
{ \
return store_in_##reg (dev, buf, count,
0x##
offset); \
return store_in_##reg (dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_in_##reg##offset, store_regs_in_##reg##offset);
static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_in_##reg##offset, store_regs_in_##reg##offset);
...
@@ -384,18 +384,18 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
...
@@ -384,18 +384,18 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
#define sysfs_fan_offset(offset) \
#define sysfs_fan_offset(offset) \
static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \
static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan(dev, buf,
0x##
offset); \
return show_fan(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
#define sysfs_fan_min_offset(offset) \
#define sysfs_fan_min_offset(offset) \
static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
{ \
{ \
return show_fan_min(dev, buf,
0x##
offset); \
return show_fan_min(dev, buf, offset); \
} \
} \
static ssize_t store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \
static ssize_t store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \
{ \
{ \
return store_fan_min(dev, buf, count,
0x##
offset); \
return store_fan_min(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, show_regs_fan_min##offset, store_regs_fan_min##offset);
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, show_regs_fan_min##offset, store_regs_fan_min##offset);
...
@@ -464,18 +464,18 @@ store_temp_reg(HYST, max_hyst);
...
@@ -464,18 +464,18 @@ store_temp_reg(HYST, max_hyst);
static ssize_t \
static ssize_t \
show_regs_temp_##offset (struct device *dev, char *buf) \
show_regs_temp_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_temp(dev, buf,
0x##
offset); \
return show_temp(dev, buf, offset); \
} \
} \
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
#define sysfs_temp_reg_offset(reg, offset) \
#define sysfs_temp_reg_offset(reg, offset) \
static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
{ \
{ \
return show_temp_##reg (dev, buf,
0x##
offset); \
return show_temp_##reg (dev, buf, offset); \
} \
} \
static ssize_t store_regs_temp_##reg##offset (struct device *dev, const char *buf, size_t count) \
static ssize_t store_regs_temp_##reg##offset (struct device *dev, const char *buf, size_t count) \
{ \
{ \
return store_temp_##reg (dev, buf, count,
0x##
offset); \
return store_temp_##reg (dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);
static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);
...
@@ -740,22 +740,26 @@ static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \
...
@@ -740,22 +740,26 @@ static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_pwm_reg(dev, buf, offset); \
return show_pwm_reg(dev, buf, offset); \
} \
} \
static ssize_t store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \
static ssize_t store_regs_pwm_##offset (struct device *dev, \
const char *buf, size_t count) \
{ \
{ \
return store_pwm_reg(dev, buf, count, offset); \
return store_pwm_reg(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, show_regs_pwm_##offset, store_regs_pwm_##offset);
static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
show_regs_pwm_##offset, store_regs_pwm_##offset);
#define sysfs_pwmenable(offset) \
#define sysfs_pwmenable(offset) \
static ssize_t show_regs_pwmenable_##offset (struct device *dev, char *buf) \
static ssize_t show_regs_pwmenable_##offset (struct device *dev, char *buf) \
{ \
{ \
return show_pwmenable_reg(dev, buf, offset); \
return show_pwmenable_reg(dev, buf, offset); \
} \
} \
static ssize_t store_regs_pwmenable_##offset (struct device *dev, const char *buf, size_t count) \
static ssize_t store_regs_pwmenable_##offset (struct device *dev, \
const char *buf, size_t count) \
{ \
{ \
return store_pwmenable_reg(dev, buf, count, offset); \
return store_pwmenable_reg(dev, buf, count, offset); \
} \
} \
static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO | S_IWUSR, show_regs_pwmenable_##offset, store_regs_pwmenable_##offset);
static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
show_regs_pwmenable_##offset, store_regs_pwmenable_##offset);
sysfs_pwm
(
1
);
sysfs_pwm
(
1
);
sysfs_pwm
(
2
);
sysfs_pwm
(
2
);
...
@@ -765,12 +769,12 @@ sysfs_pwm(4);
...
@@ -765,12 +769,12 @@ sysfs_pwm(4);
#define device_create_file_pwm(client, offset) \
#define device_create_file_pwm(client, offset) \
do { \
do { \
device_create_file(&client->dev, &dev_attr_
fan##offset##_pwm
); \
device_create_file(&client->dev, &dev_attr_
pwm##offset
); \
} while (0)
} while (0)
#define device_create_file_pwmenable(client, offset) \
#define device_create_file_pwmenable(client, offset) \
do { \
do { \
device_create_file(&client->dev, &dev_attr_
fan##offset##_pwm
_enable); \
device_create_file(&client->dev, &dev_attr_
pwm##offset##
_enable); \
} while (0)
} while (0)
static
ssize_t
static
ssize_t
...
@@ -1062,6 +1066,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -1062,6 +1066,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
if
(
is_isa
)
if
(
is_isa
)
if
(
!
request_region
(
address
,
W83781D_EXTENT
,
"w83781d"
))
{
if
(
!
request_region
(
address
,
W83781D_EXTENT
,
"w83781d"
))
{
dev_dbg
(
&
adapter
->
dev
,
"Request of region "
"0x%x-0x%x for w83781d failed
\n
"
,
address
,
address
+
W83781D_EXTENT
-
1
);
err
=
-
EBUSY
;
err
=
-
EBUSY
;
goto
ERROR0
;
goto
ERROR0
;
}
}
...
@@ -1075,15 +1082,11 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -1075,15 +1082,11 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
/* We need the timeouts for at least some LM78-like
/* We need the timeouts for at least some LM78-like
chips. But only if we read 'undefined' registers. */
chips. But only if we read 'undefined' registers. */
i
=
inb_p
(
address
+
1
);
i
=
inb_p
(
address
+
1
);
if
(
inb_p
(
address
+
2
)
!=
i
)
{
if
(
inb_p
(
address
+
2
)
!=
i
err
=
-
ENODEV
;
||
inb_p
(
address
+
3
)
!=
i
goto
ERROR1
;
||
inb_p
(
address
+
7
)
!=
i
)
{
}
dev_dbg
(
&
adapter
->
dev
,
"Detection of w83781d "
if
(
inb_p
(
address
+
3
)
!=
i
)
{
"chip failed at step 1
\n
"
);
err
=
-
ENODEV
;
goto
ERROR1
;
}
if
(
inb_p
(
address
+
7
)
!=
i
)
{
err
=
-
ENODEV
;
err
=
-
ENODEV
;
goto
ERROR1
;
goto
ERROR1
;
}
}
...
@@ -1092,8 +1095,13 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -1092,8 +1095,13 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
/* Let's just hope nothing breaks here */
/* Let's just hope nothing breaks here */
i
=
inb_p
(
address
+
5
)
&
0x7f
;
i
=
inb_p
(
address
+
5
)
&
0x7f
;
outb_p
(
~
i
&
0x7f
,
address
+
5
);
outb_p
(
~
i
&
0x7f
,
address
+
5
);
if
((
inb_p
(
address
+
5
)
&
0x7f
)
!=
(
~
i
&
0x7f
))
{
val2
=
inb_p
(
address
+
5
)
&
0x7f
;
if
(
val2
!=
(
~
i
&
0x7f
))
{
outb_p
(
i
,
address
+
5
);
outb_p
(
i
,
address
+
5
);
dev_dbg
(
&
adapter
->
dev
,
"Detection of w83781d "
"chip failed at step 2 (0x%x != "
"0x%x at 0x%x)
\n
"
,
val2
,
~
i
&
0x7f
,
address
+
5
);
err
=
-
ENODEV
;
err
=
-
ENODEV
;
goto
ERROR1
;
goto
ERROR1
;
}
}
...
@@ -1125,7 +1133,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -1125,7 +1133,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
force_*=... parameter, and the Winbond will be reset to the right
force_*=... parameter, and the Winbond will be reset to the right
bank. */
bank. */
if
(
kind
<
0
)
{
if
(
kind
<
0
)
{
if
(
w83781d_read_value
(
new_client
,
W83781D_REG_CONFIG
)
&
0x80
){
if
(
w83781d_read_value
(
new_client
,
W83781D_REG_CONFIG
)
&
0x80
)
{
dev_dbg
(
&
new_client
->
dev
,
"Detection failed at step "
"3
\n
"
);
err
=
-
ENODEV
;
err
=
-
ENODEV
;
goto
ERROR2
;
goto
ERROR2
;
}
}
...
@@ -1135,6 +1145,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -1135,6 +1145,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
if
((
!
(
val1
&
0x07
))
&&
if
((
!
(
val1
&
0x07
))
&&
(((
!
(
val1
&
0x80
))
&&
(
val2
!=
0xa3
)
&&
(
val2
!=
0xc3
))
(((
!
(
val1
&
0x80
))
&&
(
val2
!=
0xa3
)
&&
(
val2
!=
0xc3
))
||
((
val1
&
0x80
)
&&
(
val2
!=
0x5c
)
&&
(
val2
!=
0x12
))))
{
||
((
val1
&
0x80
)
&&
(
val2
!=
0x5c
)
&&
(
val2
!=
0x12
))))
{
dev_dbg
(
&
new_client
->
dev
,
"Detection failed at step "
"4
\n
"
);
err
=
-
ENODEV
;
err
=
-
ENODEV
;
goto
ERROR2
;
goto
ERROR2
;
}
}
...
@@ -1144,6 +1156,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -1144,6 +1156,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
((
val1
&
0x80
)
&&
(
val2
==
0x5c
))))
{
((
val1
&
0x80
)
&&
(
val2
==
0x5c
))))
{
if
(
w83781d_read_value
if
(
w83781d_read_value
(
new_client
,
W83781D_REG_I2C_ADDR
)
!=
address
)
{
(
new_client
,
W83781D_REG_I2C_ADDR
)
!=
address
)
{
dev_dbg
(
&
new_client
->
dev
,
"Detection failed "
"at step 5
\n
"
);
err
=
-
ENODEV
;
err
=
-
ENODEV
;
goto
ERROR2
;
goto
ERROR2
;
}
}
...
@@ -1166,6 +1180,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -1166,6 +1180,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
else
if
(
val2
==
0x12
)
else
if
(
val2
==
0x12
)
vendid
=
asus
;
vendid
=
asus
;
else
{
else
{
dev_dbg
(
&
new_client
->
dev
,
"Chip was made by neither "
"Winbond nor Asus?
\n
"
);
err
=
-
ENODEV
;
err
=
-
ENODEV
;
goto
ERROR2
;
goto
ERROR2
;
}
}
...
@@ -1186,10 +1202,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
...
@@ -1186,10 +1202,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
kind
=
w83697hf
;
kind
=
w83697hf
;
else
{
else
{
if
(
kind
==
0
)
if
(
kind
==
0
)
dev_warn
(
&
new_client
->
dev
,
dev_warn
(
&
new_client
->
dev
,
"Ignoring 'force' "
"Ignoring 'force' parameter for unknown chip at
"
"parameter for unknown chip at
"
"adapter %d, address 0x%02x
\n
"
,
"adapter %d, address 0x%02x
\n
"
,
i2c_adapter_id
(
adapter
),
address
);
i2c_adapter_id
(
adapter
),
address
);
err
=
-
EINVAL
;
err
=
-
EINVAL
;
goto
ERROR2
;
goto
ERROR2
;
}
}
...
...
drivers/w1/Makefile
View file @
dc9f9ccd
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
# Makefile for the Dallas's 1-wire bus.
# Makefile for the Dallas's 1-wire bus.
#
#
ifneq
($(CONFIG_NET), y)
EXTRA_CFLAGS
+=
-DNETLINK_DISABLED
endif
obj-$(CONFIG_W1)
+=
wire.o
obj-$(CONFIG_W1)
+=
wire.o
wire-objs
:=
w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o
wire-objs
:=
w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o
...
...
drivers/w1/dscore.c
View file @
dc9f9ccd
...
@@ -727,12 +727,19 @@ void ds_disconnect(struct usb_interface *intf)
...
@@ -727,12 +727,19 @@ void ds_disconnect(struct usb_interface *intf)
{
{
struct
ds_device
*
dev
;
struct
ds_device
*
dev
;
dev
=
usb_get_intfdata
(
intf
);
dev
=
usb_get_intfdata
(
intf
);
usb_set_intfdata
(
intf
,
NULL
);
usb_set_intfdata
(
intf
,
NULL
);
while
(
atomic_read
(
&
dev
->
refcnt
))
while
(
atomic_read
(
&
dev
->
refcnt
))
{
printk
(
KERN_INFO
"Waiting for DS to become free: refcnt=%d.
\n
"
,
atomic_read
(
&
dev
->
refcnt
));
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
HZ
);
schedule_timeout
(
HZ
);
if
(
signal_pending
(
current
))
flush_signals
(
current
);
}
usb_put_dev
(
dev
->
udev
);
usb_put_dev
(
dev
->
udev
);
kfree
(
dev
);
kfree
(
dev
);
ds_dev
=
NULL
;
ds_dev
=
NULL
;
...
...
drivers/w1/w1.c
View file @
dc9f9ccd
...
@@ -47,9 +47,11 @@ MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
...
@@ -47,9 +47,11 @@ MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
static
int
w1_timeout
=
10
;
static
int
w1_timeout
=
10
;
int
w1_max_slave_count
=
10
;
int
w1_max_slave_count
=
10
;
int
w1_max_slave_ttl
=
10
;
module_param_named
(
timeout
,
w1_timeout
,
int
,
0
);
module_param_named
(
timeout
,
w1_timeout
,
int
,
0
);
module_param_named
(
max_slave_count
,
w1_max_slave_count
,
int
,
0
);
module_param_named
(
max_slave_count
,
w1_max_slave_count
,
int
,
0
);
module_param_named
(
slave_ttl
,
w1_max_slave_ttl
,
int
,
0
);
spinlock_t
w1_mlock
=
SPIN_LOCK_UNLOCKED
;
spinlock_t
w1_mlock
=
SPIN_LOCK_UNLOCKED
;
LIST_HEAD
(
w1_masters
);
LIST_HEAD
(
w1_masters
);
...
@@ -431,6 +433,7 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
...
@@ -431,6 +433,7 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
return
err
;
return
err
;
}
}
sl
->
ttl
=
dev
->
slave_ttl
;
dev
->
slave_count
++
;
dev
->
slave_count
++
;
memcpy
(
&
msg
.
id
.
id
,
rn
,
sizeof
(
msg
.
id
.
id
));
memcpy
(
&
msg
.
id
.
id
,
rn
,
sizeof
(
msg
.
id
.
id
));
...
@@ -446,8 +449,15 @@ static void w1_slave_detach(struct w1_slave *sl)
...
@@ -446,8 +449,15 @@ static void w1_slave_detach(struct w1_slave *sl)
dev_info
(
&
sl
->
dev
,
"%s: detaching %s.
\n
"
,
__func__
,
sl
->
name
);
dev_info
(
&
sl
->
dev
,
"%s: detaching %s.
\n
"
,
__func__
,
sl
->
name
);
while
(
atomic_read
(
&
sl
->
refcnt
))
while
(
atomic_read
(
&
sl
->
refcnt
))
{
schedule_timeout
(
10
);
printk
(
KERN_INFO
"Waiting for %s to become free: refcnt=%d.
\n
"
,
sl
->
name
,
atomic_read
(
&
sl
->
refcnt
));
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
HZ
);
if
(
signal_pending
(
current
))
flush_signals
(
current
);
}
sysfs_remove_bin_file
(
&
sl
->
dev
.
kobj
,
&
sl
->
attr_bin
);
sysfs_remove_bin_file
(
&
sl
->
dev
.
kobj
,
&
sl
->
attr_bin
);
device_remove_file
(
&
sl
->
dev
,
&
sl
->
attr_name
);
device_remove_file
(
&
sl
->
dev
,
&
sl
->
attr_name
);
...
@@ -504,8 +514,8 @@ static void w1_search(struct w1_master *dev)
...
@@ -504,8 +514,8 @@ static void w1_search(struct w1_master *dev)
* All who don't sleep must send ID bit and COMPLEMENT ID bit.
* All who don't sleep must send ID bit and COMPLEMENT ID bit.
* They actually are ANDed between all senders.
* They actually are ANDed between all senders.
*/
*/
id_bit
=
w1_
read_bit
(
dev
);
id_bit
=
w1_
touch_bit
(
dev
,
1
);
comp_bit
=
w1_
read_bit
(
dev
);
comp_bit
=
w1_
touch_bit
(
dev
,
1
);
if
(
id_bit
&&
comp_bit
)
if
(
id_bit
&&
comp_bit
)
break
;
break
;
...
@@ -536,7 +546,10 @@ static void w1_search(struct w1_master *dev)
...
@@ -536,7 +546,10 @@ static void w1_search(struct w1_master *dev)
* and make all who don't have "search_bit" in "i"'th position
* and make all who don't have "search_bit" in "i"'th position
* in it's registration number sleep.
* in it's registration number sleep.
*/
*/
w1_write_bit
(
dev
,
search_bit
);
if
(
dev
->
bus_master
->
touch_bit
)
w1_touch_bit
(
dev
,
search_bit
);
else
w1_write_bit
(
dev
,
search_bit
);
}
}
#endif
#endif
...
@@ -569,7 +582,7 @@ static void w1_search(struct w1_master *dev)
...
@@ -569,7 +582,7 @@ static void w1_search(struct w1_master *dev)
}
}
if
(
slave_count
==
dev
->
slave_count
&&
if
(
slave_count
==
dev
->
slave_count
&&
((
rn
>>
56
)
&
0xff
)
==
w1_calc_crc8
((
u8
*
)
&
rn
,
7
))
{
rn
&&
((
rn
>>
56
)
&
0xff
)
==
w1_calc_crc8
((
u8
*
)
&
rn
,
7
))
{
w1_attach_slave_device
(
dev
,
(
struct
w1_reg_num
*
)
&
rn
);
w1_attach_slave_device
(
dev
,
(
struct
w1_reg_num
*
)
&
rn
);
}
}
}
}
...
@@ -718,7 +731,7 @@ int w1_process(void *data)
...
@@ -718,7 +731,7 @@ int w1_process(void *data)
list_for_each_safe
(
ent
,
n
,
&
dev
->
slist
)
{
list_for_each_safe
(
ent
,
n
,
&
dev
->
slist
)
{
sl
=
list_entry
(
ent
,
struct
w1_slave
,
w1_slave_entry
);
sl
=
list_entry
(
ent
,
struct
w1_slave
,
w1_slave_entry
);
if
(
sl
&&
!
test_bit
(
W1_SLAVE_ACTIVE
,
(
unsigned
long
*
)
&
sl
->
flags
))
{
if
(
sl
&&
!
test_bit
(
W1_SLAVE_ACTIVE
,
(
unsigned
long
*
)
&
sl
->
flags
)
&&
!--
sl
->
ttl
)
{
list_del
(
&
sl
->
w1_slave_entry
);
list_del
(
&
sl
->
w1_slave_entry
);
w1_slave_detach
(
sl
);
w1_slave_detach
(
sl
);
...
@@ -726,6 +739,8 @@ int w1_process(void *data)
...
@@ -726,6 +739,8 @@ int w1_process(void *data)
dev
->
slave_count
--
;
dev
->
slave_count
--
;
}
}
else
if
(
test_bit
(
W1_SLAVE_ACTIVE
,
(
unsigned
long
*
)
&
sl
->
flags
))
sl
->
ttl
=
dev
->
slave_ttl
;
}
}
up
(
&
dev
->
mutex
);
up
(
&
dev
->
mutex
);
}
}
...
...
drivers/w1/w1.h
View file @
dc9f9ccd
...
@@ -63,6 +63,7 @@ struct w1_slave
...
@@ -63,6 +63,7 @@ struct w1_slave
atomic_t
refcnt
;
atomic_t
refcnt
;
u8
rom
[
9
];
u8
rom
[
9
];
u32
flags
;
u32
flags
;
int
ttl
;
struct
w1_master
*
master
;
struct
w1_master
*
master
;
struct
w1_family
*
family
;
struct
w1_family
*
family
;
...
@@ -99,6 +100,7 @@ struct w1_master
...
@@ -99,6 +100,7 @@ struct w1_master
struct
list_head
slist
;
struct
list_head
slist
;
int
max_slave_count
,
slave_count
;
int
max_slave_count
,
slave_count
;
unsigned
long
attempts
;
unsigned
long
attempts
;
int
slave_ttl
;
int
initialized
;
int
initialized
;
u32
id
;
u32
id
;
...
...
drivers/w1/w1_family.c
View file @
dc9f9ccd
...
@@ -84,8 +84,15 @@ void w1_unregister_family(struct w1_family *fent)
...
@@ -84,8 +84,15 @@ void w1_unregister_family(struct w1_family *fent)
spin_unlock
(
&
w1_flock
);
spin_unlock
(
&
w1_flock
);
while
(
atomic_read
(
&
fent
->
refcnt
))
while
(
atomic_read
(
&
fent
->
refcnt
))
{
schedule_timeout
(
10
);
printk
(
KERN_INFO
"Waiting for family %u to become free: refcnt=%d.
\n
"
,
fent
->
fid
,
atomic_read
(
&
fent
->
refcnt
));
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
HZ
);
if
(
signal_pending
(
current
))
flush_signals
(
current
);
}
}
}
/*
/*
...
...
drivers/w1/w1_int.c
View file @
dc9f9ccd
...
@@ -32,12 +32,13 @@ extern struct device_driver w1_driver;
...
@@ -32,12 +32,13 @@ extern struct device_driver w1_driver;
extern
struct
bus_type
w1_bus_type
;
extern
struct
bus_type
w1_bus_type
;
extern
struct
device
w1_device
;
extern
struct
device
w1_device
;
extern
int
w1_max_slave_count
;
extern
int
w1_max_slave_count
;
extern
int
w1_max_slave_ttl
;
extern
struct
list_head
w1_masters
;
extern
struct
list_head
w1_masters
;
extern
spinlock_t
w1_mlock
;
extern
spinlock_t
w1_mlock
;
extern
int
w1_process
(
void
*
);
extern
int
w1_process
(
void
*
);
struct
w1_master
*
w1_alloc_dev
(
u32
id
,
int
slave_count
,
struct
w1_master
*
w1_alloc_dev
(
u32
id
,
int
slave_count
,
int
slave_ttl
,
struct
device_driver
*
driver
,
struct
device
*
device
)
struct
device_driver
*
driver
,
struct
device
*
device
)
{
{
struct
w1_master
*
dev
;
struct
w1_master
*
dev
;
...
@@ -65,6 +66,7 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count,
...
@@ -65,6 +66,7 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count,
dev
->
kpid
=
-
1
;
dev
->
kpid
=
-
1
;
dev
->
initialized
=
0
;
dev
->
initialized
=
0
;
dev
->
id
=
id
;
dev
->
id
=
id
;
dev
->
slave_ttl
=
slave_ttl
;
atomic_set
(
&
dev
->
refcnt
,
2
);
atomic_set
(
&
dev
->
refcnt
,
2
);
...
@@ -121,7 +123,7 @@ int w1_add_master_device(struct w1_bus_master *master)
...
@@ -121,7 +123,7 @@ int w1_add_master_device(struct w1_bus_master *master)
int
retval
=
0
;
int
retval
=
0
;
struct
w1_netlink_msg
msg
;
struct
w1_netlink_msg
msg
;
dev
=
w1_alloc_dev
(
w1_ids
++
,
w1_max_slave_count
,
&
w1_driver
,
&
w1_device
);
dev
=
w1_alloc_dev
(
w1_ids
++
,
w1_max_slave_count
,
w1_max_slave_ttl
,
&
w1_driver
,
&
w1_device
);
if
(
!
dev
)
if
(
!
dev
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -179,8 +181,15 @@ void __w1_remove_master_device(struct w1_master *dev)
...
@@ -179,8 +181,15 @@ void __w1_remove_master_device(struct w1_master *dev)
"%s: Failed to send signal to w1 kernel thread %d.
\n
"
,
"%s: Failed to send signal to w1 kernel thread %d.
\n
"
,
__func__
,
dev
->
kpid
);
__func__
,
dev
->
kpid
);
while
(
atomic_read
(
&
dev
->
refcnt
))
while
(
atomic_read
(
&
dev
->
refcnt
))
{
schedule_timeout
(
10
);
printk
(
KERN_INFO
"Waiting for %s to become free: refcnt=%d.
\n
"
,
dev
->
name
,
atomic_read
(
&
dev
->
refcnt
));
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
HZ
);
if
(
signal_pending
(
current
))
flush_signals
(
current
);
}
msg
.
id
.
mst
.
id
=
dev
->
id
;
msg
.
id
.
mst
.
id
=
dev
->
id
;
msg
.
id
.
mst
.
pid
=
dev
->
kpid
;
msg
.
id
.
mst
.
pid
=
dev
->
kpid
;
...
...
drivers/w1/w1_int.h
View file @
dc9f9ccd
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include "w1.h"
#include "w1.h"
struct
w1_master
*
w1_alloc_dev
(
int
,
struct
device_driver
*
,
struct
device
*
);
struct
w1_master
*
w1_alloc_dev
(
u32
,
int
,
int
,
struct
device_driver
*
,
struct
device
*
);
void
w1_free_dev
(
struct
w1_master
*
dev
);
void
w1_free_dev
(
struct
w1_master
*
dev
);
int
w1_add_master_device
(
struct
w1_bus_master
*
);
int
w1_add_master_device
(
struct
w1_bus_master
*
);
void
w1_remove_master_device
(
struct
w1_bus_master
*
);
void
w1_remove_master_device
(
struct
w1_bus_master
*
);
...
...
drivers/w1/w1_netlink.c
View file @
dc9f9ccd
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "w1_log.h"
#include "w1_log.h"
#include "w1_netlink.h"
#include "w1_netlink.h"
#ifndef NETLINK_DISABLED
void
w1_netlink_send
(
struct
w1_master
*
dev
,
struct
w1_netlink_msg
*
msg
)
void
w1_netlink_send
(
struct
w1_master
*
dev
,
struct
w1_netlink_msg
*
msg
)
{
{
unsigned
int
size
;
unsigned
int
size
;
...
@@ -53,3 +54,10 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
...
@@ -53,3 +54,10 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
nlmsg_failure:
nlmsg_failure:
return
;
return
;
}
}
#else
#warning Netlink support is disabled. Please compile with NET support enabled.
void
w1_netlink_send
(
struct
w1_master
*
dev
,
struct
w1_netlink_msg
*
msg
)
{
}
#endif
drivers/w1/w1_therm.c
View file @
dc9f9ccd
...
@@ -59,19 +59,28 @@ static ssize_t w1_therm_read_name(struct device *dev, char *buf)
...
@@ -59,19 +59,28 @@ static ssize_t w1_therm_read_name(struct device *dev, char *buf)
return
sprintf
(
buf
,
"%s
\n
"
,
sl
->
name
);
return
sprintf
(
buf
,
"%s
\n
"
,
sl
->
name
);
}
}
static
inline
int
w1_convert_temp
(
u8
rom
[
9
])
{
int
t
,
h
;
if
(
rom
[
1
]
==
0
)
t
=
((
s32
)
rom
[
0
]
>>
1
)
*
1000
;
else
t
=
1000
*
(
-
1
*
(
s32
)(
0x100
-
rom
[
0
])
>>
1
);
t
-=
250
;
h
=
1000
*
((
s32
)
rom
[
7
]
-
(
s32
)
rom
[
6
]);
h
/=
(
s32
)
rom
[
7
];
t
+=
h
;
return
t
;
}
static
ssize_t
w1_therm_read_temp
(
struct
device
*
dev
,
char
*
buf
)
static
ssize_t
w1_therm_read_temp
(
struct
device
*
dev
,
char
*
buf
)
{
{
struct
w1_slave
*
sl
=
container_of
(
dev
,
struct
w1_slave
,
dev
);
struct
w1_slave
*
sl
=
container_of
(
dev
,
struct
w1_slave
,
dev
);
s16
temp
;
/*
return
sprintf
(
buf
,
"%d
\n
"
,
w1_convert_temp
(
sl
->
rom
));
* Must be more precise.
*/
temp
=
0
;
temp
<<=
sl
->
rom
[
1
]
/
2
;
temp
|=
sl
->
rom
[
0
]
/
2
;
return
sprintf
(
buf
,
"%d
\n
"
,
temp
*
1000
);
}
}
static
int
w1_therm_check_rom
(
u8
rom
[
9
])
static
int
w1_therm_check_rom
(
u8
rom
[
9
])
...
@@ -92,7 +101,6 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
...
@@ -92,7 +101,6 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
struct
w1_master
*
dev
=
sl
->
master
;
struct
w1_master
*
dev
=
sl
->
master
;
u8
rom
[
9
],
crc
,
verdict
;
u8
rom
[
9
],
crc
,
verdict
;
int
i
,
max_trying
=
10
;
int
i
,
max_trying
=
10
;
u16
temp
;
atomic_inc
(
&
sl
->
refcnt
);
atomic_inc
(
&
sl
->
refcnt
);
if
(
down_interruptible
(
&
sl
->
master
->
mutex
))
{
if
(
down_interruptible
(
&
sl
->
master
->
mutex
))
{
...
@@ -120,6 +128,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
...
@@ -120,6 +128,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
if
(
!
w1_reset_bus
(
dev
))
{
if
(
!
w1_reset_bus
(
dev
))
{
int
count
=
0
;
int
count
=
0
;
u8
match
[
9
]
=
{
W1_MATCH_ROM
,
};
u8
match
[
9
]
=
{
W1_MATCH_ROM
,
};
unsigned
long
tm
;
memcpy
(
&
match
[
1
],
(
u64
*
)
&
sl
->
reg_num
,
8
);
memcpy
(
&
match
[
1
],
(
u64
*
)
&
sl
->
reg_num
,
8
);
...
@@ -127,24 +136,29 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
...
@@ -127,24 +136,29 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
w1_write_8
(
dev
,
W1_CONVERT_TEMP
);
w1_write_8
(
dev
,
W1_CONVERT_TEMP
);
if
(
count
<
10
)
{
tm
=
jiffies
+
msecs_to_jiffies
(
750
);
if
(
!
w1_reset_bus
(
dev
))
{
while
(
time_before
(
jiffies
,
tm
))
{
w1_write_block
(
dev
,
match
,
9
);
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
tm
-
jiffies
);
w1_write_8
(
dev
,
W1_READ_SCRATCHPAD
);
if
((
count
=
w1_read_block
(
dev
,
rom
,
9
))
!=
9
)
{
dev_warn
(
&
dev
->
dev
,
"w1_read_block() returned %d instead of 9.
\n
"
,
count
);
}
crc
=
w1_calc_crc8
(
rom
,
8
);
if
(
signal_pending
(
current
))
flush_signals
(
current
);
}
if
(
rom
[
8
]
==
crc
&&
rom
[
0
])
if
(
!
w1_reset_bus
(
dev
))
{
verdict
=
1
;
w1_write_block
(
dev
,
match
,
9
);
w1_write_8
(
dev
,
W1_READ_SCRATCHPAD
);
if
((
count
=
w1_read_block
(
dev
,
rom
,
9
))
!=
9
)
{
dev_warn
(
&
dev
->
dev
,
"w1_read_block() returned %d instead of 9.
\n
"
,
count
);
}
}
crc
=
w1_calc_crc8
(
rom
,
8
);
if
(
rom
[
8
]
==
crc
&&
rom
[
0
])
verdict
=
1
;
}
}
else
dev_warn
(
&
dev
->
dev
,
"18S20 doesn't respond to CONVERT_TEMP.
\n
"
);
}
}
if
(
!
w1_therm_check_rom
(
rom
))
if
(
!
w1_therm_check_rom
(
rom
))
...
@@ -157,12 +171,13 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
...
@@ -157,12 +171,13 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
crc
,
(
verdict
)
?
"YES"
:
"NO"
);
crc
,
(
verdict
)
?
"YES"
:
"NO"
);
if
(
verdict
)
if
(
verdict
)
memcpy
(
sl
->
rom
,
rom
,
sizeof
(
sl
->
rom
));
memcpy
(
sl
->
rom
,
rom
,
sizeof
(
sl
->
rom
));
else
dev_warn
(
&
dev
->
dev
,
"18S20 doesn't respond to CONVERT_TEMP.
\n
"
);
for
(
i
=
0
;
i
<
9
;
++
i
)
for
(
i
=
0
;
i
<
9
;
++
i
)
count
+=
sprintf
(
buf
+
count
,
"%02x "
,
sl
->
rom
[
i
]);
count
+=
sprintf
(
buf
+
count
,
"%02x "
,
sl
->
rom
[
i
]);
temp
=
0
;
temp
<<=
sl
->
rom
[
1
]
/
2
;
count
+=
sprintf
(
buf
+
count
,
"t=%d
\n
"
,
w1_convert_temp
(
rom
));
temp
|=
sl
->
rom
[
0
]
/
2
;
count
+=
sprintf
(
buf
+
count
,
"t=%u
\n
"
,
temp
);
out:
out:
up
(
&
dev
->
mutex
);
up
(
&
dev
->
mutex
);
out_dec:
out_dec:
...
...
include/linux/i2c-vid.h
View file @
dc9f9ccd
...
@@ -29,7 +29,22 @@
...
@@ -29,7 +29,22 @@
*/
*/
/*
/*
Legal val values 00 - 1F.
AMD Opteron processors don't follow the Intel VRM spec.
I'm going to "make up" 2.4 as the VRM spec for the Opterons.
No good reason just a mnemonic for the 24x Opteron processor
series
Opteron VID encoding is:
00000 = 1.550 V
00001 = 1.525 V
. . . .
11110 = 0.800 V
11111 = 0.000 V (off)
*/
/*
Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
vrm is the Intel VRM document version.
vrm is the Intel VRM document version.
Note: vrm version is scaled by 10 and the return value is scaled by 1000
Note: vrm version is scaled by 10 and the return value is scaled by 1000
to avoid floating point in the kernel.
to avoid floating point in the kernel.
...
@@ -41,9 +56,28 @@ int i2c_which_vrm(void);
...
@@ -41,9 +56,28 @@ int i2c_which_vrm(void);
static
inline
int
vid_from_reg
(
int
val
,
int
vrm
)
static
inline
int
vid_from_reg
(
int
val
,
int
vrm
)
{
{
int
vid
;
switch
(
vrm
)
{
switch
(
vrm
)
{
case
0
:
case
0
:
return
0
;
return
0
;
case
100
:
/* VRD 10.0 */
if
((
val
&
0x1f
)
==
0x1f
)
return
0
;
if
((
val
&
0x1f
)
<=
0x09
||
val
==
0x0a
)
vid
=
10875
-
(
val
&
0x1f
)
*
250
;
else
vid
=
18625
-
(
val
&
0x1f
)
*
250
;
if
(
val
&
0x20
)
vid
-=
125
;
vid
/=
10
;
/* only return 3 dec. places for now */
return
vid
;
case
24
:
/* Opteron processor */
return
(
val
==
0x1f
?
0
:
1550
-
val
*
25
);
case
91
:
/* VRM 9.1 */
case
91
:
/* VRM 9.1 */
case
90
:
/* VRM 9.0 */
case
90
:
/* VRM 9.0 */
return
(
val
==
0x1f
?
0
:
return
(
val
==
0x1f
?
0
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment