diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-09-18 16:45:46 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-09-18 16:45:46 -0400 |
commit | 2bb5095affdb8d6e8646a5b8b5a35c1d6a28c3e7 (patch) | |
tree | 5fb1e8ae4f2882a592855b5c2afd2872a312cbb8 /drivers/i2c/i2c-core.c | |
parent | 4f8cf8240a0c8b232c2ae22e019a4ba1d5f19ccd (diff) |
i2c: Provide compatibility links for i2c adapters
Some user-space applications may be relying on i2c adapters showing up
as class devices in sysfs. Provide compatibility links for them for
the time being. We will remove them after a long transition period.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index a18a251dabf9..8d80fceca6a4 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -538,6 +538,10 @@ static struct device_type i2c_adapter_type = { | |||
538 | .release = i2c_adapter_dev_release, | 538 | .release = i2c_adapter_dev_release, |
539 | }; | 539 | }; |
540 | 540 | ||
541 | #ifdef CONFIG_I2C_COMPAT | ||
542 | static struct class_compat *i2c_adapter_compat_class; | ||
543 | #endif | ||
544 | |||
541 | static void i2c_scan_static_board_info(struct i2c_adapter *adapter) | 545 | static void i2c_scan_static_board_info(struct i2c_adapter *adapter) |
542 | { | 546 | { |
543 | struct i2c_devinfo *devinfo; | 547 | struct i2c_devinfo *devinfo; |
@@ -595,6 +599,14 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
595 | 599 | ||
596 | dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); | 600 | dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); |
597 | 601 | ||
602 | #ifdef CONFIG_I2C_COMPAT | ||
603 | res = class_compat_create_link(i2c_adapter_compat_class, &adap->dev, | ||
604 | adap->dev.parent); | ||
605 | if (res) | ||
606 | dev_warn(&adap->dev, | ||
607 | "Failed to create compatibility class link\n"); | ||
608 | #endif | ||
609 | |||
598 | /* create pre-declared device nodes */ | 610 | /* create pre-declared device nodes */ |
599 | if (adap->nr < __i2c_first_dynamic_bus_num) | 611 | if (adap->nr < __i2c_first_dynamic_bus_num) |
600 | i2c_scan_static_board_info(adap); | 612 | i2c_scan_static_board_info(adap); |
@@ -773,6 +785,11 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
773 | checking the returned value. */ | 785 | checking the returned value. */ |
774 | res = device_for_each_child(&adap->dev, NULL, __unregister_client); | 786 | res = device_for_each_child(&adap->dev, NULL, __unregister_client); |
775 | 787 | ||
788 | #ifdef CONFIG_I2C_COMPAT | ||
789 | class_compat_remove_link(i2c_adapter_compat_class, &adap->dev, | ||
790 | adap->dev.parent); | ||
791 | #endif | ||
792 | |||
776 | /* clean up the sysfs representation */ | 793 | /* clean up the sysfs representation */ |
777 | init_completion(&adap->dev_released); | 794 | init_completion(&adap->dev_released); |
778 | device_unregister(&adap->dev); | 795 | device_unregister(&adap->dev); |
@@ -978,12 +995,23 @@ static int __init i2c_init(void) | |||
978 | retval = bus_register(&i2c_bus_type); | 995 | retval = bus_register(&i2c_bus_type); |
979 | if (retval) | 996 | if (retval) |
980 | return retval; | 997 | return retval; |
998 | #ifdef CONFIG_I2C_COMPAT | ||
999 | i2c_adapter_compat_class = class_compat_register("i2c-adapter"); | ||
1000 | if (!i2c_adapter_compat_class) { | ||
1001 | retval = -ENOMEM; | ||
1002 | goto bus_err; | ||
1003 | } | ||
1004 | #endif | ||
981 | retval = i2c_add_driver(&dummy_driver); | 1005 | retval = i2c_add_driver(&dummy_driver); |
982 | if (retval) | 1006 | if (retval) |
983 | goto bus_err; | 1007 | goto class_err; |
984 | return 0; | 1008 | return 0; |
985 | 1009 | ||
1010 | class_err: | ||
1011 | #ifdef CONFIG_I2C_COMPAT | ||
1012 | class_compat_unregister(i2c_adapter_compat_class); | ||
986 | bus_err: | 1013 | bus_err: |
1014 | #endif | ||
987 | bus_unregister(&i2c_bus_type); | 1015 | bus_unregister(&i2c_bus_type); |
988 | return retval; | 1016 | return retval; |
989 | } | 1017 | } |
@@ -991,6 +1019,9 @@ bus_err: | |||
991 | static void __exit i2c_exit(void) | 1019 | static void __exit i2c_exit(void) |
992 | { | 1020 | { |
993 | i2c_del_driver(&dummy_driver); | 1021 | i2c_del_driver(&dummy_driver); |
1022 | #ifdef CONFIG_I2C_COMPAT | ||
1023 | class_compat_unregister(i2c_adapter_compat_class); | ||
1024 | #endif | ||
994 | bus_unregister(&i2c_bus_type); | 1025 | bus_unregister(&i2c_bus_type); |
995 | } | 1026 | } |
996 | 1027 | ||