Skip to content

Commit

Permalink
Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/jdelvare/staging

* 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  therm_windtunnel: Convert to a new-style i2c driver
  therm_adt746x: Convert to a new-style i2c driver
  windfarm: Convert to new-style i2c drivers
  therm_pm72: Convert to a new-style i2c driver
  i2c-viapro: Add new PCI device ID for VX855
  i2c/chips: Move max6875 to drivers/misc/eeprom
  i2c: Do not give adapters a default parent
  i2c: Do not probe for TV chips on Voodoo3 adapters
  i2c: Retry automatically on arbitration loss
  i2c: Remove void casts
  • Loading branch information
Linus Torvalds committed Jun 16, 2009
2 parents 86ade88 + 036533e commit 4858704
Show file tree
Hide file tree
Showing 20 changed files with 403 additions and 341 deletions.
4 changes: 4 additions & 0 deletions Documentation/i2c/busses/i2c-viapro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Supported adapters:
* VIA Technologies, Inc. VX800/VX820
Datasheet: available on http://linux.via.com.tw

* VIA Technologies, Inc. VX855/VX875
Datasheet: Availability unknown

Authors:
Kyösti Mälkki <kmalkki@cc.hut.fi>,
Mark D. Studebaker <mdsxyz123@yahoo.com>,
Expand Down Expand Up @@ -53,6 +56,7 @@ Your lspci -n listing must show one of these :
device 1106:3287 (VT8251)
device 1106:8324 (CX700)
device 1106:8353 (VX800/VX820)
device 1106:8409 (VX855/VX875)

If none of these show up, you should look in the BIOS for settings like
enable ACPI / SMBus or even USB.
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/configs/bigsur_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ CONFIG_EEPROM_LEGACY=y
CONFIG_SENSORS_PCF8574=y
# CONFIG_PCF8575 is not set
CONFIG_SENSORS_PCF8591=y
CONFIG_SENSORS_MAX6875=y
CONFIG_EEPROM_MAX6875=y
# CONFIG_SENSORS_TSL2550 is not set
CONFIG_I2C_DEBUG_CORE=y
CONFIG_I2C_DEBUG_ALGO=y
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/configs/mtx1_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@ CONFIG_EEPROM_LEGACY=m
CONFIG_SENSORS_PCF8574=m
CONFIG_SENSORS_PCA9539=m
CONFIG_SENSORS_PCF8591=m
CONFIG_SENSORS_MAX6875=m
CONFIG_EEPROM_MAX6875=m
# CONFIG_SENSORS_TSL2550 is not set
# CONFIG_I2C_DEBUG_CORE is not set
# CONFIG_I2C_DEBUG_ALGO is not set
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/configs/ppc6xx_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,7 @@ CONFIG_PCF8575=m
CONFIG_SENSORS_PCA9539=m
CONFIG_SENSORS_PCF8591=m
# CONFIG_TPS65010 is not set
CONFIG_SENSORS_MAX6875=m
CONFIG_EEPROM_MAX6875=m
CONFIG_SENSORS_TSL2550=m
CONFIG_MCU_MPC8349EMITX=m
# CONFIG_I2C_DEBUG_CORE is not set
Expand Down
6 changes: 3 additions & 3 deletions drivers/i2c/busses/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ config I2C_VIA
will be called i2c-via.

config I2C_VIAPRO
tristate "VIA VT82C596/82C686/82xx and CX700/VX800/VX820"
tristate "VIA VT82C596/82C686/82xx and CX700/VX8xx"
depends on PCI
help
If you say yes to this option, support will be included for the VIA
Expand All @@ -225,8 +225,8 @@ config I2C_VIAPRO
VT8237R/A/S
VT8251
CX700
VX800
VX820
VX800/VX820
VX855/VX875

This driver can also be built as a module. If so, the module
will be called i2c-viapro.
Expand Down
4 changes: 4 additions & 0 deletions drivers/i2c/busses/i2c-viapro.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
VT8251 0x3287 yes
CX700 0x8324 yes
VX800/VX820 0x8353 yes
VX855/VX875 0x8409 yes
Note: we assume there can only be one device, with one SMBus interface.
*/
Expand Down Expand Up @@ -404,6 +405,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
switch (pdev->device) {
case PCI_DEVICE_ID_VIA_CX700:
case PCI_DEVICE_ID_VIA_VX800:
case PCI_DEVICE_ID_VIA_VX855:
case PCI_DEVICE_ID_VIA_8251:
case PCI_DEVICE_ID_VIA_8237:
case PCI_DEVICE_ID_VIA_8237A:
Expand Down Expand Up @@ -469,6 +471,8 @@ static struct pci_device_id vt596_ids[] = {
.driver_data = SMBBA3 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800),
.driver_data = SMBBA3 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855),
.driver_data = SMBBA3 },
{ 0, }
};

