Commit 729d6dd571464954f625e6b80950d9e4e3bd94f7

Authored by Jean Delvare
1 parent 352da9820e

i2c: Get rid of the legacy binding model

We converted all the legacy i2c drivers so we can finally get rid of
the legacy binding model. Hooray!

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>

Showing 4 changed files with 20 additions and 127 deletions Side-by-side Diff

Documentation/feature-removal-schedule.txt
... ... @@ -368,15 +368,6 @@
368 368  
369 369 ---------------------------
370 370  
371   -What: i2c_attach_client(), i2c_detach_client(), i2c_driver->detach_client()
372   -When: 2.6.30
373   -Check: i2c_attach_client i2c_detach_client
374   -Why: Deprecated by the new (standard) device driver binding model. Use
375   - i2c_driver->probe() and ->remove() instead.
376   -Who: Jean Delvare <khali@linux-fr.org>
377   -
378   ----------------------------
379   -
380 371 What: fscher and fscpos drivers
381 372 When: June 2009
382 373 Why: Deprecated by the new fschmd driver.
Documentation/i2c/writing-clients
... ... @@ -126,20 +126,10 @@
126 126 that can't be distinguished by protocol probing, or which need some board
127 127 specific information to operate correctly.
128 128  
129   -Accordingly, the I2C stack now has two models for associating I2C devices
130   -with their drivers: the original "legacy" model, and a newer one that's
131   -fully compatible with the Linux 2.6 driver model. These models do not mix,
132   -since the "legacy" model requires drivers to create "i2c_client" device
133   -objects after SMBus style probing, while the Linux driver model expects
134   -drivers to be given such device objects in their probe() routines.
135 129  
136   -The legacy model is deprecated now and will soon be removed, so we no
137   -longer document it here.
  130 +Device/Driver Binding
  131 +---------------------
138 132  
139   -
140   -Standard Driver Model Binding ("New Style")
141   --------------------------------------------
142   -
143 133 System infrastructure, typically board-specific initialization code or
144 134 boot firmware, reports what I2C devices exist. For example, there may be
145 135 a table, in the kernel or from the boot loader, identifying I2C devices
... ... @@ -201,7 +191,7 @@
201 191 devices on a PC's SMBus. In that case, you may want to let your driver
202 192 detect supported devices automatically. This is how the legacy model
203 193 was working, and is now available as an extension to the standard
204   -driver model (so that we can finally get rid of the legacy model.)
  194 +driver model.
