提交 5672bc81 编写于 作者: L Linus Torvalds

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:
  of/i2c: Fix module load order issue caused by of_i2c.c
  i2c: Fix checks which cause legacy suspend to never get called
  i2c-pca: Fix waitforcompletion() return value
  i2c: Fix for suspend/resume issue
  i2c: Remove obsolete cleanup for clientdata
......@@ -677,6 +677,11 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev,
dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
cpm->adap.name);
/*
* register OF I2C devices
*/
of_i2c_register_devices(&cpm->adap);
return 0;
out_shut:
cpm_i2c_shutdown(cpm);
......
......@@ -761,6 +761,9 @@ static int __devinit iic_probe(struct platform_device *ofdev,
dev_info(&ofdev->dev, "using %s mode\n",
dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
/* Now register all the child nodes */
of_i2c_register_devices(adap);
return 0;
error_cleanup:
......
......@@ -632,6 +632,7 @@ static int __devinit fsl_i2c_probe(struct platform_device *op,
dev_err(i2c->dev, "failed to add adapter\n");
goto fail_add;
}
of_i2c_register_devices(&i2c->adap);
return result;
......
......@@ -71,8 +71,8 @@ static int pca_isa_readbyte(void *pd, int reg)
static int pca_isa_waitforcompletion(void *pd)
{
long ret = ~0;
unsigned long timeout;
long ret;
if (irq > -1) {
ret = wait_event_timeout(pca_wait,
......@@ -81,11 +81,15 @@ static int pca_isa_waitforcompletion(void *pd)
} else {
/* Do polling */
timeout = jiffies + pca_isa_ops.timeout;
while (((pca_isa_readbyte(pd, I2C_PCA_CON)
& I2C_PCA_CON_SI) == 0)
&& (ret = time_before(jiffies, timeout)))
do {
ret = time_before(jiffies, timeout);
if (pca_isa_readbyte(pd, I2C_PCA_CON)
& I2C_PCA_CON_SI)
break;
udelay(100);
} while (ret);
}
return ret > 0;
}
......
......@@ -80,8 +80,8 @@ static void i2c_pca_pf_writebyte32(void *pd, int reg, int val)
static int i2c_pca_pf_waitforcompletion(void *pd)
{
struct i2c_pca_pf_data *i2c = pd;
long ret = ~0;
unsigned long timeout;
long ret;
if (i2c->irq) {
ret = wait_event_timeout(i2c->wait,
......@@ -90,10 +90,13 @@ static int i2c_pca_pf_waitforcompletion(void *pd)
} else {
/* Do polling */
timeout = jiffies + i2c->adap.timeout;
while (((i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
& I2C_PCA_CON_SI) == 0)
&& (ret = time_before(jiffies, timeout)))
do {
ret = time_before(jiffies, timeout);
if (i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
& I2C_PCA_CON_SI)
break;
udelay(100);
} while (ret);
}
return ret > 0;
......
......@@ -32,7 +32,6 @@
#include <linux/init.h>
#include <linux/idr.h>
#include <linux/mutex.h>
#include <linux/of_i2c.h>
#include <linux/of_device.h>
#include <linux/completion.h>
#include <linux/hardirq.h>
......@@ -197,11 +196,12 @@ static int i2c_device_pm_suspend(struct device *dev)
{
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
if (pm_runtime_suspended(dev))
return 0;
if (pm)
return pm->suspend ? pm->suspend(dev) : 0;
if (pm) {
if (pm_runtime_suspended(dev))
return 0;
else
return pm->suspend ? pm->suspend(dev) : 0;
}
return i2c_legacy_suspend(dev, PMSG_SUSPEND);
}
......@@ -216,12 +216,6 @@ static int i2c_device_pm_resume(struct device *dev)
else
ret = i2c_legacy_resume(dev);
if (!ret) {
pm_runtime_disable(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
}
return ret;
}
......@@ -229,11 +223,12 @@ static int i2c_device_pm_freeze(struct device *dev)
{
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
if (pm_runtime_suspended(dev))
return 0;
if (pm)
return pm->freeze ? pm->freeze(dev) : 0;
if (pm) {
if (pm_runtime_suspended(dev))
return 0;
else
return pm->freeze ? pm->freeze(dev) : 0;
}
return i2c_legacy_suspend(dev, PMSG_FREEZE);
}
......@@ -242,11 +237,12 @@ static int i2c_device_pm_thaw(struct device *dev)
{
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
if (pm_runtime_suspended(dev))
return 0;
if (pm)
return pm->thaw ? pm->thaw(dev) : 0;
if (pm) {
if (pm_runtime_suspended(dev))
return 0;
else
return pm->thaw ? pm->thaw(dev) : 0;
}
return i2c_legacy_resume(dev);
}
......@@ -255,11 +251,12 @@ static int i2c_device_pm_poweroff(struct device *dev)
{
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
if (pm_runtime_suspended(dev))
return 0;
if (pm)
return pm->poweroff ? pm->poweroff(dev) : 0;
if (pm) {
if (pm_runtime_suspended(dev))
return 0;
else
return pm->poweroff ? pm->poweroff(dev) : 0;
}
return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
}
......@@ -876,9 +873,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
if (adap->nr < __i2c_first_dynamic_bus_num)
i2c_scan_static_board_info(adap);
/* Register devices from the device tree */
of_i2c_register_devices(adap);
/* Notify drivers */
mutex_lock(&core_lock);
bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
......
......@@ -190,7 +190,6 @@ static int __devexit bh1780_remove(struct i2c_client *client)
ddata = i2c_get_clientdata(client);
sysfs_remove_group(&client->dev.kobj, &bh1780_attr_group);
i2c_set_clientdata(client, NULL);
kfree(ddata);
return 0;
......
......@@ -256,7 +256,6 @@ static int __devexit ad5398_remove(struct i2c_client *client)
regulator_unregister(chip->rdev);
kfree(chip);
i2c_set_clientdata(client, NULL);
return 0;
}
......
......@@ -191,8 +191,6 @@ static int __devexit isl6271a_remove(struct i2c_client *i2c)
struct isl_pmic *pmic = i2c_get_clientdata(i2c);
int i;
i2c_set_clientdata(i2c, NULL);
for (i = 0; i < 3; i++)
regulator_unregister(pmic->rdev[i]);
......
......@@ -268,7 +268,6 @@ static int __devinit ds3232_probe(struct i2c_client *client,
free_irq(client->irq, client);
out_free:
i2c_set_clientdata(client, NULL);
kfree(ds3232);
return ret;
}
......@@ -287,7 +286,6 @@ static int __devexit ds3232_remove(struct i2c_client *client)
}
rtc_device_unregister(ds3232->rtc);
i2c_set_clientdata(client, NULL);
kfree(ds3232);
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册