Expand Down
1 change: 0 additions & 1 deletion drivers/i2c/busses/i2c-voodoo3.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ static struct i2c_algo_bit_data voo_i2c_bit_data = {

static struct i2c_adapter voodoo3_i2c_adapter = {
.owner = THIS_MODULE,
.class = I2C_CLASS_TV_ANALOG,
.name = "I2C Voodoo3/Banshee adapter",
.algo_data = &voo_i2c_bit_data,
};
Expand Down
15 changes: 0 additions & 15 deletions drivers/i2c/chips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,6 @@ config SENSORS_PCA9539
This driver is deprecated and will be dropped soon. Use
drivers/gpio/pca953x.c instead.

config SENSORS_MAX6875
tristate "Maxim MAX6875 Power supply supervisor"
depends on EXPERIMENTAL
help
If you say yes here you get support for the Maxim MAX6875
EEPROM-programmable, quad power-supply sequencer/supervisor.

This provides an interface to program the EEPROM and reset the chip.

This driver also supports the Maxim MAX6874 hex power-supply
sequencer/supervisor if found at a compatible address.

This driver can also be built as a module. If so, the module
will be called max6875.

config SENSORS_TSL2550
tristate "Taos TSL2550 ambient light sensor"
depends on EXPERIMENTAL
Expand Down
1 change: 0 additions & 1 deletion drivers/i2c/chips/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#

obj-$(CONFIG_DS1682) += ds1682.o
obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
obj-$(CONFIG_PCF8575) += pcf8575.o
Expand Down
43 changes: 27 additions & 16 deletions drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/idr.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>
#include <linux/completion.h>
#include <linux/hardirq.h>
Expand Down Expand Up @@ -451,16 +450,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)

mutex_lock(&core_lock);

/* Add the adapter to the driver core.
* If the parent pointer is not set up,
* we add this adapter to the host bus.
*/
if (adap->dev.parent == NULL) {
adap->dev.parent = &platform_bus;
pr_debug("I2C adapter driver [%s] forgot to specify "
"physical device\n", adap->name);
}

/* Set default timeout to 1 second if not already set */
if (adap->timeout == 0)
adap->timeout = HZ;
Expand Down Expand Up @@ -1022,7 +1011,8 @@ module_exit(i2c_exit);
*/
int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
{
int ret;
unsigned long orig_jiffies;
int ret, try;

/* REVISIT the fault reporting model here is weak:
*
Expand Down Expand Up @@ -1060,7 +1050,15 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
mutex_lock_nested(&adap->bus_lock, adap->level);
}

ret = adap->algo->master_xfer(adap,msgs,num);
/* Retry automatically on arbitration loss */
orig_jiffies = jiffies;
for (ret = 0, try = 0; try <= adap->retries; try++) {
ret = adap->algo->master_xfer(adap, msgs, num);
if (ret != -EAGAIN)
break;
if (time_after(jiffies, orig_jiffies + adap->timeout))
break;
}
mutex_unlock(&adap->bus_lock);

return ret;
Expand Down Expand Up @@ -1509,7 +1507,7 @@ struct i2c_adapter* i2c_get_adapter(int id)
struct i2c_adapter *adapter;

mutex_lock(&core_lock);
adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
adapter = idr_find(&i2c_adapter_idr, id);
if (adapter && !try_module_get(adapter->owner))
adapter = NULL;

Expand Down Expand Up @@ -1995,14 +1993,27 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
char read_write, u8 command, int protocol,
union i2c_smbus_data *data)
{
unsigned long orig_jiffies;
int try;
s32 res;

flags &= I2C_M_TEN | I2C_CLIENT_PEC;

if (adapter->algo->smbus_xfer) {
mutex_lock(&adapter->bus_lock);
res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write,
command, protocol, data);

/* Retry automatically on arbitration loss */
orig_jiffies = jiffies;
for (res = 0, try = 0; try <= adapter->retries; try++) {
res = adapter->algo->smbus_xfer(adapter, addr, flags,
read_write, command,
protocol, data);
if (res != -EAGAIN)
break;
if (time_after(jiffies,
orig_jiffies + adapter->timeout))
break;
}
mutex_unlock(&adapter->bus_lock);
} else
res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write,
Expand Down
84 changes: 42 additions & 42 deletions drivers/macintosh/therm_adt746x.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ MODULE_PARM_DESC(verbose,"Verbose log operations "
"(default 0)");

struct thermostat {
struct i2c_client clt;
struct i2c_client *clt;
u8 temps[3];
u8 cached_temp[3];
u8 initial_limits[3];
Expand All @@ -87,9 +87,6 @@ static struct of_device * of_dev;
static struct thermostat* thermostat;
static struct task_struct *thread_therm = NULL;

static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
int busno);

