i2c-core-acpi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. /*
  2. * Linux I2C core ACPI support code
  3. *
  4. * Copyright (C) 2014 Intel Corp, Author: Lan Tianyu <tianyu.lan@intel.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. */
  11. #include <linux/acpi.h>
  12. #include <linux/device.h>
  13. #include <linux/err.h>
  14. #include <linux/i2c.h>
  15. #include <linux/list.h>
  16. #include <linux/module.h>
  17. #include <linux/slab.h>
  18. #include "i2c-core.h"
  19. struct i2c_acpi_handler_data {
  20. struct acpi_connection_info info;
  21. struct i2c_adapter *adapter;
  22. };
  23. struct gsb_buffer {
  24. u8 status;
  25. u8 len;
  26. union {
  27. u16 wdata;
  28. u8 bdata;
  29. u8 data[0];
  30. };
  31. } __packed;
  32. struct i2c_acpi_lookup {
  33. struct i2c_board_info *info;
  34. acpi_handle adapter_handle;
  35. acpi_handle device_handle;
  36. acpi_handle search_handle;
  37. int n;
  38. int index;
  39. u32 speed;
  40. u32 min_speed;
  41. };
  42. static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data)
  43. {
  44. struct i2c_acpi_lookup *lookup = data;
  45. struct i2c_board_info *info = lookup->info;
  46. struct acpi_resource_i2c_serialbus *sb;
  47. acpi_status status;
  48. if (info->addr || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
  49. return 1;
  50. sb = &ares->data.i2c_serial_bus;
  51. if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C)
  52. return 1;
  53. if (lookup->index != -1 && lookup->n++ != lookup->index)
  54. return 1;
  55. status = acpi_get_handle(lookup->device_handle,
  56. sb->resource_source.string_ptr,
  57. &lookup->adapter_handle);
  58. if (!ACPI_SUCCESS(status))
  59. return 1;
  60. info->addr = sb->slave_address;
  61. lookup->speed = sb->connection_speed;
  62. if (sb->access_mode == ACPI_I2C_10BIT_MODE)
  63. info->flags |= I2C_CLIENT_TEN;
  64. return 1;
  65. }
  66. static const struct acpi_device_id i2c_acpi_ignored_device_ids[] = {
  67. /*
  68. * ACPI video acpi_devices, which are handled by the acpi-video driver
  69. * sometimes contain a SERIAL_TYPE_I2C ACPI resource, ignore these.
  70. */
  71. { ACPI_VIDEO_HID, 0 },
  72. {}
  73. };
  74. static int i2c_acpi_do_lookup(struct acpi_device *adev,
  75. struct i2c_acpi_lookup *lookup)
  76. {
  77. struct i2c_board_info *info = lookup->info;
  78. struct list_head resource_list;
  79. int ret;
  80. if (acpi_bus_get_status(adev) || !adev->status.present ||
  81. acpi_device_enumerated(adev))
  82. return -EINVAL;
  83. if (acpi_match_device_ids(adev, i2c_acpi_ignored_device_ids) == 0)
  84. return -ENODEV;
  85. memset(info, 0, sizeof(*info));
  86. lookup->device_handle = acpi_device_handle(adev);
  87. /* Look up for I2cSerialBus resource */
  88. INIT_LIST_HEAD(&resource_list);
  89. ret = acpi_dev_get_resources(adev, &resource_list,
  90. i2c_acpi_fill_info, lookup);
  91. acpi_dev_free_resource_list(&resource_list);
  92. if (ret < 0 || !info->addr)
  93. return -EINVAL;
  94. return 0;
  95. }
  96. static int i2c_acpi_get_info(struct acpi_device *adev,
  97. struct i2c_board_info *info,
  98. struct i2c_adapter *adapter,
  99. acpi_handle *adapter_handle)
  100. {
  101. struct list_head resource_list;
  102. struct resource_entry *entry;
  103. struct i2c_acpi_lookup lookup;
  104. int ret;
  105. memset(&lookup, 0, sizeof(lookup));
  106. lookup.info = info;
  107. lookup.index = -1;
  108. ret = i2c_acpi_do_lookup(adev, &lookup);
  109. if (ret)
  110. return ret;
  111. if (adapter) {
  112. /* The adapter must match the one in I2cSerialBus() connector */
  113. if (ACPI_HANDLE(&adapter->dev) != lookup.adapter_handle)
  114. return -ENODEV;
  115. } else {
  116. struct acpi_device *adapter_adev;
  117. /* The adapter must be present */
  118. if (acpi_bus_get_device(lookup.adapter_handle, &adapter_adev))
  119. return -ENODEV;
  120. if (acpi_bus_get_status(adapter_adev) ||
  121. !adapter_adev->status.present)
  122. return -ENODEV;
  123. }
  124. info->fwnode = acpi_fwnode_handle(adev);
  125. if (adapter_handle)
  126. *adapter_handle = lookup.adapter_handle;
  127. /* Then fill IRQ number if any */
  128. INIT_LIST_HEAD(&resource_list);
  129. ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
  130. if (ret < 0)
  131. return -EINVAL;
  132. resource_list_for_each_entry(entry, &resource_list) {
  133. if (resource_type(entry->res) == IORESOURCE_IRQ) {
  134. info->irq = entry->res->start;
  135. break;
  136. }
  137. }
  138. acpi_dev_free_resource_list(&resource_list);
  139. acpi_set_modalias(adev, dev_name(&adev->dev), info->type,
  140. sizeof(info->type));
  141. return 0;
  142. }
  143. static void i2c_acpi_register_device(struct i2c_adapter *adapter,
  144. struct acpi_device *adev,
  145. struct i2c_board_info *info)
  146. {
  147. adev->power.flags.ignore_parent = true;
  148. acpi_device_set_enumerated(adev);
  149. if (!i2c_new_device(adapter, info)) {
  150. adev->power.flags.ignore_parent = false;
  151. dev_err(&adapter->dev,
  152. "failed to add I2C device %s from ACPI\n",
  153. dev_name(&adev->dev));
  154. }
  155. }
  156. static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level,
  157. void *data, void **return_value)
  158. {
  159. struct i2c_adapter *adapter = data;
  160. struct acpi_device *adev;
  161. struct i2c_board_info info;
  162. if (acpi_bus_get_device(handle, &adev))
  163. return AE_OK;
  164. if (i2c_acpi_get_info(adev, &info, adapter, NULL))
  165. return AE_OK;
  166. i2c_acpi_register_device(adapter, adev, &info);
  167. return AE_OK;
  168. }
  169. #define I2C_ACPI_MAX_SCAN_DEPTH 32
  170. /**
  171. * i2c_acpi_register_devices - enumerate I2C slave devices behind adapter
  172. * @adap: pointer to adapter
  173. *
  174. * Enumerate all I2C slave devices behind this adapter by walking the ACPI
  175. * namespace. When a device is found it will be added to the Linux device
  176. * model and bound to the corresponding ACPI handle.
  177. */
  178. void i2c_acpi_register_devices(struct i2c_adapter *adap)
  179. {
  180. acpi_status status;
  181. if (!has_acpi_companion(&adap->dev))
  182. return;
  183. status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
  184. I2C_ACPI_MAX_SCAN_DEPTH,
  185. i2c_acpi_add_device, NULL,
  186. adap, NULL);
  187. if (ACPI_FAILURE(status))
  188. dev_warn(&adap->dev, "failed to enumerate I2C slaves\n");
  189. }
  190. const struct acpi_device_id *
  191. i2c_acpi_match_device(const struct acpi_device_id *matches,
  192. struct i2c_client *client)
  193. {
  194. if (!(client && matches))
  195. return NULL;
  196. return acpi_match_device(matches, &client->dev);
  197. }
  198. static acpi_status i2c_acpi_lookup_speed(acpi_handle handle, u32 level,
  199. void *data, void **return_value)
  200. {
  201. struct i2c_acpi_lookup *lookup = data;
  202. struct acpi_device *adev;
  203. if (acpi_bus_get_device(handle, &adev))
  204. return AE_OK;
  205. if (i2c_acpi_do_lookup(adev, lookup))
  206. return AE_OK;
  207. if (lookup->search_handle != lookup->adapter_handle)
  208. return AE_OK;
  209. if (lookup->speed <= lookup->min_speed)
  210. lookup->min_speed = lookup->speed;
  211. return AE_OK;
  212. }
  213. /**
  214. * i2c_acpi_find_bus_speed - find I2C bus speed from ACPI
  215. * @dev: The device owning the bus
  216. *
  217. * Find the I2C bus speed by walking the ACPI namespace for all I2C slaves
  218. * devices connected to this bus and use the speed of slowest device.
  219. *
  220. * Returns the speed in Hz or zero
  221. */
  222. u32 i2c_acpi_find_bus_speed(struct device *dev)
  223. {
  224. struct i2c_acpi_lookup lookup;
  225. struct i2c_board_info dummy;
  226. acpi_status status;
  227. if (!has_acpi_companion(dev))
  228. return 0;
  229. memset(&lookup, 0, sizeof(lookup));
  230. lookup.search_handle = ACPI_HANDLE(dev);
  231. lookup.min_speed = UINT_MAX;
  232. lookup.info = &dummy;
  233. lookup.index = -1;
  234. status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
  235. I2C_ACPI_MAX_SCAN_DEPTH,
  236. i2c_acpi_lookup_speed, NULL,
  237. &lookup, NULL);
  238. if (ACPI_FAILURE(status)) {
  239. dev_warn(dev, "unable to find I2C bus speed from ACPI\n");
  240. return 0;
  241. }
  242. return lookup.min_speed != UINT_MAX ? lookup.min_speed : 0;
  243. }
  244. EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
  245. static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
  246. {
  247. struct i2c_adapter *adapter = i2c_verify_adapter(dev);
  248. if (!adapter)
  249. return 0;
  250. return ACPI_HANDLE(dev) == (acpi_handle)data;
  251. }
  252. static int i2c_acpi_find_match_device(struct device *dev, void *data)
  253. {
  254. return ACPI_COMPANION(dev) == data;
  255. }
  256. static struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
  257. {
  258. struct device *dev;
  259. dev = bus_find_device(&i2c_bus_type, NULL, handle,
  260. i2c_acpi_find_match_adapter);
  261. return dev ? i2c_verify_adapter(dev) : NULL;
  262. }
  263. static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
  264. {
  265. struct device *dev;
  266. dev = bus_find_device(&i2c_bus_type, NULL, adev,
  267. i2c_acpi_find_match_device);
  268. return dev ? i2c_verify_client(dev) : NULL;
  269. }
  270. static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value,
  271. void *arg)
  272. {
  273. struct acpi_device *adev = arg;
  274. struct i2c_board_info info;
  275. acpi_handle adapter_handle;
  276. struct i2c_adapter *adapter;
  277. struct i2c_client *client;
  278. switch (value) {
  279. case ACPI_RECONFIG_DEVICE_ADD:
  280. if (i2c_acpi_get_info(adev, &info, NULL, &adapter_handle))
  281. break;
  282. adapter = i2c_acpi_find_adapter_by_handle(adapter_handle);
  283. if (!adapter)
  284. break;
  285. i2c_acpi_register_device(adapter, adev, &info);
  286. break;
  287. case ACPI_RECONFIG_DEVICE_REMOVE:
  288. if (!acpi_device_enumerated(adev))
  289. break;
  290. client = i2c_acpi_find_client_by_adev(adev);
  291. if (!client)
  292. break;
  293. i2c_unregister_device(client);
  294. put_device(&client->dev);
  295. break;
  296. }
  297. return NOTIFY_OK;
  298. }
  299. struct notifier_block i2c_acpi_notifier = {
  300. .notifier_call = i2c_acpi_notify,
  301. };
  302. /**
  303. * i2c_acpi_new_device - Create i2c-client for the Nth I2cSerialBus resource
  304. * @dev: Device owning the ACPI resources to get the client from
  305. * @index: Index of ACPI resource to get
  306. * @info: describes the I2C device; note this is modified (addr gets set)
  307. * Context: can sleep
  308. *
  309. * By default the i2c subsys creates an i2c-client for the first I2cSerialBus
  310. * resource of an acpi_device, but some acpi_devices have multiple I2cSerialBus
  311. * resources, in that case this function can be used to create an i2c-client
  312. * for other I2cSerialBus resources in the Current Resource Settings table.
  313. *
  314. * Also see i2c_new_device, which this function calls to create the i2c-client.
  315. *
  316. * Returns a pointer to the new i2c-client, or NULL if the adapter is not found.
  317. */
  318. struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
  319. struct i2c_board_info *info)
  320. {
  321. struct i2c_acpi_lookup lookup;
  322. struct i2c_adapter *adapter;
  323. struct acpi_device *adev;
  324. LIST_HEAD(resource_list);
  325. int ret;
  326. adev = ACPI_COMPANION(dev);
  327. if (!adev)
  328. return NULL;
  329. memset(&lookup, 0, sizeof(lookup));
  330. lookup.info = info;
  331. lookup.device_handle = acpi_device_handle(adev);
  332. lookup.index = index;
  333. ret = acpi_dev_get_resources(adev, &resource_list,
  334. i2c_acpi_fill_info, &lookup);
  335. acpi_dev_free_resource_list(&resource_list);
  336. if (ret < 0 || !info->addr)
  337. return NULL;
  338. adapter = i2c_acpi_find_adapter_by_handle(lookup.adapter_handle);
  339. if (!adapter)
  340. return NULL;
  341. return i2c_new_device(adapter, info);
  342. }
  343. EXPORT_SYMBOL_GPL(i2c_acpi_new_device);
  344. #ifdef CONFIG_ACPI_I2C_OPREGION
  345. static int acpi_gsb_i2c_read_bytes(struct i2c_client *client,
  346. u8 cmd, u8 *data, u8 data_len)
  347. {
  348. struct i2c_msg msgs[2];
  349. int ret;
  350. u8 *buffer;
  351. buffer = kzalloc(data_len, GFP_KERNEL);
  352. if (!buffer)
  353. return AE_NO_MEMORY;
  354. msgs[0].addr = client->addr;
  355. msgs[0].flags = client->flags;
  356. msgs[0].len = 1;
  357. msgs[0].buf = &cmd;
  358. msgs[1].addr = client->addr;
  359. msgs[1].flags = client->flags | I2C_M_RD;
  360. msgs[1].len = data_len;
  361. msgs[1].buf = buffer;
  362. ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
  363. if (ret < 0) {
  364. /* Getting a NACK is unfortunately normal with some DSTDs */
  365. if (ret == -EREMOTEIO)
  366. dev_dbg(&client->adapter->dev, "i2c read %d bytes from client@%#x starting at reg %#x failed, error: %d\n",
  367. data_len, client->addr, cmd, ret);
  368. else
  369. dev_err(&client->adapter->dev, "i2c read %d bytes from client@%#x starting at reg %#x failed, error: %d\n",
  370. data_len, client->addr, cmd, ret);
  371. /* 2 transfers must have completed successfully */
  372. } else if (ret == 2) {
  373. memcpy(data, buffer, data_len);
  374. ret = 0;
  375. } else {
  376. ret = -EIO;
  377. }
  378. kfree(buffer);
  379. return ret;
  380. }
  381. static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
  382. u8 cmd, u8 *data, u8 data_len)
  383. {
  384. struct i2c_msg msgs[1];
  385. u8 *buffer;
  386. int ret = AE_OK;
  387. buffer = kzalloc(data_len + 1, GFP_KERNEL);
  388. if (!buffer)
  389. return AE_NO_MEMORY;
  390. buffer[0] = cmd;
  391. memcpy(buffer + 1, data, data_len);
  392. msgs[0].addr = client->addr;
  393. msgs[0].flags = client->flags;
  394. msgs[0].len = data_len + 1;
  395. msgs[0].buf = buffer;
  396. ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
  397. kfree(buffer);
  398. if (ret < 0) {
  399. dev_err(&client->adapter->dev, "i2c write failed: %d\n", ret);
  400. return ret;
  401. }
  402. /* 1 transfer must have completed successfully */
  403. return (ret == 1) ? 0 : -EIO;
  404. }
  405. static acpi_status
  406. i2c_acpi_space_handler(u32 function, acpi_physical_address command,
  407. u32 bits, u64 *value64,
  408. void *handler_context, void *region_context)
  409. {
  410. struct gsb_buffer *gsb = (struct gsb_buffer *)value64;
  411. struct i2c_acpi_handler_data *data = handler_context;
  412. struct acpi_connection_info *info = &data->info;
  413. struct acpi_resource_i2c_serialbus *sb;
  414. struct i2c_adapter *adapter = data->adapter;
  415. struct i2c_client *client;
  416. struct acpi_resource *ares;
  417. u32 accessor_type = function >> 16;
  418. u8 action = function & ACPI_IO_MASK;
  419. acpi_status ret;
  420. int status;
  421. ret = acpi_buffer_to_resource(info->connection, info->length, &ares);
  422. if (ACPI_FAILURE(ret))
  423. return ret;
  424. client = kzalloc(sizeof(*client), GFP_KERNEL);
  425. if (!client) {
  426. ret = AE_NO_MEMORY;
  427. goto err;
  428. }
  429. if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
  430. ret = AE_BAD_PARAMETER;
  431. goto err;
  432. }
  433. sb = &ares->data.i2c_serial_bus;
  434. if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
  435. ret = AE_BAD_PARAMETER;
  436. goto err;
  437. }
  438. client->adapter = adapter;
  439. client->addr = sb->slave_address;
  440. if (sb->access_mode == ACPI_I2C_10BIT_MODE)
  441. client->flags |= I2C_CLIENT_TEN;
  442. switch (accessor_type) {
  443. case ACPI_GSB_ACCESS_ATTRIB_SEND_RCV:
  444. if (action == ACPI_READ) {
  445. status = i2c_smbus_read_byte(client);
  446. if (status >= 0) {
  447. gsb->bdata = status;
  448. status = 0;
  449. }
  450. } else {
  451. status = i2c_smbus_write_byte(client, gsb->bdata);
  452. }
  453. break;
  454. case ACPI_GSB_ACCESS_ATTRIB_BYTE:
  455. if (action == ACPI_READ) {
  456. status = i2c_smbus_read_byte_data(client, command);
  457. if (status >= 0) {
  458. gsb->bdata = status;
  459. status = 0;
  460. }
  461. } else {
  462. status = i2c_smbus_write_byte_data(client, command,
  463. gsb->bdata);
  464. }
  465. break;
  466. case ACPI_GSB_ACCESS_ATTRIB_WORD:
  467. if (action == ACPI_READ) {
  468. status = i2c_smbus_read_word_data(client, command);
  469. if (status >= 0) {
  470. gsb->wdata = status;
  471. status = 0;
  472. }
  473. } else {
  474. status = i2c_smbus_write_word_data(client, command,
  475. gsb->wdata);
  476. }
  477. break;
  478. case ACPI_GSB_ACCESS_ATTRIB_BLOCK:
  479. if (action == ACPI_READ) {
  480. status = i2c_smbus_read_block_data(client, command,
  481. gsb->data);
  482. if (status >= 0) {
  483. gsb->len = status;
  484. status = 0;
  485. }
  486. } else {
  487. status = i2c_smbus_write_block_data(client, command,
  488. gsb->len, gsb->data);
  489. }
  490. break;
  491. case ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE:
  492. if (action == ACPI_READ) {
  493. status = acpi_gsb_i2c_read_bytes(client, command,
  494. gsb->data, info->access_length);
  495. } else {
  496. status = acpi_gsb_i2c_write_bytes(client, command,
  497. gsb->data, info->access_length);
  498. }
  499. break;
  500. default:
  501. dev_warn(&adapter->dev, "protocol 0x%02x not supported for client 0x%02x\n",
  502. accessor_type, client->addr);
  503. ret = AE_BAD_PARAMETER;
  504. goto err;
  505. }
  506. gsb->status = status;
  507. err:
  508. kfree(client);
  509. ACPI_FREE(ares);
  510. return ret;
  511. }
  512. int i2c_acpi_install_space_handler(struct i2c_adapter *adapter)
  513. {
  514. acpi_handle handle;
  515. struct i2c_acpi_handler_data *data;
  516. acpi_status status;
  517. if (!adapter->dev.parent)
  518. return -ENODEV;
  519. handle = ACPI_HANDLE(adapter->dev.parent);
  520. if (!handle)
  521. return -ENODEV;
  522. data = kzalloc(sizeof(struct i2c_acpi_handler_data),
  523. GFP_KERNEL);
  524. if (!data)
  525. return -ENOMEM;
  526. data->adapter = adapter;
  527. status = acpi_bus_attach_private_data(handle, (void *)data);
  528. if (ACPI_FAILURE(status)) {
  529. kfree(data);
  530. return -ENOMEM;
  531. }
  532. status = acpi_install_address_space_handler(handle,
  533. ACPI_ADR_SPACE_GSBUS,
  534. &i2c_acpi_space_handler,
  535. NULL,
  536. data);
  537. if (ACPI_FAILURE(status)) {
  538. dev_err(&adapter->dev, "Error installing i2c space handler\n");
  539. acpi_bus_detach_private_data(handle);
  540. kfree(data);
  541. return -ENOMEM;
  542. }
  543. acpi_walk_dep_device_list(handle);
  544. return 0;
  545. }
  546. void i2c_acpi_remove_space_handler(struct i2c_adapter *adapter)
  547. {
  548. acpi_handle handle;
  549. struct i2c_acpi_handler_data *data;
  550. acpi_status status;
  551. if (!adapter->dev.parent)
  552. return;
  553. handle = ACPI_HANDLE(adapter->dev.parent);
  554. if (!handle)
  555. return;
  556. acpi_remove_address_space_handler(handle,
  557. ACPI_ADR_SPACE_GSBUS,
  558. &i2c_acpi_space_handler);
  559. status = acpi_bus_get_private_data(handle, (void **)&data);
  560. if (ACPI_SUCCESS(status))
  561. kfree(data);
  562. acpi_bus_detach_private_data(handle);
  563. }
  564. #endif /* CONFIG_ACPI_I2C_OPREGION */