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