[PATCH 2/3] scsi: de-dup calls to scsi_setup_write_ext()
Caleb Connolly
caleb.connolly at linaro.org
Tue Mar 25 14:45:44 CET 2025
On 3/25/25 14:38, Neil Armstrong wrote:
> On 25/03/2025 14:02, Caleb Connolly wrote:
>> This gets called with the same parameter in two paths in scsi_write(),
>> de-dup them to prepare for additional logic after the write.
>>
>> Signed-off-by: Caleb Connolly <caleb.connolly at linaro.org>
>> ---
>> drivers/scsi/scsi.c | 17 +++++++++++------
>> 1 file changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
>> index
>> 34ac47c03ab397ca999abf130d84ccbd3be4c419..1aa7fbdbb5278e387de72a3c3e73d19ea0342fff 100644
>> --- a/drivers/scsi/scsi.c
>> +++ b/drivers/scsi/scsi.c
>> @@ -220,25 +220,30 @@ static ulong scsi_write(struct udevice *dev,
>> lbaint_t blknr, lbaint_t blkcnt,
>> pccb->dma_dir = DMA_TO_DEVICE;
>> if (blks > max_blks) {
>> pccb->datalen = block_dev->blksz * max_blks;
>> smallblks = max_blks;
>> - scsi_setup_write_ext(pccb, start, smallblks);
>> - start += max_blks;
>> - blks -= max_blks;
>> } else {
>> pccb->datalen = block_dev->blksz * blks;
>> smallblks = (unsigned short)blks;
>> - scsi_setup_write_ext(pccb, start, smallblks);
>> - start += blks;
>> - blks = 0;
>> }
>> +
>> debug("%s: startblk " LBAF ", blccnt %x buffer %lx\n",
>> __func__, start, smallblks, buf_addr);
>> + scsi_setup_write_ext(pccb, start, smallblks);
>> +
>> if (scsi_exec(bdev, pccb)) {
>> scsi_print_error(pccb);
>> blkcnt -= blks;
>> break;
>> }
>> +
>> + if (blks > max_blks) {
>> + start += max_blks;
>> + blks -= max_blks;
>> + } else {
>> + start += blks;
>> + blks = 0;
>> + }
>
> Ok this changes the logic and the result of blkcnt on error, before
> is accounted the current command in the blkcnt but now it doesn't.
Ooh good point, will fix that in v2.
>
> Weird we do not return any errors
Yeahh and scsi_print_error() is just a stub... This is probably
something worth looking at in the future.
>
>> buf_addr += pccb->datalen;
>> } while (blks != 0);
>> debug("%s: end startblk " LBAF ", blccnt %x buffer %lX\n",
>> __func__, start, smallblks, buf_addr);
>>
>
--
Caleb (they/them)
More information about the U-Boot
mailing list