blk.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef BLK_H
  8. #define BLK_H
  9. #ifdef CONFIG_SYS_64BIT_LBA
  10. typedef uint64_t lbaint_t;
  11. #define LBAFlength "ll"
  12. #else
  13. typedef ulong lbaint_t;
  14. #define LBAFlength "l"
  15. #endif
  16. #define LBAF "%" LBAFlength "x"
  17. #define LBAFU "%" LBAFlength "u"
  18. /* Interface types: */
  19. enum if_type {
  20. IF_TYPE_UNKNOWN = 0,
  21. IF_TYPE_IDE,
  22. IF_TYPE_SCSI,
  23. IF_TYPE_ATAPI,
  24. IF_TYPE_USB,
  25. IF_TYPE_DOC,
  26. IF_TYPE_MMC,
  27. IF_TYPE_SD,
  28. IF_TYPE_SATA,
  29. IF_TYPE_HOST,
  30. IF_TYPE_SYSTEMACE,
  31. IF_TYPE_NVME,
  32. IF_TYPE_COUNT, /* Number of interface types */
  33. };
  34. /*
  35. * With driver model (CONFIG_BLK) this is uclass platform data, accessible
  36. * with dev_get_uclass_platdata(dev)
  37. */
  38. struct blk_desc {
  39. /*
  40. * TODO: With driver model we should be able to use the parent
  41. * device's uclass instead.
  42. */
  43. enum if_type if_type; /* type of the interface */
  44. int devnum; /* device number */
  45. unsigned char part_type; /* partition type */
  46. unsigned char target; /* target SCSI ID */
  47. unsigned char lun; /* target LUN */
  48. unsigned char hwpart; /* HW partition, e.g. for eMMC */
  49. unsigned char type; /* device type */
  50. unsigned char removable; /* removable device */
  51. #ifdef CONFIG_LBA48
  52. /* device can use 48bit addr (ATA/ATAPI v7) */
  53. unsigned char lba48;
  54. #endif
  55. lbaint_t lba; /* number of blocks */
  56. unsigned long blksz; /* block size */
  57. int log2blksz; /* for convenience: log2(blksz) */
  58. char vendor[40+1]; /* IDE model, SCSI Vendor */
  59. char product[20+1]; /* IDE Serial no, SCSI product */
  60. char revision[8+1]; /* firmware revision */
  61. #if CONFIG_IS_ENABLED(BLK)
  62. /*
  63. * For now we have a few functions which take struct blk_desc as a
  64. * parameter. This field allows them to look up the associated
  65. * device. Once these functions are removed we can drop this field.
  66. */
  67. struct udevice *bdev;
  68. #else
  69. unsigned long (*block_read)(struct blk_desc *block_dev,
  70. lbaint_t start,
  71. lbaint_t blkcnt,
  72. void *buffer);
  73. unsigned long (*block_write)(struct blk_desc *block_dev,
  74. lbaint_t start,
  75. lbaint_t blkcnt,
  76. const void *buffer);
  77. unsigned long (*block_erase)(struct blk_desc *block_dev,
  78. lbaint_t start,
  79. lbaint_t blkcnt);
  80. void *priv; /* driver private struct pointer */
  81. #endif
  82. };
  83. #define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz))
  84. #define PAD_TO_BLOCKSIZE(size, blk_desc) \
  85. (PAD_SIZE(size, blk_desc->blksz))
  86. #ifdef CONFIG_BLOCK_CACHE
  87. /**
  88. * blkcache_read() - attempt to read a set of blocks from cache
  89. *
  90. * @param iftype - IF_TYPE_x for type of device
  91. * @param dev - device index of particular type
  92. * @param start - starting block number
  93. * @param blkcnt - number of blocks to read
  94. * @param blksz - size in bytes of each block
  95. * @param buf - buffer to contain cached data
  96. *
  97. * @return - '1' if block returned from cache, '0' otherwise.
  98. */
  99. int blkcache_read(int iftype, int dev,
  100. lbaint_t start, lbaint_t blkcnt,
  101. unsigned long blksz, void *buffer);
  102. /**
  103. * blkcache_fill() - make data read from a block device available
  104. * to the block cache
  105. *
  106. * @param iftype - IF_TYPE_x for type of device
  107. * @param dev - device index of particular type
  108. * @param start - starting block number
  109. * @param blkcnt - number of blocks available
  110. * @param blksz - size in bytes of each block
  111. * @param buf - buffer containing data to cache
  112. *
  113. */
  114. void blkcache_fill(int iftype, int dev,
  115. lbaint_t start, lbaint_t blkcnt,
  116. unsigned long blksz, void const *buffer);
  117. /**
  118. * blkcache_invalidate() - discard the cache for a set of blocks
  119. * because of a write or device (re)initialization.
  120. *
  121. * @param iftype - IF_TYPE_x for type of device
  122. * @param dev - device index of particular type
  123. */
  124. void blkcache_invalidate(int iftype, int dev);
  125. /**
  126. * blkcache_configure() - configure block cache
  127. *
  128. * @param blocks - maximum blocks per entry
  129. * @param entries - maximum entries in cache
  130. */
  131. void blkcache_configure(unsigned blocks, unsigned entries);
  132. /*
  133. * statistics of the block cache
  134. */
  135. struct block_cache_stats {
  136. unsigned hits;
  137. unsigned misses;
  138. unsigned entries; /* current entry count */
  139. unsigned max_blocks_per_entry;
  140. unsigned max_entries;
  141. };
  142. /**
  143. * get_blkcache_stats() - return statistics and reset
  144. *
  145. * @param stats - statistics are copied here
  146. */
  147. void blkcache_stats(struct block_cache_stats *stats);
  148. #else
  149. static inline int blkcache_read(int iftype, int dev,
  150. lbaint_t start, lbaint_t blkcnt,
  151. unsigned long blksz, void *buffer)
  152. {
  153. return 0;
  154. }
  155. static inline void blkcache_fill(int iftype, int dev,
  156. lbaint_t start, lbaint_t blkcnt,
  157. unsigned long blksz, void const *buffer) {}
  158. static inline void blkcache_invalidate(int iftype, int dev) {}
  159. #endif
  160. #if CONFIG_IS_ENABLED(BLK)
  161. struct udevice;
  162. /* Operations on block devices */
  163. struct blk_ops {
  164. /**
  165. * read() - read from a block device
  166. *
  167. * @dev: Device to read from
  168. * @start: Start block number to read (0=first)
  169. * @blkcnt: Number of blocks to read
  170. * @buffer: Destination buffer for data read
  171. * @return number of blocks read, or -ve error number (see the
  172. * IS_ERR_VALUE() macro
  173. */
  174. unsigned long (*read)(struct udevice *dev, lbaint_t start,
  175. lbaint_t blkcnt, void *buffer);
  176. /**
  177. * write() - write to a block device
  178. *
  179. * @dev: Device to write to
  180. * @start: Start block number to write (0=first)
  181. * @blkcnt: Number of blocks to write
  182. * @buffer: Source buffer for data to write
  183. * @return number of blocks written, or -ve error number (see the
  184. * IS_ERR_VALUE() macro
  185. */
  186. unsigned long (*write)(struct udevice *dev, lbaint_t start,
  187. lbaint_t blkcnt, const void *buffer);
  188. /**
  189. * erase() - erase a section of a block device
  190. *
  191. * @dev: Device to (partially) erase
  192. * @start: Start block number to erase (0=first)
  193. * @blkcnt: Number of blocks to erase
  194. * @return number of blocks erased, or -ve error number (see the
  195. * IS_ERR_VALUE() macro
  196. */
  197. unsigned long (*erase)(struct udevice *dev, lbaint_t start,
  198. lbaint_t blkcnt);
  199. /**
  200. * select_hwpart() - select a particular hardware partition
  201. *
  202. * Some devices (e.g. MMC) can support partitioning at the hardware
  203. * level. This is quite separate from the normal idea of
  204. * software-based partitions. MMC hardware partitions must be
  205. * explicitly selected. Once selected only the region of the device
  206. * covered by that partition is accessible.
  207. *
  208. * The MMC standard provides for two boot partitions (numbered 1 and 2),
  209. * rpmb (3), and up to 4 addition general-purpose partitions (4-7).
  210. *
  211. * @desc: Block device to update
  212. * @hwpart: Hardware partition number to select. 0 means the raw
  213. * device, 1 is the first partition, 2 is the second, etc.
  214. * @return 0 if OK, -ve on error
  215. */
  216. int (*select_hwpart)(struct udevice *dev, int hwpart);
  217. };
  218. #define blk_get_ops(dev) ((struct blk_ops *)(dev)->driver->ops)
  219. /*
  220. * These functions should take struct udevice instead of struct blk_desc,
  221. * but this is convenient for migration to driver model. Add a 'd' prefix
  222. * to the function operations, so that blk_read(), etc. can be reserved for
  223. * functions with the correct arguments.
  224. */
  225. unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
  226. lbaint_t blkcnt, void *buffer);
  227. unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
  228. lbaint_t blkcnt, const void *buffer);
  229. unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
  230. lbaint_t blkcnt);
  231. /**
  232. * blk_find_device() - Find a block device
  233. *
  234. * This function does not activate the device. The device will be returned
  235. * whether or not it is activated.
  236. *
  237. * @if_type: Interface type (enum if_type_t)
  238. * @devnum: Device number (specific to each interface type)
  239. * @devp: the device, if found
  240. * @return 0 if found, -ENODEV if no device found, or other -ve error value
  241. */
  242. int blk_find_device(int if_type, int devnum, struct udevice **devp);
  243. /**
  244. * blk_get_device() - Find and probe a block device ready for use
  245. *
  246. * @if_type: Interface type (enum if_type_t)
  247. * @devnum: Device number (specific to each interface type)
  248. * @devp: the device, if found
  249. * @return 0 if found, -ENODEV if no device found, or other -ve error value
  250. */
  251. int blk_get_device(int if_type, int devnum, struct udevice **devp);
  252. /**
  253. * blk_first_device() - Find the first device for a given interface
  254. *
  255. * The device is probed ready for use
  256. *
  257. * @devnum: Device number (specific to each interface type)
  258. * @devp: the device, if found
  259. * @return 0 if found, -ENODEV if no device, or other -ve error value
  260. */
  261. int blk_first_device(int if_type, struct udevice **devp);
  262. /**
  263. * blk_next_device() - Find the next device for a given interface
  264. *
  265. * This can be called repeatedly after blk_first_device() to iterate through
  266. * all devices of the given interface type.
  267. *
  268. * The device is probed ready for use
  269. *
  270. * @devp: On entry, the previous device returned. On exit, the next
  271. * device, if found
  272. * @return 0 if found, -ENODEV if no device, or other -ve error value
  273. */
  274. int blk_next_device(struct udevice **devp);
  275. /**
  276. * blk_create_device() - Create a new block device
  277. *
  278. * @parent: Parent of the new device
  279. * @drv_name: Driver name to use for the block device
  280. * @name: Name for the device
  281. * @if_type: Interface type (enum if_type_t)
  282. * @devnum: Device number, specific to the interface type, or -1 to
  283. * allocate the next available number
  284. * @blksz: Block size of the device in bytes (typically 512)
  285. * @size: Total size of the device in bytes
  286. * @devp: the new device (which has not been probed)
  287. */
  288. int blk_create_device(struct udevice *parent, const char *drv_name,
  289. const char *name, int if_type, int devnum, int blksz,
  290. lbaint_t size, struct udevice **devp);
  291. /**
  292. * blk_create_devicef() - Create a new named block device
  293. *
  294. * @parent: Parent of the new device
  295. * @drv_name: Driver name to use for the block device
  296. * @name: Name for the device (parent name is prepended)
  297. * @if_type: Interface type (enum if_type_t)
  298. * @devnum: Device number, specific to the interface type, or -1 to
  299. * allocate the next available number
  300. * @blksz: Block size of the device in bytes (typically 512)
  301. * @size: Total size of the device in bytes
  302. * @devp: the new device (which has not been probed)
  303. */
  304. int blk_create_devicef(struct udevice *parent, const char *drv_name,
  305. const char *name, int if_type, int devnum, int blksz,
  306. lbaint_t size, struct udevice **devp);
  307. /**
  308. * blk_prepare_device() - Prepare a block device for use
  309. *
  310. * This reads partition information from the device if supported.
  311. *
  312. * @dev: Device to prepare
  313. * @return 0 if ok, -ve on error
  314. */
  315. int blk_prepare_device(struct udevice *dev);
  316. /**
  317. * blk_unbind_all() - Unbind all device of the given interface type
  318. *
  319. * The devices are removed and then unbound.
  320. *
  321. * @if_type: Interface type to unbind
  322. * @return 0 if OK, -ve on error
  323. */
  324. int blk_unbind_all(int if_type);
  325. /**
  326. * blk_find_max_devnum() - find the maximum device number for an interface type
  327. *
  328. * Finds the last allocated device number for an interface type @if_type. The
  329. * next number is safe to use for a newly allocated device.
  330. *
  331. * @if_type: Interface type to scan
  332. * @return maximum device number found, or -ENODEV if none, or other -ve on
  333. * error
  334. */
  335. int blk_find_max_devnum(enum if_type if_type);
  336. /**
  337. * blk_select_hwpart() - select a hardware partition
  338. *
  339. * Select a hardware partition if the device supports it (typically MMC does)
  340. *
  341. * @dev: Device to update
  342. * @hwpart: Partition number to select
  343. * @return 0 if OK, -ve on error
  344. */
  345. int blk_select_hwpart(struct udevice *dev, int hwpart);
  346. /**
  347. * blk_get_from_parent() - obtain a block device by looking up its parent
  348. *
  349. * All devices with
  350. */
  351. int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
  352. #else
  353. #include <errno.h>
  354. /*
  355. * These functions should take struct udevice instead of struct blk_desc,
  356. * but this is convenient for migration to driver model. Add a 'd' prefix
  357. * to the function operations, so that blk_read(), etc. can be reserved for
  358. * functions with the correct arguments.
  359. */
  360. static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
  361. lbaint_t blkcnt, void *buffer)
  362. {
  363. ulong blks_read;
  364. if (blkcache_read(block_dev->if_type, block_dev->devnum,
  365. start, blkcnt, block_dev->blksz, buffer))
  366. return blkcnt;
  367. /*
  368. * We could check if block_read is NULL and return -ENOSYS. But this
  369. * bloats the code slightly (cause some board to fail to build), and
  370. * it would be an error to try an operation that does not exist.
  371. */
  372. blks_read = block_dev->block_read(block_dev, start, blkcnt, buffer);
  373. if (blks_read == blkcnt)
  374. blkcache_fill(block_dev->if_type, block_dev->devnum,
  375. start, blkcnt, block_dev->blksz, buffer);
  376. return blks_read;
  377. }
  378. static inline ulong blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
  379. lbaint_t blkcnt, const void *buffer)
  380. {
  381. blkcache_invalidate(block_dev->if_type, block_dev->devnum);
  382. return block_dev->block_write(block_dev, start, blkcnt, buffer);
  383. }
  384. static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
  385. lbaint_t blkcnt)
  386. {
  387. blkcache_invalidate(block_dev->if_type, block_dev->devnum);
  388. return block_dev->block_erase(block_dev, start, blkcnt);
  389. }
  390. /**
  391. * struct blk_driver - Driver for block interface types
  392. *
  393. * This provides access to the block devices for each interface type. One
  394. * driver should be provided using U_BOOT_LEGACY_BLK() for each interface
  395. * type that is to be supported.
  396. *
  397. * @if_typename: Interface type name
  398. * @if_type: Interface type
  399. * @max_devs: Maximum number of devices supported
  400. * @desc: Pointer to list of devices for this interface type,
  401. * or NULL to use @get_dev() instead
  402. */
  403. struct blk_driver {
  404. const char *if_typename;
  405. enum if_type if_type;
  406. int max_devs;
  407. struct blk_desc *desc;
  408. /**
  409. * get_dev() - get a pointer to a block device given its number
  410. *
  411. * Each interface allocates its own devices and typically
  412. * struct blk_desc is contained with the interface's data structure.
  413. * There is no global numbering for block devices. This method allows
  414. * the device for an interface type to be obtained when @desc is NULL.
  415. *
  416. * @devnum: Device number (0 for first device on that interface,
  417. * 1 for second, etc.
  418. * @descp: Returns pointer to the block device on success
  419. * @return 0 if OK, -ve on error
  420. */
  421. int (*get_dev)(int devnum, struct blk_desc **descp);
  422. /**
  423. * select_hwpart() - Select a hardware partition
  424. *
  425. * Some devices (e.g. MMC) can support partitioning at the hardware
  426. * level. This is quite separate from the normal idea of
  427. * software-based partitions. MMC hardware partitions must be
  428. * explicitly selected. Once selected only the region of the device
  429. * covered by that partition is accessible.
  430. *
  431. * The MMC standard provides for two boot partitions (numbered 1 and 2),
  432. * rpmb (3), and up to 4 addition general-purpose partitions (4-7).
  433. * Partition 0 is the main user-data partition.
  434. *
  435. * @desc: Block device descriptor
  436. * @hwpart: Hardware partition number to select. 0 means the main
  437. * user-data partition, 1 is the first partition, 2 is
  438. * the second, etc.
  439. * @return 0 if OK, other value for an error
  440. */
  441. int (*select_hwpart)(struct blk_desc *desc, int hwpart);
  442. };
  443. /*
  444. * Declare a new U-Boot legacy block driver. New drivers should use driver
  445. * model (UCLASS_BLK).
  446. */
  447. #define U_BOOT_LEGACY_BLK(__name) \
  448. ll_entry_declare(struct blk_driver, __name, blk_driver)
  449. struct blk_driver *blk_driver_lookup_type(int if_type);
  450. #endif /* !CONFIG_BLK */
  451. /**
  452. * blk_get_devnum_by_typename() - Get a block device by type and number
  453. *
  454. * This looks through the available block devices of the given type, returning
  455. * the one with the given @devnum.
  456. *
  457. * @if_type: Block device type
  458. * @devnum: Device number
  459. * @return point to block device descriptor, or NULL if not found
  460. */
  461. struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum);
  462. /**
  463. * blk_get_devnum_by_type() - Get a block device by type name, and number
  464. *
  465. * This looks up the block device type based on @if_typename, then calls
  466. * blk_get_devnum_by_type().
  467. *
  468. * @if_typename: Block device type name
  469. * @devnum: Device number
  470. * @return point to block device descriptor, or NULL if not found
  471. */
  472. struct blk_desc *blk_get_devnum_by_typename(const char *if_typename,
  473. int devnum);
  474. /**
  475. * blk_dselect_hwpart() - select a hardware partition
  476. *
  477. * This selects a hardware partition (such as is supported by MMC). The block
  478. * device size may change as this effectively points the block device to a
  479. * partition at the hardware level. See the select_hwpart() method above.
  480. *
  481. * @desc: Block device descriptor for the device to select
  482. * @hwpart: Partition number to select
  483. * @return 0 if OK, -ve on error
  484. */
  485. int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
  486. /**
  487. * blk_list_part() - list the partitions for block devices of a given type
  488. *
  489. * This looks up the partition type for each block device of type @if_type,
  490. * then displays a list of partitions.
  491. *
  492. * @if_type: Block device type
  493. * @return 0 if OK, -ENODEV if there is none of that type
  494. */
  495. int blk_list_part(enum if_type if_type);
  496. /**
  497. * blk_list_devices() - list the block devices of a given type
  498. *
  499. * This lists each block device of the type @if_type, showing the capacity
  500. * as well as type-specific information.
  501. *
  502. * @if_type: Block device type
  503. */
  504. void blk_list_devices(enum if_type if_type);
  505. /**
  506. * blk_show_device() - show information about a given block device
  507. *
  508. * This shows the block device capacity as well as type-specific information.
  509. *
  510. * @if_type: Block device type
  511. * @devnum: Device number
  512. * @return 0 if OK, -ENODEV for invalid device number
  513. */
  514. int blk_show_device(enum if_type if_type, int devnum);
  515. /**
  516. * blk_print_device_num() - show information about a given block device
  517. *
  518. * This is similar to blk_show_device() but returns an error if the block
  519. * device type is unknown.
  520. *
  521. * @if_type: Block device type
  522. * @devnum: Device number
  523. * @return 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
  524. * device is not connected
  525. */
  526. int blk_print_device_num(enum if_type if_type, int devnum);
  527. /**
  528. * blk_print_part_devnum() - print the partition information for a device
  529. *
  530. * @if_type: Block device type
  531. * @devnum: Device number
  532. * @return 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
  533. * the interface type is not supported, other -ve on other error
  534. */
  535. int blk_print_part_devnum(enum if_type if_type, int devnum);
  536. /**
  537. * blk_read_devnum() - read blocks from a device
  538. *
  539. * @if_type: Block device type
  540. * @devnum: Device number
  541. * @blkcnt: Number of blocks to read
  542. * @buffer: Address to write data to
  543. * @return number of blocks read, or -ve error number on error
  544. */
  545. ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
  546. lbaint_t blkcnt, void *buffer);
  547. /**
  548. * blk_write_devnum() - write blocks to a device
  549. *
  550. * @if_type: Block device type
  551. * @devnum: Device number
  552. * @blkcnt: Number of blocks to write
  553. * @buffer: Address to read data from
  554. * @return number of blocks written, or -ve error number on error
  555. */
  556. ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
  557. lbaint_t blkcnt, const void *buffer);
  558. /**
  559. * blk_select_hwpart_devnum() - select a hardware partition
  560. *
  561. * This is similar to blk_dselect_hwpart() but it looks up the interface and
  562. * device number.
  563. *
  564. * @if_type: Block device type
  565. * @devnum: Device number
  566. * @hwpart: Partition number to select
  567. * @return 0 if OK, -ve on error
  568. */
  569. int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
  570. /**
  571. * blk_get_if_type_name() - Get the name of an interface type
  572. *
  573. * @if_type: Interface type to check
  574. * @return name of interface, or NULL if none
  575. */
  576. const char *blk_get_if_type_name(enum if_type if_type);
  577. /**
  578. * blk_common_cmd() - handle common commands with block devices
  579. *
  580. * @args: Number of arguments to the command (argv[0] is the command itself)
  581. * @argv: Command arguments
  582. * @if_type: Interface type
  583. * @cur_devnump: Current device number for this interface type
  584. * @return 0 if OK, CMD_RET_ERROR on error
  585. */
  586. int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
  587. int *cur_devnump);
  588. #endif