ipath_eeprom.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. /*
  2. * Copyright (c) 2006 QLogic, Inc. All rights reserved.
  3. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #include <linux/delay.h>
  34. #include <linux/pci.h>
  35. #include <linux/vmalloc.h>
  36. #include "ipath_kernel.h"
  37. /*
  38. * InfiniPath I2C driver for a serial eeprom. This is not a generic
  39. * I2C interface. For a start, the device we're using (Atmel AT24C11)
  40. * doesn't work like a regular I2C device. It looks like one
  41. * electrically, but not logically. Normal I2C devices have a single
  42. * 7-bit or 10-bit I2C address that they respond to. Valid 7-bit
  43. * addresses range from 0x03 to 0x77. Addresses 0x00 to 0x02 and 0x78
  44. * to 0x7F are special reserved addresses (e.g. 0x00 is the "general
  45. * call" address.) The Atmel device, on the other hand, responds to ALL
  46. * 7-bit addresses. It's designed to be the only device on a given I2C
  47. * bus. A 7-bit address corresponds to the memory address within the
  48. * Atmel device itself.
  49. *
  50. * Also, the timing requirements mean more than simple software
  51. * bitbanging, with readbacks from chip to ensure timing (simple udelay
  52. * is not enough).
  53. *
  54. * This all means that accessing the device is specialized enough
  55. * that using the standard kernel I2C bitbanging interface would be
  56. * impossible. For example, the core I2C eeprom driver expects to find
  57. * a device at one or more of a limited set of addresses only. It doesn't
  58. * allow writing to an eeprom. It also doesn't provide any means of
  59. * accessing eeprom contents from within the kernel, only via sysfs.
  60. */
  61. enum i2c_type {
  62. i2c_line_scl = 0,
  63. i2c_line_sda
  64. };
  65. enum i2c_state {
  66. i2c_line_low = 0,
  67. i2c_line_high
  68. };
  69. #define READ_CMD 1
  70. #define WRITE_CMD 0
  71. static int eeprom_init;
  72. /*
  73. * The gpioval manipulation really should be protected by spinlocks
  74. * or be converted to use atomic operations.
  75. */
  76. /**
  77. * i2c_gpio_set - set a GPIO line
  78. * @dd: the infinipath device
  79. * @line: the line to set
  80. * @new_line_state: the state to set
  81. *
  82. * Returns 0 if the line was set to the new state successfully, non-zero
  83. * on error.
  84. */
  85. static int i2c_gpio_set(struct ipath_devdata *dd,
  86. enum i2c_type line,
  87. enum i2c_state new_line_state)
  88. {
  89. u64 out_mask, dir_mask, *gpioval;
  90. unsigned long flags = 0;
  91. gpioval = &dd->ipath_gpio_out;
  92. if (line == i2c_line_scl) {
  93. dir_mask = dd->ipath_gpio_scl;
  94. out_mask = (1UL << dd->ipath_gpio_scl_num);
  95. } else {
  96. dir_mask = dd->ipath_gpio_sda;
  97. out_mask = (1UL << dd->ipath_gpio_sda_num);
  98. }
  99. spin_lock_irqsave(&dd->ipath_gpio_lock, flags);
  100. if (new_line_state == i2c_line_high) {
  101. /* tri-state the output rather than force high */
  102. dd->ipath_extctrl &= ~dir_mask;
  103. } else {
  104. /* config line to be an output */
  105. dd->ipath_extctrl |= dir_mask;
  106. }
  107. ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, dd->ipath_extctrl);
  108. /* set output as well (no real verify) */
  109. if (new_line_state == i2c_line_high)
  110. *gpioval |= out_mask;
  111. else
  112. *gpioval &= ~out_mask;
  113. ipath_write_kreg(dd, dd->ipath_kregs->kr_gpio_out, *gpioval);
  114. spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags);
  115. return 0;
  116. }
  117. /**
  118. * i2c_gpio_get - get a GPIO line state
  119. * @dd: the infinipath device
  120. * @line: the line to get
  121. * @curr_statep: where to put the line state
  122. *
  123. * Returns 0 if the line was set to the new state successfully, non-zero
  124. * on error. curr_state is not set on error.
  125. */
  126. static int i2c_gpio_get(struct ipath_devdata *dd,
  127. enum i2c_type line,
  128. enum i2c_state *curr_statep)
  129. {
  130. u64 read_val, mask;
  131. int ret;
  132. unsigned long flags = 0;
  133. /* check args */
  134. if (curr_statep == NULL) {
  135. ret = 1;
  136. goto bail;
  137. }
  138. /* config line to be an input */
  139. if (line == i2c_line_scl)
  140. mask = dd->ipath_gpio_scl;
  141. else
  142. mask = dd->ipath_gpio_sda;
  143. spin_lock_irqsave(&dd->ipath_gpio_lock, flags);
  144. dd->ipath_extctrl &= ~mask;
  145. ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, dd->ipath_extctrl);
  146. /*
  147. * Below is very unlikely to reflect true input state if Output
  148. * Enable actually changed.
  149. */
  150. read_val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extstatus);
  151. spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags);
  152. if (read_val & mask)
  153. *curr_statep = i2c_line_high;
  154. else
  155. *curr_statep = i2c_line_low;
  156. ret = 0;
  157. bail:
  158. return ret;
  159. }
  160. /**
  161. * i2c_wait_for_writes - wait for a write
  162. * @dd: the infinipath device
  163. *
  164. * We use this instead of udelay directly, so we can make sure
  165. * that previous register writes have been flushed all the way
  166. * to the chip. Since we are delaying anyway, the cost doesn't
  167. * hurt, and makes the bit twiddling more regular
  168. */
  169. static void i2c_wait_for_writes(struct ipath_devdata *dd)
  170. {
  171. (void)ipath_read_kreg32(dd, dd->ipath_kregs->kr_scratch);
  172. rmb();
  173. }
  174. static void scl_out(struct ipath_devdata *dd, u8 bit)
  175. {
  176. udelay(1);
  177. i2c_gpio_set(dd, i2c_line_scl, bit ? i2c_line_high : i2c_line_low);
  178. i2c_wait_for_writes(dd);
  179. }
  180. static void sda_out(struct ipath_devdata *dd, u8 bit)
  181. {
  182. i2c_gpio_set(dd, i2c_line_sda, bit ? i2c_line_high : i2c_line_low);
  183. i2c_wait_for_writes(dd);
  184. }
  185. static u8 sda_in(struct ipath_devdata *dd, int wait)
  186. {
  187. enum i2c_state bit;
  188. if (i2c_gpio_get(dd, i2c_line_sda, &bit))
  189. ipath_dbg("get bit failed!\n");
  190. if (wait)
  191. i2c_wait_for_writes(dd);
  192. return bit == i2c_line_high ? 1U : 0;
  193. }
  194. /**
  195. * i2c_ackrcv - see if ack following write is true
  196. * @dd: the infinipath device
  197. */
  198. static int i2c_ackrcv(struct ipath_devdata *dd)
  199. {
  200. u8 ack_received;
  201. /* AT ENTRY SCL = LOW */
  202. /* change direction, ignore data */
  203. ack_received = sda_in(dd, 1);
  204. scl_out(dd, i2c_line_high);
  205. ack_received = sda_in(dd, 1) == 0;
  206. scl_out(dd, i2c_line_low);
  207. return ack_received;
  208. }
  209. /**
  210. * wr_byte - write a byte, one bit at a time
  211. * @dd: the infinipath device
  212. * @data: the byte to write
  213. *
  214. * Returns 0 if we got the following ack, otherwise 1
  215. */
  216. static int wr_byte(struct ipath_devdata *dd, u8 data)
  217. {
  218. int bit_cntr;
  219. u8 bit;
  220. for (bit_cntr = 7; bit_cntr >= 0; bit_cntr--) {
  221. bit = (data >> bit_cntr) & 1;
  222. sda_out(dd, bit);
  223. scl_out(dd, i2c_line_high);
  224. scl_out(dd, i2c_line_low);
  225. }
  226. return (!i2c_ackrcv(dd)) ? 1 : 0;
  227. }
  228. static void send_ack(struct ipath_devdata *dd)
  229. {
  230. sda_out(dd, i2c_line_low);
  231. scl_out(dd, i2c_line_high);
  232. scl_out(dd, i2c_line_low);
  233. sda_out(dd, i2c_line_high);
  234. }
  235. /**
  236. * i2c_startcmd - transmit the start condition, followed by address/cmd
  237. * @dd: the infinipath device
  238. * @offset_dir: direction byte
  239. *
  240. * (both clock/data high, clock high, data low while clock is high)
  241. */
  242. static int i2c_startcmd(struct ipath_devdata *dd, u8 offset_dir)
  243. {
  244. int res;
  245. /* issue start sequence */
  246. sda_out(dd, i2c_line_high);
  247. scl_out(dd, i2c_line_high);
  248. sda_out(dd, i2c_line_low);
  249. scl_out(dd, i2c_line_low);
  250. /* issue length and direction byte */
  251. res = wr_byte(dd, offset_dir);
  252. if (res)
  253. ipath_cdbg(VERBOSE, "No ack to complete start\n");
  254. return res;
  255. }
  256. /**
  257. * stop_cmd - transmit the stop condition
  258. * @dd: the infinipath device
  259. *
  260. * (both clock/data low, clock high, data high while clock is high)
  261. */
  262. static void stop_cmd(struct ipath_devdata *dd)
  263. {
  264. scl_out(dd, i2c_line_low);
  265. sda_out(dd, i2c_line_low);
  266. scl_out(dd, i2c_line_high);
  267. sda_out(dd, i2c_line_high);
  268. udelay(2);
  269. }
  270. /**
  271. * eeprom_reset - reset I2C communication
  272. * @dd: the infinipath device
  273. */
  274. static int eeprom_reset(struct ipath_devdata *dd)
  275. {
  276. int clock_cycles_left = 9;
  277. u64 *gpioval = &dd->ipath_gpio_out;
  278. int ret;
  279. unsigned long flags;
  280. spin_lock_irqsave(&dd->ipath_gpio_lock, flags);
  281. /* Make sure shadows are consistent */
  282. dd->ipath_extctrl = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extctrl);
  283. *gpioval = ipath_read_kreg64(dd, dd->ipath_kregs->kr_gpio_out);
  284. spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags);
  285. ipath_cdbg(VERBOSE, "Resetting i2c eeprom; initial gpioout reg "
  286. "is %llx\n", (unsigned long long) *gpioval);
  287. eeprom_init = 1;
  288. /*
  289. * This is to get the i2c into a known state, by first going low,
  290. * then tristate sda (and then tristate scl as first thing
  291. * in loop)
  292. */
  293. scl_out(dd, i2c_line_low);
  294. sda_out(dd, i2c_line_high);
  295. while (clock_cycles_left--) {
  296. scl_out(dd, i2c_line_high);
  297. if (sda_in(dd, 0)) {
  298. sda_out(dd, i2c_line_low);
  299. scl_out(dd, i2c_line_low);
  300. ret = 0;
  301. goto bail;
  302. }
  303. scl_out(dd, i2c_line_low);
  304. }
  305. ret = 1;
  306. bail:
  307. return ret;
  308. }
  309. /**
  310. * ipath_eeprom_read - receives bytes from the eeprom via I2C
  311. * @dd: the infinipath device
  312. * @eeprom_offset: address to read from
  313. * @buffer: where to store result
  314. * @len: number of bytes to receive
  315. */
  316. int ipath_eeprom_read(struct ipath_devdata *dd, u8 eeprom_offset,
  317. void *buffer, int len)
  318. {
  319. /* compiler complains unless initialized */
  320. u8 single_byte = 0;
  321. int bit_cntr;
  322. int ret;
  323. if (!eeprom_init)
  324. eeprom_reset(dd);
  325. eeprom_offset = (eeprom_offset << 1) | READ_CMD;
  326. if (i2c_startcmd(dd, eeprom_offset)) {
  327. ipath_dbg("Failed startcmd\n");
  328. stop_cmd(dd);
  329. ret = 1;
  330. goto bail;
  331. }
  332. /*
  333. * eeprom keeps clocking data out as long as we ack, automatically
  334. * incrementing the address.
  335. */
  336. while (len-- > 0) {
  337. /* get data */
  338. single_byte = 0;
  339. for (bit_cntr = 8; bit_cntr; bit_cntr--) {
  340. u8 bit;
  341. scl_out(dd, i2c_line_high);
  342. bit = sda_in(dd, 0);
  343. single_byte |= bit << (bit_cntr - 1);
  344. scl_out(dd, i2c_line_low);
  345. }
  346. /* send ack if not the last byte */
  347. if (len)
  348. send_ack(dd);
  349. *((u8 *) buffer) = single_byte;
  350. buffer++;
  351. }
  352. stop_cmd(dd);
  353. ret = 0;
  354. bail:
  355. return ret;
  356. }
  357. /**
  358. * ipath_eeprom_write - writes data to the eeprom via I2C
  359. * @dd: the infinipath device
  360. * @eeprom_offset: where to place data
  361. * @buffer: data to write
  362. * @len: number of bytes to write
  363. */
  364. int ipath_eeprom_write(struct ipath_devdata *dd, u8 eeprom_offset,
  365. const void *buffer, int len)
  366. {
  367. u8 single_byte;
  368. int sub_len;
  369. const u8 *bp = buffer;
  370. int max_wait_time, i;
  371. int ret;
  372. if (!eeprom_init)
  373. eeprom_reset(dd);
  374. while (len > 0) {
  375. if (i2c_startcmd(dd, (eeprom_offset << 1) | WRITE_CMD)) {
  376. ipath_dbg("Failed to start cmd offset %u\n",
  377. eeprom_offset);
  378. goto failed_write;
  379. }
  380. sub_len = min(len, 4);
  381. eeprom_offset += sub_len;
  382. len -= sub_len;
  383. for (i = 0; i < sub_len; i++) {
  384. if (wr_byte(dd, *bp++)) {
  385. ipath_dbg("no ack after byte %u/%u (%u "
  386. "total remain)\n", i, sub_len,
  387. len + sub_len - i);
  388. goto failed_write;
  389. }
  390. }
  391. stop_cmd(dd);
  392. /*
  393. * wait for write complete by waiting for a successful
  394. * read (the chip replies with a zero after the write
  395. * cmd completes, and before it writes to the eeprom.
  396. * The startcmd for the read will fail the ack until
  397. * the writes have completed. We do this inline to avoid
  398. * the debug prints that are in the real read routine
  399. * if the startcmd fails.
  400. */
  401. max_wait_time = 100;
  402. while (i2c_startcmd(dd, READ_CMD)) {
  403. stop_cmd(dd);
  404. if (!--max_wait_time) {
  405. ipath_dbg("Did not get successful read to "
  406. "complete write\n");
  407. goto failed_write;
  408. }
  409. }
  410. /* now read the zero byte */
  411. for (i = single_byte = 0; i < 8; i++) {
  412. u8 bit;
  413. scl_out(dd, i2c_line_high);
  414. bit = sda_in(dd, 0);
  415. scl_out(dd, i2c_line_low);
  416. single_byte <<= 1;
  417. single_byte |= bit;
  418. }
  419. stop_cmd(dd);
  420. }
  421. ret = 0;
  422. goto bail;
  423. failed_write:
  424. stop_cmd(dd);
  425. ret = 1;
  426. bail:
  427. return ret;
  428. }
  429. static u8 flash_csum(struct ipath_flash *ifp, int adjust)
  430. {
  431. u8 *ip = (u8 *) ifp;
  432. u8 csum = 0, len;
  433. for (len = 0; len < ifp->if_length; len++)
  434. csum += *ip++;
  435. csum -= ifp->if_csum;
  436. csum = ~csum;
  437. if (adjust)
  438. ifp->if_csum = csum;
  439. return csum;
  440. }
  441. /**
  442. * ipath_get_guid - get the GUID from the i2c device
  443. * @dd: the infinipath device
  444. *
  445. * We have the capability to use the ipath_nguid field, and get
  446. * the guid from the first chip's flash, to use for all of them.
  447. */
  448. void ipath_get_eeprom_info(struct ipath_devdata *dd)
  449. {
  450. void *buf;
  451. struct ipath_flash *ifp;
  452. __be64 guid;
  453. int len;
  454. u8 csum, *bguid;
  455. int t = dd->ipath_unit;
  456. struct ipath_devdata *dd0 = ipath_lookup(0);
  457. if (t && dd0->ipath_nguid > 1 && t <= dd0->ipath_nguid) {
  458. u8 *bguid, oguid;
  459. dd->ipath_guid = dd0->ipath_guid;
  460. bguid = (u8 *) & dd->ipath_guid;
  461. oguid = bguid[7];
  462. bguid[7] += t;
  463. if (oguid > bguid[7]) {
  464. if (bguid[6] == 0xff) {
  465. if (bguid[5] == 0xff) {
  466. ipath_dev_err(
  467. dd,
  468. "Can't set %s GUID from "
  469. "base, wraps to OUI!\n",
  470. ipath_get_unit_name(t));
  471. dd->ipath_guid = 0;
  472. goto bail;
  473. }
  474. bguid[5]++;
  475. }
  476. bguid[6]++;
  477. }
  478. dd->ipath_nguid = 1;
  479. ipath_dbg("nguid %u, so adding %u to device 0 guid, "
  480. "for %llx\n",
  481. dd0->ipath_nguid, t,
  482. (unsigned long long) be64_to_cpu(dd->ipath_guid));
  483. goto bail;
  484. }
  485. len = offsetof(struct ipath_flash, if_future);
  486. buf = vmalloc(len);
  487. if (!buf) {
  488. ipath_dev_err(dd, "Couldn't allocate memory to read %u "
  489. "bytes from eeprom for GUID\n", len);
  490. goto bail;
  491. }
  492. if (ipath_eeprom_read(dd, 0, buf, len)) {
  493. ipath_dev_err(dd, "Failed reading GUID from eeprom\n");
  494. goto done;
  495. }
  496. ifp = (struct ipath_flash *)buf;
  497. csum = flash_csum(ifp, 0);
  498. if (csum != ifp->if_csum) {
  499. dev_info(&dd->pcidev->dev, "Bad I2C flash checksum: "
  500. "0x%x, not 0x%x\n", csum, ifp->if_csum);
  501. goto done;
  502. }
  503. if (*(__be64 *) ifp->if_guid == 0ULL ||
  504. *(__be64 *) ifp->if_guid == __constant_cpu_to_be64(-1LL)) {
  505. ipath_dev_err(dd, "Invalid GUID %llx from flash; "
  506. "ignoring\n",
  507. *(unsigned long long *) ifp->if_guid);
  508. /* don't allow GUID if all 0 or all 1's */
  509. goto done;
  510. }
  511. /* complain, but allow it */
  512. if (*(u64 *) ifp->if_guid == 0x100007511000000ULL)
  513. dev_info(&dd->pcidev->dev, "Warning, GUID %llx is "
  514. "default, probably not correct!\n",
  515. *(unsigned long long *) ifp->if_guid);
  516. bguid = ifp->if_guid;
  517. if (!bguid[0] && !bguid[1] && !bguid[2]) {
  518. /* original incorrect GUID format in flash; fix in
  519. * core copy, by shifting up 2 octets; don't need to
  520. * change top octet, since both it and shifted are
  521. * 0.. */
  522. bguid[1] = bguid[3];
  523. bguid[2] = bguid[4];
  524. bguid[3] = bguid[4] = 0;
  525. guid = *(__be64 *) ifp->if_guid;
  526. ipath_cdbg(VERBOSE, "Old GUID format in flash, top 3 zero, "
  527. "shifting 2 octets\n");
  528. } else
  529. guid = *(__be64 *) ifp->if_guid;
  530. dd->ipath_guid = guid;
  531. dd->ipath_nguid = ifp->if_numguid;
  532. /*
  533. * Things are slightly complicated by the desire to transparently
  534. * support both the Pathscale 10-digit serial number and the QLogic
  535. * 13-character version.
  536. */
  537. if ((ifp->if_fversion > 1) && ifp->if_sprefix[0]
  538. && ((u8 *)ifp->if_sprefix)[0] != 0xFF) {
  539. /* This board has a Serial-prefix, which is stored
  540. * elsewhere for backward-compatibility.
  541. */
  542. char *snp = dd->ipath_serial;
  543. int len;
  544. memcpy(snp, ifp->if_sprefix, sizeof ifp->if_sprefix);
  545. snp[sizeof ifp->if_sprefix] = '\0';
  546. len = strlen(snp);
  547. snp += len;
  548. len = (sizeof dd->ipath_serial) - len;
  549. if (len > sizeof ifp->if_serial) {
  550. len = sizeof ifp->if_serial;
  551. }
  552. memcpy(snp, ifp->if_serial, len);
  553. } else
  554. memcpy(dd->ipath_serial, ifp->if_serial,
  555. sizeof ifp->if_serial);
  556. if (!strstr(ifp->if_comment, "Tested successfully"))
  557. ipath_dev_err(dd, "Board SN %s did not pass functional "
  558. "test: %s\n", dd->ipath_serial,
  559. ifp->if_comment);
  560. ipath_cdbg(VERBOSE, "Initted GUID to %llx from eeprom\n",
  561. (unsigned long long) be64_to_cpu(dd->ipath_guid));
  562. done:
  563. vfree(buf);
  564. bail:;
  565. }