static size_t sdio_write_modem_data(const u8 * buf, u32 len) { size_t ret = 0; u32 result = SDHCI_TRANSFER_OK; u32 resend_count = 0; wake_lock(&s_ipc_sdio_wake_lock); do { printk("SDIO WRITE START\n"); ipc_info_change_status(IPC_TX_CHANNEL, IPC_STATUS_CONNECTED); ret = sprd_sdio_channel_tx(buf, len, (resend_count & ((1 << 17) - 1))); set_cp_awake(true); if(!ret) { result = SDHCI_TRANSFER_OK; ret = len; } else { ipc_info_error_status(IPC_TX_CHANNEL, IPC_STATUS_CRC_ERROR); result = SDHCI_TRANSFER_ERROR; printk("SDIO WRITE FAIL\n"); ret = 0; } ipc_info_change_status(IPC_TX_CHANNEL, IPC_STATUS_DISCONNECTED); if(result) { resend_count++; msleep(200); } } while(result && (resend_count < MAX_SDIO_TX_RETRY)); wake_unlock(&s_ipc_sdio_wake_lock); ipc_info_change_status(IPC_TX_CHANNEL, IPC_STATUS_IDLE); if(resend_count >= MAX_SDIO_TX_RETRY) { while(1) { msleep(2000); printk("sdio_write_modem_data write fail 3 times \n"); } } return ret; }
int modem_sdio_write(char *buffer,int size) { return sprd_sdio_channel_tx((const char *)buffer,size, 0); }