Skip to content

Commit

Permalink
disk: Rename block functions
Browse files Browse the repository at this point in the history
Use the uclass type as the first part of the function name, to be
consistent with the methods in other block drivers.

Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
sjg20 authored and trini committed Oct 31, 2022
1 parent b190deb commit 76c839f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 20 deletions.
24 changes: 12 additions & 12 deletions disk/disk-uclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int part_create_block_devices(struct udevice *blk_dev)
return 0;
}

static ulong blk_part_read(struct udevice *dev, lbaint_t start,
static ulong part_blk_read(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt, void *buffer)
{
struct udevice *parent;
Expand All @@ -88,7 +88,7 @@ static ulong blk_part_read(struct udevice *dev, lbaint_t start,
return ops->read(parent, start, blkcnt, buffer);
}

static ulong blk_part_write(struct udevice *dev, lbaint_t start,
static ulong part_blk_write(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt, const void *buffer)
{
struct udevice *parent;
Expand All @@ -111,7 +111,7 @@ static ulong blk_part_write(struct udevice *dev, lbaint_t start,
return ops->write(parent, start, blkcnt, buffer);
}

static ulong blk_part_erase(struct udevice *dev, lbaint_t start,
static ulong part_blk_erase(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt)
{
struct udevice *parent;
Expand All @@ -135,9 +135,9 @@ static ulong blk_part_erase(struct udevice *dev, lbaint_t start,
}

static const struct blk_ops blk_part_ops = {
.read = blk_part_read,
.write = blk_part_write,
.erase = blk_part_erase,
.read = part_blk_read,
.write = part_blk_write,
.erase = part_blk_erase,
};

U_BOOT_DRIVER(blk_partition) = {
Expand Down Expand Up @@ -168,8 +168,8 @@ static struct blk_desc *dev_get_blk(struct udevice *dev)
return block_dev;
}

unsigned long dev_read(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt, void *buffer)
unsigned long disk_blk_read(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt, void *buffer)
{
struct blk_desc *block_dev;
const struct blk_ops *ops;
Expand Down Expand Up @@ -202,8 +202,8 @@ unsigned long dev_read(struct udevice *dev, lbaint_t start,
return blks_read;
}

unsigned long dev_write(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt, const void *buffer)
unsigned long disk_blk_write(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt, const void *buffer)
{
struct blk_desc *block_dev;
const struct blk_ops *ops;
Expand All @@ -221,8 +221,8 @@ unsigned long dev_write(struct udevice *dev, lbaint_t start,
return ops->write(dev, start, blkcnt, buffer);
}

unsigned long dev_erase(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt)
unsigned long disk_blk_erase(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt)
{
struct blk_desc *block_dev;
const struct blk_ops *ops;
Expand Down
42 changes: 36 additions & 6 deletions include/part.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,42 @@ struct udevice;
*/
int part_create_block_devices(struct udevice *blk_dev);

unsigned long dev_read(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt, void *buffer);
unsigned long dev_write(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt, const void *buffer);
unsigned long dev_erase(struct udevice *dev, lbaint_t start,
lbaint_t blkcnt);
/**
* disk_blk_read() - read blocks from a disk partition
*
* @dev: Device to read from (UCLASS_PARTITION)
* @start: Start block number to read in the partition (0=first)
* @blkcnt: Number of blocks to read
* @buffer: Destination buffer for data read
* Returns: number of blocks read, or -ve error number (see the
* IS_ERR_VALUE() macro
*/
ulong disk_blk_read(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
void *buffer);

/**
* disk_blk_write() - write to a disk partition
*
* @dev: Device to write to (UCLASS_PARTITION)
* @start: Start block number to write in the partition (0=first)
* @blkcnt: Number of blocks to write
* @buffer: Source buffer for data to write
* Returns: number of blocks written, or -ve error number (see the
* IS_ERR_VALUE() macro
*/
ulong disk_blk_write(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
const void *buffer);

/**
* disk_blk_erase() - erase a section of a disk partition
*
* @dev: Device to (partially) erase (UCLASS_PARTITION)
* @start: Start block number to erase in the partition (0=first)
* @blkcnt: Number of blocks to erase
* Returns: number of blocks erased, or -ve error number (see the
* IS_ERR_VALUE() macro
*/
ulong disk_blk_erase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);

/*
* We don't support printing partition information in SPL and only support
Expand Down
6 changes: 4 additions & 2 deletions lib/efi_loader/efi_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this,
if (CONFIG_IS_ENABLED(PARTITIONS) &&
device_get_uclass_id(diskobj->header.dev) == UCLASS_PARTITION) {
if (direction == EFI_DISK_READ)
n = dev_read(diskobj->header.dev, lba, blocks, buffer);
n = disk_blk_read(diskobj->header.dev, lba, blocks,
buffer);
else
n = dev_write(diskobj->header.dev, lba, blocks, buffer);
n = disk_blk_write(diskobj->header.dev, lba, blocks,
buffer);
} else {
/* dev is a block device (UCLASS_BLK) */
struct blk_desc *desc;
Expand Down

0 comments on commit 76c839f

Please sign in to comment.