Hi Jan, On Tue, Oct 6, 2026 at 3:00 PM Jan Kehren <[email protected]> wrote: > > The AVB IO helpers and struct mmc_part only ever touched struct blk_desc: > nothing in them is mmc-specific. The names say otherwise, which makes the > mmc assumption in AVB look wider than it is. > > Rename them after what they do, in the AVB namespace rather than the block > layer's: avb_blk_read_and_flush(), avb_blk_write(), avb_blk_byte_io(), > struct avb_blk_part and enum avb_io_type with AVB_IO_READ/AVB_IO_WRITE. > The block descriptor field loses its mmc_ prefix for the same reason. > > No functional change. > > Signed-off-by: Jan Kehren <[email protected]>
Tested-by: Igor Opaniuk <[email protected]> Reviewed-by: Igor Opaniuk <[email protected]> > --- > Changes in v2: > - New patch: split out of "avb: Take a storage interface in the AVB > operations" so the rename lands on its own, with no functional change > - Keep the _and_flush suffix on avb_blk_read_and_flush(), it still flushes > the cache after reading > - Re-align continuation lines that the longer helper names had broken > > common/avb_verify.c | 106 +++++++++++++++++++++---------------------- > include/avb_verify.h | 12 ++--- > 2 files changed, 59 insertions(+), 59 deletions(-) > > diff --git a/common/avb_verify.c b/common/avb_verify.c > index b96cd1ebd7..fc29433c3c 100644 > --- a/common/avb_verify.c > +++ b/common/avb_verify.c > @@ -304,13 +304,13 @@ char *avb_set_enforce_verity(const char *cmdline) > > /** > * > ============================================================================ > - * IO(mmc) auxiliary functions > + * Block IO auxiliary functions > * > ============================================================================ > */ > -static unsigned long mmc_read_and_flush(struct mmc_part *part, > - lbaint_t start, > - lbaint_t sectors, > - void *buffer) > +static unsigned long avb_blk_read_and_flush(struct avb_blk_part *part, > + lbaint_t start, > + lbaint_t sectors, > + void *buffer) > { > unsigned long blks; > void *tmp_buf; > @@ -342,7 +342,7 @@ static unsigned long mmc_read_and_flush(struct mmc_part > *part, > tmp_buf = buffer; > } > > - blks = blk_dread(part->mmc_blk, > + blks = blk_dread(part->blk, > start, sectors, tmp_buf); > /* flush cache after read */ > flush_cache((ulong)tmp_buf, sectors * part->info.blksz); > @@ -353,8 +353,8 @@ static unsigned long mmc_read_and_flush(struct mmc_part > *part, > return blks; > } > > -static unsigned long mmc_write(struct mmc_part *part, lbaint_t start, > - lbaint_t sectors, void *buffer) > +static unsigned long avb_blk_write(struct avb_blk_part *part, lbaint_t start, > + lbaint_t sectors, void *buffer) > { > void *tmp_buf; > size_t buf_size; > @@ -382,19 +382,19 @@ static unsigned long mmc_write(struct mmc_part *part, > lbaint_t start, > tmp_buf = buffer; > } > > - return blk_dwrite(part->mmc_blk, > + return blk_dwrite(part->blk, > start, sectors, tmp_buf); > } > > -static struct mmc_part *get_partition(AvbOps *ops, const char *partition) > +static struct avb_blk_part *get_partition(AvbOps *ops, const char *partition) > { > int ret; > u8 dev_num; > int part_num = 0; > - struct mmc_part *part; > - struct blk_desc *mmc_blk; > + struct avb_blk_part *part; > + struct blk_desc *blk; > > - part = malloc(sizeof(struct mmc_part)); > + part = malloc(sizeof(struct avb_blk_part)); > if (!part) > return NULL; > > @@ -421,20 +421,20 @@ static struct mmc_part *get_partition(AvbOps *ops, > const char *partition) > } > } > > - mmc_blk = mmc_get_blk_desc(part->mmc); > - if (!mmc_blk) { > + blk = mmc_get_blk_desc(part->mmc); > + if (!blk) { > printf("%s: failed to obtain block descriptor\n", __func__); > goto err; > } > > - ret = part_get_info_by_name(mmc_blk, partition, &part->info); > + ret = part_get_info_by_name(blk, partition, &part->info); > if (ret < 0) { > printf("%s: can't find partition '%s'\n", __func__, > partition); > goto err; > } > > part->dev_num = dev_num; > - part->mmc_blk = mmc_blk; > + part->blk = blk; > > return part; > err: > @@ -442,22 +442,22 @@ err: > return NULL; > } > > -static AvbIOResult mmc_byte_io(AvbOps *ops, > - const char *partition, > - s64 offset, > - size_t num_bytes, > - void *buffer, > - size_t *out_num_read, > - enum mmc_io_type io_type) > +static AvbIOResult avb_blk_byte_io(AvbOps *ops, > + const char *partition, > + s64 offset, > + size_t num_bytes, > + void *buffer, > + size_t *out_num_read, > + enum avb_io_type io_type) > { > ulong ret; > - struct mmc_part *part; > + struct avb_blk_part *part; > u64 start_offset, start_sector, sectors, residue; > u8 *tmp_buf; > size_t io_cnt = 0; > AvbIOResult io_ret = AVB_IO_RESULT_OK; > > - if (!partition || !buffer || io_type > IO_WRITE) > + if (!partition || !buffer || io_type > AVB_IO_WRITE) > return AVB_IO_RESULT_ERROR_IO; > > part = get_partition(ops, partition); > @@ -486,11 +486,11 @@ static AvbIOResult mmc_byte_io(AvbOps *ops, > residue = num_bytes; > } > > - if (io_type == IO_READ) { > - ret = mmc_read_and_flush(part, > - part->info.start + > - start_sector, > - 1, tmp_buf); > + if (io_type == AVB_IO_READ) { > + ret = avb_blk_read_and_flush(part, > + part->info.start > + > + start_sector, > + 1, tmp_buf); > > if (ret != 1) { > printf("%s: read error (%ld, %lld)\n", > @@ -505,10 +505,10 @@ static AvbIOResult mmc_byte_io(AvbOps *ops, > tmp_buf += (start_offset % part->info.blksz); > memcpy(buffer, (void *)tmp_buf, residue); > } else { > - ret = mmc_read_and_flush(part, > - part->info.start + > - start_sector, > - 1, tmp_buf); > + ret = avb_blk_read_and_flush(part, > + part->info.start > + > + start_sector, > + 1, tmp_buf); > > if (ret != 1) { > printf("%s: read error (%ld, %lld)\n", > @@ -520,8 +520,8 @@ static AvbIOResult mmc_byte_io(AvbOps *ops, > start_offset % part->info.blksz, > buffer, residue); > > - ret = mmc_write(part, part->info.start + > - start_sector, 1, tmp_buf); > + ret = avb_blk_write(part, part->info.start + > + start_sector, 1, tmp_buf); > if (ret != 1) { > printf("%s: write error (%ld, > %lld)\n", > __func__, ret, start_sector); > @@ -538,16 +538,16 @@ static AvbIOResult mmc_byte_io(AvbOps *ops, > } > > if (sectors) { > - if (io_type == IO_READ) { > - ret = mmc_read_and_flush(part, > - part->info.start + > - start_sector, > - sectors, buffer); > + if (io_type == AVB_IO_READ) { > + ret = avb_blk_read_and_flush(part, > + part->info.start > + > + start_sector, > + sectors, buffer); > } else { > - ret = mmc_write(part, > - part->info.start + > - start_sector, > - sectors, buffer); > + ret = avb_blk_write(part, > + part->info.start + > + start_sector, > + sectors, buffer); > } > > if (!ret) { > @@ -564,7 +564,7 @@ static AvbIOResult mmc_byte_io(AvbOps *ops, > } > > /* Set counter for read operation */ > - if (io_type == IO_READ && out_num_read) > + if (io_type == AVB_IO_READ && out_num_read) > *out_num_read = io_cnt; > > out: > @@ -603,8 +603,8 @@ static AvbIOResult read_from_partition(AvbOps *ops, > void *buffer, > size_t *out_num_read) > { > - return mmc_byte_io(ops, partition_name, offset_from_partition, > - num_bytes, buffer, out_num_read, IO_READ); > + return avb_blk_byte_io(ops, partition_name, offset_from_partition, > + num_bytes, buffer, out_num_read, AVB_IO_READ); > } > > /** > @@ -630,8 +630,8 @@ static AvbIOResult write_to_partition(AvbOps *ops, > size_t num_bytes, > const void *buffer) > { > - return mmc_byte_io(ops, partition_name, offset_from_partition, > - num_bytes, (void *)buffer, NULL, IO_WRITE); > + return avb_blk_byte_io(ops, partition_name, offset_from_partition, > + num_bytes, (void *)buffer, NULL, AVB_IO_WRITE); > } > > /** > @@ -883,7 +883,7 @@ static AvbIOResult get_unique_guid_for_partition(AvbOps > *ops, > char *guid_buf, > size_t guid_buf_size) > { > - struct mmc_part *part; > + struct avb_blk_part *part; > size_t uuid_size; > > part = get_partition(ops, partition); > @@ -920,7 +920,7 @@ static AvbIOResult get_size_of_partition(AvbOps *ops, > const char *partition, > u64 *out_size_num_bytes) > { > - struct mmc_part *part; > + struct avb_blk_part *part; > > if (!out_size_num_bytes) > return AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE; > diff --git a/include/avb_verify.h b/include/avb_verify.h > index 66655aab87..8c97adbfbf 100644 > --- a/include/avb_verify.h > +++ b/include/avb_verify.h > @@ -32,16 +32,16 @@ struct AvbOpsData { > #endif > }; > > -struct mmc_part { > +struct avb_blk_part { > int dev_num; > struct mmc *mmc; > - struct blk_desc *mmc_blk; > + struct blk_desc *blk; > struct disk_partition info; > }; > > -enum mmc_io_type { > - IO_READ, > - IO_WRITE > +enum avb_io_type { > + AVB_IO_READ, > + AVB_IO_WRITE > }; > > AvbOps *avb_ops_alloc(int boot_device); > @@ -78,7 +78,7 @@ const char *str_avb_slot_error(AvbSlotVerifyResult res); > * I/O helper inline functions > * > ============================================================================ > */ > -static inline uint64_t calc_offset(struct mmc_part *part, int64_t offset) > +static inline uint64_t calc_offset(struct avb_blk_part *part, int64_t offset) > { > u64 part_size = part->info.size * part->info.blksz; > > -- > 2.43.0 >
