diff options
author | Jarkko Nikula <jarkko.nikula@linux.intel.com> | 2016-08-12 10:02:52 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2016-08-25 18:42:09 -0400 |
commit | aec809fc63f61a85e4300bb70081fbe6b492171c (patch) | |
tree | 806941e95d3324d026b003f472ba4576b0c74ef9 /drivers/i2c | |
parent | b6e67145f14903ca430e011db3b771d8de4c3d8a (diff) |
i2c: core: Cleanup I2C ACPI namespace, take 2
I2C ACPI enumeration was originally implemented in another module under
drivers/acpi/ but was later moved into i2c-core with added support for
I2C ACPI operation region.
Rename these acpi_i2c_ prefixed functions, structures and defines in
i2c-core to i2c_acpi_ in order to have more consistent name space.
This is updated version from commit a7003b65801e ("i2c: core: Cleanup I2C
ACPI namespace") that got reverted due merge conflicts from
commit 525e6fabeae2 ("i2c / ACPI: add support for ACPI reconfigure
notifications").
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 56e50ca905ba..d4b2f66d8994 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -88,7 +88,7 @@ void i2c_transfer_trace_unreg(void) | |||
88 | } | 88 | } |
89 | 89 | ||
90 | #if defined(CONFIG_ACPI) | 90 | #if defined(CONFIG_ACPI) |
91 | struct acpi_i2c_handler_data { | 91 | struct i2c_acpi_handler_data { |
92 | struct acpi_connection_info info; | 92 | struct acpi_connection_info info; |
93 | struct i2c_adapter *adapter; | 93 | struct i2c_adapter *adapter; |
94 | }; | 94 | }; |
@@ -103,15 +103,15 @@ struct gsb_buffer { | |||
103 | }; | 103 | }; |
104 | } __packed; | 104 | } __packed; |
105 | 105 | ||
106 | struct acpi_i2c_lookup { | 106 | struct i2c_acpi_lookup { |
107 | struct i2c_board_info *info; | 107 | struct i2c_board_info *info; |
108 | acpi_handle adapter_handle; | 108 | acpi_handle adapter_handle; |
109 | acpi_handle device_handle; | 109 | acpi_handle device_handle; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | static int acpi_i2c_fill_info(struct acpi_resource *ares, void *data) | 112 | static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data) |
113 | { | 113 | { |
114 | struct acpi_i2c_lookup *lookup = data; | 114 | struct i2c_acpi_lookup *lookup = data; |
115 | struct i2c_board_info *info = lookup->info; | 115 | struct i2c_board_info *info = lookup->info; |
116 | struct acpi_resource_i2c_serialbus *sb; | 116 | struct acpi_resource_i2c_serialbus *sb; |
117 | acpi_status status; | 117 | acpi_status status; |
@@ -136,13 +136,13 @@ static int acpi_i2c_fill_info(struct acpi_resource *ares, void *data) | |||
136 | return 1; | 136 | return 1; |
137 | } | 137 | } |
138 | 138 | ||
139 | static int acpi_i2c_get_info(struct acpi_device *adev, | 139 | static int i2c_acpi_get_info(struct acpi_device *adev, |
140 | struct i2c_board_info *info, | 140 | struct i2c_board_info *info, |
141 | acpi_handle *adapter_handle) | 141 | acpi_handle *adapter_handle) |
142 | { | 142 | { |
143 | struct list_head resource_list; | 143 | struct list_head resource_list; |
144 | struct resource_entry *entry; | 144 | struct resource_entry *entry; |
145 | struct acpi_i2c_lookup lookup; | 145 | struct i2c_acpi_lookup lookup; |
146 | int ret; | 146 | int ret; |
147 | 147 | ||
148 | if (acpi_bus_get_status(adev) || !adev->status.present || | 148 | if (acpi_bus_get_status(adev) || !adev->status.present || |
@@ -159,7 +159,7 @@ static int acpi_i2c_get_info(struct acpi_device *adev, | |||
159 | /* Look up for I2cSerialBus resource */ | 159 | /* Look up for I2cSerialBus resource */ |
160 | INIT_LIST_HEAD(&resource_list); | 160 | INIT_LIST_HEAD(&resource_list); |
161 | ret = acpi_dev_get_resources(adev, &resource_list, | 161 | ret = acpi_dev_get_resources(adev, &resource_list, |
162 | acpi_i2c_fill_info, &lookup); | 162 | i2c_acpi_fill_info, &lookup); |
163 | acpi_dev_free_resource_list(&resource_list); | 163 | acpi_dev_free_resource_list(&resource_list); |
164 | 164 | ||
165 | if (ret < 0 || !info->addr) | 165 | if (ret < 0 || !info->addr) |
@@ -186,7 +186,7 @@ static int acpi_i2c_get_info(struct acpi_device *adev, | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | static void acpi_i2c_register_device(struct i2c_adapter *adapter, | 189 | static void i2c_acpi_register_device(struct i2c_adapter *adapter, |
190 | struct acpi_device *adev, | 190 | struct acpi_device *adev, |
191 | struct i2c_board_info *info) | 191 | struct i2c_board_info *info) |
192 | { | 192 | { |
@@ -201,7 +201,7 @@ static void acpi_i2c_register_device(struct i2c_adapter *adapter, | |||
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level, | 204 | static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level, |
205 | void *data, void **return_value) | 205 | void *data, void **return_value) |
206 | { | 206 | { |
207 | struct i2c_adapter *adapter = data; | 207 | struct i2c_adapter *adapter = data; |
@@ -212,28 +212,28 @@ static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level, | |||
212 | if (acpi_bus_get_device(handle, &adev)) | 212 | if (acpi_bus_get_device(handle, &adev)) |
213 | return AE_OK; | 213 | return AE_OK; |
214 | 214 | ||
215 | if (acpi_i2c_get_info(adev, &info, &adapter_handle)) | 215 | if (i2c_acpi_get_info(adev, &info, &adapter_handle)) |
216 | return AE_OK; | 216 | return AE_OK; |
217 | 217 | ||
218 | if (adapter_handle != ACPI_HANDLE(&adapter->dev)) | 218 | if (adapter_handle != ACPI_HANDLE(&adapter->dev)) |
219 | return AE_OK; | 219 | return AE_OK; |
220 | 220 | ||
221 | acpi_i2c_register_device(adapter, adev, &info); | 221 | i2c_acpi_register_device(adapter, adev, &info); |
222 | 222 | ||
223 | return AE_OK; | 223 | return AE_OK; |
224 | } | 224 | } |
225 | 225 | ||
226 | #define ACPI_I2C_MAX_SCAN_DEPTH 32 | 226 | #define I2C_ACPI_MAX_SCAN_DEPTH 32 |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * acpi_i2c_register_devices - enumerate I2C slave devices behind adapter | 229 | * i2c_acpi_register_devices - enumerate I2C slave devices behind adapter |
230 | * @adap: pointer to adapter | 230 | * @adap: pointer to adapter |
231 | * | 231 | * |
232 | * Enumerate all I2C slave devices behind this adapter by walking the ACPI | 232 | * Enumerate all I2C slave devices behind this adapter by walking the ACPI |
233 | * namespace. When a device is found it will be added to the Linux device | 233 | * namespace. When a device is found it will be added to the Linux device |
234 | * model and bound to the corresponding ACPI handle. | 234 | * model and bound to the corresponding ACPI handle. |
235 | */ | 235 | */ |
236 | static void acpi_i2c_register_devices(struct i2c_adapter *adap) | 236 | static void i2c_acpi_register_devices(struct i2c_adapter *adap) |
237 | { | 237 | { |
238 | acpi_status status; | 238 | acpi_status status; |
239 | 239 | ||
@@ -241,14 +241,14 @@ static void acpi_i2c_register_devices(struct i2c_adapter *adap) | |||
241 | return; | 241 | return; |
242 | 242 | ||
243 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 243 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
244 | ACPI_I2C_MAX_SCAN_DEPTH, | 244 | I2C_ACPI_MAX_SCAN_DEPTH, |
245 | acpi_i2c_add_device, NULL, | 245 | i2c_acpi_add_device, NULL, |
246 | adap, NULL); | 246 | adap, NULL); |
247 | if (ACPI_FAILURE(status)) | 247 | if (ACPI_FAILURE(status)) |
248 | dev_warn(&adap->dev, "failed to enumerate I2C slaves\n"); | 248 | dev_warn(&adap->dev, "failed to enumerate I2C slaves\n"); |
249 | } | 249 | } |
250 | 250 | ||
251 | static int acpi_i2c_match_adapter(struct device *dev, void *data) | 251 | static int i2c_acpi_match_adapter(struct device *dev, void *data) |
252 | { | 252 | { |
253 | struct i2c_adapter *adapter = i2c_verify_adapter(dev); | 253 | struct i2c_adapter *adapter = i2c_verify_adapter(dev); |
254 | 254 | ||
@@ -258,29 +258,29 @@ static int acpi_i2c_match_adapter(struct device *dev, void *data) | |||
258 | return ACPI_HANDLE(dev) == (acpi_handle)data; | 258 | return ACPI_HANDLE(dev) == (acpi_handle)data; |
259 | } | 259 | } |
260 | 260 | ||
261 | static int acpi_i2c_match_device(struct device *dev, void *data) | 261 | static int i2c_acpi_match_device(struct device *dev, void *data) |
262 | { | 262 | { |
263 | return ACPI_COMPANION(dev) == data; | 263 | return ACPI_COMPANION(dev) == data; |
264 | } | 264 | } |
265 | 265 | ||
266 | static struct i2c_adapter *acpi_i2c_find_adapter_by_handle(acpi_handle handle) | 266 | static struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle) |
267 | { | 267 | { |
268 | struct device *dev; | 268 | struct device *dev; |
269 | 269 | ||
270 | dev = bus_find_device(&i2c_bus_type, NULL, handle, | 270 | dev = bus_find_device(&i2c_bus_type, NULL, handle, |
271 | acpi_i2c_match_adapter); | 271 | i2c_acpi_match_adapter); |
272 | return dev ? i2c_verify_adapter(dev) : NULL; | 272 | return dev ? i2c_verify_adapter(dev) : NULL; |
273 | } | 273 | } |
274 | 274 | ||
275 | static struct i2c_client *acpi_i2c_find_client_by_adev(struct acpi_device *adev) | 275 | static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev) |
276 | { | 276 | { |
277 | struct device *dev; | 277 | struct device *dev; |
278 | 278 | ||
279 | dev = bus_find_device(&i2c_bus_type, NULL, adev, acpi_i2c_match_device); | 279 | dev = bus_find_device(&i2c_bus_type, NULL, adev, i2c_acpi_match_device); |
280 | return dev ? i2c_verify_client(dev) : NULL; | 280 | return dev ? i2c_verify_client(dev) : NULL; |
281 | } | 281 | } |
282 | 282 | ||
283 | static int acpi_i2c_notify(struct notifier_block *nb, unsigned long value, | 283 | static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value, |
284 | void *arg) | 284 | void *arg) |
285 | { | 285 | { |
286 | struct acpi_device *adev = arg; | 286 | struct acpi_device *adev = arg; |
@@ -291,20 +291,20 @@ static int acpi_i2c_notify(struct notifier_block *nb, unsigned long value, | |||
291 | 291 | ||
292 | switch (value) { | 292 | switch (value) { |
293 | case ACPI_RECONFIG_DEVICE_ADD: | 293 | case ACPI_RECONFIG_DEVICE_ADD: |
294 | if (acpi_i2c_get_info(adev, &info, &adapter_handle)) | 294 | if (i2c_acpi_get_info(adev, &info, &adapter_handle)) |
295 | break; | 295 | break; |
296 | 296 | ||
297 | adapter = acpi_i2c_find_adapter_by_handle(adapter_handle); | 297 | adapter = i2c_acpi_find_adapter_by_handle(adapter_handle); |
298 | if (!adapter) | 298 | if (!adapter) |
299 | break; | 299 | break; |
300 | 300 | ||
301 | acpi_i2c_register_device(adapter, adev, &info); | 301 | i2c_acpi_register_device(adapter, adev, &info); |
302 | break; | 302 | break; |
303 | case ACPI_RECONFIG_DEVICE_REMOVE: | 303 | case ACPI_RECONFIG_DEVICE_REMOVE: |
304 | if (!acpi_device_enumerated(adev)) | 304 | if (!acpi_device_enumerated(adev)) |
305 | break; | 305 | break; |
306 | 306 | ||
307 | client = acpi_i2c_find_client_by_adev(adev); | 307 | client = i2c_acpi_find_client_by_adev(adev); |
308 | if (!client) | 308 | if (!client) |
309 | break; | 309 | break; |
310 | 310 | ||
@@ -317,10 +317,10 @@ static int acpi_i2c_notify(struct notifier_block *nb, unsigned long value, | |||
317 | } | 317 | } |
318 | 318 | ||
319 | static struct notifier_block i2c_acpi_notifier = { | 319 | static struct notifier_block i2c_acpi_notifier = { |
320 | .notifier_call = acpi_i2c_notify, | 320 | .notifier_call = i2c_acpi_notify, |
321 | }; | 321 | }; |
322 | #else /* CONFIG_ACPI */ | 322 | #else /* CONFIG_ACPI */ |
323 | static inline void acpi_i2c_register_devices(struct i2c_adapter *adap) { } | 323 | static inline void i2c_acpi_register_devices(struct i2c_adapter *adap) { } |
324 | extern struct notifier_block i2c_acpi_notifier; | 324 | extern struct notifier_block i2c_acpi_notifier; |
325 | #endif /* CONFIG_ACPI */ | 325 | #endif /* CONFIG_ACPI */ |
326 | 326 | ||
@@ -386,12 +386,12 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client, | |||
386 | } | 386 | } |
387 | 387 | ||
388 | static acpi_status | 388 | static acpi_status |
389 | acpi_i2c_space_handler(u32 function, acpi_physical_address command, | 389 | i2c_acpi_space_handler(u32 function, acpi_physical_address command, |
390 | u32 bits, u64 *value64, | 390 | u32 bits, u64 *value64, |
391 | void *handler_context, void *region_context) | 391 | void *handler_context, void *region_context) |
392 | { | 392 | { |
393 | struct gsb_buffer *gsb = (struct gsb_buffer *)value64; | 393 | struct gsb_buffer *gsb = (struct gsb_buffer *)value64; |
394 | struct acpi_i2c_handler_data *data = handler_context; | 394 | struct i2c_acpi_handler_data *data = handler_context; |
395 | struct acpi_connection_info *info = &data->info; | 395 | struct acpi_connection_info *info = &data->info; |
396 | struct acpi_resource_i2c_serialbus *sb; | 396 | struct acpi_resource_i2c_serialbus *sb; |
397 | struct i2c_adapter *adapter = data->adapter; | 397 | struct i2c_adapter *adapter = data->adapter; |
@@ -510,10 +510,10 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command, | |||
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) | 513 | static int i2c_acpi_install_space_handler(struct i2c_adapter *adapter) |
514 | { | 514 | { |
515 | acpi_handle handle; | 515 | acpi_handle handle; |
516 | struct acpi_i2c_handler_data *data; | 516 | struct i2c_acpi_handler_data *data; |
517 | acpi_status status; | 517 | acpi_status status; |
518 | 518 | ||
519 | if (!adapter->dev.parent) | 519 | if (!adapter->dev.parent) |
@@ -524,7 +524,7 @@ static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) | |||
524 | if (!handle) | 524 | if (!handle) |
525 | return -ENODEV; | 525 | return -ENODEV; |
526 | 526 | ||
527 | data = kzalloc(sizeof(struct acpi_i2c_handler_data), | 527 | data = kzalloc(sizeof(struct i2c_acpi_handler_data), |
528 | GFP_KERNEL); | 528 | GFP_KERNEL); |
529 | if (!data) | 529 | if (!data) |
530 | return -ENOMEM; | 530 | return -ENOMEM; |
@@ -538,7 +538,7 @@ static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) | |||
538 | 538 | ||
539 | status = acpi_install_address_space_handler(handle, | 539 | status = acpi_install_address_space_handler(handle, |
540 | ACPI_ADR_SPACE_GSBUS, | 540 | ACPI_ADR_SPACE_GSBUS, |
541 | &acpi_i2c_space_handler, | 541 | &i2c_acpi_space_handler, |
542 | NULL, | 542 | NULL, |
543 | data); | 543 | data); |
544 | if (ACPI_FAILURE(status)) { | 544 | if (ACPI_FAILURE(status)) { |
@@ -552,10 +552,10 @@ static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) | |||
552 | return 0; | 552 | return 0; |
553 | } | 553 | } |
554 | 554 | ||
555 | static void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter) | 555 | static void i2c_acpi_remove_space_handler(struct i2c_adapter *adapter) |
556 | { | 556 | { |
557 | acpi_handle handle; | 557 | acpi_handle handle; |
558 | struct acpi_i2c_handler_data *data; | 558 | struct i2c_acpi_handler_data *data; |
559 | acpi_status status; | 559 | acpi_status status; |
560 | 560 | ||
561 | if (!adapter->dev.parent) | 561 | if (!adapter->dev.parent) |
@@ -568,7 +568,7 @@ static void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter) | |||
568 | 568 | ||
569 | acpi_remove_address_space_handler(handle, | 569 | acpi_remove_address_space_handler(handle, |
570 | ACPI_ADR_SPACE_GSBUS, | 570 | ACPI_ADR_SPACE_GSBUS, |
571 | &acpi_i2c_space_handler); | 571 | &i2c_acpi_space_handler); |
572 | 572 | ||
573 | status = acpi_bus_get_private_data(handle, (void **)&data); | 573 | status = acpi_bus_get_private_data(handle, (void **)&data); |
574 | if (ACPI_SUCCESS(status)) | 574 | if (ACPI_SUCCESS(status)) |
@@ -577,10 +577,10 @@ static void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter) | |||
577 | acpi_bus_detach_private_data(handle); | 577 | acpi_bus_detach_private_data(handle); |
578 | } | 578 | } |
579 | #else /* CONFIG_ACPI_I2C_OPREGION */ | 579 | #else /* CONFIG_ACPI_I2C_OPREGION */ |
580 | static inline void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter) | 580 | static inline void i2c_acpi_remove_space_handler(struct i2c_adapter *adapter) |
581 | { } | 581 | { } |
582 | 582 | ||
583 | static inline int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) | 583 | static inline int i2c_acpi_install_space_handler(struct i2c_adapter *adapter) |
584 | { return 0; } | 584 | { return 0; } |
585 | #endif /* CONFIG_ACPI_I2C_OPREGION */ | 585 | #endif /* CONFIG_ACPI_I2C_OPREGION */ |
586 | 586 | ||
@@ -1752,8 +1752,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
1752 | 1752 | ||
1753 | /* create pre-declared device nodes */ | 1753 | /* create pre-declared device nodes */ |
1754 | of_i2c_register_devices(adap); | 1754 | of_i2c_register_devices(adap); |
1755 | acpi_i2c_register_devices(adap); | 1755 | i2c_acpi_register_devices(adap); |
1756 | acpi_i2c_install_space_handler(adap); | 1756 | i2c_acpi_install_space_handler(adap); |
1757 | 1757 | ||
1758 | if (adap->nr < __i2c_first_dynamic_bus_num) | 1758 | if (adap->nr < __i2c_first_dynamic_bus_num) |
1759 | i2c_scan_static_board_info(adap); | 1759 | i2c_scan_static_board_info(adap); |
@@ -1925,7 +1925,7 @@ void i2c_del_adapter(struct i2c_adapter *adap) | |||
1925 | return; | 1925 | return; |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | acpi_i2c_remove_space_handler(adap); | 1928 | i2c_acpi_remove_space_handler(adap); |
1929 | /* Tell drivers about this removal */ | 1929 | /* Tell drivers about this removal */ |
1930 | mutex_lock(&core_lock); | 1930 | mutex_lock(&core_lock); |
1931 | bus_for_each_drv(&i2c_bus_type, NULL, adap, | 1931 | bus_for_each_drv(&i2c_bus_type, NULL, adap, |