/* This function performs SD write in polled mode.  */
s32 XSdPs_Write(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff)
/* This function performs SD write in polled mode.  */
s32 XSdPs_Write(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff)
{
    s32 Status;
    u16 BlkSize;
    BlkSize = XSDPS_BLK_SIZE_512_MASK;
    XSdPs_SetupWriteDma(InstancePtr, BlkCnt, BlkSize, Buff);
    if (BlkCnt == 1U) {
        Status = XSdPs_CmdTransfer(InstancePtr, CMD24, Arg, BlkCnt);
        if (Status != XST_SUCCESS) {
            Status = XST_FAILURE;
            goto RETURN_PATH;
        }
    } else {
        Status = XSdPs_CmdTransfer(InstancePtr, CMD25, Arg, BlkCnt);
        if (Status != XST_SUCCESS) {
            Status = XST_FAILURE;
            goto RETURN_PATH;
        }
    }
    Status = XSdps_CheckTransferDone(InstancePtr);
    if (Status != XST_SUCCESS) {
        Status = XST_FAILURE;
    }
    Status = XST_SUCCESS;
    RETURN_PATH:
        return Status;
}