aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2016-03-07 06:49:17 -0500
committerWolfram Sang <wsa@the-dreams.de>2016-03-12 10:58:11 -0500
commit95026658c46ea2d94498d0dac1282e28cd47c64a (patch)
treeb6785a2eca9069814a7c6f5f1d9d0c2e39e2352f /drivers/i2c/i2c-core.c
parent30e31a1fbc1fc0fae001a96d9b4c375806fb8f41 (diff)
i2c: do not use internal data from driver core
The variable p is a data structure which is used by the driver core internally and it is not expected that busses will be directly accessing these driver core internal only data. Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [wsa: removed the unlikely()] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 2949ab3c2293..f4726cdbb06a 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -73,6 +73,7 @@ static struct device_type i2c_client_type;
73static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); 73static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
74 74
75static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE; 75static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE;
76static bool is_registered;
76 77
77void i2c_transfer_trace_reg(void) 78void i2c_transfer_trace_reg(void)
78{ 79{
@@ -1529,7 +1530,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
1529 int res = 0; 1530 int res = 0;
1530 1531
1531 /* Can't register until after driver model init */ 1532 /* Can't register until after driver model init */
1532 if (unlikely(WARN_ON(!i2c_bus_type.p))) { 1533 if (WARN_ON(!is_registered)) {
1533 res = -EAGAIN; 1534 res = -EAGAIN;
1534 goto out_list; 1535 goto out_list;
1535 } 1536 }
@@ -1926,7 +1927,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
1926 int res; 1927 int res;
1927 1928
1928 /* Can't register until after driver model init */ 1929 /* Can't register until after driver model init */
1929 if (unlikely(WARN_ON(!i2c_bus_type.p))) 1930 if (WARN_ON(!is_registered))
1930 return -EAGAIN; 1931 return -EAGAIN;
1931 1932
1932 /* add the driver to the list of i2c drivers in the driver core */ 1933 /* add the driver to the list of i2c drivers in the driver core */
@@ -2118,6 +2119,7 @@ static int __init i2c_init(void)
2118 if (IS_ENABLED(CONFIG_OF_DYNAMIC)) 2119 if (IS_ENABLED(CONFIG_OF_DYNAMIC))
2119 WARN_ON(of_reconfig_notifier_register(&i2c_of_notifier)); 2120 WARN_ON(of_reconfig_notifier_register(&i2c_of_notifier));
2120 2121
2122 is_registered = true;
2121 return 0; 2123 return 0;
2122 2124
2123class_err: 2125class_err: