gpiolib-of.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * OF helpers for the GPIO API
  3. *
  4. * Copyright (c) 2007-2008 MontaVista Software, Inc.
  5. *
  6. * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/device.h>
  14. #include <linux/err.h>
  15. #include <linux/errno.h>
  16. #include <linux/module.h>
  17. #include <linux/io.h>
  18. #include <linux/gpio/consumer.h>
  19. #include <linux/of.h>
  20. #include <linux/of_address.h>
  21. #include <linux/of_gpio.h>
  22. #include <linux/pinctrl/pinctrl.h>
  23. #include <linux/slab.h>
  24. #include <linux/gpio/machine.h>
  25. #include "gpiolib.h"
  26. static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data)
  27. {
  28. struct of_phandle_args *gpiospec = data;
  29. return chip->gpiodev->dev.of_node == gpiospec->np &&
  30. chip->of_xlate(chip, gpiospec, NULL) >= 0;
  31. }
  32. static struct gpio_chip *of_find_gpiochip_by_xlate(
  33. struct of_phandle_args *gpiospec)
  34. {
  35. return gpiochip_find(gpiospec, of_gpiochip_match_node_and_xlate);
  36. }
  37. static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip,
  38. struct of_phandle_args *gpiospec,
  39. enum of_gpio_flags *flags)
  40. {
  41. int ret;
  42. if (chip->of_gpio_n_cells != gpiospec->args_count)
  43. return ERR_PTR(-EINVAL);
  44. ret = chip->of_xlate(chip, gpiospec, flags);
  45. if (ret < 0)
  46. return ERR_PTR(ret);
  47. return gpiochip_get_desc(chip, ret);
  48. }
  49. static void of_gpio_flags_quirks(struct device_node *np,
  50. enum of_gpio_flags *flags)
  51. {
  52. /*
  53. * Some GPIO fixed regulator quirks.
  54. * Note that active low is the default.
  55. */
  56. if (IS_ENABLED(CONFIG_REGULATOR) &&
  57. (of_device_is_compatible(np, "regulator-fixed") ||
  58. of_device_is_compatible(np, "reg-fixed-voltage") ||
  59. of_device_is_compatible(np, "regulator-gpio"))) {
  60. /*
  61. * The regulator GPIO handles are specified such that the
  62. * presence or absence of "enable-active-high" solely controls
  63. * the polarity of the GPIO line. Any phandle flags must
  64. * be actively ignored.
  65. */
  66. if (*flags & OF_GPIO_ACTIVE_LOW) {
  67. pr_warn("%s GPIO handle specifies active low - ignored\n",
  68. of_node_full_name(np));
  69. *flags &= ~OF_GPIO_ACTIVE_LOW;
  70. }
  71. if (!of_property_read_bool(np, "enable-active-high"))
  72. *flags |= OF_GPIO_ACTIVE_LOW;
  73. }
  74. /*
  75. * Legacy open drain handling for fixed voltage regulators.
  76. */
  77. if (IS_ENABLED(CONFIG_REGULATOR) &&
  78. of_device_is_compatible(np, "reg-fixed-voltage") &&
  79. of_property_read_bool(np, "gpio-open-drain")) {
  80. *flags |= (OF_GPIO_SINGLE_ENDED | OF_GPIO_OPEN_DRAIN);
  81. pr_info("%s uses legacy open drain flag - update the DTS if you can\n",
  82. of_node_full_name(np));
  83. }
  84. }
  85. /**
  86. * of_get_named_gpiod_flags() - Get a GPIO descriptor and flags for GPIO API
  87. * @np: device node to get GPIO from
  88. * @propname: property name containing gpio specifier(s)
  89. * @index: index of the GPIO
  90. * @flags: a flags pointer to fill in
  91. *
  92. * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
  93. * value on the error condition. If @flags is not NULL the function also fills
  94. * in flags for the GPIO.
  95. */
  96. struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np,
  97. const char *propname, int index, enum of_gpio_flags *flags)
  98. {
  99. struct of_phandle_args gpiospec;
  100. struct gpio_chip *chip;
  101. struct gpio_desc *desc;
  102. int ret;
  103. ret = of_parse_phandle_with_args_map(np, propname, "gpio", index,
  104. &gpiospec);
  105. if (ret) {
  106. pr_debug("%s: can't parse '%s' property of node '%pOF[%d]'\n",
  107. __func__, propname, np, index);
  108. return ERR_PTR(ret);
  109. }
  110. chip = of_find_gpiochip_by_xlate(&gpiospec);
  111. if (!chip) {
  112. desc = ERR_PTR(-EPROBE_DEFER);
  113. goto out;
  114. }
  115. desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, flags);
  116. if (IS_ERR(desc))
  117. goto out;
  118. if (flags)
  119. of_gpio_flags_quirks(np, flags);
  120. pr_debug("%s: parsed '%s' property of node '%pOF[%d]' - status (%d)\n",
  121. __func__, propname, np, index,
  122. PTR_ERR_OR_ZERO(desc));
  123. out:
  124. of_node_put(gpiospec.np);
  125. return desc;
  126. }
  127. int of_get_named_gpio_flags(struct device_node *np, const char *list_name,
  128. int index, enum of_gpio_flags *flags)
  129. {
  130. struct gpio_desc *desc;
  131. desc = of_get_named_gpiod_flags(np, list_name, index, flags);
  132. if (IS_ERR(desc))
  133. return PTR_ERR(desc);
  134. else
  135. return desc_to_gpio(desc);
  136. }
  137. EXPORT_SYMBOL(of_get_named_gpio_flags);
  138. /*
  139. * The SPI GPIO bindings happened before we managed to establish that GPIO
  140. * properties should be named "foo-gpios" so we have this special kludge for
  141. * them.
  142. */
  143. static struct gpio_desc *of_find_spi_gpio(struct device *dev, const char *con_id,
  144. enum of_gpio_flags *of_flags)
  145. {
  146. char prop_name[32]; /* 32 is max size of property name */
  147. struct device_node *np = dev->of_node;
  148. struct gpio_desc *desc;
  149. /*
  150. * Hopefully the compiler stubs the rest of the function if this
  151. * is false.
  152. */
  153. if (!IS_ENABLED(CONFIG_SPI_MASTER))
  154. return ERR_PTR(-ENOENT);
  155. /* Allow this specifically for "spi-gpio" devices */
  156. if (!of_device_is_compatible(np, "spi-gpio") || !con_id)
  157. return ERR_PTR(-ENOENT);
  158. /* Will be "gpio-sck", "gpio-mosi" or "gpio-miso" */
  159. snprintf(prop_name, sizeof(prop_name), "%s-%s", "gpio", con_id);
  160. desc = of_get_named_gpiod_flags(np, prop_name, 0, of_flags);
  161. return desc;
  162. }
  163. /*
  164. * Some regulator bindings happened before we managed to establish that GPIO
  165. * properties should be named "foo-gpios" so we have this special kludge for
  166. * them.
  167. */
  168. static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char *con_id,
  169. enum of_gpio_flags *of_flags)
  170. {
  171. /* These are the connection IDs we accept as legacy GPIO phandles */
  172. const char *whitelist[] = {
  173. "wlf,ldoena", /* Arizona */
  174. "wlf,ldo1ena", /* WM8994 */
  175. "wlf,ldo2ena", /* WM8994 */
  176. };
  177. struct device_node *np = dev->of_node;
  178. struct gpio_desc *desc;
  179. int i;
  180. if (!IS_ENABLED(CONFIG_REGULATOR))
  181. return ERR_PTR(-ENOENT);
  182. if (!con_id)
  183. return ERR_PTR(-ENOENT);
  184. i = match_string(whitelist, ARRAY_SIZE(whitelist), con_id);
  185. if (i < 0)
  186. return ERR_PTR(-ENOENT);
  187. desc = of_get_named_gpiod_flags(np, con_id, 0, of_flags);
  188. return desc;
  189. }
  190. struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
  191. unsigned int idx,
  192. enum gpio_lookup_flags *flags)
  193. {
  194. char prop_name[32]; /* 32 is max size of property name */
  195. enum of_gpio_flags of_flags;
  196. struct gpio_desc *desc;
  197. unsigned int i;
  198. /* Try GPIO property "foo-gpios" and "foo-gpio" */
  199. for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
  200. if (con_id)
  201. snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id,
  202. gpio_suffixes[i]);
  203. else
  204. snprintf(prop_name, sizeof(prop_name), "%s",
  205. gpio_suffixes[i]);
  206. desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
  207. &of_flags);
  208. /*
  209. * -EPROBE_DEFER in our case means that we found a
  210. * valid GPIO property, but no controller has been
  211. * registered so far.
  212. *
  213. * This means we don't need to look any further for
  214. * alternate name conventions, and we should really
  215. * preserve the return code for our user to be able to
  216. * retry probing later.
  217. */
  218. if (IS_ERR(desc) && PTR_ERR(desc) == -EPROBE_DEFER)
  219. return desc;
  220. if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
  221. break;
  222. }
  223. /* Special handling for SPI GPIOs if used */
  224. if (IS_ERR(desc))
  225. desc = of_find_spi_gpio(dev, con_id, &of_flags);
  226. /* Special handling for regulator GPIOs if used */
  227. if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)
  228. desc = of_find_regulator_gpio(dev, con_id, &of_flags);
  229. if (IS_ERR(desc))
  230. return desc;
  231. if (of_flags & OF_GPIO_ACTIVE_LOW)
  232. *flags |= GPIO_ACTIVE_LOW;
  233. if (of_flags & OF_GPIO_SINGLE_ENDED) {
  234. if (of_flags & OF_GPIO_OPEN_DRAIN)
  235. *flags |= GPIO_OPEN_DRAIN;
  236. else
  237. *flags |= GPIO_OPEN_SOURCE;
  238. }
  239. if (of_flags & OF_GPIO_TRANSITORY)
  240. *flags |= GPIO_TRANSITORY;
  241. return desc;
  242. }
  243. /**
  244. * of_parse_own_gpio() - Get a GPIO hog descriptor, names and flags for GPIO API
  245. * @np: device node to get GPIO from
  246. * @chip: GPIO chip whose hog is parsed
  247. * @idx: Index of the GPIO to parse
  248. * @name: GPIO line name
  249. * @lflags: gpio_lookup_flags - returned from of_find_gpio() or
  250. * of_parse_own_gpio()
  251. * @dflags: gpiod_flags - optional GPIO initialization flags
  252. *
  253. * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
  254. * value on the error condition.
  255. */
  256. static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
  257. struct gpio_chip *chip,
  258. unsigned int idx, const char **name,
  259. enum gpio_lookup_flags *lflags,
  260. enum gpiod_flags *dflags)
  261. {
  262. struct device_node *chip_np;
  263. enum of_gpio_flags xlate_flags;
  264. struct of_phandle_args gpiospec;
  265. struct gpio_desc *desc;
  266. unsigned int i;
  267. u32 tmp;
  268. int ret;
  269. chip_np = chip->of_node;
  270. if (!chip_np)
  271. return ERR_PTR(-EINVAL);
  272. xlate_flags = 0;
  273. *lflags = 0;
  274. *dflags = 0;
  275. ret = of_property_read_u32(chip_np, "#gpio-cells", &tmp);
  276. if (ret)
  277. return ERR_PTR(ret);
  278. gpiospec.np = chip_np;
  279. gpiospec.args_count = tmp;
  280. for (i = 0; i < tmp; i++) {
  281. ret = of_property_read_u32_index(np, "gpios", idx * tmp + i,
  282. &gpiospec.args[i]);
  283. if (ret)
  284. return ERR_PTR(ret);
  285. }
  286. desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, &xlate_flags);
  287. if (IS_ERR(desc))
  288. return desc;
  289. if (xlate_flags & OF_GPIO_ACTIVE_LOW)
  290. *lflags |= GPIO_ACTIVE_LOW;
  291. if (xlate_flags & OF_GPIO_TRANSITORY)
  292. *lflags |= GPIO_TRANSITORY;
  293. if (of_property_read_bool(np, "input"))
  294. *dflags |= GPIOD_IN;
  295. else if (of_property_read_bool(np, "output-low"))
  296. *dflags |= GPIOD_OUT_LOW;
  297. else if (of_property_read_bool(np, "output-high"))
  298. *dflags |= GPIOD_OUT_HIGH;
  299. else {
  300. pr_warn("GPIO line %d (%pOFn): no hogging state specified, bailing out\n",
  301. desc_to_gpio(desc), np);
  302. return ERR_PTR(-EINVAL);
  303. }
  304. if (name && of_property_read_string(np, "line-name", name))
  305. *name = np->name;
  306. return desc;
  307. }
  308. /**
  309. * of_gpiochip_scan_gpios - Scan gpio-controller for gpio definitions
  310. * @chip: gpio chip to act on
  311. *
  312. * This is only used by of_gpiochip_add to request/set GPIO initial
  313. * configuration.
  314. * It returns error if it fails otherwise 0 on success.
  315. */
  316. static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
  317. {
  318. struct gpio_desc *desc = NULL;
  319. struct device_node *np;
  320. const char *name;
  321. enum gpio_lookup_flags lflags;
  322. enum gpiod_flags dflags;
  323. unsigned int i;
  324. int ret;
  325. for_each_available_child_of_node(chip->of_node, np) {
  326. if (!of_property_read_bool(np, "gpio-hog"))
  327. continue;
  328. for (i = 0;; i++) {
  329. desc = of_parse_own_gpio(np, chip, i, &name, &lflags,
  330. &dflags);
  331. if (IS_ERR(desc))
  332. break;
  333. ret = gpiod_hog(desc, name, lflags, dflags);
  334. if (ret < 0) {
  335. of_node_put(np);
  336. return ret;
  337. }
  338. }
  339. }
  340. return 0;
  341. }
  342. /**
  343. * of_gpio_simple_xlate - translate gpiospec to the GPIO number and flags
  344. * @gc: pointer to the gpio_chip structure
  345. * @gpiospec: GPIO specifier as found in the device tree
  346. * @flags: a flags pointer to fill in
  347. *
  348. * This is simple translation function, suitable for the most 1:1 mapped
  349. * GPIO chips. This function performs only one sanity check: whether GPIO
  350. * is less than ngpios (that is specified in the gpio_chip).
  351. */
  352. int of_gpio_simple_xlate(struct gpio_chip *gc,
  353. const struct of_phandle_args *gpiospec, u32 *flags)
  354. {
  355. /*
  356. * We're discouraging gpio_cells < 2, since that way you'll have to
  357. * write your own xlate function (that will have to retrieve the GPIO
  358. * number and the flags from a single gpio cell -- this is possible,
  359. * but not recommended).
  360. */
  361. if (gc->of_gpio_n_cells < 2) {
  362. WARN_ON(1);
  363. return -EINVAL;
  364. }
  365. if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
  366. return -EINVAL;
  367. if (gpiospec->args[0] >= gc->ngpio)
  368. return -EINVAL;
  369. if (flags)
  370. *flags = gpiospec->args[1];
  371. return gpiospec->args[0];
  372. }
  373. EXPORT_SYMBOL(of_gpio_simple_xlate);
  374. /**
  375. * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank)
  376. * @np: device node of the GPIO chip
  377. * @mm_gc: pointer to the of_mm_gpio_chip allocated structure
  378. * @data: driver data to store in the struct gpio_chip
  379. *
  380. * To use this function you should allocate and fill mm_gc with:
  381. *
  382. * 1) In the gpio_chip structure:
  383. * - all the callbacks
  384. * - of_gpio_n_cells
  385. * - of_xlate callback (optional)
  386. *
  387. * 3) In the of_mm_gpio_chip structure:
  388. * - save_regs callback (optional)
  389. *
  390. * If succeeded, this function will map bank's memory and will
  391. * do all necessary work for you. Then you'll able to use .regs
  392. * to manage GPIOs from the callbacks.
  393. */
  394. int of_mm_gpiochip_add_data(struct device_node *np,
  395. struct of_mm_gpio_chip *mm_gc,
  396. void *data)
  397. {
  398. int ret = -ENOMEM;
  399. struct gpio_chip *gc = &mm_gc->gc;
  400. gc->label = kasprintf(GFP_KERNEL, "%pOF", np);
  401. if (!gc->label)
  402. goto err0;
  403. mm_gc->regs = of_iomap(np, 0);
  404. if (!mm_gc->regs)
  405. goto err1;
  406. gc->base = -1;
  407. if (mm_gc->save_regs)
  408. mm_gc->save_regs(mm_gc);
  409. mm_gc->gc.of_node = np;
  410. ret = gpiochip_add_data(gc, data);
  411. if (ret)
  412. goto err2;
  413. return 0;
  414. err2:
  415. iounmap(mm_gc->regs);
  416. err1:
  417. kfree(gc->label);
  418. err0:
  419. pr_err("%pOF: GPIO chip registration failed with status %d\n", np, ret);
  420. return ret;
  421. }
  422. EXPORT_SYMBOL(of_mm_gpiochip_add_data);
  423. /**
  424. * of_mm_gpiochip_remove - Remove memory mapped GPIO chip (bank)
  425. * @mm_gc: pointer to the of_mm_gpio_chip allocated structure
  426. */
  427. void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
  428. {
  429. struct gpio_chip *gc = &mm_gc->gc;
  430. if (!mm_gc)
  431. return;
  432. gpiochip_remove(gc);
  433. iounmap(mm_gc->regs);
  434. kfree(gc->label);
  435. }
  436. EXPORT_SYMBOL(of_mm_gpiochip_remove);
  437. static void of_gpiochip_init_valid_mask(struct gpio_chip *chip)
  438. {
  439. int len, i;
  440. u32 start, count;
  441. struct device_node *np = chip->of_node;
  442. len = of_property_count_u32_elems(np, "gpio-reserved-ranges");
  443. if (len < 0 || len % 2 != 0)
  444. return;
  445. for (i = 0; i < len; i += 2) {
  446. of_property_read_u32_index(np, "gpio-reserved-ranges",
  447. i, &start);
  448. of_property_read_u32_index(np, "gpio-reserved-ranges",
  449. i + 1, &count);
  450. if (start >= chip->ngpio || start + count >= chip->ngpio)
  451. continue;
  452. bitmap_clear(chip->valid_mask, start, count);
  453. }
  454. };
  455. #ifdef CONFIG_PINCTRL
  456. static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
  457. {
  458. struct device_node *np = chip->of_node;
  459. struct of_phandle_args pinspec;
  460. struct pinctrl_dev *pctldev;
  461. int index = 0, ret;
  462. const char *name;
  463. static const char group_names_propname[] = "gpio-ranges-group-names";
  464. struct property *group_names;
  465. if (!np)
  466. return 0;
  467. group_names = of_find_property(np, group_names_propname, NULL);
  468. for (;; index++) {
  469. ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
  470. index, &pinspec);
  471. if (ret)
  472. break;
  473. pctldev = of_pinctrl_get(pinspec.np);
  474. of_node_put(pinspec.np);
  475. if (!pctldev)
  476. return -EPROBE_DEFER;
  477. if (pinspec.args[2]) {
  478. if (group_names) {
  479. of_property_read_string_index(np,
  480. group_names_propname,
  481. index, &name);
  482. if (strlen(name)) {
  483. pr_err("%pOF: Group name of numeric GPIO ranges must be the empty string.\n",
  484. np);
  485. break;
  486. }
  487. }
  488. /* npins != 0: linear range */
  489. ret = gpiochip_add_pin_range(chip,
  490. pinctrl_dev_get_devname(pctldev),
  491. pinspec.args[0],
  492. pinspec.args[1],
  493. pinspec.args[2]);
  494. if (ret)
  495. return ret;
  496. } else {
  497. /* npins == 0: special range */
  498. if (pinspec.args[1]) {
  499. pr_err("%pOF: Illegal gpio-range format.\n",
  500. np);
  501. break;
  502. }
  503. if (!group_names) {
  504. pr_err("%pOF: GPIO group range requested but no %s property.\n",
  505. np, group_names_propname);
  506. break;
  507. }
  508. ret = of_property_read_string_index(np,
  509. group_names_propname,
  510. index, &name);
  511. if (ret)
  512. break;
  513. if (!strlen(name)) {
  514. pr_err("%pOF: Group name of GPIO group range cannot be the empty string.\n",
  515. np);
  516. break;
  517. }
  518. ret = gpiochip_add_pingroup_range(chip, pctldev,
  519. pinspec.args[0], name);
  520. if (ret)
  521. return ret;
  522. }
  523. }
  524. return 0;
  525. }
  526. #else
  527. static int of_gpiochip_add_pin_range(struct gpio_chip *chip) { return 0; }
  528. #endif
  529. int of_gpiochip_add(struct gpio_chip *chip)
  530. {
  531. int status;
  532. if (!chip->of_node)
  533. return 0;
  534. if (!chip->of_xlate) {
  535. chip->of_gpio_n_cells = 2;
  536. chip->of_xlate = of_gpio_simple_xlate;
  537. }
  538. if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS)
  539. return -EINVAL;
  540. of_gpiochip_init_valid_mask(chip);
  541. status = of_gpiochip_add_pin_range(chip);
  542. if (status)
  543. return status;
  544. /* If the chip defines names itself, these take precedence */
  545. if (!chip->names)
  546. devprop_gpiochip_set_names(chip,
  547. of_fwnode_handle(chip->of_node));
  548. of_node_get(chip->of_node);
  549. return of_gpiochip_scan_gpios(chip);
  550. }
  551. void of_gpiochip_remove(struct gpio_chip *chip)
  552. {
  553. gpiochip_remove_pin_ranges(chip);
  554. of_node_put(chip->of_node);
  555. }