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());
}
}