X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/7a1ed62033184b79388b541258a14bc579389bdb..7aaec0f97677b451e024ef5d1cd2b675a914d440:/avr/cmd_sd.c diff --git a/avr/cmd_sd.c b/avr/cmd_sd.c index 06c9338..440bfd4 100644 --- a/avr/cmd_sd.c +++ b/avr/cmd_sd.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2014 Leo C. + * (C) Copyright 2014, 2018 Leo C. * * SPDX-License-Identifier: GPL-2.0 */ @@ -7,7 +7,6 @@ #include "cmd_sd.h" #include "diskio.h" -#include "ff.h" #include "eval_arg.h" #include "print-utils.h" #include "z80-if.h" @@ -52,10 +51,8 @@ command_ret_t do_init(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * cons dev = (BYTE) eval_arg(argv[1], NULL); - if (disk_status(dev) & STA_NODISK) { - printf_P(PSTR("No Disk\n")); - return CMD_RET_FAILURE; - } + if (disk_status(dev) & STA_NODISK) + cmd_error(CMD_RET_FAILURE, 0, PSTR("No disk")); res = disk_initialize(dev); printf_P(PSTR("rc=%.2x\n"), res); @@ -154,10 +151,8 @@ command_ret_t do_dump(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * cons for ( ; count; count--, sec++) { res = disk_read(dev, buffer, sec, 1); - if (res) { - printf_P(PSTR("rc=%.2x\n"), res); - return CMD_RET_FAILURE; - } + if (res) + cmd_error(CMD_RET_FAILURE, 0, PSTR("rc=%.2x"), res); sprintf_P(header, PSTR("Sector: %lu"), sec); dump_ram(buffer, 0, FF_MAX_SS, header); @@ -208,10 +203,7 @@ command_ret_t do_read(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * cons for (nr = 0; nr < count;) { nr++; if ((res = disk_read(dev, buffer, sec, 1)) == RES_OK) { - if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) { - my_puts_P(PSTR("Bus timeout\n")); - return CMD_RET_FAILURE; - } + z80_bus_request_or_exit(); z80_write_block(buffer, addr /*+ base*/, FF_MAX_SS); z80_bus_cmd(Release); sec++; addr += FF_MAX_SS; @@ -269,10 +261,7 @@ command_ret_t do_write(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * con for (nr = 0; nr < count;) { nr++; - if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) { - my_puts_P(PSTR("Bus timeout\n")); - return CMD_RET_FAILURE; - } + z80_bus_request_or_exit(); z80_read_block(buffer, addr /*+ base*/, FF_MAX_SS); z80_bus_cmd(Release); @@ -317,7 +306,7 @@ command_ret_t do_ioctl_sync(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char cmd_tbl_t cmd_tbl_sd[] = { CMD_TBL_ITEM( status, 2, CTBL_RPT, do_status, - "Socket staus", + "Socket status", "drive" ), CMD_TBL_ITEM( @@ -362,7 +351,7 @@ CMD_TBL_ITEM( /* This does not use the CMD_TBL_ITEM macro as ? can't be used in symbol names */ {FSTR("?"), CONFIG_SYS_MAXARGS, 1, do_help, - FSTR("Alias for 'help'"), + NULL, #ifdef CONFIG_SYS_LONGHELP FSTR(""), #endif /* CONFIG_SYS_LONGHELP */ @@ -376,7 +365,7 @@ CMD_TBL_END(cmd_tbl_sd) }; -command_ret_t do_sd(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]) +command_ret_t do_sd(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc UNUSED, char * const argv[] UNUSED) { puts_P(PSTR("Huch?")); return CMD_RET_USAGE;