You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
* 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: i2c: Remove all i2c_set_clientdata(client, NULL) in drivers i2c/busses: Move two drivers to embedded section i2c: Rename i2c_check_addr to i2c_check_addr_busy i2c: Document reserved I2C addresses i2c: Check for address validity on client registration i2c: Share the I2C device presence detection code Documentation/i2c: Checkpatch cleanup
This commit is contained in:
@@ -6,12 +6,12 @@ Supported adapters:
|
||||
http://www.ali.com.tw/eng/support/datasheet_request.php
|
||||
|
||||
Authors:
|
||||
Frodo Looijaard <frodol@dds.nl>,
|
||||
Frodo Looijaard <frodol@dds.nl>,
|
||||
Philip Edelbrock <phil@netroedge.com>,
|
||||
Mark D. Studebaker <mdsxyz123@yahoo.com>,
|
||||
Dan Eaton <dan.eaton@rocketlogix.com>,
|
||||
Stephen Rousset<stephen.rousset@rocketlogix.com>
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ For an overview of these chips see http://www.acerlabs.com
|
||||
The M1563 southbridge is deceptively similar to the M1533, with a few
|
||||
notable exceptions. One of those happens to be the fact they upgraded the
|
||||
i2c core to be SMBus 2.0 compliant, and happens to be almost identical to
|
||||
the i2c controller found in the Intel 801 south bridges.
|
||||
the i2c controller found in the Intel 801 south bridges.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
@@ -6,8 +6,8 @@ Supported adapters:
|
||||
http://www.ali.com.tw/eng/support/datasheet_request.php
|
||||
|
||||
Authors:
|
||||
Frodo Looijaard <frodol@dds.nl>,
|
||||
Philip Edelbrock <phil@netroedge.com>,
|
||||
Frodo Looijaard <frodol@dds.nl>,
|
||||
Philip Edelbrock <phil@netroedge.com>,
|
||||
Mark D. Studebaker <mdsxyz123@yahoo.com>
|
||||
|
||||
Module Parameters
|
||||
@@ -40,10 +40,10 @@ M1541 and M1543C South Bridges.
|
||||
The M1543C is a South bridge for desktop systems.
|
||||
The M1541 is a South bridge for portable systems.
|
||||
They are part of the following ALI chipsets:
|
||||
|
||||
* "Aladdin Pro 2" includes the M1621 Slot 1 North bridge with AGP and
|
||||
|
||||
* "Aladdin Pro 2" includes the M1621 Slot 1 North bridge with AGP and
|
||||
100MHz CPU Front Side bus
|
||||
* "Aladdin V" includes the M1541 Socket 7 North bridge with AGP and 100MHz
|
||||
* "Aladdin V" includes the M1541 Socket 7 North bridge with AGP and 100MHz
|
||||
CPU Front Side bus
|
||||
Some Aladdin V motherboards:
|
||||
Asus P5A
|
||||
@@ -77,7 +77,7 @@ output of lspci will show something similar to the following:
|
||||
** then run lspci.
|
||||
** If you see the 1533 and 5229 devices but NOT the 7101 device,
|
||||
** then you must enable ACPI, the PMU, SMB, or something similar
|
||||
** in the BIOS.
|
||||
** in the BIOS.
|
||||
** The driver won't work if it can't find the M7101 device.
|
||||
|
||||
The SMB controller is part of the M7101 device, which is an ACPI-compliant
|
||||
@@ -87,8 +87,8 @@ The whole M7101 device has to be enabled for the SMB to work. You can't
|
||||
just enable the SMB alone. The SMB and the ACPI have separate I/O spaces.
|
||||
We make sure that the SMB is enabled. We leave the ACPI alone.
|
||||
|
||||
Features
|
||||
--------
|
||||
Features
|
||||
--------
|
||||
|
||||
This driver controls the SMB Host only. The SMB Slave
|
||||
controller on the M15X3 is not enabled. This driver does not use
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
Kernel driver i2c-pca-isa
|
||||
|
||||
Supported adapters:
|
||||
This driver supports ISA boards using the Philips PCA 9564
|
||||
Parallel bus to I2C bus controller
|
||||
This driver supports ISA boards using the Philips PCA 9564
|
||||
Parallel bus to I2C bus controller
|
||||
|
||||
Author: Ian Campbell <icampbell@arcom.com>, Arcom Control Systems
|
||||
Author: Ian Campbell <icampbell@arcom.com>, Arcom Control Systems
|
||||
|
||||
Module Parameters
|
||||
-----------------
|
||||
@@ -12,12 +12,12 @@ Module Parameters
|
||||
* base int
|
||||
I/O base address
|
||||
* irq int
|
||||
IRQ interrupt
|
||||
* clock int
|
||||
IRQ interrupt
|
||||
* clock int
|
||||
Clock rate as described in table 1 of PCA9564 datasheet
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
This driver supports ISA boards using the Philips PCA 9564
|
||||
Parallel bus to I2C bus controller
|
||||
This driver supports ISA boards using the Philips PCA 9564
|
||||
Parallel bus to I2C bus controller
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
Kernel driver i2c-sis5595
|
||||
|
||||
Authors:
|
||||
Authors:
|
||||
Frodo Looijaard <frodol@dds.nl>,
|
||||
Mark D. Studebaker <mdsxyz123@yahoo.com>,
|
||||
Philip Edelbrock <phil@netroedge.com>
|
||||
Philip Edelbrock <phil@netroedge.com>
|
||||
|
||||
Supported adapters:
|
||||
* Silicon Integrated Systems Corp. SiS5595 Southbridge
|
||||
Datasheet: Publicly available at the Silicon Integrated Systems Corp. site.
|
||||
|
||||
Note: all have mfr. ID 0x1039.
|
||||
Note: all have mfr. ID 0x1039.
|
||||
|
||||
SUPPORTED PCI ID
|
||||
5595 0008
|
||||
|
||||
Note: these chips contain a 0008 device which is incompatible with the
|
||||
5595. We recognize these by the presence of the listed
|
||||
"blacklist" PCI ID and refuse to load.
|
||||
|
||||
NOT SUPPORTED PCI ID BLACKLIST PCI ID
|
||||
540 0008 0540
|
||||
550 0008 0550
|
||||
5513 0008 5511
|
||||
5581 0008 5597
|
||||
5582 0008 5597
|
||||
5597 0008 5597
|
||||
5598 0008 5597/5598
|
||||
630 0008 0630
|
||||
645 0008 0645
|
||||
646 0008 0646
|
||||
648 0008 0648
|
||||
650 0008 0650
|
||||
651 0008 0651
|
||||
730 0008 0730
|
||||
735 0008 0735
|
||||
745 0008 0745
|
||||
746 0008 0746
|
||||
SUPPORTED PCI ID
|
||||
5595 0008
|
||||
|
||||
Note: these chips contain a 0008 device which is incompatible with the
|
||||
5595. We recognize these by the presence of the listed
|
||||
"blacklist" PCI ID and refuse to load.
|
||||
|
||||
NOT SUPPORTED PCI ID BLACKLIST PCI ID
|
||||
540 0008 0540
|
||||
550 0008 0550
|
||||
5513 0008 5511
|
||||
5581 0008 5597
|
||||
5582 0008 5597
|
||||
5597 0008 5597
|
||||
5598 0008 5597/5598
|
||||
630 0008 0630
|
||||
645 0008 0645
|
||||
646 0008 0646
|
||||
648 0008 0648
|
||||
650 0008 0650
|
||||
651 0008 0651
|
||||
730 0008 0730
|
||||
735 0008 0735
|
||||
745 0008 0745
|
||||
746 0008 0746
|
||||
|
||||
Module Parameters
|
||||
-----------------
|
||||
|
||||
@@ -14,9 +14,9 @@ Module Parameters
|
||||
* force = [1|0] Forcibly enable the SIS630. DANGEROUS!
|
||||
This can be interesting for chipsets not named
|
||||
above to check if it works for you chipset, but DANGEROUS!
|
||||
|
||||
* high_clock = [1|0] Forcibly set Host Master Clock to 56KHz (default,
|
||||
what your BIOS use). DANGEROUS! This should be a bit
|
||||
|
||||
* high_clock = [1|0] Forcibly set Host Master Clock to 56KHz (default,
|
||||
what your BIOS use). DANGEROUS! This should be a bit
|
||||
faster, but freeze some systems (i.e. my Laptop).
|
||||
|
||||
|
||||
@@ -44,6 +44,6 @@ Philip Edelbrock <phil@netroedge.com>
|
||||
- testing SiS730 support
|
||||
Mark M. Hoffman <mhoffman@lightlink.com>
|
||||
- bug fixes
|
||||
|
||||
|
||||
To anyone else which I forgot here ;), thanks!
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
The I2C protocol knows about two kinds of device addresses: normal 7 bit
|
||||
The I2C protocol knows about two kinds of device addresses: normal 7 bit
|
||||
addresses, and an extended set of 10 bit addresses. The sets of addresses
|
||||
do not intersect: the 7 bit address 0x10 is not the same as the 10 bit
|
||||
address 0x10 (though a single device could respond to both of them). You
|
||||
select a 10 bit address by adding an extra byte after the address
|
||||
byte:
|
||||
S Addr7 Rd/Wr ....
|
||||
S Addr7 Rd/Wr ....
|
||||
becomes
|
||||
S 11110 Addr10 Rd/Wr
|
||||
S is the start bit, Rd/Wr the read/write bit, and if you count the number
|
||||
of bits, you will see the there are 8 after the S bit for 7 bit addresses,
|
||||
and 16 after the S bit for 10 bit addresses.
|
||||
|
||||
WARNING! The current 10 bit address support is EXPERIMENTAL. There are
|
||||
WARNING! The current 10 bit address support is EXPERIMENTAL. There are
|
||||
several places in the code that will cause SEVERE PROBLEMS with 10 bit
|
||||
addresses, even though there is some basic handling and hooks. Also,
|
||||
almost no supported adapter handles the 10 bit addresses correctly.
|
||||
|
||||
@@ -316,7 +316,6 @@ static int __devinit adt7411_probe(struct i2c_client *client,
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
|
||||
exit_free:
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return ret;
|
||||
}
|
||||
@@ -327,7 +326,6 @@ static int __devexit adt7411_remove(struct i2c_client *client)
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1141,7 +1141,6 @@ exit_remove:
|
||||
&(asc7621_params[i].sda.dev_attr));
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return err;
|
||||
}
|
||||
@@ -1196,7 +1195,6 @@ static int asc7621_remove(struct i2c_client *client)
|
||||
&(asc7621_params[i].sda.dev_attr));
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -662,7 +662,6 @@ exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &f75375_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -672,7 +671,6 @@ static int f75375_remove(struct i2c_client *client)
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &f75375_group);
|
||||
kfree(data);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +236,6 @@ error_hwmon_device_register:
|
||||
sysfs_remove_group(&client->dev.kobj, &g760a_group);
|
||||
error_sysfs_create_group:
|
||||
kfree(data);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
|
||||
return err;
|
||||
}
|
||||
@@ -247,7 +246,6 @@ static int g760a_remove(struct i2c_client *client)
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &g760a_group);
|
||||
kfree(data);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,6 @@ static int lm73_remove(struct i2c_client *client)
|
||||
|
||||
hwmon_device_unregister(hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &lm73_group);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,6 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &lm75_group);
|
||||
exit_free:
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return status;
|
||||
}
|
||||
@@ -204,7 +203,6 @@ static int lm75_remove(struct i2c_client *client)
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &lm75_group);
|
||||
lm75_write_value(client, LM75_REG_CONF, data->orig_conf);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -399,7 +399,6 @@ static int lm95241_remove(struct i2c_client *client)
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &lm95241_group);
|
||||
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,6 @@ fail_remove_sysfs:
|
||||
fail_restore_config:
|
||||
tmp102_write_reg(client, TMP102_CONF_REG, tmp102->config_orig);
|
||||
fail_free:
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(tmp102);
|
||||
|
||||
return status;
|
||||
@@ -247,7 +246,6 @@ static int __devexit tmp102_remove(struct i2c_client *client)
|
||||
config | TMP102_CONF_SD);
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(tmp102);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -295,7 +295,6 @@ exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &tmp421_group);
|
||||
|
||||
exit_free:
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
|
||||
return err;
|
||||
@@ -308,7 +307,6 @@ static int tmp421_remove(struct i2c_client *client)
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &tmp421_group);
|
||||
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1197,7 +1197,6 @@ ERROR4:
|
||||
if (data->lm75[1])
|
||||
i2c_unregister_device(data->lm75[1]);
|
||||
ERROR3:
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
ERROR1:
|
||||
return err;
|
||||
@@ -1219,7 +1218,6 @@ w83781d_remove(struct i2c_client *client)
|
||||
if (data->lm75[1])
|
||||
i2c_unregister_device(data->lm75[1]);
|
||||
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
|
||||
+20
-20
@@ -475,6 +475,26 @@ config I2C_PASEMI
|
||||
help
|
||||
Supports the PA Semi PWRficient on-chip SMBus interfaces.
|
||||
|
||||
config I2C_PCA_PLATFORM
|
||||
tristate "PCA9564/PCA9665 as platform device"
|
||||
select I2C_ALGOPCA
|
||||
default n
|
||||
help
|
||||
This driver supports a memory mapped Philips PCA9564/PCA9665
|
||||
parallel bus to I2C bus controller.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called i2c-pca-platform.
|
||||
|
||||
config I2C_PMCMSP
|
||||
tristate "PMC MSP I2C TWI Controller"
|
||||
depends on PMC_MSP
|
||||
help
|
||||
This driver supports the PMC TWI controller on MSP devices.
|
||||
|
||||
This driver can also be built as module. If so, the module
|
||||
will be called i2c-pmcmsp.
|
||||
|
||||
config I2C_PNX
|
||||
tristate "I2C bus support for Philips PNX targets"
|
||||
depends on ARCH_PNX4008
|
||||
@@ -711,26 +731,6 @@ config I2C_PCA_ISA
|
||||
delays when I2C/SMBus chip drivers are loaded (e.g. at boot
|
||||
time). If unsure, say N.
|
||||
|
||||
config I2C_PCA_PLATFORM
|
||||
tristate "PCA9564/PCA9665 as platform device"
|
||||
select I2C_ALGOPCA
|
||||
default n
|
||||
help
|
||||
This driver supports a memory mapped Philips PCA9564/PCA9665
|
||||
parallel bus to I2C bus controller.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called i2c-pca-platform.
|
||||
|
||||
config I2C_PMCMSP
|
||||
tristate "PMC MSP I2C TWI Controller"
|
||||
depends on PMC_MSP
|
||||
help
|
||||
This driver supports the PMC TWI controller on MSP devices.
|
||||
|
||||
This driver can also be built as module. If so, the module
|
||||
will be called i2c-pmcmsp.
|
||||
|
||||
config I2C_SIBYTE
|
||||
tristate "SiByte SMBus interface"
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
|
||||
@@ -27,7 +27,7 @@ obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o
|
||||
obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o
|
||||
obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o
|
||||
|
||||
# Embebbed system I2C/SMBus host controller drivers
|
||||
# Embedded system I2C/SMBus host controller drivers
|
||||
obj-$(CONFIG_I2C_AT91) += i2c-at91.o
|
||||
obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
|
||||
obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
|
||||
@@ -46,6 +46,8 @@ obj-$(CONFIG_I2C_NOMADIK) += i2c-nomadik.o
|
||||
obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o
|
||||
obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
|
||||
obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o
|
||||
obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pca-platform.o
|
||||
obj-$(CONFIG_I2C_PMCMSP) += i2c-pmcmsp.o
|
||||
obj-$(CONFIG_I2C_PNX) += i2c-pnx.o
|
||||
obj-$(CONFIG_I2C_PXA) += i2c-pxa.o
|
||||
obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o
|
||||
@@ -68,8 +70,6 @@ obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o
|
||||
obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o
|
||||
obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
|
||||
obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
|
||||
obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pca-platform.o
|
||||
obj-$(CONFIG_I2C_PMCMSP) += i2c-pmcmsp.o
|
||||
obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
|
||||
obj-$(CONFIG_I2C_STUB) += i2c-stub.o
|
||||
obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
|
||||
|
||||
+110
-69
@@ -47,7 +47,6 @@ static DEFINE_MUTEX(core_lock);
|
||||
static DEFINE_IDR(i2c_adapter_idr);
|
||||
|
||||
static struct device_type i2c_client_type;
|
||||
static int i2c_check_addr(struct i2c_adapter *adapter, int addr);
|
||||
static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -371,6 +370,59 @@ struct i2c_client *i2c_verify_client(struct device *dev)
|
||||
EXPORT_SYMBOL(i2c_verify_client);
|
||||
|
||||
|
||||
/* This is a permissive address validity check, I2C address map constraints
|
||||
* are purposedly not enforced, except for the general call address. */
|
||||
static int i2c_check_client_addr_validity(const struct i2c_client *client)
|
||||
{
|
||||
if (client->flags & I2C_CLIENT_TEN) {
|
||||
/* 10-bit address, all values are valid */
|
||||
if (client->addr > 0x3ff)
|
||||
return -EINVAL;
|
||||
} else {
|
||||
/* 7-bit address, reject the general call address */
|
||||
if (client->addr == 0x00 || client->addr > 0x7f)
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* And this is a strict address validity check, used when probing. If a
|
||||
* device uses a reserved address, then it shouldn't be probed. 7-bit
|
||||
* addressing is assumed, 10-bit address devices are rare and should be
|
||||
* explicitly enumerated. */
|
||||
static int i2c_check_addr_validity(unsigned short addr)
|
||||
{
|
||||
/*
|
||||
* Reserved addresses per I2C specification:
|
||||
* 0x00 General call address / START byte
|
||||
* 0x01 CBUS address
|
||||
* 0x02 Reserved for different bus format
|
||||
* 0x03 Reserved for future purposes
|
||||
* 0x04-0x07 Hs-mode master code
|
||||
* 0x78-0x7b 10-bit slave addressing
|
||||
* 0x7c-0x7f Reserved for future purposes
|
||||
*/
|
||||
if (addr < 0x08 || addr > 0x77)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __i2c_check_addr_busy(struct device *dev, void *addrp)
|
||||
{
|
||||
struct i2c_client *client = i2c_verify_client(dev);
|
||||
int addr = *(int *)addrp;
|
||||
|
||||
if (client && client->addr == addr)
|
||||
return -EBUSY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
|
||||
{
|
||||
return device_for_each_child(&adapter->dev, &addr,
|
||||
__i2c_check_addr_busy);
|
||||
}
|
||||
|
||||
/**
|
||||
* i2c_new_device - instantiate an i2c device
|
||||
* @adap: the adapter managing the device
|
||||
@@ -410,8 +462,16 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
|
||||
|
||||
strlcpy(client->name, info->type, sizeof(client->name));
|
||||
|
||||
/* Check for address validity */
|
||||
status = i2c_check_client_addr_validity(client);
|
||||
if (status) {
|
||||
dev_err(&adap->dev, "Invalid %d-bit I2C address 0x%02hx\n",
|
||||
client->flags & I2C_CLIENT_TEN ? 10 : 7, client->addr);
|
||||
goto out_err_silent;
|
||||
}
|
||||
|
||||
/* Check for address business */
|
||||
status = i2c_check_addr(adap, client->addr);
|
||||
status = i2c_check_addr_busy(adap, client->addr);
|
||||
if (status)
|
||||
goto out_err;
|
||||
|
||||
@@ -436,6 +496,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
|
||||
out_err:
|
||||
dev_err(&adap->dev, "Failed to register i2c client %s at 0x%02x "
|
||||
"(%d)\n", client->name, client->addr, status);
|
||||
out_err_silent:
|
||||
kfree(client);
|
||||
return NULL;
|
||||
}
|
||||
@@ -561,15 +622,9 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (info.addr < 0x03 || info.addr > 0x77) {
|
||||
dev_err(dev, "%s: Invalid I2C address 0x%hx\n", "new_device",
|
||||
info.addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
client = i2c_new_device(adap, &info);
|
||||
if (!client)
|
||||
return -EEXIST;
|
||||
return -EINVAL;
|
||||
|
||||
/* Keep track of the added device */
|
||||
i2c_lock_adapter(adap);
|
||||
@@ -1024,21 +1079,6 @@ EXPORT_SYMBOL(i2c_del_driver);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int __i2c_check_addr(struct device *dev, void *addrp)
|
||||
{
|
||||
struct i2c_client *client = i2c_verify_client(dev);
|
||||
int addr = *(int *)addrp;
|
||||
|
||||
if (client && client->addr == addr)
|
||||
return -EBUSY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int i2c_check_addr(struct i2c_adapter *adapter, int addr)
|
||||
{
|
||||
return device_for_each_child(&adapter->dev, &addr, __i2c_check_addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* i2c_use_client - increments the reference count of the i2c client structure
|
||||
* @client: the client being referenced
|
||||
@@ -1277,6 +1317,41 @@ EXPORT_SYMBOL(i2c_master_recv);
|
||||
* ----------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Legacy default probe function, mostly relevant for SMBus. The default
|
||||
* probe method is a quick write, but it is known to corrupt the 24RF08
|
||||
* EEPROMs due to a state machine bug, and could also irreversibly
|
||||
* write-protect some EEPROMs, so for address ranges 0x30-0x37 and 0x50-0x5f,
|
||||
* we use a short byte read instead. Also, some bus drivers don't implement
|
||||
* quick write, so we fallback to a byte read in that case too.
|
||||
* On x86, there is another special case for FSC hardware monitoring chips,
|
||||
* which want regular byte reads (address 0x73.) Fortunately, these are the
|
||||
* only known chips using this I2C address on PC hardware.
|
||||
* Returns 1 if probe succeeded, 0 if not.
|
||||
*/
|
||||
static int i2c_default_probe(struct i2c_adapter *adap, unsigned short addr)
|
||||
{
|
||||
int err;
|
||||
union i2c_smbus_data dummy;
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
if (addr == 0x73 && (adap->class & I2C_CLASS_HWMON)
|
||||
&& i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE_DATA))
|
||||
err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0,
|
||||
I2C_SMBUS_BYTE_DATA, &dummy);
|
||||
else
|
||||
#endif
|
||||
if ((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50
|
||||
|| !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK))
|
||||
err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0,
|
||||
I2C_SMBUS_BYTE, &dummy);
|
||||
else
|
||||
err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0,
|
||||
I2C_SMBUS_QUICK, NULL);
|
||||
|
||||
return err >= 0;
|
||||
}
|
||||
|
||||
static int i2c_detect_address(struct i2c_client *temp_client,
|
||||
struct i2c_driver *driver)
|
||||
{
|
||||
@@ -1286,34 +1361,20 @@ static int i2c_detect_address(struct i2c_client *temp_client,
|
||||
int err;
|
||||
|
||||
/* Make sure the address is valid */
|
||||
if (addr < 0x03 || addr > 0x77) {
|
||||
err = i2c_check_addr_validity(addr);
|
||||
if (err) {
|
||||
dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
|
||||
addr);
|
||||
return -EINVAL;
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Skip if already in use */
|
||||
if (i2c_check_addr(adapter, addr))
|
||||
if (i2c_check_addr_busy(adapter, addr))
|
||||
return 0;
|
||||
|
||||
/* Make sure there is something at this address */
|
||||
if (addr == 0x73 && (adapter->class & I2C_CLASS_HWMON)) {
|
||||
/* Special probe for FSC hwmon chips */
|
||||
union i2c_smbus_data dummy;
|
||||
|
||||
if (i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_READ, 0,
|
||||
I2C_SMBUS_BYTE_DATA, &dummy) < 0)
|
||||
return 0;
|
||||
} else {
|
||||
if (i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_WRITE, 0,
|
||||
I2C_SMBUS_QUICK, NULL) < 0)
|
||||
return 0;
|
||||
|
||||
/* Prevent 24RF08 corruption */
|
||||
if ((addr & ~0x0f) == 0x50)
|
||||
i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_WRITE, 0,
|
||||
I2C_SMBUS_QUICK, NULL);
|
||||
}
|
||||
if (!i2c_default_probe(adapter, addr))
|
||||
return 0;
|
||||
|
||||
/* Finally call the custom detection function */
|
||||
memset(&info, 0, sizeof(struct i2c_board_info));
|
||||
@@ -1407,42 +1468,22 @@ i2c_new_probed_device(struct i2c_adapter *adap,
|
||||
|
||||
for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) {
|
||||
/* Check address validity */
|
||||
if (addr_list[i] < 0x03 || addr_list[i] > 0x77) {
|
||||
if (i2c_check_addr_validity(addr_list[i]) < 0) {
|
||||
dev_warn(&adap->dev, "Invalid 7-bit address "
|
||||
"0x%02x\n", addr_list[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check address availability */
|
||||
if (i2c_check_addr(adap, addr_list[i])) {
|
||||
if (i2c_check_addr_busy(adap, addr_list[i])) {
|
||||
dev_dbg(&adap->dev, "Address 0x%02x already in "
|
||||
"use, not probing\n", addr_list[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Test address responsiveness
|
||||
The default probe method is a quick write, but it is known
|
||||
to corrupt the 24RF08 EEPROMs due to a state machine bug,
|
||||
and could also irreversibly write-protect some EEPROMs, so
|
||||
for address ranges 0x30-0x37 and 0x50-0x5f, we use a byte
|
||||
read instead. Also, some bus drivers don't implement
|
||||
quick write, so we fallback to a byte read it that case
|
||||
too. */
|
||||
if ((addr_list[i] & ~0x07) == 0x30
|
||||
|| (addr_list[i] & ~0x0f) == 0x50
|
||||
|| !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) {
|
||||
union i2c_smbus_data data;
|
||||
|
||||
if (i2c_smbus_xfer(adap, addr_list[i], 0,
|
||||
I2C_SMBUS_READ, 0,
|
||||
I2C_SMBUS_BYTE, &data) >= 0)
|
||||
break;
|
||||
} else {
|
||||
if (i2c_smbus_xfer(adap, addr_list[i], 0,
|
||||
I2C_SMBUS_WRITE, 0,
|
||||
I2C_SMBUS_QUICK, NULL) >= 0)
|
||||
break;
|
||||
}
|
||||
/* Test address responsiveness */
|
||||
if (i2c_default_probe(adap, addr_list[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (addr_list[i] == I2C_CLIENT_END) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user