ams: globally prefer R_RETURN to return for ams::Result

This commit is contained in:
Michael Scire 2022-03-26 14:48:33 -07:00
parent dd78ede99f
commit bbf22b4c60
325 changed files with 1955 additions and 1993 deletions

View file

@ -131,7 +131,7 @@ namespace ams::sdmmc::impl {
Result BaseDeviceAccessor::IssueCommandGoIdleState() const {
/* Issue the command. */
Command command(CommandIndex_GoIdleState, 0, ResponseType_R0, false);
return m_host_controller->IssueCommand(std::addressof(command));
R_RETURN(m_host_controller->IssueCommand(std::addressof(command)));
}
Result BaseDeviceAccessor::IssueCommandAllSendCid(void *dst, size_t dst_size) const {
@ -155,7 +155,7 @@ namespace ams::sdmmc::impl {
const u32 arg = static_cast<u32>(m_base_device->GetRca()) << 16;
/* Issue the command. */
return this->IssueCommandAndCheckR1(CommandIndex_SelectCard, arg, true, DeviceState_Unknown);
R_RETURN(this->IssueCommandAndCheckR1(CommandIndex_SelectCard, arg, true, DeviceState_Unknown));
}
Result BaseDeviceAccessor::IssueCommandSendCsd(void *dst, size_t dst_size) const {
@ -183,12 +183,12 @@ namespace ams::sdmmc::impl {
const u32 arg = static_cast<u32>(m_base_device->GetRca()) << 16;
/* Issue the command. */
return this->IssueCommandAndCheckR1(out_device_status, CommandIndex_SendStatus, arg, false, DeviceState_Tran, status_ignore_mask);
R_RETURN(this->IssueCommandAndCheckR1(out_device_status, CommandIndex_SendStatus, arg, false, DeviceState_Tran, status_ignore_mask));
}
Result BaseDeviceAccessor::IssueCommandSetBlockLenToSectorSize() const {
/* Issue the command. */
return this->IssueCommandAndCheckR1(CommandIndex_SetBlockLen, SectorSize, false, DeviceState_Tran);
R_RETURN(this->IssueCommandAndCheckR1(CommandIndex_SetBlockLen, SectorSize, false, DeviceState_Tran));
}
Result BaseDeviceAccessor::IssueCommandMultipleBlock(u32 *out_num_transferred_blocks, u32 sector_index, u32 num_sectors, void *buf, bool is_read) const {
@ -237,7 +237,7 @@ namespace ams::sdmmc::impl {
}
/* Return the result we chose. */
return result_to_return;
R_RETURN(result_to_return);
}
/* Get the responses. */
@ -339,7 +339,7 @@ namespace ams::sdmmc::impl {
if (R_FAILED(result)) {
/* Log that we failed after a re-startup. */
this->PushErrorLog(true, "%s %X %X:%X", is_read ? "R" : "W", cur_sector_index, cur_sectors, result.GetValue());
return result;
R_RETURN(result);
}
/* Log that we succeeded after a retry. */

View file

@ -419,18 +419,18 @@ namespace ams::sdmmc::impl {
}
Result CheckRemoved() const {
return m_base_device->CheckRemoved();
R_RETURN(m_base_device->CheckRemoved());
}
Result IssueCommandAndCheckR1(u32 *out_response, u32 command_index, u32 command_arg, bool is_busy, DeviceState expected_state, u32 status_ignore_mask) const;
Result IssueCommandAndCheckR1(u32 command_index, u32 command_arg, bool is_busy, DeviceState expected_state, u32 status_ignore_mask) const {
u32 dummy;
return this->IssueCommandAndCheckR1(std::addressof(dummy), command_index, command_arg, is_busy, expected_state, status_ignore_mask);
R_RETURN(this->IssueCommandAndCheckR1(std::addressof(dummy), command_index, command_arg, is_busy, expected_state, status_ignore_mask));
}
Result IssueCommandAndCheckR1(u32 command_index, u32 command_arg, bool is_busy, DeviceState expected_state) const {
return this->IssueCommandAndCheckR1(command_index, command_arg, is_busy, expected_state, 0);
R_RETURN(this->IssueCommandAndCheckR1(command_index, command_arg, is_busy, expected_state, 0));
}
Result IssueCommandGoIdleState() const;
@ -441,11 +441,11 @@ namespace ams::sdmmc::impl {
Result IssueCommandSendStatus(u32 status_ignore_mask) const {
u32 dummy;
return this->IssueCommandSendStatus(std::addressof(dummy), status_ignore_mask);
R_RETURN(this->IssueCommandSendStatus(std::addressof(dummy), status_ignore_mask));
}
Result IssueCommandSendStatus() const {
return this->IssueCommandSendStatus(0);
R_RETURN(this->IssueCommandSendStatus(0));
}
Result IssueCommandSetBlockLenToSectorSize() const;

View file

@ -88,7 +88,7 @@ namespace ams::sdmmc::impl {
return_result = result;
}
}
return return_result;
R_RETURN(return_result);
}
/* Get the response. */

View file

@ -177,11 +177,11 @@ namespace ams::sdmmc::impl {
virtual Result IssueStopTransmissionCommand(u32 *out_response) = 0;
ALWAYS_INLINE Result IssueCommand(const Command *command, TransferData *xfer_data) {
return this->IssueCommand(command, xfer_data, nullptr);
R_RETURN(this->IssueCommand(command, xfer_data, nullptr));
}
ALWAYS_INLINE Result IssueCommand(const Command *command) {
return this->IssueCommand(command, nullptr, nullptr);
R_RETURN(this->IssueCommand(command, nullptr, nullptr));
}
virtual void GetLastResponse(u32 *out_response, size_t response_size, ResponseType response_type) const = 0;

View file

@ -357,15 +357,15 @@ namespace ams::sdmmc::impl {
IHostController *hc = BaseDeviceAccessor::GetHostController();
if (hc->IsSupportedTuning() && hc->GetBusPower() == BusPower_1_8V) {
if (hc->GetBusWidth() == BusWidth_8Bit && IsSupportedHs400(device_type) && max_sm == SpeedMode_MmcHs400) {
return this->ChangeToHs400();
R_RETURN(this->ChangeToHs400());
} else if ((hc->GetBusWidth() == BusWidth_8Bit || hc->GetBusWidth() == BusWidth_4Bit) && IsSupportedHs200(device_type) && (max_sm == SpeedMode_MmcHs400 || max_sm == SpeedMode_MmcHs200)) {
return this->ChangeToHs200();
R_RETURN(this->ChangeToHs200());
}
}
/* Check if we can switch to high speed. */
if (IsSupportedHighSpeed(device_type)) {
return this->ChangeToHighSpeed(true);
R_RETURN(this->ChangeToHighSpeed(true));
}
/* We can't, so stay at normal speeds. */
@ -492,7 +492,7 @@ namespace ams::sdmmc::impl {
/* We failed to start up with all sets of parameters. */
BaseDeviceAccessor::PushErrorTimeStamp();
return result;
R_RETURN(result);
}
Result MmcDeviceAccessor::OnReadWrite(u32 sector_index, u32 num_sectors, void *buf, size_t buf_size, bool is_read) {
@ -505,7 +505,7 @@ namespace ams::sdmmc::impl {
}
/* Do the read/write. */
return BaseDeviceAccessor::ReadWriteMultiple(sector_index, num_sectors, sector_index_alignment, buf, buf_size, is_read);
R_RETURN(BaseDeviceAccessor::ReadWriteMultiple(sector_index, num_sectors, sector_index_alignment, buf, buf_size, is_read));
}
Result MmcDeviceAccessor::ReStartup() {
@ -516,7 +516,7 @@ namespace ams::sdmmc::impl {
Result result = this->StartupMmcDevice(m_max_bus_width, m_max_speed_mode, m_work_buffer, m_work_buffer_size);
if (R_FAILED(result)) {
BaseDeviceAccessor::PushErrorLog(false, "S %d %d:%X", m_max_bus_width, m_max_speed_mode, result.GetValue());
return result;
R_RETURN(result);
}
R_SUCCEED();
@ -676,7 +676,7 @@ namespace ams::sdmmc::impl {
/* Otherwise, check if we should reject the error. */
if (!sdmmc::ResultUnexpectedDeviceState::Includes(result)) {
return result;
R_RETURN(result);
}
/* Check if timeout has been exceeded. */

View file

@ -709,7 +709,7 @@ namespace ams::sdmmc::impl {
}
#endif
return result;
R_RETURN(result);
}
Result SdCardDeviceAccessor::OnReadWrite(u32 sector_index, u32 num_sectors, void *buf, size_t buf_size, bool is_read) {
@ -724,7 +724,7 @@ namespace ams::sdmmc::impl {
}
#endif
return result;
R_RETURN(result);
}
Result SdCardDeviceAccessor::ReStartup() {
@ -737,7 +737,7 @@ namespace ams::sdmmc::impl {
AMS_SDMMC_CHECK_SD_CARD_REMOVED();
BaseDeviceAccessor::PushErrorLog(false, "S %d %d:%X", m_max_bus_width, m_max_speed_mode, result.GetValue());
return result;
R_RETURN(result);
}
R_SUCCEED();
@ -825,7 +825,7 @@ namespace ams::sdmmc::impl {
#endif
/* Activate the base device. */
return BaseDeviceAccessor::Activate();
R_RETURN(BaseDeviceAccessor::Activate());
}
Result SdCardDeviceAccessor::GetSpeedMode(SpeedMode *out_speed_mode) const {

View file

@ -461,10 +461,10 @@ namespace ams::sdmmc::impl {
this->AbortTransaction();
}
return result;
R_RETURN(result);
} else if (sdmmc::ResultDeviceRemoved::Includes(result)) {
/* Otherwise, check if the device was removed. */
return result;
R_RETURN(result);
} else {
/* If the device wasn't removed, cancel our transaction. */
this->AbortTransaction();
@ -495,7 +495,7 @@ namespace ams::sdmmc::impl {
} else {
/* Otherwise, we have a generic failure. */
this->AbortTransaction();
return result;
R_RETURN(result);
}
}
}
@ -538,13 +538,13 @@ namespace ams::sdmmc::impl {
} else {
/* Abort the transaction. */
this->AbortTransaction();
return result;
R_RETURN(result);
}
return result;
R_RETURN(result);
} else if (sdmmc::ResultDeviceRemoved::Includes(result)) {
/* Otherwise, check if the device was removed. */
return result;
R_RETURN(result);
} else {
/* Otherwise, timeout if the transfer hasn't advanced. */
if (last_block_count != reg::Read(m_registers->block_count)) {
@ -597,7 +597,7 @@ namespace ams::sdmmc::impl {
} else {
/* Otherwise, we have a generic failure. */
this->AbortTransaction();
return result;
R_RETURN(result);
}
}
}
@ -967,7 +967,7 @@ namespace ams::sdmmc::impl {
/* After we issue the command, we need to wait 8 device clocks. */
ON_SCOPE_EXIT { WaitClocks(8, m_device_clock_frequency_khz); };
return this->IssueCommandWithDeviceClock(command, xfer_data, out_num_transferred_blocks);
R_RETURN(this->IssueCommandWithDeviceClock(command, xfer_data, out_num_transferred_blocks));
}
}
@ -996,7 +996,7 @@ namespace ams::sdmmc::impl {
/* After we issue the command, we need to wait 8 device clocks. */
ON_SCOPE_EXIT { WaitClocks(8, m_device_clock_frequency_khz); };
return this->IssueStopTransmissionCommandWithDeviceClock(out_response);
R_RETURN(this->IssueStopTransmissionCommandWithDeviceClock(out_response));
}
}

View file

@ -499,7 +499,7 @@ namespace ams::sdmmc::impl {
SdHostStandardController::AbortTransaction();
R_THROW(sdmmc::ResultIssueTuningCommandSoftwareTimeout());
} else {
return result;
R_RETURN(result);
}
}
#else
@ -804,7 +804,7 @@ namespace ams::sdmmc::impl {
this->CalibrateDriveStrength(SdHostStandardController::GetBusPower());
}
return SdHostStandardController::IssueCommand(command, xfer_data, out_num_transferred_blocks);
R_RETURN(SdHostStandardController::IssueCommand(command, xfer_data, out_num_transferred_blocks));
}
Result SdmmcController::IssueStopTransmissionCommand(u32 *out_response) {
@ -813,7 +813,7 @@ namespace ams::sdmmc::impl {
this->CalibrateDriveStrength(SdHostStandardController::GetBusPower());
}
return SdHostStandardController::IssueStopTransmissionCommand(out_response);
R_RETURN(SdHostStandardController::IssueStopTransmissionCommand(out_response));
}
Result SdmmcController::Tuning(SpeedMode speed_mode, u32 command_index) {
@ -957,7 +957,7 @@ namespace ams::sdmmc::impl {
/* Nintendo sets the current bus power regardless of whether the call succeeds. */
ON_SCOPE_EXIT { m_current_bus_power = BusPower_3_3V; };
/* TODO: return pcv::PowerOn(pcv::PowerControlTarget_SdCard, 3300000); */
/* TODO: R_RETURN(pcv::PowerOn(pcv::PowerControlTarget_SdCard, 3300000)); */
R_SUCCEED();
}
@ -986,7 +986,7 @@ namespace ams::sdmmc::impl {
/* Nintendo sets the current bus power regardless of whether the call succeeds. */
ON_SCOPE_EXIT { m_current_bus_power = BusPower_1_8V; };
/* TODO: return pcv::ChangeVoltage(pcv::PowerControlTarget_SdCard, 1800000); */
/* TODO: R_RETURN(pcv::ChangeVoltage(pcv::PowerControlTarget_SdCard, 1800000)); */
R_SUCCEED();
}
@ -1013,11 +1013,11 @@ namespace ams::sdmmc::impl {
Result Sdmmc1Controller::PowerOn(BusPower bus_power) {
#if defined(AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL)
if (m_is_pcv_control) {
return this->PowerOnForPcvControl(bus_power);
R_RETURN(this->PowerOnForPcvControl(bus_power));
} else
#endif
{
return this->PowerOnForRegisterControl(bus_power);
R_RETURN(this->PowerOnForRegisterControl(bus_power));
}
}
@ -1035,11 +1035,11 @@ namespace ams::sdmmc::impl {
Result Sdmmc1Controller::LowerBusPower() {
#if defined(AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL)
if (m_is_pcv_control) {
return this->LowerBusPowerForPcvControl();
R_RETURN(this->LowerBusPowerForPcvControl());
} else
#endif
{
return this->LowerBusPowerForRegisterControl();
R_RETURN(this->LowerBusPowerForRegisterControl());
}
}

View file

@ -99,7 +99,7 @@ namespace ams::sdmmc {
}
Result Activate(Port port) {
return GetDeviceAccessor(port)->Activate();
R_RETURN(GetDeviceAccessor(port)->Activate());
}
void Deactivate(Port port) {
@ -107,35 +107,35 @@ namespace ams::sdmmc {
}
Result Read(void *dst, size_t dst_size, Port port, u32 sector_index, u32 num_sectors) {
return GetDeviceAccessor(port)->ReadWrite(sector_index, num_sectors, dst, dst_size, true);
R_RETURN(GetDeviceAccessor(port)->ReadWrite(sector_index, num_sectors, dst, dst_size, true));
}
Result Write(Port port, u32 sector_index, u32 num_sectors, const void *src, size_t src_size) {
return GetDeviceAccessor(port)->ReadWrite(sector_index, num_sectors, const_cast<void *>(src), src_size, false);
R_RETURN(GetDeviceAccessor(port)->ReadWrite(sector_index, num_sectors, const_cast<void *>(src), src_size, false));
}
Result CheckConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port) {
return GetDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width);
R_RETURN(GetDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width));
}
Result GetDeviceSpeedMode(SpeedMode *out, Port port) {
return GetDeviceAccessor(port)->GetSpeedMode(out);
R_RETURN(GetDeviceAccessor(port)->GetSpeedMode(out));
}
Result GetDeviceMemoryCapacity(u32 *out_num_sectors, Port port) {
return GetDeviceAccessor(port)->GetMemoryCapacity(out_num_sectors);
R_RETURN(GetDeviceAccessor(port)->GetMemoryCapacity(out_num_sectors));
}
Result GetDeviceStatus(u32 *out_device_status, Port port) {
return GetDeviceAccessor(port)->GetDeviceStatus(out_device_status);
R_RETURN(GetDeviceAccessor(port)->GetDeviceStatus(out_device_status));
}
Result GetDeviceCid(void *out, size_t out_size, Port port) {
return GetDeviceAccessor(port)->GetCid(out, out_size);
R_RETURN(GetDeviceAccessor(port)->GetCid(out, out_size));
}
Result GetDeviceCsd(void *out, size_t out_size, Port port) {
return GetDeviceAccessor(port)->GetCsd(out, out_size);
R_RETURN(GetDeviceAccessor(port)->GetCsd(out, out_size));
}
void GetAndClearErrorInfo(ErrorInfo *out_error_info, size_t *out_log_size, char *out_log_buffer, size_t log_buffer_size, Port port) {

View file

@ -51,27 +51,27 @@ namespace ams::sdmmc {
}
Result AwakenGcAsic(Port port) {
return GetGcAsicDeviceAccessor(port)->AwakenGcAsic();
R_RETURN(GetGcAsicDeviceAccessor(port)->AwakenGcAsic());
}
Result WriteGcAsicOperation(Port port, const void *op_buf, size_t op_buf_size) {
return GetGcAsicDeviceAccessor(port)->WriteGcAsicOperation(op_buf, op_buf_size);
R_RETURN(GetGcAsicDeviceAccessor(port)->WriteGcAsicOperation(op_buf, op_buf_size));
}
Result FinishGcAsicOperation(Port port) {
return GetGcAsicDeviceAccessor(port)->FinishGcAsicOperation();
R_RETURN(GetGcAsicDeviceAccessor(port)->FinishGcAsicOperation());
}
Result AbortGcAsicOperation(Port port) {
return GetGcAsicDeviceAccessor(port)->AbortGcAsicOperation();
R_RETURN(GetGcAsicDeviceAccessor(port)->AbortGcAsicOperation());
}
Result SleepGcAsic(Port port) {
return GetGcAsicDeviceAccessor(port)->SleepGcAsic();
R_RETURN(GetGcAsicDeviceAccessor(port)->SleepGcAsic());
}
Result UpdateGcAsicKey(Port port) {
return GetGcAsicDeviceAccessor(port)->UpdateGcAsicKey();
R_RETURN(GetGcAsicDeviceAccessor(port)->UpdateGcAsicKey());
}
void SignalGcRemovedEvent(Port port) {

View file

@ -59,23 +59,23 @@ namespace ams::sdmmc {
}
Result SelectMmcPartition(Port port, MmcPartition mmc_partition) {
return GetMmcDeviceAccessor(port)->SelectMmcPartition(mmc_partition);
R_RETURN(GetMmcDeviceAccessor(port)->SelectMmcPartition(mmc_partition));
}
Result EraseMmc(Port port) {
return GetMmcDeviceAccessor(port)->EraseMmc();
R_RETURN(GetMmcDeviceAccessor(port)->EraseMmc());
}
Result GetMmcBootPartitionCapacity(u32 *out_num_sectors, Port port) {
return GetMmcDeviceAccessor(port)->GetMmcBootPartitionCapacity(out_num_sectors);
R_RETURN(GetMmcDeviceAccessor(port)->GetMmcBootPartitionCapacity(out_num_sectors));
}
Result GetMmcExtendedCsd(void *out_buffer, size_t buffer_size, Port port) {
return GetMmcDeviceAccessor(port)->GetMmcExtendedCsd(out_buffer, buffer_size);
R_RETURN(GetMmcDeviceAccessor(port)->GetMmcExtendedCsd(out_buffer, buffer_size));
}
Result CheckMmcConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port) {
return GetMmcDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width);
R_RETURN(GetMmcDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width));
}
}

View file

@ -59,27 +59,27 @@ namespace ams::sdmmc {
}
Result GetSdCardProtectedAreaCapacity(u32 *out_num_sectors, Port port) {
return GetSdCardDeviceAccessor(port)->GetSdCardProtectedAreaCapacity(out_num_sectors);
R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardProtectedAreaCapacity(out_num_sectors));
}
Result GetSdCardScr(void *dst, size_t dst_size, Port port) {
return GetSdCardDeviceAccessor(port)->GetSdCardScr(dst, dst_size);
R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardScr(dst, dst_size));
}
Result GetSdCardSwitchFunctionStatus(void *dst, size_t dst_size, Port port, SdCardSwitchFunction switch_function) {
return GetSdCardDeviceAccessor(port)->GetSdCardSwitchFunctionStatus(dst, dst_size, switch_function);
R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardSwitchFunctionStatus(dst, dst_size, switch_function));
}
Result GetSdCardCurrentConsumption(u16 *out_current_consumption, Port port, SpeedMode speed_mode) {
return GetSdCardDeviceAccessor(port)->GetSdCardCurrentConsumption(out_current_consumption, speed_mode);
R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardCurrentConsumption(out_current_consumption, speed_mode));
}
Result GetSdCardSdStatus(void *dst, size_t dst_size, Port port) {
return GetSdCardDeviceAccessor(port)->GetSdCardSdStatus(dst, dst_size);
R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardSdStatus(dst, dst_size));
}
Result CheckSdCardConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port) {
return GetSdCardDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width);
R_RETURN(GetSdCardDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width));
}
bool IsSdCardInserted(Port port) {