Commit 37581a1c authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge kroah.com:/home/greg/linux/BK/bleed-2.5

into kroah.com:/home/greg/linux/BK/i2c-2.5
parents 797886bf 7eaa539b
......@@ -196,17 +196,6 @@ config I2C_CHARDEV
<file:Documentation/modules.txt>.
The module will be called i2c-dev.
config I2C_PROC
tristate "I2C /proc interface (required for hardware sensors)"
depends on I2C && SYSCTL
help
This provides support for i2c device entries in the /proc filesystem.
The entries will be found in /proc/sys/dev/sensors.
This code is also available as a module. If you want to compile
it as a module, say M here and read <file:Documentation/modules.txt>.
The module will be called i2c-proc.
source drivers/i2c/busses/Kconfig
source drivers/i2c/chips/Kconfig
......
......@@ -14,5 +14,5 @@ obj-$(CONFIG_ITE_I2C_ALGO) += i2c-algo-ite.o
obj-$(CONFIG_ITE_I2C_ADAP) += i2c-adap-ite.o
obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o
obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
obj-$(CONFIG_I2C_PROC) += i2c-proc.o
obj-$(CONFIG_I2C_SENSOR) += i2c-sensor.o
obj-y += busses/ chips/
#
# Sensor device configuration
# All depend on EXPERIMENTAL, I2C and I2C_PROC.
# All depend on EXPERIMENTAL and I2C
#
menu "I2C Hardware Sensors Chip support"
config SENSORS_ADM1021
tristate " Analog Devices ADM1021 and compatibles"
depends on I2C && I2C_PROC
depends on I2C && EXPERIMENTAL
help
If you say yes here you get support for Analog Devices ADM1021
and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
......@@ -24,7 +24,7 @@ config SENSORS_ADM1021
config SENSORS_LM75
tristate " National Semiconductors LM75 and compatibles"
depends on I2C && I2C_PROC
depends on I2C && EXPERIMENTAL
help
If you say yes here you get support for National Semiconductor LM75
sensor chips and clones: Dallas Semi DS75 and DS1775, TelCon
......@@ -36,5 +36,37 @@ config SENSORS_LM75
You will also need the latest user-space utilties: you can find them
in the lm_sensors package, which you can download at
http://www.lm-sensors.nu
config SENSORS_VIA686A
tristate " VIA686A"
depends on I2C && EXPERIMENTAL
help
support for via686a
If you say yes here you get support for the integrated sensors in
Via 686A/B South Bridges. This can also be built as a module
which can be inserted and removed while the kernel is running.
You will also need the latest user-space utilties: you can find them
in the lm_sensors package, which you can download at
http://www.lm-sensors.nu
config SENSORS_W83781D
tristate " Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
depends on I2C && EXPERIMENTAL
help
If you say yes here you get support for the Winbond W8378x series
of sensor chips: the W83781D, W83782D, W83783S and W83682HF,
and the similar Asus AS99127F. This
can also be built as a module which can be inserted and removed
while the kernel is running.
You will also need the latest user-space utilties: you can find them
in the lm_sensors package, which you can download at
http://www.lm-sensors.nu
config I2C_SENSOR
tristate
depends on SENSORS_ADM1021 || SENSORS_LM75 || SENSORS_VIA686A || SENSORS_W83781D
default m
endmenu
......@@ -4,3 +4,5 @@
obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o
obj-$(CONFIG_SENSORS_LM75) += lm75.o
obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
obj-$(CONFIG_SENSORS_W83781D) += w83781d.o
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -29,7 +29,6 @@
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/seq_file.h>
......@@ -46,15 +45,6 @@ static DECLARE_MUTEX(core_lists);
/**** debug level */
static int i2c_debug;
#ifdef CONFIG_PROC_FS
static int i2cproc_register(struct i2c_adapter *adap, int bus);
static void i2cproc_remove(int bus);
#else
# define i2cproc_register(adap, bus) 0
# define i2cproc_remove(bus) do { } while (0)
#endif /* CONFIG_PROC_FS */
int i2c_device_probe(struct device *dev)
{
return -ENODEV;
......@@ -98,10 +88,6 @@ int i2c_add_adapter(struct i2c_adapter *adap)
goto out_unlock;
}
res = i2cproc_register(adap, i);
if (res)
goto out_unlock;
adapters[i] = adap;
init_MUTEX(&adap->bus);
......@@ -180,8 +166,6 @@ int i2c_del_adapter(struct i2c_adapter *adap)
}
}
i2cproc_remove(i);
/* clean up the sysfs representation */
device_unregister(&adap->dev);
......@@ -392,7 +376,8 @@ int i2c_attach_client(struct i2c_client *client)
client->dev.driver = &client->driver->driver;
client->dev.bus = &i2c_bus_type;
snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), "i2c_dev_%d", i);
snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
"%d-%04x", i2c_adapter_id(adapter), client->addr);
printk("registering %s\n", client->dev.bus_id);
device_register(&client->dev);
......@@ -494,173 +479,6 @@ int i2c_release_client(struct i2c_client *client)
return 0;
}
#ifdef CONFIG_PROC_FS
/* This function generates the output for /proc/bus/i2c-? */
static ssize_t i2cproc_bus_read(struct file *file, char *buf,
size_t count, loff_t *ppos)
{
struct inode *inode = file->f_dentry->d_inode;
char *kbuf;
struct i2c_client *client;
int i,j,k,order_nr,len=0;
size_t len_total;
int order[I2C_CLIENT_MAX];
#define OUTPUT_LENGTH_PER_LINE 70
len_total = file->f_pos + count;
if (len_total > (I2C_CLIENT_MAX * OUTPUT_LENGTH_PER_LINE) )
/* adjust to maximum file size */
len_total = (I2C_CLIENT_MAX * OUTPUT_LENGTH_PER_LINE);
for (i = 0; i < I2C_ADAP_MAX; i++)
if (adapters[i]->inode == inode->i_ino) {
/* We need a bit of slack in the kernel buffer; this makes the
sprintf safe. */
if (! (kbuf = kmalloc(len_total +
OUTPUT_LENGTH_PER_LINE,
GFP_KERNEL)))
return -ENOMEM;
/* Order will hold the indexes of the clients
sorted by address */
order_nr=0;
for (j = 0; j < I2C_CLIENT_MAX; j++) {
if ((client = adapters[i]->clients[j]) &&
(client->driver->id != I2C_DRIVERID_I2CDEV)) {
for(k = order_nr;
(k > 0) &&
adapters[i]->clients[order[k-1]]->
addr > client->addr;
k--)
order[k] = order[k-1];
order[k] = j;
order_nr++;
}
}
for (j = 0; (j < order_nr) && (len < len_total); j++) {
client = adapters[i]->clients[order[j]];
len += sprintf(kbuf+len,"%02x\t%-32s\t%-32s\n",
client->addr,
client->dev.name,
client->driver->name);
}
len = len - file->f_pos;
if (len > count)
len = count;
if (len < 0)
len = 0;
if (copy_to_user (buf,kbuf+file->f_pos, len)) {
kfree(kbuf);
return -EFAULT;
}
file->f_pos += len;
kfree(kbuf);
return len;
}
return -ENOENT;
}
static struct file_operations i2cproc_operations = {
.read = i2cproc_bus_read,
};
/* This function generates the output for /proc/bus/i2c */
static int bus_i2c_show(struct seq_file *s, void *p)
{
int i;
down(&core_lists);
for (i = 0; i < I2C_ADAP_MAX; i++) {
struct i2c_adapter *adapter = adapters[i];
if (!adapter)
continue;
seq_printf(s, "i2c-%d\t", i);
if (adapter->algo->smbus_xfer) {
if (adapter->algo->master_xfer)
seq_printf(s, "smbus/i2c");
else
seq_printf(s, "smbus ");
} else if (adapter->algo->master_xfer)
seq_printf(s ,"i2c ");
else
seq_printf(s, "dummy ");
seq_printf(s, "\t%-32s\t%-32s\n",
adapter->dev.name, adapter->algo->name);
}
up(&core_lists);
return 0;
}
static int bus_i2c_open(struct inode *inode, struct file *file)
{
return single_open(file, bus_i2c_show, NULL);
}
static struct file_operations bus_i2c_fops = {
.open = bus_i2c_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int i2cproc_register(struct i2c_adapter *adap, int bus)
{
struct proc_dir_entry *proc_entry;
char name[8];
sprintf(name, "i2c-%d", bus);
proc_entry = create_proc_entry(name, 0, proc_bus);
if (!proc_entry)
goto fail;
proc_entry->proc_fops = &i2cproc_operations;
proc_entry->owner = adap->owner;
adap->inode = proc_entry->low_ino;
return 0;
fail:
printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/%s\n", name);
return -ENOENT;
}
static void i2cproc_remove(int bus)
{
char name[8];
sprintf(name,"i2c-%d", bus);
remove_proc_entry(name, proc_bus);
}
static int __init i2cproc_init(void)
{
struct proc_dir_entry *proc_bus_i2c;
proc_bus_i2c = create_proc_entry("i2c", 0, proc_bus);
if (!proc_bus_i2c)
goto fail;
proc_bus_i2c->proc_fops = &bus_i2c_fops;
proc_bus_i2c->owner = THIS_MODULE;
return 0;
fail:
printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/i2c");
return -ENOENT;
}
static void __exit i2cproc_cleanup(void)
{
remove_proc_entry("i2c",proc_bus);
}
#else
static int __init i2cproc_init(void) { return 0; }
static void __exit i2cproc_cleanup(void) { }
#endif /* CONFIG_PROC_FS */
/* match always succeeds, as we want the probe() to tell if we really accept this match */
static int i2c_device_match(struct device *dev, struct device_driver *drv)
{
......@@ -675,13 +493,11 @@ struct bus_type i2c_bus_type = {
static int __init i2c_init(void)
{
bus_register(&i2c_bus_type);
return i2cproc_init();
return bus_register(&i2c_bus_type);
}
static void __exit i2c_exit(void)
{
i2cproc_cleanup();
bus_unregister(&i2c_bus_type);
}
......
This diff is collapsed.
/*
i2c-sensor.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl> and
Mark D. Studebaker <mdsxyz123@yahoo.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/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/ctype.h>
#include <linux/sysctl.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <asm/uaccess.h>
/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */
int i2c_detect(struct i2c_adapter *adapter,
struct i2c_address_data *address_data,
i2c_found_addr_proc * found_proc)
{
int addr, i, found, j, err;
struct i2c_force_data *this_force;
int is_isa = i2c_is_isa_adapter(adapter);
int adapter_id =
is_isa ? SENSORS_ISA_BUS : i2c_adapter_id(adapter);
/* Forget it if we can't probe using SMBUS_QUICK */
if ((!is_isa) &&
!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK))
return -1;
for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) {
/* XXX: WTF is going on here??? */
if ((is_isa && check_region(addr, 1)) ||
(!is_isa && i2c_check_addr(adapter, addr)))
continue;
/* If it is in one of the force entries, we don't do any
detection at all */
found = 0;
for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) {
for (j = 0; !found && (this_force->force[j] != SENSORS_I2C_END); j += 2) {
if ( ((adapter_id == this_force->force[j]) ||
((this_force->force[j] == SENSORS_ANY_I2C_BUS) && !is_isa)) &&
(addr == this_force->force[j + 1]) ) {
dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr);
if ((err = found_proc(adapter, addr, this_force->kind)))
return err;
found = 1;
}
}
}
if (found)
continue;
/* If this address is in one of the ignores, we can forget about it
right now */
for (i = 0; !found && (address_data->ignore[i] != SENSORS_I2C_END); i += 2) {
if ( ((adapter_id == address_data->ignore[i]) ||
((address_data->ignore[i] == SENSORS_ANY_I2C_BUS) &&
!is_isa)) &&
(addr == address_data->ignore[i + 1])) {
dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
found = 1;
}
}
for (i = 0; !found && (address_data->ignore_range[i] != SENSORS_I2C_END); i += 3) {
if ( ((adapter_id == address_data->ignore_range[i]) ||
((address_data-> ignore_range[i] == SENSORS_ANY_I2C_BUS) &
!is_isa)) &&
(addr >= address_data->ignore_range[i + 1]) &&
(addr <= address_data->ignore_range[i + 2])) {
dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, addr %04x\n", adapter_id, addr);
found = 1;
}
}
if (found)
continue;
/* Now, we will do a detection, but only if it is in the normal or
probe entries */
if (is_isa) {
for (i = 0; !found && (address_data->normal_isa[i] != SENSORS_ISA_END); i += 1) {
if (addr == address_data->normal_isa[i]) {
dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr);
found = 1;
}
}
for (i = 0; !found && (address_data->normal_isa_range[i] != SENSORS_ISA_END); i += 3) {
if ((addr >= address_data->normal_isa_range[i]) &&
(addr <= address_data->normal_isa_range[i + 1]) &&
((addr - address_data->normal_isa_range[i]) % address_data->normal_isa_range[i + 2] == 0)) {
dev_dbg(&adapter->dev, "found normal isa_range entry for adapter %d, addr %04x", adapter_id, addr);
found = 1;
}
}
} else {
for (i = 0; !found && (address_data->normal_i2c[i] != SENSORS_I2C_END); i += 1) {
if (addr == address_data->normal_i2c[i]) {
found = 1;
dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x", adapter_id, addr);
}
}
for (i = 0; !found && (address_data->normal_i2c_range[i] != SENSORS_I2C_END); i += 2) {
if ((addr >= address_data->normal_i2c_range[i]) &&
(addr <= address_data->normal_i2c_range[i + 1])) {
dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, addr %04x\n", adapter_id, addr);
found = 1;
}
}
}
for (i = 0;
!found && (address_data->probe[i] != SENSORS_I2C_END);
i += 2) {
if (((adapter_id == address_data->probe[i]) ||
((address_data->
probe[i] == SENSORS_ANY_I2C_BUS) & !is_isa))
&& (addr == address_data->probe[i + 1])) {
dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
found = 1;
}
}
for (i = 0; !found && (address_data->probe_range[i] != SENSORS_I2C_END); i += 3) {
if ( ((adapter_id == address_data->probe_range[i]) ||
((address_data->probe_range[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) &&
(addr >= address_data->probe_range[i + 1]) &&
(addr <= address_data->probe_range[i + 2])) {
found = 1;
dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, addr %04x\n", adapter_id, addr);
}
}
if (!found)
continue;
/* OK, so we really should examine this address. First check
whether there is some client here at all! */
if (is_isa ||
(i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0))
if ((err = found_proc(adapter, addr, -1)))
return err;
}
return 0;
}
static int __init i2c_sensor_init(void)
{
return 0;
}
static void __exit i2c_sensor_exit(void)
{
}
EXPORT_SYMBOL(i2c_detect);
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
MODULE_DESCRIPTION("i2c-sensor driver");
MODULE_LICENSE("GPL");
module_init(i2c_sensor_init);
module_exit(i2c_sensor_exit);
......@@ -231,7 +231,7 @@ int adv717x_probe(struct i2c_adapter *adap)
static int adv717x_detach(struct i2c_client *client)
{
i2c_detach_client(client);
i2c_get_clientdata(client);
kfree(i2c_get_clientdata(client));
kfree(client);
return 0;
}
......
......@@ -87,7 +87,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
if (cmd == SOUND_MIXER_INFO) {
mixer_info info;
strncpy(info.id, "tv card", sizeof(info.id));
strncpy(info.name, client->name, sizeof(info.name));
strncpy(info.name, client->dev.name, sizeof(info.name));
info.modify_counter = 42 /* FIXME */;
if (copy_to_user((void *)arg, &info, sizeof(info)))
return -EFAULT;
......@@ -96,7 +96,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
if (cmd == SOUND_OLD_MIXER_INFO) {
_old_mixer_info info;
strncpy(info.id, "tv card", sizeof(info.id));
strncpy(info.name, client->name, sizeof(info.name));
strncpy(info.name, client->dev.name, sizeof(info.name));
if (copy_to_user((void *)arg, &info, sizeof(info)))
return -EFAULT;
return 0;
......@@ -237,7 +237,7 @@ static int tvmixer_adapters(struct i2c_adapter *adap)
int i;
if (debug)
printk("tvmixer: adapter %s\n",adap->name);
printk("tvmixer: adapter %s\n",adap->dev.name);
for (i=0; i<I2C_CLIENT_MAX; i++) {
if (!adap->clients[i])
continue;
......@@ -261,10 +261,10 @@ static int tvmixer_clients(struct i2c_client *client)
/* ignore that one */
if (debug)
printk("tvmixer: %s is not a tv card\n",
client->adapter->name);
client->adapter->dev.name);
return -1;
}
printk("tvmixer: debug: %s\n",client->name);
printk("tvmixer: debug: %s\n",client->dev.name);
/* unregister ?? */
for (i = 0; i < DEV_MAX; i++) {
......@@ -273,7 +273,7 @@ static int tvmixer_clients(struct i2c_client *client)
unregister_sound_mixer(devices[i].minor);
devices[i].dev = NULL;
devices[i].minor = -1;
printk("tvmixer: %s unregistered (#1)\n",client->name);
printk("tvmixer: %s unregistered (#1)\n",client->dev.name);
return 0;
}
}
......@@ -298,13 +298,13 @@ static int tvmixer_clients(struct i2c_client *client)
if (0 != client->driver->command(client,VIDIOCGAUDIO,&va)) {
if (debug)
printk("tvmixer: %s: VIDIOCGAUDIO failed\n",
client->name);
client->dev.name);
return -1;
}
if (0 == (va.flags & VIDEO_AUDIO_VOLUME)) {
if (debug)
printk("tvmixer: %s: has no volume control\n",
client->name);
client->dev.name);
return -1;
}
......@@ -318,7 +318,7 @@ static int tvmixer_clients(struct i2c_client *client)
devices[i].count = 0;
devices[i].dev = client;
printk("tvmixer: %s (%s) registered with minor %d\n",
client->name,client->adapter->name,minor);
client->dev.name,client->adapter->dev.name,minor);
return 0;
}
......@@ -344,7 +344,7 @@ static void tvmixer_cleanup_module(void)
if (devices[i].minor != -1) {
unregister_sound_mixer(devices[i].minor);
printk("tvmixer: %s unregistered (#2)\n",
devices[i].dev->name);
devices[i].dev->dev.name);
}
}
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment