A_STATUS ar6000_WriteDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address, A_UCHAR *data, A_UINT32 length) { A_UINT32 count; A_STATUS status = A_OK; for (count = 0; count < length; count += 4, address += 4) { if ((status = HIFDiagWriteAccess(hifDevice, address, *((A_UINT32 *)&data[count]))) != A_OK) { break; } } return status; }
static ssize_t ath_procfs_diag_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { hif_handle_t hif_hdl; int rv; A_UINT8 *write_buffer = NULL; write_buffer = (A_UINT8 *)vos_mem_malloc(count); if (NULL == write_buffer) { pr_debug("%s: vos_mem_alloc failed\n", __func__); return -EINVAL; } if(copy_from_user(write_buffer, buf, count)) { vos_mem_free(write_buffer); return -EFAULT; } hif_hdl = get_hif_hdl_from_file(file); pr_debug("wr buff 0x%p buf 0x%p cnt %zu offset 0x%x value 0x%x\n", write_buffer, buf, count, (int)*pos, *((A_UINT32 *)write_buffer)); if ((count == 4) && ((((A_UINT32)(*pos)) & 3) == 0)) { /* reading a word? */ A_UINT32 value = *((A_UINT32 *)write_buffer); rv = HIFDiagWriteAccess(hif_hdl, (A_UINT32)(*pos), value); } else { rv = HIFDiagWriteMem(hif_hdl, (A_UINT32)(*pos), (A_UINT8 *)write_buffer, count); } vos_mem_free(write_buffer); if (rv == 0) { return count; } else { return -EIO; } }
/* * Write to the AR6000 through its diagnostic window. * No cooperation from the Target is required for this. */ A_STATUS ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data) { return HIFDiagWriteAccess(hifDevice, *address, *data); }