static void write_both_fan_speed(struct thermostat *th, int speed);
static void write_fan_speed(struct thermostat *th, int speed, int fan);

Expand All @@ -101,7 +98,7 @@ write_reg(struct thermostat* th, int reg, u8 data)

tmp[0] = reg;
tmp[1] = data;
rc = i2c_master_send(&th->clt, (const char *)tmp, 2);
rc = i2c_master_send(th->clt, (const char *)tmp, 2);
if (rc < 0)
return rc;
if (rc != 2)
Expand All @@ -116,12 +113,12 @@ read_reg(struct thermostat* th, int reg)
int rc;

reg_addr = (u8)reg;
rc = i2c_master_send(&th->clt, &reg_addr, 1);
rc = i2c_master_send(th->clt, &reg_addr, 1);
if (rc < 0)
return rc;
if (rc != 1)
return -ENODEV;
rc = i2c_master_recv(&th->clt, (char *)&data, 1);
rc = i2c_master_recv(th->clt, (char *)&data, 1);
if (rc < 0)
return rc;
return data;
Expand All @@ -131,26 +128,36 @@ static int
attach_thermostat(struct i2c_adapter *adapter)
{
unsigned long bus_no;
struct i2c_board_info info;
struct i2c_client *client;

if (strncmp(adapter->name, "uni-n", 5))
return -ENODEV;
bus_no = simple_strtoul(adapter->name + 6, NULL, 10);
if (bus_no != therm_bus)
return -ENODEV;
return attach_one_thermostat(adapter, therm_address, bus_no);

memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "therm_adt746x", I2C_NAME_SIZE);
info.addr = therm_address;
client = i2c_new_device(adapter, &info);
if (!client)
return -ENODEV;

/*
* Let i2c-core delete that device on driver removal.
* This is safe because i2c-core holds the core_lock mutex for us.
*/
list_add_tail(&client->detected, &client->driver->clients);
return 0;
}

static int
detach_thermostat(struct i2c_adapter *adapter)
remove_thermostat(struct i2c_client *client)
{
struct thermostat* th;
struct thermostat *th = i2c_get_clientdata(client);
int i;

if (thermostat == NULL)
return 0;

th = thermostat;

if (thread_therm != NULL) {
kthread_stop(thread_therm);
}
Expand All @@ -166,23 +173,13 @@ detach_thermostat(struct i2c_adapter *adapter)

write_both_fan_speed(th, -1);

i2c_detach_client(&th->clt);

thermostat = NULL;

kfree(th);

return 0;
}

static struct i2c_driver thermostat_driver = {
.driver = {
.name = "therm_adt746x",
},
.attach_adapter = attach_thermostat,
.detach_adapter = detach_thermostat,
};

static int read_fan_speed(struct thermostat *th, u8 addr)
{
u8 tmp[2];
Expand Down Expand Up @@ -371,8 +368,8 @@ static void set_limit(struct thermostat *th, int i)
th->limits[i] = default_limits_local[i] + limit_adjust;
}

static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
int busno)
static int probe_thermostat(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct thermostat* th;
int rc;
Expand All @@ -385,16 +382,12 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
if (!th)
return -ENOMEM;

th->clt.addr = addr;
th->clt.adapter = adapter;
th->clt.driver = &thermostat_driver;
strcpy(th->clt.name, "thermostat");
i2c_set_clientdata(client, th);
th->clt = client;

rc = read_reg(th, 0);
if (rc < 0) {
printk(KERN_ERR "adt746x: Thermostat failed to read config "
"from bus %d !\n",
busno);
dev_err(&client->dev, "Thermostat failed to read config!\n");
kfree(th);
return -ENODEV;
}
Expand Down Expand Up @@ -423,14 +416,6 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,

thermostat = th;

if (i2c_attach_client(&th->clt)) {
printk(KERN_INFO "adt746x: Thermostat failed to attach "
"client !\n");
thermostat = NULL;
kfree(th);
return -ENODEV;
}

/* be sure to really write fan speed the first time */
th->last_speed[0] = -2;
th->last_speed[1] = -2;
Expand All @@ -456,6 +441,21 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
return 0;
}

static const struct i2c_device_id therm_adt746x_id[] = {
{ "therm_adt746x", 0 },
{ }
};

static struct i2c_driver thermostat_driver = {
.driver = {
.name = "therm_adt746x",
},
.attach_adapter = attach_thermostat,
.probe = probe_thermostat,
.remove = remove_thermostat,
.id_table = therm_adt746x_id,
};

/*
* Now, unfortunately, sysfs doesn't give us a nice void * we could
* pass around to the attribute functions, so we don't really have
Expand Down
Loading

0 comments on commit 4858704

Please sign in to comment.