diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/Kconfig | 8 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 33 |
2 files changed, 40 insertions, 1 deletions
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 711ca08ab776..d7ece131b4f4 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig | |||
@@ -27,6 +27,14 @@ config I2C_BOARDINFO | |||
27 | boolean | 27 | boolean |
28 | default y | 28 | default y |
29 | 29 | ||
30 | config I2C_COMPAT | ||
31 | boolean "Enable compatibility bits for old user-space" | ||
32 | default y | ||
33 | help | ||
34 | Say Y here if you intend to run lm-sensors 3.1.1 or older, or any | ||
35 | other user-space package which expects i2c adapters to be class | ||
36 | devices. If you don't know, say Y. | ||
37 | |||
30 | config I2C_CHARDEV | 38 | config I2C_CHARDEV |
31 | tristate "I2C device interface" | 39 | tristate "I2C device interface" |
32 | help | 40 | help |
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 | ||