205 195  
206 196 You simply have to define a detect callback which will attempt to
207 197 identify supported devices (returning 0 for supported ones and -ENODEV
drivers/i2c/i2c-core.c
... ... @@ -43,6 +43,7 @@
43 43  
44 44 #define is_newstyle_driver(d) ((d)->probe || (d)->remove || (d)->detect)
45 45  
  46 +static int i2c_attach_client(struct i2c_client *client);
46 47 static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
47 48  
48 49 /* ------------------------------------------------------------------------- */
... ... @@ -83,10 +84,6 @@
83 84 {
84 85 struct i2c_client *client = to_i2c_client(dev);
85 86  
86   - /* by definition, legacy drivers can't hotplug */
87   - if (dev->driver)
88   - return 0;
89   -
90 87 if (add_uevent_var(env, "MODALIAS=%s%s",
91 88 I2C_MODULE_PREFIX, client->name))
92 89 return -ENOMEM;
... ... @@ -455,7 +452,7 @@
455 452  
456 453 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
457 454  
458   - /* create pre-declared device nodes for new-style drivers */
  455 + /* create pre-declared device nodes */
459 456 if (adap->nr < __i2c_first_dynamic_bus_num)
460 457 i2c_scan_static_board_info(adap);
461 458  
462 459  
... ... @@ -617,26 +614,9 @@
617 614 if (res)
618 615 goto out_unlock;
619 616  
620   - /* detach any active clients. This must be done first, because
621   - * it can fail; in which case we give up. */
  617 + /* Detach any active clients */
622 618 list_for_each_entry_safe_reverse(client, _n, &adap->clients, list) {
623   - struct i2c_driver *driver;
624   -
625   - driver = client->driver;
626   -
627   - /* new style, follow standard driver model */
628   - if (!driver || is_newstyle_driver(driver)) {
629   - i2c_unregister_device(client);
630   - continue;
631   - }
632   -
633   - /* legacy drivers create and remove clients themselves */
634   - if ((res = driver->detach_client(client))) {
635   - dev_err(&adap->dev, "detach_client failed for client "
636   - "[%s] at address 0x%02x\n", client->name,
637   - client->addr);
638   - goto out_unlock;
639   - }
  619 + i2c_unregister_device(client);
640 620 }
641 621  
642 622 /* clean up the sysfs representation */
... ... @@ -680,11 +660,7 @@
680 660  
681 661 /*
682 662 * An i2c_driver is used with one or more i2c_client (device) nodes to access
683   - * i2c slave chips, on a bus instance associated with some i2c_adapter. There
684   - * are two models for binding the driver to its device: "new style" drivers
685   - * follow the standard Linux driver model and just respond to probe() calls
686   - * issued if the driver core sees they match(); "legacy" drivers create device
687   - * nodes themselves.
  663 + * i2c slave chips, on a bus instance associated with some i2c_adapter.
688 664 */
689 665  
690 666 int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
691 667  
... ... @@ -695,21 +671,11 @@
695 671 if (unlikely(WARN_ON(!i2c_bus_type.p)))
696 672 return -EAGAIN;
697 673  
698   - /* new style driver methods can't mix with legacy ones */
699   - if (is_newstyle_driver(driver)) {
700   - if (driver->detach_adapter || driver->detach_client) {
701   - printk(KERN_WARNING
702   - "i2c-core: driver [%s] is confused\n",
703   - driver->driver.name);
704   - return -EINVAL;
705   - }
706   - }
707   -
708 674 /* add the driver to the list of i2c drivers in the driver core */
709 675 driver->driver.owner = owner;
710 676 driver->driver.bus = &i2c_bus_type;
711 677  
712   - /* for new style drivers, when registration returns the driver core
  678 + /* When registration returns, the driver core
713 679 * will have called probe() for all matching-but-unbound devices.
714 680 */
715 681 res = driver_register(&driver->driver);
716 682  
... ... @@ -748,29 +714,11 @@
748 714 if (is_newstyle_driver(driver))
749 715 return 0;
750 716  
751   - /* Have a look at each adapter, if clients of this driver are still
752   - * attached. If so, detach them to be able to kill the driver
753   - * afterwards.
754   - */
755 717 if (driver->detach_adapter) {
756 718 if (driver->detach_adapter(adapter))
757 719 dev_err(&adapter->dev,
758 720 "detach_adapter failed for driver [%s]\n",
759 721 driver->driver.name);
760   - } else {
761   - struct i2c_client *client, *_n;
762   -
763   - list_for_each_entry_safe(client, _n, &adapter->clients, list) {
764   - if (client->driver != driver)
765   - continue;
766   - dev_dbg(&adapter->dev,
767   - "detaching client [%s] at 0x%02x\n",
768   - client->name, client->addr);
769   - if (driver->detach_client(client))
770   - dev_err(&adapter->dev, "detach_client "
771   - "failed for client [%s] at 0x%02x\n",
772   - client->name, client->addr);
773   - }
774 722 }
775 723  
776 724 return 0;
... ... @@ -812,7 +760,7 @@
812 760 return device_for_each_child(&adapter->dev, &addr, __i2c_check_addr);
813 761 }
814 762  
815   -int i2c_attach_client(struct i2c_client *client)
  763 +static int i2c_attach_client(struct i2c_client *client)
816 764 {
817 765 struct i2c_adapter *adapter = client->adapter;
818 766 int res;
... ... @@ -854,23 +802,6 @@
854 802 "(%d)\n", client->name, client->addr, res);
855 803 return res;
856 804 }
857   -EXPORT_SYMBOL(i2c_attach_client);
858   -
859   -int i2c_detach_client(struct i2c_client *client)
860   -{
861   - struct i2c_adapter *adapter = client->adapter;
862   -
863   - mutex_lock(&adapter->clist_lock);
864   - list_del(&client->list);
865   - mutex_unlock(&adapter->clist_lock);
866   -
867   - init_completion(&client->released);
868   - device_unregister(&client->dev);
869   - wait_for_completion(&client->released);
870   -
871   - return 0;
872   -}
873   -EXPORT_SYMBOL(i2c_detach_client);
874 805  
875 806 /**
876 807 * i2c_use_client - increments the reference count of the i2c client structure
... ... @@ -100,9 +100,8 @@
100 100 * @class: What kind of i2c device we instantiate (for detect)
101 101 * @attach_adapter: Callback for bus addition (for legacy drivers)
102 102 * @detach_adapter: Callback for bus removal (for legacy drivers)
103   - * @detach_client: Callback for device removal (for legacy drivers)
104   - * @probe: Callback for device binding (new-style drivers)
105   - * @remove: Callback for device unbinding (new-style drivers)
  103 + * @probe: Callback for device binding
  104 + * @remove: Callback for device unbinding
106 105 * @shutdown: Callback for device shutdown
107 106 * @suspend: Callback for device suspend
108 107 * @resume: Callback for device resume
109 108  
... ... @@ -137,26 +136,14 @@
137 136 int id;
138 137 unsigned int class;
139 138  
140   - /* Notifies the driver that a new bus has appeared. This routine
141   - * can be used by the driver to test if the bus meets its conditions
142   - * & seek for the presence of the chip(s) it supports. If found, it
143   - * registers the client(s) that are on the bus to the i2c admin. via
144   - * i2c_attach_client. (LEGACY I2C DRIVERS ONLY)
  139 + /* Notifies the driver that a new bus has appeared or is about to be
  140 + * removed. You should avoid using this if you can, it will probably
  141 + * be removed in a near future.
145 142 */
146 143 int (*attach_adapter)(struct i2c_adapter *);
147 144 int (*detach_adapter)(struct i2c_adapter *);
148 145  
149   - /* tells the driver that a client is about to be deleted & gives it
150   - * the chance to remove its private data. Also, if the client struct
151   - * has been dynamically allocated by the driver in the function above,
152   - * it must be freed here. (LEGACY I2C DRIVERS ONLY)
153   - */
154   - int (*detach_client)(struct i2c_client *) __deprecated;
155   -
156   - /* Standard driver model interfaces, for "new style" i2c drivers.
157   - * With the driver model, device enumeration is NEVER done by drivers;
158   - * it's done by infrastructure. (NEW STYLE DRIVERS ONLY)
159   - */
  146 + /* Standard driver model interfaces */
