From: Bin Meng Date: Tue, 26 Sep 2023 08:43:41 +0000 (+0800) Subject: dm: blk: Rename get_desc() and make it externally visible X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=a9bf25cb93b96502da814f22cd2fbb284272a800;p=u-boot.git dm: blk: Rename get_desc() and make it externally visible get_desc() can be useful outside blk-uclass.c. Let's change it to an API and make it externally visible. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 885513893f..c9f7d468c5 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -178,17 +178,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev) return NULL; } -/** - * get_desc() - Get the block device descriptor for the given device number - * - * @uclass_id: Interface type - * @devnum: Device number (0 = first) - * @descp: Returns block device descriptor on success - * Return: 0 on success, -ENODEV if there is no such device and no device - * with a higher device number, -ENOENT if there is no such device but there - * is one with a higher number, or other -ve on other error. - */ -static int get_desc(enum uclass_id uclass_id, int devnum, struct blk_desc **descp) +int blk_get_desc(enum uclass_id uclass_id, int devnum, struct blk_desc **descp) { bool found_more = false; struct udevice *dev; @@ -240,7 +230,7 @@ int blk_list_part(enum uclass_id uclass_id) int ret; for (ok = 0, devnum = 0;; ++devnum) { - ret = get_desc(uclass_id, devnum, &desc); + ret = blk_get_desc(uclass_id, devnum, &desc); if (ret == -ENODEV) break; else if (ret) @@ -263,7 +253,7 @@ int blk_print_part_devnum(enum uclass_id uclass_id, int devnum) struct blk_desc *desc; int ret; - ret = get_desc(uclass_id, devnum, &desc); + ret = blk_get_desc(uclass_id, devnum, &desc); if (ret) return ret; if (desc->type == DEV_TYPE_UNKNOWN) @@ -280,7 +270,7 @@ void blk_list_devices(enum uclass_id uclass_id) int i; for (i = 0;; ++i) { - ret = get_desc(uclass_id, i, &desc); + ret = blk_get_desc(uclass_id, i, &desc); if (ret == -ENODEV) break; else if (ret) @@ -297,7 +287,7 @@ int blk_print_device_num(enum uclass_id uclass_id, int devnum) struct blk_desc *desc; int ret; - ret = get_desc(uclass_id, devnum, &desc); + ret = blk_get_desc(uclass_id, devnum, &desc); if (ret) return ret; printf("\nIDE device %d: ", devnum); @@ -312,7 +302,7 @@ int blk_show_device(enum uclass_id uclass_id, int devnum) int ret; printf("\nDevice %d: ", devnum); - ret = get_desc(uclass_id, devnum, &desc); + ret = blk_get_desc(uclass_id, devnum, &desc); if (ret == -ENODEV || ret == -ENOENT) { printf("unknown device\n"); return -ENODEV; @@ -334,7 +324,7 @@ ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start, ulong n; int ret; - ret = get_desc(uclass_id, devnum, &desc); + ret = blk_get_desc(uclass_id, devnum, &desc); if (ret) return ret; n = blk_dread(desc, start, blkcnt, buffer); @@ -350,7 +340,7 @@ ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start, struct blk_desc *desc; int ret; - ret = get_desc(uclass_id, devnum, &desc); + ret = blk_get_desc(uclass_id, devnum, &desc); if (ret) return ret; return blk_dwrite(desc, start, blkcnt, buffer); diff --git a/include/blk.h b/include/blk.h index bbff057aed..b453b5a602 100644 --- a/include/blk.h +++ b/include/blk.h @@ -515,6 +515,18 @@ const char *blk_get_devtype(struct udevice *dev); */ struct blk_desc *blk_get_by_device(struct udevice *dev); +/** + * blk_get_desc() - Get the block device descriptor for the given device number + * + * @uclass_id: Interface type + * @devnum: Device number (0 = first) + * @descp: Returns block device descriptor on success + * Return: 0 on success, -ENODEV if there is no such device and no device + * with a higher device number, -ENOENT if there is no such device but there + * is one with a higher number, or other -ve on other error. + */ +int blk_get_desc(enum uclass_id uclass_id, int devnum, struct blk_desc **descp); + #else #include /*