Commit 95026658 authored by Sudip Mukherjee's avatar Sudip Mukherjee Committed by Wolfram Sang

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: default avatarSudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
[wsa: removed the unlikely()]
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 30e31a1f
...@@ -73,6 +73,7 @@ static struct device_type i2c_client_type; ...@@ -73,6 +73,7 @@ static struct device_type i2c_client_type;
static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE; static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE;
static bool is_registered;
void i2c_transfer_trace_reg(void) void i2c_transfer_trace_reg(void)
{ {
...@@ -1529,7 +1530,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap) ...@@ -1529,7 +1530,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
int res = 0; int res = 0;
/* Can't register until after driver model init */ /* Can't register until after driver model init */
if (unlikely(WARN_ON(!i2c_bus_type.p))) { if (WARN_ON(!is_registered)) {
res = -EAGAIN; res = -EAGAIN;
goto out_list; goto out_list;
} }
...@@ -1926,7 +1927,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) ...@@ -1926,7 +1927,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
int res; int res;
/* Can't register until after driver model init */ /* Can't register until after driver model init */
if (unlikely(WARN_ON(!i2c_bus_type.p))) if (WARN_ON(!is_registered))
return -EAGAIN; return -EAGAIN;
/* add the driver to the list of i2c drivers in the driver core */ /* add the driver to the list of i2c drivers in the driver core */
...@@ -2118,6 +2119,7 @@ static int __init i2c_init(void) ...@@ -2118,6 +2119,7 @@ static int __init i2c_init(void)
if (IS_ENABLED(CONFIG_OF_DYNAMIC)) if (IS_ENABLED(CONFIG_OF_DYNAMIC))
WARN_ON(of_reconfig_notifier_register(&i2c_of_notifier)); WARN_ON(of_reconfig_notifier_register(&i2c_of_notifier));
is_registered = true;
return 0; return 0;
class_err: class_err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment