Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[pandora-kernel.git] / drivers / i2c / i2c-core.c
index 045ba6e..70c30e6 100644 (file)
@@ -348,7 +348,7 @@ 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. */
+ * are purposely 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) {
@@ -797,6 +797,9 @@ static int i2c_do_add_adapter(struct i2c_driver *driver,
 
        /* Let legacy drivers scan this bus for matching devices */
        if (driver->attach_adapter) {
+               dev_warn(&adap->dev, "attach_adapter method is deprecated\n");
+               dev_warn(&adap->dev, "Please use another way to instantiate "
+                        "your i2c_client\n");
                /* We ignore the return code; if it fails, too bad */
                driver->attach_adapter(adap);
        }
@@ -981,6 +984,7 @@ static int i2c_do_del_adapter(struct i2c_driver *driver,
 
        if (!driver->detach_adapter)
                return 0;
+       dev_warn(&adapter->dev, "detach_adapter method is deprecated\n");
        res = driver->detach_adapter(adapter);
        if (res)
                dev_err(&adapter->dev, "detach_adapter failed (%d) "
@@ -1091,6 +1095,18 @@ EXPORT_SYMBOL(i2c_del_adapter);
 
 /* ------------------------------------------------------------------------- */
 
+int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *))
+{
+       int res;
+
+       mutex_lock(&core_lock);
+       res = bus_for_each_dev(&i2c_bus_type, NULL, data, fn);
+       mutex_unlock(&core_lock);
+
+       return res;
+}
+EXPORT_SYMBOL_GPL(i2c_for_each_dev);
+
 static int __process_new_driver(struct device *dev, void *data)
 {
        if (dev->type != &i2c_adapter_type)
@@ -1134,9 +1150,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
 
        INIT_LIST_HEAD(&driver->clients);
        /* Walk the adapters that are already present */
-       mutex_lock(&core_lock);
-       bus_for_each_dev(&i2c_bus_type, NULL, driver, __process_new_driver);
-       mutex_unlock(&core_lock);
+       i2c_for_each_dev(driver, __process_new_driver);
 
        return 0;
 }
@@ -1156,9 +1170,7 @@ static int __process_removed_driver(struct device *dev, void *data)
  */
 void i2c_del_driver(struct i2c_driver *driver)
 {
-       mutex_lock(&core_lock);
-       bus_for_each_dev(&i2c_bus_type, NULL, driver, __process_removed_driver);
-       mutex_unlock(&core_lock);
+       i2c_for_each_dev(driver, __process_removed_driver);
 
        driver_unregister(&driver->driver);
        pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
@@ -1581,12 +1593,12 @@ i2c_new_probed_device(struct i2c_adapter *adap,
 }
 EXPORT_SYMBOL_GPL(i2c_new_probed_device);
 
-struct i2c_adapter *i2c_get_adapter(int id)
+struct i2c_adapter *i2c_get_adapter(int nr)
 {
        struct i2c_adapter *adapter;
 
        mutex_lock(&core_lock);
-       adapter = idr_find(&i2c_adapter_idr, id);
+       adapter = idr_find(&i2c_adapter_idr, nr);
        if (adapter && !try_module_get(adapter->owner))
                adapter = NULL;