160 147 int (*probe)(struct i2c_client *, const struct i2c_device_id *);
161 148 int (*remove)(struct i2c_client *);
162 149  
... ... @@ -248,11 +235,10 @@
248 235 * that, such as chip type, configuration, associated IRQ, and so on.
249 236 *
250 237 * i2c_board_info is used to build tables of information listing I2C devices
251   - * that are present. This information is used to grow the driver model tree
252   - * for "new style" I2C drivers. For mainboards this is done statically using
253   - * i2c_register_board_info(); bus numbers identify adapters that aren't
254   - * yet available. For add-on boards, i2c_new_device() does this dynamically
255   - * with the adapter already known.
  238 + * that are present. This information is used to grow the driver model tree.
  239 + * For mainboards this is done statically using i2c_register_board_info();
  240 + * bus numbers identify adapters that aren't yet available. For add-on boards,
  241 + * i2c_new_device() does this dynamically with the adapter already known.
256 242 */
257 243 struct i2c_board_info {
258 244 char type[I2C_NAME_SIZE];
... ... @@ -424,11 +410,6 @@
424 410 {
425 411 return i2c_register_driver(THIS_MODULE, driver);
426 412 }
427   -
428   -/* These are deprecated, your driver should use the standard .probe()
429   - * and .remove() methods instead. */
430   -extern int __deprecated i2c_attach_client(struct i2c_client *);
431   -extern int __deprecated i2c_detach_client(struct i2c_client *);
432 413  
433 414 extern struct i2c_client *i2c_use_client(struct i2c_client *client);
434 415 extern void i2c_release_client(struct i2c_client *client);