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:
  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
  • Loading branch information
Linus Torvalds committed Oct 7, 2010
2 parents 27b3d80 + 925bb9c commit 5672bc8
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 44 deletions.
5 changes: 5 additions & 0 deletions drivers/i2c/busses/i2c-cpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions drivers/i2c/busses/i2c-ibm_iic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions drivers/i2c/busses/i2c-mpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 8 additions & 4 deletions drivers/i2c/busses/i2c-pca-isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}

Expand Down
11 changes: 7 additions & 4 deletions drivers/i2c/busses/i2c-pca-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
54 changes: 24 additions & 30 deletions drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
}
Expand All @@ -216,24 +216,19 @@ 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;
}

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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion drivers/misc/bh1780gli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion drivers/regulator/ad5398.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/regulator/isl6271a-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
2 changes: 0 additions & 2 deletions drivers/rtc/rtc-ds3232.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 5672bc8

Please sign in to comment.