2010-09-30 02:24:07 -06:00
|
|
|
#include <linux/fs.h>
|
|
|
|
|
2010-09-08 15:46:36 -06:00
|
|
|
#include "headers.h"
|
2014-05-22 04:17:26 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
static int bcm_handle_nvm_read_cmd(struct bcm_mini_adapter *ad,
|
2014-08-10 06:31:57 -06:00
|
|
|
PUCHAR read_data,
|
2014-08-10 06:31:58 -06:00
|
|
|
struct bcm_nvm_readwrite *nvm_rw)
|
2014-05-22 04:17:26 -06:00
|
|
|
{
|
2014-08-10 06:31:59 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-05-22 04:17:26 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
down(&ad->NVMRdmWrmLock);
|
2014-05-22 04:17:26 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
if ((ad->IdleMode == TRUE) || (ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-05-22 04:17:26 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad,
|
2014-05-22 04:17:26 -06:00
|
|
|
DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-08-10 06:31:56 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-10 06:31:57 -06:00
|
|
|
kfree(read_data);
|
2014-05-22 04:17:26 -06:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
status = BeceemNVMRead(ad, (PUINT)read_data,
|
2014-08-10 06:31:58 -06:00
|
|
|
nvm_rw->uiOffset,
|
|
|
|
nvm_rw->uiNumBytes);
|
2014-08-10 06:31:56 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-05-22 04:17:26 -06:00
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
if (status != STATUS_SUCCESS) {
|
2014-08-10 06:31:57 -06:00
|
|
|
kfree(read_data);
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-05-22 04:17:26 -06:00
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:58 -06:00
|
|
|
if (copy_to_user(nvm_rw->pBuffer, read_data, nvm_rw->uiNumBytes)) {
|
2014-08-10 06:31:57 -06:00
|
|
|
kfree(read_data);
|
2014-05-22 04:17:26 -06:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
static int handle_flash2x_adapter(struct bcm_mini_adapter *ad,
|
2014-08-10 06:31:57 -06:00
|
|
|
PUCHAR read_data,
|
2014-08-10 06:31:58 -06:00
|
|
|
struct bcm_nvm_readwrite *nvm_rw)
|
2014-05-22 04:17:27 -06:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* New Requirement:-
|
|
|
|
* DSD section updation will be allowed in two case:-
|
|
|
|
* 1. if DSD sig is present in DSD header means dongle
|
|
|
|
* is ok and updation is fruitfull
|
|
|
|
* 2. if point 1 failes then user buff should have
|
|
|
|
* DSD sig. this point ensures that if dongle is
|
|
|
|
* corrupted then user space program first modify
|
|
|
|
* the DSD header with valid DSD sig so that this
|
|
|
|
* as well as further write may be worthwhile.
|
|
|
|
*
|
|
|
|
* This restriction has been put assuming that
|
|
|
|
* if DSD sig is corrupted, DSD data won't be
|
|
|
|
* considered valid.
|
|
|
|
*/
|
2014-08-10 06:31:59 -06:00
|
|
|
INT status;
|
2014-08-10 06:32:00 -06:00
|
|
|
ULONG dsd_magic_num_in_usr_buff = 0;
|
2014-05-22 04:17:27 -06:00
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
status = BcmFlash2xCorruptSig(ad, ad->eActiveDSD);
|
|
|
|
if (status == STATUS_SUCCESS)
|
2014-05-22 04:17:27 -06:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
2014-08-10 06:31:58 -06:00
|
|
|
if (((nvm_rw->uiOffset + nvm_rw->uiNumBytes) !=
|
2014-08-10 06:31:56 -06:00
|
|
|
ad->uiNVMDSDSize) ||
|
2014-08-10 06:31:58 -06:00
|
|
|
(nvm_rw->uiNumBytes < SIGNATURE_SIZE)) {
|
2014-05-22 04:17:27 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:27 -06:00
|
|
|
"DSD Sig is present neither in Flash nor User provided Input..");
|
2014-08-10 06:31:56 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-10 06:31:57 -06:00
|
|
|
kfree(read_data);
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-05-22 04:17:27 -06:00
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:00 -06:00
|
|
|
dsd_magic_num_in_usr_buff =
|
2014-08-10 06:31:58 -06:00
|
|
|
ntohl(*(PUINT)(read_data + nvm_rw->uiNumBytes -
|
2014-05-22 04:17:27 -06:00
|
|
|
SIGNATURE_SIZE));
|
2014-08-10 06:32:00 -06:00
|
|
|
if (dsd_magic_num_in_usr_buff != DSD_IMAGE_MAGIC_NUMBER) {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:27 -06:00
|
|
|
"DSD Sig is present neither in Flash nor User provided Input..");
|
2014-08-10 06:31:56 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-10 06:31:57 -06:00
|
|
|
kfree(read_data);
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-05-22 04:17:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-09-08 15:46:36 -06:00
|
|
|
/***************************************************************
|
|
|
|
* Function - bcm_char_open()
|
|
|
|
*
|
|
|
|
* Description - This is the "open" entry point for the character
|
|
|
|
* driver.
|
|
|
|
*
|
|
|
|
* Parameters - inode: Pointer to the Inode structure of char device
|
|
|
|
* filp : File pointer of the char device
|
|
|
|
*
|
|
|
|
* Returns - Zero(Success)
|
|
|
|
****************************************************************/
|
2010-11-01 08:17:54 -06:00
|
|
|
|
2013-04-29 07:49:04 -06:00
|
|
|
static int bcm_char_open(struct inode *inode, struct file *filp)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2014-08-10 06:31:56 -06:00
|
|
|
struct bcm_mini_adapter *ad = NULL;
|
2014-08-10 06:32:01 -06:00
|
|
|
struct bcm_tarang_data *tarang = NULL;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
ad = GET_BCM_ADAPTER(gblpnetdev);
|
2014-08-10 06:32:01 -06:00
|
|
|
tarang = kzalloc(sizeof(struct bcm_tarang_data), GFP_KERNEL);
|
|
|
|
if (!tarang)
|
2011-02-11 20:38:22 -07:00
|
|
|
return -ENOMEM;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:32:01 -06:00
|
|
|
tarang->Adapter = ad;
|
|
|
|
tarang->RxCntrlMsgBitMask = 0xFFFFFFFF & ~(1 << 0xB);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
down(&ad->RxAppControlQueuelock);
|
2014-08-10 06:32:01 -06:00
|
|
|
tarang->next = ad->pTarangs;
|
|
|
|
ad->pTarangs = tarang;
|
2014-08-10 06:31:56 -06:00
|
|
|
up(&ad->RxAppControlQueuelock);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
|
|
|
/* Store the Adapter structure */
|
2014-08-10 06:32:01 -06:00
|
|
|
filp->private_data = tarang;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
/* Start Queuing the control response Packets */
|
2014-08-10 06:31:56 -06:00
|
|
|
atomic_inc(&ad->ApplicationRunning);
|
2010-09-30 02:24:07 -06:00
|
|
|
|
|
|
|
nonseekable_open(inode, filp);
|
2010-09-08 15:46:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
2011-02-11 20:38:22 -07:00
|
|
|
|
2010-09-08 15:46:36 -06:00
|
|
|
static int bcm_char_release(struct inode *inode, struct file *filp)
|
|
|
|
{
|
2014-08-10 06:32:01 -06:00
|
|
|
struct bcm_tarang_data *tarang, *tmp, *ptmp;
|
2014-08-10 06:31:56 -06:00
|
|
|
struct bcm_mini_adapter *ad = NULL;
|
2011-02-11 20:38:23 -07:00
|
|
|
struct sk_buff *pkt, *npkt;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:32:01 -06:00
|
|
|
tarang = (struct bcm_tarang_data *)filp->private_data;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:32:01 -06:00
|
|
|
if (tarang == NULL)
|
2011-02-11 20:38:23 -07:00
|
|
|
return 0;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:32:01 -06:00
|
|
|
ad = tarang->Adapter;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
down(&ad->RxAppControlQueuelock);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
tmp = ad->pTarangs;
|
2011-02-11 20:38:23 -07:00
|
|
|
for (ptmp = NULL; tmp; ptmp = tmp, tmp = tmp->next) {
|
2014-08-10 06:32:01 -06:00
|
|
|
if (tmp == tarang)
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:23 -07:00
|
|
|
if (tmp) {
|
|
|
|
if (!ptmp)
|
2014-08-10 06:31:56 -06:00
|
|
|
ad->pTarangs = tmp->next;
|
2011-02-11 20:38:23 -07:00
|
|
|
else
|
|
|
|
ptmp->next = tmp->next;
|
|
|
|
} else {
|
2014-08-10 06:31:56 -06:00
|
|
|
up(&ad->RxAppControlQueuelock);
|
2011-02-11 20:38:23 -07:00
|
|
|
return 0;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:01 -06:00
|
|
|
pkt = tarang->RxAppControlHead;
|
2011-02-11 20:38:23 -07:00
|
|
|
while (pkt) {
|
|
|
|
npkt = pkt->next;
|
|
|
|
kfree_skb(pkt);
|
|
|
|
pkt = npkt;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
up(&ad->RxAppControlQueuelock);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
/* Stop Queuing the control response Packets */
|
2014-08-10 06:31:56 -06:00
|
|
|
atomic_dec(&ad->ApplicationRunning);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:32:01 -06:00
|
|
|
kfree(tarang);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
|
|
|
/* remove this filp from the asynchronously notified filp's */
|
2011-02-11 20:38:23 -07:00
|
|
|
filp->private_data = NULL;
|
|
|
|
return 0;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:55 -06:00
|
|
|
static ssize_t bcm_char_read(struct file *filp,
|
|
|
|
char __user *buf,
|
|
|
|
size_t size,
|
2011-02-11 20:38:24 -07:00
|
|
|
loff_t *f_pos)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2014-08-10 06:32:01 -06:00
|
|
|
struct bcm_tarang_data *tarang = filp->private_data;
|
|
|
|
struct bcm_mini_adapter *ad = tarang->Adapter;
|
2014-08-10 06:32:03 -06:00
|
|
|
struct sk_buff *packet = NULL;
|
2014-08-10 06:32:02 -06:00
|
|
|
ssize_t pkt_len = 0;
|
2011-08-15 20:07:41 -06:00
|
|
|
int wait_ret_val = 0;
|
2011-02-11 20:38:24 -07:00
|
|
|
unsigned long ret = 0;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-05-22 04:17:25 -06:00
|
|
|
wait_ret_val = wait_event_interruptible(
|
2014-08-10 06:31:56 -06:00
|
|
|
ad->process_read_wait_queue,
|
2014-08-10 06:32:01 -06:00
|
|
|
(tarang->RxAppControlHead ||
|
2014-08-10 06:31:56 -06:00
|
|
|
ad->device_removed));
|
2014-05-22 04:17:25 -06:00
|
|
|
|
2011-02-11 20:38:24 -07:00
|
|
|
if ((wait_ret_val == -ERESTARTSYS)) {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2011-02-11 20:38:24 -07:00
|
|
|
"Exiting as i've been asked to exit!!!\n");
|
2010-09-08 15:46:36 -06:00
|
|
|
return wait_ret_val;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
if (ad->device_removed) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2011-02-11 20:38:24 -07:00
|
|
|
"Device Removed... Killing the Apps...\n");
|
2010-09-08 15:46:36 -06:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
if (false == ad->fw_download_done)
|
2010-09-08 15:46:36 -06:00
|
|
|
return -EACCES;
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
down(&ad->RxAppControlQueuelock);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:32:01 -06:00
|
|
|
if (tarang->RxAppControlHead) {
|
2014-08-10 06:32:03 -06:00
|
|
|
packet = tarang->RxAppControlHead;
|
2014-08-10 06:32:01 -06:00
|
|
|
DEQUEUEPACKET(tarang->RxAppControlHead,
|
|
|
|
tarang->RxAppControlTail);
|
|
|
|
tarang->AppCtrlQueueLen--;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
up(&ad->RxAppControlQueuelock);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-10 06:32:03 -06:00
|
|
|
if (packet) {
|
|
|
|
pkt_len = packet->len;
|
|
|
|
ret = copy_to_user(buf, packet->data,
|
2014-08-10 06:32:02 -06:00
|
|
|
min_t(size_t, pkt_len, size));
|
2011-02-11 20:38:24 -07:00
|
|
|
if (ret) {
|
2014-08-10 06:32:03 -06:00
|
|
|
dev_kfree_skb(packet);
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2011-02-11 20:38:24 -07:00
|
|
|
"Returning from copy to user failure\n");
|
2010-09-08 15:46:36 -06:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2010-11-01 07:26:47 -06:00
|
|
|
"Read %zd Bytes From Adapter packet = %p by process %d!\n",
|
2014-08-10 06:32:03 -06:00
|
|
|
pkt_len, packet, current->pid);
|
|
|
|
dev_kfree_skb(packet);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "<\n");
|
2014-08-10 06:32:02 -06:00
|
|
|
return pkt_len;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_reg_read_private(void __user *argp,
|
2014-08-10 06:31:56 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:05 -07:00
|
|
|
{
|
2014-08-10 06:32:04 -06:00
|
|
|
struct bcm_rdm_buffer rdm_buff = {0};
|
2014-08-10 06:32:05 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:45:05 -07:00
|
|
|
PCHAR temp_buff;
|
2014-08-10 06:31:59 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-08-10 06:32:06 -06:00
|
|
|
UINT buff_len;
|
2014-02-13 12:45:05 -07:00
|
|
|
u16 temp_value;
|
|
|
|
int bytes;
|
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:05 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (io_buff.InputLength > sizeof(rdm_buff))
|
2014-02-13 12:45:05 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_from_user(&rdm_buff, io_buff.InputBuffer,
|
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:05 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (io_buff.OutputLength > USHRT_MAX ||
|
|
|
|
io_buff.OutputLength == 0) {
|
2014-02-13 12:45:05 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:06 -06:00
|
|
|
buff_len = io_buff.OutputLength;
|
|
|
|
temp_value = 4 - (buff_len % 4);
|
|
|
|
buff_len += temp_value % 4;
|
2014-02-13 12:45:05 -07:00
|
|
|
|
2014-08-10 06:32:06 -06:00
|
|
|
temp_buff = kmalloc(buff_len, GFP_KERNEL);
|
2014-02-13 12:45:05 -07:00
|
|
|
if (!temp_buff)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2014-08-10 06:32:04 -06:00
|
|
|
bytes = rdmalt(ad, (UINT)rdm_buff.Register,
|
2014-08-10 06:32:06 -06:00
|
|
|
(PUINT)temp_buff, buff_len);
|
2014-02-13 12:45:05 -07:00
|
|
|
if (bytes > 0) {
|
2014-08-10 06:31:59 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, temp_buff, bytes)) {
|
2014-02-13 12:45:05 -07:00
|
|
|
kfree(temp_buff);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
} else {
|
2014-08-10 06:31:59 -06:00
|
|
|
status = bytes;
|
2014-02-13 12:45:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
kfree(temp_buff);
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-02-13 12:45:05 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_reg_write_private(void __user *argp,
|
2014-08-10 06:31:56 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:11 -07:00
|
|
|
{
|
2014-08-10 06:32:07 -06:00
|
|
|
struct bcm_wrm_buffer wrm_buff = {0};
|
2014-08-10 06:32:05 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-10 06:32:08 -06:00
|
|
|
UINT tmp = 0;
|
2014-08-10 06:31:59 -06:00
|
|
|
INT status;
|
2014-02-13 12:45:11 -07:00
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:11 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:07 -06:00
|
|
|
if (io_buff.InputLength > sizeof(wrm_buff))
|
2014-02-13 12:45:11 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Get WrmBuffer structure */
|
2014-08-10 06:32:07 -06:00
|
|
|
if (copy_from_user(&wrm_buff, io_buff.InputBuffer,
|
2014-08-10 06:32:05 -06:00
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:11 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:08 -06:00
|
|
|
tmp = wrm_buff.Register & EEPROM_REJECT_MASK;
|
2014-08-10 06:31:56 -06:00
|
|
|
if (!((ad->pstargetparams->m_u32Customize) & VSG_MODE) &&
|
2014-08-10 06:32:08 -06:00
|
|
|
((tmp == EEPROM_REJECT_REG_1) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_2) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_3) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_4))) {
|
2014-02-13 12:45:11 -07:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:11 -07:00
|
|
|
"EEPROM Access Denied, not in VSG Mode\n");
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:07 -06:00
|
|
|
status = wrmalt(ad, (UINT)wrm_buff.Register,
|
|
|
|
(PUINT)wrm_buff.Data, sizeof(ULONG));
|
2014-02-13 12:45:11 -07:00
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
if (status == STATUS_SUCCESS) {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:11 -07:00
|
|
|
DBG_LVL_ALL, "WRM Done\n");
|
|
|
|
} else {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:11 -07:00
|
|
|
DBG_LVL_ALL, "WRM Failed\n");
|
2014-08-10 06:31:59 -06:00
|
|
|
status = -EFAULT;
|
2014-02-13 12:45:11 -07:00
|
|
|
}
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-02-13 12:45:11 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_eeprom_reg_read(void __user *argp,
|
2014-08-10 06:31:56 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:16 -07:00
|
|
|
{
|
2014-08-10 06:32:04 -06:00
|
|
|
struct bcm_rdm_buffer rdm_buff = {0};
|
2014-08-10 06:32:05 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:45:16 -07:00
|
|
|
PCHAR temp_buff = NULL;
|
2014-08-10 06:32:08 -06:00
|
|
|
UINT tmp = 0;
|
2014-08-10 06:31:59 -06:00
|
|
|
INT status;
|
2014-02-13 12:45:16 -07:00
|
|
|
int bytes;
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:45:16 -07:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:16 -07:00
|
|
|
"Device in Idle Mode, Blocking Rdms\n");
|
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:16 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (io_buff.InputLength > sizeof(rdm_buff))
|
2014-02-13 12:45:16 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_from_user(&rdm_buff, io_buff.InputBuffer,
|
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:16 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (io_buff.OutputLength > USHRT_MAX ||
|
|
|
|
io_buff.OutputLength == 0) {
|
2014-02-13 12:45:16 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
temp_buff = kmalloc(io_buff.OutputLength, GFP_KERNEL);
|
2014-02-13 12:45:16 -07:00
|
|
|
if (!temp_buff)
|
|
|
|
return STATUS_FAILURE;
|
|
|
|
|
2014-08-10 06:32:04 -06:00
|
|
|
if ((((ULONG)rdm_buff.Register & 0x0F000000) != 0x0F000000) ||
|
|
|
|
((ULONG)rdm_buff.Register & 0x3)) {
|
2014-02-13 12:45:16 -07:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:16 -07:00
|
|
|
"RDM Done On invalid Address : %x Access Denied.\n",
|
2014-08-10 06:32:04 -06:00
|
|
|
(int)rdm_buff.Register);
|
2014-02-13 12:45:16 -07:00
|
|
|
|
|
|
|
kfree(temp_buff);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:08 -06:00
|
|
|
tmp = rdm_buff.Register & EEPROM_REJECT_MASK;
|
2014-08-10 06:32:04 -06:00
|
|
|
bytes = rdmaltWithLock(ad, (UINT)rdm_buff.Register,
|
2014-08-10 06:32:05 -06:00
|
|
|
(PUINT)temp_buff, io_buff.OutputLength);
|
2014-02-13 12:45:16 -07:00
|
|
|
|
|
|
|
if (bytes > 0) {
|
2014-08-10 06:31:59 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, temp_buff, bytes)) {
|
2014-02-13 12:45:16 -07:00
|
|
|
kfree(temp_buff);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
} else {
|
2014-08-10 06:31:59 -06:00
|
|
|
status = bytes;
|
2014-02-13 12:45:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
kfree(temp_buff);
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-02-13 12:45:16 -07:00
|
|
|
}
|
2014-02-13 12:45:11 -07:00
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_eeprom_reg_write(void __user *argp,
|
2014-08-10 06:31:56 -06:00
|
|
|
struct bcm_mini_adapter *ad,
|
2014-05-22 04:17:28 -06:00
|
|
|
UINT cmd)
|
2014-02-13 12:45:21 -07:00
|
|
|
{
|
2014-08-10 06:32:07 -06:00
|
|
|
struct bcm_wrm_buffer wrm_buff = {0};
|
2014-08-10 06:32:05 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-10 06:32:08 -06:00
|
|
|
UINT tmp = 0;
|
2014-08-10 06:31:59 -06:00
|
|
|
INT status;
|
2014-02-13 12:45:21 -07:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:45:21 -07:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:21 -07:00
|
|
|
"Device in Idle Mode, Blocking Wrms\n");
|
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:21 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:07 -06:00
|
|
|
if (io_buff.InputLength > sizeof(wrm_buff))
|
2014-02-13 12:45:21 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Get WrmBuffer structure */
|
2014-08-10 06:32:07 -06:00
|
|
|
if (copy_from_user(&wrm_buff, io_buff.InputBuffer,
|
2014-08-10 06:32:05 -06:00
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:21 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:07 -06:00
|
|
|
if ((((ULONG)wrm_buff.Register & 0x0F000000) != 0x0F000000) ||
|
|
|
|
((ULONG)wrm_buff.Register & 0x3)) {
|
2014-02-13 12:45:21 -07:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:21 -07:00
|
|
|
"WRM Done On invalid Address : %x Access Denied.\n",
|
2014-08-10 06:32:07 -06:00
|
|
|
(int)wrm_buff.Register);
|
2014-02-13 12:45:21 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:08 -06:00
|
|
|
tmp = wrm_buff.Register & EEPROM_REJECT_MASK;
|
2014-08-10 06:31:56 -06:00
|
|
|
if (!((ad->pstargetparams->m_u32Customize) & VSG_MODE) &&
|
2014-08-10 06:32:08 -06:00
|
|
|
((tmp == EEPROM_REJECT_REG_1) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_2) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_3) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_4)) &&
|
2014-02-13 12:45:21 -07:00
|
|
|
(cmd == IOCTL_BCM_REGISTER_WRITE)) {
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:21 -07:00
|
|
|
"EEPROM Access Denied, not in VSG Mode\n");
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:07 -06:00
|
|
|
status = wrmaltWithLock(ad, (UINT)wrm_buff.Register,
|
|
|
|
(PUINT)wrm_buff.Data,
|
|
|
|
wrm_buff.Length);
|
2014-02-13 12:45:21 -07:00
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
if (status == STATUS_SUCCESS) {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, OSAL_DBG,
|
2014-02-13 12:45:21 -07:00
|
|
|
DBG_LVL_ALL, "WRM Done\n");
|
|
|
|
} else {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:21 -07:00
|
|
|
DBG_LVL_ALL, "WRM Failed\n");
|
2014-08-10 06:31:59 -06:00
|
|
|
status = -EFAULT;
|
2014-02-13 12:45:21 -07:00
|
|
|
}
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-02-13 12:45:21 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_gpio_set_request(void __user *argp,
|
2014-08-10 06:31:56 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:26 -07:00
|
|
|
{
|
|
|
|
struct bcm_gpio_info gpio_info = {0};
|
2014-08-10 06:32:05 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-10 06:32:09 -06:00
|
|
|
UCHAR reset_val[4];
|
2014-02-13 12:45:26 -07:00
|
|
|
UINT value = 0;
|
2014-08-10 06:32:10 -06:00
|
|
|
UINT bit = 0;
|
2014-08-10 06:32:11 -06:00
|
|
|
UINT operation = 0;
|
2014-08-10 06:31:59 -06:00
|
|
|
INT status;
|
2014-02-13 12:45:26 -07:00
|
|
|
int bytes;
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:45:26 -07:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:26 -07:00
|
|
|
DBG_LVL_ALL,
|
|
|
|
"GPIO Can't be set/clear in Low power Mode");
|
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:26 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (io_buff.InputLength > sizeof(gpio_info))
|
2014-02-13 12:45:26 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-10 06:32:05 -06:00
|
|
|
if (copy_from_user(&gpio_info, io_buff.InputBuffer,
|
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:26 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-10 06:32:10 -06:00
|
|
|
bit = gpio_info.uiGpioNumber;
|
2014-08-10 06:32:11 -06:00
|
|
|
operation = gpio_info.uiGpioValue;
|
2014-08-10 06:32:10 -06:00
|
|
|
value = (1<<bit);
|
2014-02-13 12:45:26 -07:00
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
if (IsReqGpioIsLedInNVM(ad, value) == false) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:26 -07:00
|
|
|
DBG_LVL_ALL,
|
|
|
|
"Sorry, Requested GPIO<0x%X> is not correspond to LED !!!",
|
|
|
|
value);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set - setting 1 */
|
2014-08-10 06:32:11 -06:00
|
|
|
if (operation) {
|
2014-02-13 12:45:26 -07:00
|
|
|
/* Set the gpio output register */
|
2014-08-10 06:31:59 -06:00
|
|
|
status = wrmaltWithLock(ad,
|
2014-02-13 12:45:26 -07:00
|
|
|
BCM_GPIO_OUTPUT_SET_REG,
|
|
|
|
(PUINT)(&value), sizeof(UINT));
|
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
if (status == STATUS_SUCCESS) {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
|
2014-02-13 12:45:26 -07:00
|
|
|
OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"Set the GPIO bit\n");
|
|
|
|
} else {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
|
2014-02-13 12:45:26 -07:00
|
|
|
OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"Failed to set the %dth GPIO\n",
|
2014-08-10 06:32:10 -06:00
|
|
|
bit);
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-02-13 12:45:26 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Set the gpio output register */
|
2014-08-10 06:31:59 -06:00
|
|
|
status = wrmaltWithLock(ad,
|
2014-02-13 12:45:26 -07:00
|
|
|
BCM_GPIO_OUTPUT_CLR_REG,
|
|
|
|
(PUINT)(&value), sizeof(UINT));
|
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
if (status == STATUS_SUCCESS) {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
|
2014-02-13 12:45:26 -07:00
|
|
|
OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"Set the GPIO bit\n");
|
|
|
|
} else {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
|
2014-02-13 12:45:26 -07:00
|
|
|
OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"Failed to clear the %dth GPIO\n",
|
2014-08-10 06:32:10 -06:00
|
|
|
bit);
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-02-13 12:45:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:56 -06:00
|
|
|
bytes = rdmaltWithLock(ad, (UINT)GPIO_MODE_REGISTER,
|
2014-08-10 06:32:09 -06:00
|
|
|
(PUINT)reset_val, sizeof(UINT));
|
2014-02-13 12:45:26 -07:00
|
|
|
if (bytes < 0) {
|
2014-08-10 06:31:59 -06:00
|
|
|
status = bytes;
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-02-13 12:45:26 -07:00
|
|
|
"GPIO_MODE_REGISTER read failed");
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-02-13 12:45:26 -07:00
|
|
|
} else {
|
2014-08-10 06:31:59 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2014-02-13 12:45:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the gpio mode register to output */
|
2014-08-10 06:32:10 -06:00
|
|
|
*(UINT *)reset_val |= (1<<bit);
|
2014-08-10 06:31:59 -06:00
|
|
|
status = wrmaltWithLock(ad, GPIO_MODE_REGISTER,
|
2014-08-10 06:32:09 -06:00
|
|
|
(PUINT)reset_val, sizeof(UINT));
|
2014-02-13 12:45:26 -07:00
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
if (status == STATUS_SUCCESS) {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:26 -07:00
|
|
|
DBG_LVL_ALL,
|
|
|
|
"Set the GPIO to output Mode\n");
|
|
|
|
} else {
|
2014-08-10 06:31:56 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:26 -07:00
|
|
|
DBG_LVL_ALL,
|
|
|
|
"Failed to put GPIO in Output Mode\n");
|
|
|
|
}
|
|
|
|
|
2014-08-10 06:31:59 -06:00
|
|
|
return status;
|
2014-02-13 12:45:26 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:31 -07:00
|
|
|
{
|
2014-08-27 04:57:39 -06:00
|
|
|
struct bcm_user_thread_req thread_req = {0};
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:45:31 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-02-13 12:45:31 -07:00
|
|
|
"User made LED thread InActive");
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:45:31 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:31 -07:00
|
|
|
DBG_LVL_ALL,
|
|
|
|
"GPIO Can't be set/clear in Low power Mode");
|
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:31 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength > sizeof(thread_req))
|
2014-02-13 12:45:31 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&thread_req, io_buff.InputBuffer,
|
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:31 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
/* if LED thread is running(Actively or Inactively)
|
|
|
|
* set it state to make inactive
|
|
|
|
*/
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->LEDInfo.led_thread_running) {
|
2014-08-27 04:57:39 -06:00
|
|
|
if (thread_req.ThreadState == LED_THREAD_ACTIVATION_REQ) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
|
2014-02-13 12:45:31 -07:00
|
|
|
OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"Activating thread req");
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->DriverState = LED_THREAD_ACTIVE;
|
2014-02-13 12:45:31 -07:00
|
|
|
} else {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
|
2014-02-13 12:45:31 -07:00
|
|
|
OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"DeActivating Thread req.....");
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->DriverState = LED_THREAD_INACTIVE;
|
2014-02-13 12:45:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* signal thread. */
|
2014-08-27 04:57:38 -06:00
|
|
|
wake_up(&ad->LEDInfo.notify_led_event);
|
2014-02-13 12:45:31 -07:00
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_gpio_status_request(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:36 -07:00
|
|
|
{
|
|
|
|
struct bcm_gpio_info gpio_info = {0};
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:41 -06:00
|
|
|
ULONG bit = 0;
|
2014-08-27 04:57:42 -06:00
|
|
|
UCHAR read[4];
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status;
|
2014-02-13 12:45:36 -07:00
|
|
|
int bytes;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE))
|
2014-02-13 12:45:36 -07:00
|
|
|
return -EACCES;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:36 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength > sizeof(gpio_info))
|
2014-02-13 12:45:36 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&gpio_info, io_buff.InputBuffer,
|
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:36 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:41 -06:00
|
|
|
bit = gpio_info.uiGpioNumber;
|
2014-02-13 12:45:36 -07:00
|
|
|
|
|
|
|
/* Set the gpio output register */
|
2014-08-27 04:57:38 -06:00
|
|
|
bytes = rdmaltWithLock(ad, (UINT)GPIO_PIN_STATE_REGISTER,
|
2014-08-27 04:57:42 -06:00
|
|
|
(PUINT)read, sizeof(UINT));
|
2014-02-13 12:45:36 -07:00
|
|
|
|
|
|
|
if (bytes < 0) {
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bytes;
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:36 -07:00
|
|
|
"RDM Failed\n");
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:36 -07:00
|
|
|
} else {
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2014-02-13 12:45:36 -07:00
|
|
|
}
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_gpio_multi_request(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:41 -07:00
|
|
|
{
|
|
|
|
struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX];
|
2014-03-13 02:34:19 -06:00
|
|
|
struct bcm_gpio_multi_info *pgpio_multi_info =
|
|
|
|
(struct bcm_gpio_multi_info *)gpio_multi_info;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:44 -06:00
|
|
|
UCHAR reset_val[4];
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-02-13 12:45:41 -07:00
|
|
|
int bytes;
|
|
|
|
|
2014-05-22 04:17:25 -06:00
|
|
|
memset(pgpio_multi_info, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
MAX_IDX * sizeof(struct bcm_gpio_multi_info));
|
2014-02-13 12:45:41 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE))
|
2014-02-13 12:45:41 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:41 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength > sizeof(gpio_multi_info))
|
2014-02-13 12:45:41 -07:00
|
|
|
return -EINVAL;
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength > sizeof(gpio_multi_info))
|
|
|
|
io_buff.OutputLength = sizeof(gpio_multi_info);
|
2014-02-13 12:45:41 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&gpio_multi_info, io_buff.InputBuffer,
|
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:41 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsReqGpioIsLedInNVM(ad, pgpio_multi_info[WIMAX_IDX].uiGPIOMask)
|
2014-05-22 04:17:28 -06:00
|
|
|
== false) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:45:41 -07:00
|
|
|
DBG_LVL_ALL,
|
|
|
|
"Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",
|
|
|
|
pgpio_multi_info[WIMAX_IDX].uiGPIOMask,
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->gpioBitMap);
|
2014-02-13 12:45:41 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the gpio output register */
|
|
|
|
if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) &
|
|
|
|
(pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) {
|
|
|
|
/* Set 1's in GPIO OUTPUT REGISTER */
|
2014-08-27 04:57:44 -06:00
|
|
|
*(UINT *)reset_val = pgpio_multi_info[WIMAX_IDX].uiGPIOMask &
|
2014-02-13 12:45:41 -07:00
|
|
|
pgpio_multi_info[WIMAX_IDX].uiGPIOCommand &
|
|
|
|
pgpio_multi_info[WIMAX_IDX].uiGPIOValue;
|
|
|
|
|
2014-08-27 04:57:44 -06:00
|
|
|
if (*(UINT *) reset_val)
|
2014-08-27 04:57:43 -06:00
|
|
|
status = wrmaltWithLock(ad,
|
2014-03-13 02:34:19 -06:00
|
|
|
BCM_GPIO_OUTPUT_SET_REG,
|
2014-08-27 04:57:44 -06:00
|
|
|
(PUINT)reset_val, sizeof(ULONG));
|
2014-02-13 12:45:41 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status != STATUS_SUCCESS) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"WRM to BCM_GPIO_OUTPUT_SET_REG Failed.");
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear to 0's in GPIO OUTPUT REGISTER */
|
2014-08-27 04:57:44 -06:00
|
|
|
*(UINT *)reset_val =
|
2014-05-22 04:17:25 -06:00
|
|
|
(pgpio_multi_info[WIMAX_IDX].uiGPIOMask &
|
2014-03-13 02:34:19 -06:00
|
|
|
pgpio_multi_info[WIMAX_IDX].uiGPIOCommand &
|
|
|
|
(~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue)));
|
2014-02-13 12:45:41 -07:00
|
|
|
|
2014-08-27 04:57:44 -06:00
|
|
|
if (*(UINT *) reset_val)
|
2014-08-27 04:57:43 -06:00
|
|
|
status = wrmaltWithLock(ad,
|
2014-08-27 04:57:44 -06:00
|
|
|
BCM_GPIO_OUTPUT_CLR_REG, (PUINT)reset_val,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(ULONG));
|
2014-02-13 12:45:41 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status != STATUS_SUCCESS) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:41 -07:00
|
|
|
"WRM to BCM_GPIO_OUTPUT_CLR_REG Failed.");
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) {
|
2014-08-27 04:57:38 -06:00
|
|
|
bytes = rdmaltWithLock(ad, (UINT)GPIO_PIN_STATE_REGISTER,
|
2014-08-27 04:57:44 -06:00
|
|
|
(PUINT)reset_val, sizeof(UINT));
|
2014-02-13 12:45:41 -07:00
|
|
|
|
|
|
|
if (bytes < 0) {
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bytes;
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:41 -07:00
|
|
|
"RDM to GPIO_PIN_STATE_REGISTER Failed.");
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:41 -07:00
|
|
|
} else {
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2014-02-13 12:45:41 -07:00
|
|
|
}
|
|
|
|
|
2014-05-22 04:17:25 -06:00
|
|
|
pgpio_multi_info[WIMAX_IDX].uiGPIOValue =
|
2014-08-27 04:57:44 -06:00
|
|
|
(*(UINT *)reset_val &
|
2014-03-13 02:34:19 -06:00
|
|
|
pgpio_multi_info[WIMAX_IDX].uiGPIOMask);
|
2014-02-13 12:45:41 -07:00
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = copy_to_user(io_buff.OutputBuffer, &gpio_multi_info,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.OutputLength);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Failed while copying Content to IOBufer for user space err:%d",
|
2014-08-27 04:57:43 -06:00
|
|
|
status);
|
2014-02-13 12:45:41 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_gpio_mode_request(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:47 -07:00
|
|
|
{
|
|
|
|
struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX];
|
2014-03-13 02:34:19 -06:00
|
|
|
struct bcm_gpio_multi_mode *pgpio_multi_mode =
|
|
|
|
(struct bcm_gpio_multi_mode *)gpio_multi_mode;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:44 -06:00
|
|
|
UCHAR reset_val[4];
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status;
|
2014-02-13 12:45:47 -07:00
|
|
|
int bytes;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE))
|
2014-02-13 12:45:47 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:47 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength > sizeof(gpio_multi_mode))
|
2014-02-13 12:45:47 -07:00
|
|
|
return -EINVAL;
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength > sizeof(gpio_multi_mode))
|
|
|
|
io_buff.OutputLength = sizeof(gpio_multi_mode);
|
2014-02-13 12:45:47 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&gpio_multi_mode, io_buff.InputBuffer,
|
|
|
|
io_buff.InputLength))
|
2014-02-13 12:45:47 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
bytes = rdmaltWithLock(ad, (UINT)GPIO_MODE_REGISTER,
|
2014-08-27 04:57:44 -06:00
|
|
|
(PUINT)reset_val, sizeof(UINT));
|
2014-02-13 12:45:47 -07:00
|
|
|
|
|
|
|
if (bytes < 0) {
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bytes;
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Read of GPIO_MODE_REGISTER failed");
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:47 -07:00
|
|
|
} else {
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2014-02-13 12:45:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Validating the request */
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsReqGpioIsLedInNVM(ad, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask)
|
2014-05-22 04:17:28 -06:00
|
|
|
== false) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-02-13 12:45:47 -07:00
|
|
|
"Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",
|
2014-03-13 02:34:19 -06:00
|
|
|
pgpio_multi_mode[WIMAX_IDX].uiGPIOMask,
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->gpioBitMap);
|
2014-02-13 12:45:47 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) {
|
|
|
|
/* write all OUT's (1's) */
|
2014-08-27 04:57:44 -06:00
|
|
|
*(UINT *) reset_val |=
|
2014-05-22 04:17:25 -06:00
|
|
|
(pgpio_multi_mode[WIMAX_IDX].uiGPIOMode &
|
2014-02-13 12:45:47 -07:00
|
|
|
pgpio_multi_mode[WIMAX_IDX].uiGPIOMask);
|
|
|
|
|
|
|
|
/* write all IN's (0's) */
|
2014-08-27 04:57:44 -06:00
|
|
|
*(UINT *) reset_val &=
|
2014-05-22 04:17:25 -06:00
|
|
|
~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) &
|
2014-02-13 12:45:47 -07:00
|
|
|
pgpio_multi_mode[WIMAX_IDX].uiGPIOMask);
|
|
|
|
|
|
|
|
/* Currently implemented return the modes of all GPIO's
|
|
|
|
* else needs to bit AND with mask
|
|
|
|
*/
|
2014-08-27 04:57:44 -06:00
|
|
|
pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)reset_val;
|
2014-02-13 12:45:47 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = wrmaltWithLock(ad, GPIO_MODE_REGISTER,
|
2014-08-27 04:57:44 -06:00
|
|
|
(PUINT)reset_val, sizeof(ULONG));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status == STATUS_SUCCESS) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad,
|
2014-03-13 02:34:19 -06:00
|
|
|
DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"WRM to GPIO_MODE_REGISTER Done");
|
2014-02-13 12:45:47 -07:00
|
|
|
} else {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:45:47 -07:00
|
|
|
"WRM to GPIO_MODE_REGISTER Failed");
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* if uiGPIOMask is 0 then return mode register configuration */
|
2014-08-27 04:57:44 -06:00
|
|
|
pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)reset_val;
|
2014-02-13 12:45:47 -07:00
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = copy_to_user(io_buff.OutputBuffer, &gpio_multi_mode,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.OutputLength);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Failed while copying Content to IOBufer for user space err:%d",
|
2014-08-27 04:57:43 -06:00
|
|
|
status);
|
2014-02-13 12:45:47 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:47 -07:00
|
|
|
}
|
2014-02-13 12:45:31 -07:00
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_misc_request(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:52 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:45 -06:00
|
|
|
PVOID buff = NULL;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status;
|
2014-02-13 12:45:52 -07:00
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:45:52 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength < sizeof(struct bcm_link_request))
|
2014-02-13 12:45:52 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength > MAX_CNTL_PKT_SIZE)
|
2014-02-13 12:45:52 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:45 -06:00
|
|
|
buff = memdup_user(io_buff.InputBuffer,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.InputLength);
|
2014-08-27 04:57:45 -06:00
|
|
|
if (IS_ERR(buff))
|
|
|
|
return PTR_ERR(buff);
|
2014-02-13 12:45:52 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->LowPowerModeSync);
|
2014-08-27 04:57:43 -06:00
|
|
|
status = wait_event_interruptible_timeout(
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->lowpower_mode_wait_queue,
|
|
|
|
!ad->bPreparingForLowPowerMode,
|
2014-05-22 04:17:25 -06:00
|
|
|
(1 * HZ));
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status == -ERESTARTSYS)
|
2014-02-13 12:45:52 -07:00
|
|
|
goto cntrlEnd;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->bPreparingForLowPowerMode) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-02-13 12:45:52 -07:00
|
|
|
"Preparing Idle Mode is still True - Hence Rejecting control message\n");
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_FAILURE;
|
2014-02-13 12:45:52 -07:00
|
|
|
goto cntrlEnd;
|
|
|
|
}
|
2014-08-27 04:57:45 -06:00
|
|
|
status = CopyBufferToControlPacket(ad, (PVOID)buff);
|
2014-02-13 12:45:52 -07:00
|
|
|
|
|
|
|
cntrlEnd:
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->LowPowerModeSync);
|
2014-08-27 04:57:45 -06:00
|
|
|
kfree(buff);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:52 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_buffer_download_start(
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:45:57 -07:00
|
|
|
{
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status;
|
2014-02-13 12:45:57 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (down_trylock(&ad->NVMRdmWrmLock)) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-02-13 12:45:57 -07:00
|
|
|
"IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n");
|
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Starting the firmware download PID =0x%x!!!!\n",
|
|
|
|
current->pid);
|
2014-02-13 12:45:57 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (down_trylock(&ad->fw_download_sema))
|
2014-02-13 12:45:57 -07:00
|
|
|
return -EBUSY;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bBinDownloaded = false;
|
|
|
|
ad->fw_download_process_pid = current->pid;
|
|
|
|
ad->bCfgDownloaded = false;
|
|
|
|
ad->fw_download_done = false;
|
|
|
|
netif_carrier_off(ad->dev);
|
|
|
|
netif_stop_queue(ad->dev);
|
2014-08-27 04:57:43 -06:00
|
|
|
status = reset_card_proc(ad);
|
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
pr_err(PFX "%s: reset_card_proc Failed!\n", ad->dev->name);
|
|
|
|
up(&ad->fw_download_sema);
|
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:57 -07:00
|
|
|
}
|
|
|
|
mdelay(10);
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:45:57 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_buffer_download(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:02 -07:00
|
|
|
{
|
2014-08-27 04:57:47 -06:00
|
|
|
struct bcm_firmware_info *fw_info = NULL;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status;
|
2014-02-13 12:46:02 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Starting the firmware download PID =0x%x!!!!\n", current->pid);
|
2014-02-13 12:46:02 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (!down_trylock(&ad->fw_download_sema)) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:46:02 -07:00
|
|
|
"Invalid way to download buffer. Use Start and then call this!!!\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
2014-02-13 12:46:02 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) {
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
2014-02-13 12:46:02 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:40 -06:00
|
|
|
"Length for FW DLD is : %lx\n", io_buff.InputLength);
|
2014-02-13 12:46:02 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength > sizeof(struct bcm_firmware_info)) {
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
2014-02-13 12:46:02 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:47 -06:00
|
|
|
fw_info = kmalloc(sizeof(*fw_info), GFP_KERNEL);
|
|
|
|
if (!fw_info) {
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
2014-02-13 12:46:02 -07:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:47 -06:00
|
|
|
if (copy_from_user(fw_info, io_buff.InputBuffer,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.InputLength)) {
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
2014-08-27 04:57:47 -06:00
|
|
|
kfree(fw_info);
|
2014-02-13 12:46:02 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:47 -06:00
|
|
|
if (!fw_info->pvMappedFirmwareAddress ||
|
|
|
|
(fw_info->u32FirmwareLength == 0)) {
|
2014-02-13 12:46:02 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Something else is wrong %lu\n",
|
2014-08-27 04:57:47 -06:00
|
|
|
fw_info->u32FirmwareLength);
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
2014-08-27 04:57:47 -06:00
|
|
|
kfree(fw_info);
|
2014-08-27 04:57:43 -06:00
|
|
|
status = -EINVAL;
|
|
|
|
return status;
|
2014-02-13 12:46:02 -07:00
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:47 -06:00
|
|
|
status = bcm_ioctl_fw_download(ad, fw_info);
|
2014-02-13 12:46:02 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status != STATUS_SUCCESS) {
|
2014-08-27 04:57:47 -06:00
|
|
|
if (fw_info->u32StartingAddress == CONFIG_BEGIN_ADDR)
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"IOCTL: Configuration File Upload Failed\n");
|
2014-02-13 12:46:02 -07:00
|
|
|
else
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"IOCTL: Firmware File Upload Failed\n");
|
2014-02-13 12:46:02 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
/* up(&ad->fw_download_sema); */
|
2014-02-13 12:46:02 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->LEDInfo.led_thread_running &
|
2014-03-13 02:34:19 -06:00
|
|
|
BCM_LED_THREAD_RUNNING_ACTIVELY) {
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->DriverState = DRIVER_INIT;
|
|
|
|
ad->LEDInfo.bLedInitDone = false;
|
|
|
|
wake_up(&ad->LEDInfo.notify_led_event);
|
2014-02-13 12:46:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status != STATUS_SUCCESS)
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
2014-02-13 12:46:02 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"IOCTL: Firmware File Uploaded\n");
|
2014-08-27 04:57:47 -06:00
|
|
|
kfree(fw_info);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:46:02 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_buffer_download_stop(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:07 -07:00
|
|
|
{
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status;
|
2014-02-13 12:46:07 -07:00
|
|
|
int timeout = 0;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (!down_trylock(&ad->fw_download_sema)) {
|
|
|
|
up(&ad->fw_download_sema);
|
2014-02-13 12:46:07 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (down_trylock(&ad->NVMRdmWrmLock)) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-02-13 12:46:07 -07:00
|
|
|
"FW download blocked as EEPROM Read/Write is in progress\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
2014-02-13 12:46:07 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bBinDownloaded = TRUE;
|
|
|
|
ad->bCfgDownloaded = TRUE;
|
|
|
|
atomic_set(&ad->CurrNumFreeTxDesc, 0);
|
|
|
|
ad->CurrNumRecvDescs = 0;
|
|
|
|
ad->downloadDDR = 0;
|
2014-02-13 12:46:07 -07:00
|
|
|
|
|
|
|
/* setting the Mips to Run */
|
2014-08-27 04:57:43 -06:00
|
|
|
status = run_card_proc(ad);
|
2014-02-13 12:46:07 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Firm Download Failed\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:46:07 -07:00
|
|
|
} else {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-02-13 12:46:07 -07:00
|
|
|
DBG_LVL_ALL, "Firm Download Over...\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
mdelay(10);
|
|
|
|
|
|
|
|
/* Wait for MailBox Interrupt */
|
2014-08-27 04:57:38 -06:00
|
|
|
if (StartInterruptUrb((struct bcm_interface_adapter *)ad->pvInterfaceAdapter))
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Unable to send interrupt...\n");
|
2014-02-13 12:46:07 -07:00
|
|
|
|
|
|
|
timeout = 5*HZ;
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->waiting_to_fw_download_done = false;
|
|
|
|
wait_event_timeout(ad->ioctl_fw_dnld_wait_queue,
|
|
|
|
ad->waiting_to_fw_download_done, timeout);
|
|
|
|
ad->fw_download_process_pid = INVALID_PID;
|
|
|
|
ad->fw_download_done = TRUE;
|
|
|
|
atomic_set(&ad->CurrNumFreeTxDesc, 0);
|
|
|
|
ad->CurrNumRecvDescs = 0;
|
|
|
|
ad->PrevNumRecvDescs = 0;
|
|
|
|
atomic_set(&ad->cntrlpktCnt, 0);
|
|
|
|
ad->LinkUpStatus = 0;
|
|
|
|
ad->LinkStatus = 0;
|
|
|
|
|
|
|
|
if (ad->LEDInfo.led_thread_running &
|
2014-03-13 02:34:19 -06:00
|
|
|
BCM_LED_THREAD_RUNNING_ACTIVELY) {
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->DriverState = FW_DOWNLOAD_DONE;
|
|
|
|
wake_up(&ad->LEDInfo.notify_led_event);
|
2014-02-13 12:46:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!timeout)
|
2014-08-27 04:57:43 -06:00
|
|
|
status = -ENODEV;
|
2014-02-13 12:46:07 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->fw_download_sema);
|
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:46:07 -07:00
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
static int bcm_char_ioctl_chip_reset(struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:12 -07:00
|
|
|
{
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status;
|
2014-08-27 04:57:48 -06:00
|
|
|
INT nvm_access;
|
2014-02-13 12:46:12 -07:00
|
|
|
|
2014-08-27 04:57:48 -06:00
|
|
|
nvm_access = down_trylock(&ad->NVMRdmWrmLock);
|
|
|
|
if (nvm_access) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
" IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n");
|
2014-02-13 12:46:12 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->RxAppControlQueuelock);
|
2014-08-27 04:57:43 -06:00
|
|
|
status = reset_card_proc(ad);
|
2014-02-13 12:46:12 -07:00
|
|
|
flushAllAppQ();
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->RxAppControlQueuelock);
|
|
|
|
up(&ad->NVMRdmWrmLock);
|
|
|
|
ResetCounters(ad);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:46:12 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_qos_threshold(ULONG arg,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:17 -07:00
|
|
|
{
|
2014-08-27 04:57:49 -06:00
|
|
|
USHORT i;
|
2014-02-13 12:46:17 -07:00
|
|
|
|
2014-08-27 04:57:49 -06:00
|
|
|
for (i = 0; i < NO_OF_QUEUES; i++) {
|
|
|
|
if (get_user(ad->PackInfo[i].uiThreshold,
|
2014-02-13 12:46:17 -07:00
|
|
|
(unsigned long __user *)arg)) {
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_switch_transfer_mode(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:22 -07:00
|
|
|
{
|
2014-08-27 04:57:50 -06:00
|
|
|
UINT data = 0;
|
2014-02-13 12:46:22 -07:00
|
|
|
|
2014-08-27 04:57:50 -06:00
|
|
|
if (copy_from_user(&data, argp, sizeof(UINT)))
|
2014-02-13 12:46:22 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:50 -06:00
|
|
|
if (data) {
|
2014-02-13 12:46:22 -07:00
|
|
|
/* Allow All Packets */
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->TransferMode = ETH_PACKET_TUNNELING_MODE;
|
2014-02-13 12:46:22 -07:00
|
|
|
} else {
|
|
|
|
/* Allow IP only Packets */
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->TransferMode = IP_PACKET_ONLY_MODE;
|
2014-02-13 12:46:22 -07:00
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-02-13 12:46:27 -07:00
|
|
|
static int bcm_char_ioctl_get_driver_version(void __user *argp)
|
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:46:27 -07:00
|
|
|
ulong len;
|
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:46:27 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
len = min_t(ulong, io_buff.OutputLength, strlen(DRV_VERSION) + 1);
|
2014-02-13 12:46:27 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, DRV_VERSION, len))
|
2014-02-13 12:46:27 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_get_current_status(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:32 -07:00
|
|
|
{
|
|
|
|
struct bcm_link_state link_state;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:46:32 -07:00
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"copy_from_user failed..\n");
|
2014-02-13 12:46:32 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength != sizeof(link_state))
|
2014-02-13 12:46:32 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
memset(&link_state, 0, sizeof(link_state));
|
2014-08-27 04:57:38 -06:00
|
|
|
link_state.bIdleMode = ad->IdleMode;
|
|
|
|
link_state.bShutdownMode = ad->bShutStatus;
|
|
|
|
link_state.ucLinkStatus = ad->LinkStatus;
|
2014-02-13 12:46:32 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, &link_state, min_t(size_t,
|
|
|
|
sizeof(link_state), io_buff.OutputLength))) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Copy_to_user Failed..\n");
|
2014-02-13 12:46:32 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-02-13 12:45:52 -07:00
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_set_mac_tracing(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:37 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:46:37 -07:00
|
|
|
UINT tracing_flag;
|
|
|
|
|
|
|
|
/* copy ioctl Buffer structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:46:37 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&tracing_flag, io_buff.InputBuffer, sizeof(UINT)))
|
2014-02-13 12:46:37 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (tracing_flag)
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->pTarangs->MacTracingEnabled = TRUE;
|
2014-02-13 12:46:37 -07:00
|
|
|
else
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->pTarangs->MacTracingEnabled = false;
|
2014-02-13 12:46:37 -07:00
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_get_dsx_indication(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:42 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:46 -06:00
|
|
|
ULONG sf_id = 0;
|
2014-02-13 12:46:42 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:46:42 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength < sizeof(struct bcm_add_indication_alt)) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Mismatch req: %lx needed is =0x%zx!!!",
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.OutputLength,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_add_indication_alt));
|
2014-02-13 12:46:42 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:46 -06:00
|
|
|
if (copy_from_user(&sf_id, io_buff.InputBuffer, sizeof(sf_id)))
|
2014-02-13 12:46:42 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:57:46 -06:00
|
|
|
"Get DSX Data SF ID is =%lx\n", sf_id);
|
|
|
|
get_dsx_sf_data_to_application(ad, sf_id, io_buff.OutputBuffer);
|
2014-02-13 12:46:42 -07:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_get_host_mibs(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad,
|
2014-08-27 04:58:14 -06:00
|
|
|
struct bcm_tarang_data *tarang)
|
2014-02-13 12:46:47 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-02-13 12:46:47 -07:00
|
|
|
PVOID temp_buff;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:46:47 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength != sizeof(struct bcm_host_stats_mibs)) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:40 -06:00
|
|
|
"Length Check failed %lu %zd\n", io_buff.OutputLength,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_host_stats_mibs));
|
2014-02-13 12:46:47 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: HOST_STATS are too big for kmalloc (122048)! */
|
|
|
|
temp_buff = kzalloc(sizeof(struct bcm_host_stats_mibs), GFP_KERNEL);
|
|
|
|
if (!temp_buff)
|
|
|
|
return STATUS_FAILURE;
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = ProcessGetHostMibs(ad, temp_buff);
|
2014-08-27 04:58:14 -06:00
|
|
|
GetDroppedAppCntrlPktMibs(temp_buff, tarang);
|
2014-02-13 12:46:47 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status != STATUS_FAILURE) {
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, temp_buff,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_host_stats_mibs))) {
|
2014-02-13 12:46:47 -07:00
|
|
|
kfree(temp_buff);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(temp_buff);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:46:47 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_bulk_wrm(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad, UINT cmd)
|
2014-02-13 12:46:52 -07:00
|
|
|
{
|
2014-08-27 04:57:51 -06:00
|
|
|
struct bcm_bulk_wrm_buffer *bulk_buff;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:52 -06:00
|
|
|
UINT tmp = 0;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-08-27 04:57:45 -06:00
|
|
|
PCHAR buff = NULL;
|
2014-02-13 12:46:52 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:46:52 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Device in Idle/Shutdown Mode, Blocking Wrms\n");
|
2014-02-13 12:46:52 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:46:52 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength < sizeof(ULONG) * 2)
|
2014-02-13 12:46:52 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:45 -06:00
|
|
|
buff = memdup_user(io_buff.InputBuffer,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.InputLength);
|
2014-08-27 04:57:45 -06:00
|
|
|
if (IS_ERR(buff))
|
|
|
|
return PTR_ERR(buff);
|
2014-02-13 12:46:52 -07:00
|
|
|
|
2014-08-27 04:57:51 -06:00
|
|
|
bulk_buff = (struct bcm_bulk_wrm_buffer *)buff;
|
2014-02-13 12:46:52 -07:00
|
|
|
|
2014-08-27 04:57:51 -06:00
|
|
|
if (((ULONG)bulk_buff->Register & 0x0F000000) != 0x0F000000 ||
|
|
|
|
((ULONG)bulk_buff->Register & 0x3)) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"WRM Done On invalid Address : %x Access Denied.\n",
|
2014-08-27 04:57:51 -06:00
|
|
|
(int)bulk_buff->Register);
|
2014-08-27 04:57:45 -06:00
|
|
|
kfree(buff);
|
2014-02-13 12:46:52 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:52 -06:00
|
|
|
tmp = bulk_buff->Register & EEPROM_REJECT_MASK;
|
2014-08-27 04:57:38 -06:00
|
|
|
if (!((ad->pstargetparams->m_u32Customize)&VSG_MODE) &&
|
2014-08-27 04:57:52 -06:00
|
|
|
((tmp == EEPROM_REJECT_REG_1) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_2) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_3) ||
|
|
|
|
(tmp == EEPROM_REJECT_REG_4)) &&
|
2014-02-13 12:46:52 -07:00
|
|
|
(cmd == IOCTL_BCM_REGISTER_WRITE)) {
|
|
|
|
|
2014-08-27 04:57:45 -06:00
|
|
|
kfree(buff);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"EEPROM Access Denied, not in VSG Mode\n");
|
2014-02-13 12:46:52 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:51 -06:00
|
|
|
if (bulk_buff->SwapEndian == false)
|
|
|
|
status = wrmWithLock(ad, (UINT)bulk_buff->Register,
|
|
|
|
(PCHAR)bulk_buff->Values,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.InputLength - 2*sizeof(ULONG));
|
2014-02-13 12:46:52 -07:00
|
|
|
else
|
2014-08-27 04:57:51 -06:00
|
|
|
status = wrmaltWithLock(ad, (UINT)bulk_buff->Register,
|
|
|
|
(PUINT)bulk_buff->Values,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.InputLength - 2*sizeof(ULONG));
|
2014-02-13 12:46:52 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status != STATUS_SUCCESS)
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n");
|
2014-02-13 12:46:52 -07:00
|
|
|
|
2014-08-27 04:57:45 -06:00
|
|
|
kfree(buff);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:46:52 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_get_nvm_size(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:46:57 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:46:57 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:46:57 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->eNVMType == NVM_EEPROM || ad->eNVMType == NVM_FLASH) {
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, &ad->uiNVMDSDSize,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(UINT)))
|
2014-02-13 12:46:57 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2014-02-13 12:46:37 -07:00
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_cal_init(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:02 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:53 -06:00
|
|
|
UINT sector_size = 0;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-02-13 12:47:02 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->eNVMType == NVM_FLASH) {
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:47:02 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:53 -06:00
|
|
|
if (copy_from_user(§or_size, io_buff.InputBuffer,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(UINT)))
|
2014-02-13 12:47:02 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:53 -06:00
|
|
|
if ((sector_size < MIN_SECTOR_SIZE) ||
|
|
|
|
(sector_size > MAX_SECTOR_SIZE)) {
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer,
|
2014-08-27 04:57:38 -06:00
|
|
|
&ad->uiSectorSize, sizeof(UINT)))
|
2014-02-13 12:47:02 -07:00
|
|
|
return -EFAULT;
|
|
|
|
} else {
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsFlash2x(ad)) {
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer,
|
2014-08-27 04:57:38 -06:00
|
|
|
&ad->uiSectorSize, sizeof(UINT)))
|
2014-02-13 12:47:02 -07:00
|
|
|
return -EFAULT;
|
|
|
|
} else {
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((TRUE == ad->bShutStatus) ||
|
|
|
|
(TRUE == ad->IdleMode)) {
|
|
|
|
BCM_DEBUG_PRINT(ad,
|
2014-03-13 02:34:19 -06:00
|
|
|
DBG_TYPE_PRINTK, 0, 0,
|
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-02-13 12:47:02 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:53 -06:00
|
|
|
ad->uiSectorSize = sector_size;
|
2014-08-27 04:57:38 -06:00
|
|
|
BcmUpdateSectorSize(ad,
|
|
|
|
ad->uiSectorSize);
|
2014-02-13 12:47:02 -07:00
|
|
|
}
|
|
|
|
}
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2014-02-13 12:47:02 -07:00
|
|
|
} else {
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_FAILURE;
|
2014-02-13 12:47:02 -07:00
|
|
|
}
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:02 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_set_debug(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:08 -07:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:54 -06:00
|
|
|
struct bcm_user_debug_state user_debug_state;
|
2014-02-13 12:47:08 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"In SET_DEBUG ioctl\n");
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:47:08 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:54 -06:00
|
|
|
if (copy_from_user(&user_debug_state, io_buff.InputBuffer,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_user_debug_state)))
|
2014-02-13 12:47:08 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ",
|
2014-08-27 04:57:54 -06:00
|
|
|
user_debug_state.OnOff, user_debug_state.Type);
|
|
|
|
/* user_debug_state.Subtype <<= 1; */
|
|
|
|
user_debug_state.Subtype = 1 << user_debug_state.Subtype;
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:54 -06:00
|
|
|
"actual Subtype=0x%x\n", user_debug_state.Subtype);
|
2014-02-13 12:47:08 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
/* Update new 'DebugState' in the ad */
|
2014-08-27 04:57:54 -06:00
|
|
|
ad->stDebugState.type |= user_debug_state.Type;
|
2014-02-13 12:47:08 -07:00
|
|
|
/* Subtype: A bitmap of 32 bits for Subtype per Type.
|
|
|
|
* Valid indexes in 'subtype' array: 1,2,4,8
|
|
|
|
* corresponding to valid Type values. Hence we can use the 'Type' field
|
|
|
|
* as the index value, ignoring the array entries 0,3,5,6,7 !
|
|
|
|
*/
|
2014-08-27 04:57:54 -06:00
|
|
|
if (user_debug_state.OnOff)
|
|
|
|
ad->stDebugState.subtype[user_debug_state.Type] |=
|
|
|
|
user_debug_state.Subtype;
|
2014-02-13 12:47:08 -07:00
|
|
|
else
|
2014-08-27 04:57:54 -06:00
|
|
|
ad->stDebugState.subtype[user_debug_state.Type] &=
|
|
|
|
~user_debug_state.Subtype;
|
2014-02-13 12:47:08 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_SHOW_DEBUG_BITMAP(ad);
|
2014-02-13 12:47:08 -07:00
|
|
|
#endif
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_nvm_rw(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad, UINT cmd)
|
2014-02-13 12:47:13 -07:00
|
|
|
{
|
2014-08-27 04:57:55 -06:00
|
|
|
struct bcm_nvm_readwrite nvm_rw;
|
2014-02-13 12:47:13 -07:00
|
|
|
struct timeval tv0, tv1;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:56 -06:00
|
|
|
PUCHAR read_data = NULL;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-02-13 12:47:13 -07:00
|
|
|
|
|
|
|
memset(&tv0, 0, sizeof(struct timeval));
|
|
|
|
memset(&tv1, 0, sizeof(struct timeval));
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->eNVMType == NVM_FLASH) &&
|
|
|
|
(ad->uiFlashLayoutMajorVersion == 0)) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n");
|
2014-02-13 12:47:13 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsFlash2x(ad)) {
|
|
|
|
if ((ad->eActiveDSD != DSD0) &&
|
|
|
|
(ad->eActiveDSD != DSD1) &&
|
|
|
|
(ad->eActiveDSD != DSD2)) {
|
2014-02-13 12:47:13 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"No DSD is active..hence NVM Command is blocked");
|
2014-02-13 12:47:13 -07:00
|
|
|
return STATUS_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:47:13 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:55 -06:00
|
|
|
if (copy_from_user(&nvm_rw,
|
2014-03-13 02:34:19 -06:00
|
|
|
(IOCTL_BCM_NVM_READ == cmd) ?
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.OutputBuffer : io_buff.InputBuffer,
|
2014-02-13 12:47:13 -07:00
|
|
|
sizeof(struct bcm_nvm_readwrite)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Deny the access if the offset crosses the cal area limit.
|
|
|
|
*/
|
2014-08-27 04:57:55 -06:00
|
|
|
if (nvm_rw.uiNumBytes > ad->uiNVMDSDSize)
|
2014-02-13 12:47:13 -07:00
|
|
|
return STATUS_FAILURE;
|
|
|
|
|
2014-08-27 04:57:55 -06:00
|
|
|
if (nvm_rw.uiOffset >
|
|
|
|
ad->uiNVMDSDSize - nvm_rw.uiNumBytes)
|
2014-02-13 12:47:13 -07:00
|
|
|
return STATUS_FAILURE;
|
|
|
|
|
2014-08-27 04:57:56 -06:00
|
|
|
read_data = memdup_user(nvm_rw.pBuffer,
|
2014-08-27 04:57:55 -06:00
|
|
|
nvm_rw.uiNumBytes);
|
2014-08-27 04:57:56 -06:00
|
|
|
if (IS_ERR(read_data))
|
|
|
|
return PTR_ERR(read_data);
|
2014-02-13 12:47:13 -07:00
|
|
|
|
|
|
|
do_gettimeofday(&tv0);
|
|
|
|
if (IOCTL_BCM_NVM_READ == cmd) {
|
2014-08-27 04:57:56 -06:00
|
|
|
int ret = bcm_handle_nvm_read_cmd(ad, read_data,
|
2014-08-27 04:57:55 -06:00
|
|
|
&nvm_rw);
|
2014-05-22 04:17:26 -06:00
|
|
|
if (ret != STATUS_SUCCESS)
|
|
|
|
return ret;
|
2014-02-13 12:47:13 -07:00
|
|
|
} else {
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:13 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:47:13 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad,
|
2014-03-13 02:34:19 -06:00
|
|
|
DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:56 -06:00
|
|
|
kfree(read_data);
|
2014-02-13 12:47:13 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bHeaderChangeAllowed = TRUE;
|
|
|
|
if (IsFlash2x(ad)) {
|
|
|
|
int ret = handle_flash2x_adapter(ad,
|
2014-08-27 04:57:56 -06:00
|
|
|
read_data,
|
2014-08-27 04:57:55 -06:00
|
|
|
&nvm_rw);
|
2014-05-22 04:17:27 -06:00
|
|
|
if (ret != STATUS_SUCCESS)
|
|
|
|
return ret;
|
2014-02-13 12:47:13 -07:00
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:56 -06:00
|
|
|
status = BeceemNVMWrite(ad, (PUINT)read_data,
|
2014-08-27 04:57:55 -06:00
|
|
|
nvm_rw.uiOffset, nvm_rw.uiNumBytes,
|
|
|
|
nvm_rw.bVerify);
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsFlash2x(ad))
|
|
|
|
BcmFlash2xWriteSig(ad, ad->eActiveDSD);
|
2014-02-13 12:47:13 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bHeaderChangeAllowed = false;
|
2014-02-13 12:47:13 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:13 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status != STATUS_SUCCESS) {
|
2014-08-27 04:57:56 -06:00
|
|
|
kfree(read_data);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:13 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
do_gettimeofday(&tv1);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
" timetaken by Write/read :%ld msec\n",
|
2014-05-22 04:17:25 -06:00
|
|
|
(tv1.tv_sec - tv0.tv_sec)*1000 +
|
|
|
|
(tv1.tv_usec - tv0.tv_usec)/1000);
|
2014-02-13 12:47:13 -07:00
|
|
|
|
2014-08-27 04:57:56 -06:00
|
|
|
kfree(read_data);
|
2014-02-13 12:47:13 -07:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_flash2x_section_read(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:18 -07:00
|
|
|
{
|
2014-08-27 04:57:57 -06:00
|
|
|
struct bcm_flash2x_readwrite flash_2x_read = {0};
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:58 -06:00
|
|
|
PUCHAR read_buff = NULL;
|
2014-08-27 04:58:15 -06:00
|
|
|
UINT nob = 0;
|
2014-08-27 04:57:59 -06:00
|
|
|
UINT buff_size = 0;
|
2014-08-27 04:58:00 -06:00
|
|
|
UINT read_bytes = 0;
|
2014-08-27 04:58:10 -06:00
|
|
|
UINT read_offset = 0;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-02-13 12:47:18 -07:00
|
|
|
void __user *OutPutBuff;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsFlash2x(ad) != TRUE) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Flash Does not have 2.x map");
|
2014-02-13 12:47:18 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-03-13 02:34:19 -06:00
|
|
|
DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called");
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:47:18 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
/* Reading FLASH 2.x READ structure */
|
2014-08-27 04:57:57 -06:00
|
|
|
if (copy_from_user(&flash_2x_read, io_buff.InputBuffer,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_flash2x_readwrite)))
|
2014-02-13 12:47:18 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:57:57 -06:00
|
|
|
"\nflash_2x_read.Section :%x",
|
|
|
|
flash_2x_read.Section);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:57:57 -06:00
|
|
|
"\nflash_2x_read.offset :%x",
|
|
|
|
flash_2x_read.offset);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:57:57 -06:00
|
|
|
"\nflash_2x_read.numOfBytes :%x",
|
|
|
|
flash_2x_read.numOfBytes);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:57:57 -06:00
|
|
|
"\nflash_2x_read.bVerify :%x\n",
|
|
|
|
flash_2x_read.bVerify);
|
2014-02-13 12:47:18 -07:00
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
/* This was internal to driver for raw read.
|
|
|
|
* now it has ben exposed to user space app.
|
|
|
|
*/
|
2014-08-27 04:57:57 -06:00
|
|
|
if (validateFlash2xReadWrite(ad, &flash_2x_read) == false)
|
2014-02-13 12:47:18 -07:00
|
|
|
return STATUS_FAILURE;
|
|
|
|
|
2014-08-27 04:58:15 -06:00
|
|
|
nob = flash_2x_read.numOfBytes;
|
|
|
|
if (nob > ad->uiSectorSize)
|
2014-08-27 04:57:59 -06:00
|
|
|
buff_size = ad->uiSectorSize;
|
2014-02-13 12:47:18 -07:00
|
|
|
else
|
2014-08-27 04:58:15 -06:00
|
|
|
buff_size = nob;
|
2014-02-13 12:47:18 -07:00
|
|
|
|
2014-08-27 04:58:10 -06:00
|
|
|
read_offset = flash_2x_read.offset;
|
2014-08-27 04:57:40 -06:00
|
|
|
OutPutBuff = io_buff.OutputBuffer;
|
2014-08-27 04:57:59 -06:00
|
|
|
read_buff = kzalloc(buff_size , GFP_KERNEL);
|
2014-02-13 12:47:18 -07:00
|
|
|
|
2014-08-27 04:57:58 -06:00
|
|
|
if (read_buff == NULL) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Memory allocation failed for Flash 2.x Read Structure");
|
2014-02-13 12:47:18 -07:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:18 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:47:18 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-05-22 04:17:28 -06:00
|
|
|
DBG_LVL_ALL,
|
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:58 -06:00
|
|
|
kfree(read_buff);
|
2014-02-13 12:47:18 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:15 -06:00
|
|
|
while (nob) {
|
|
|
|
if (nob > ad->uiSectorSize)
|
2014-08-27 04:58:00 -06:00
|
|
|
read_bytes = ad->uiSectorSize;
|
2014-02-13 12:47:18 -07:00
|
|
|
else
|
2014-08-27 04:58:15 -06:00
|
|
|
read_bytes = nob;
|
2014-02-13 12:47:18 -07:00
|
|
|
|
|
|
|
/* Reading the data from Flash 2.x */
|
2014-08-27 04:57:58 -06:00
|
|
|
status = BcmFlash2xBulkRead(ad, (PUINT)read_buff,
|
2014-08-27 04:58:10 -06:00
|
|
|
flash_2x_read.Section, read_offset, read_bytes);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad,
|
2014-03-13 02:34:19 -06:00
|
|
|
DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:57:43 -06:00
|
|
|
"Flash 2x read err with status :%d",
|
|
|
|
status);
|
2014-02-13 12:47:18 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-08-27 04:58:00 -06:00
|
|
|
DBG_LVL_ALL, read_buff, read_bytes);
|
2014-02-13 12:47:18 -07:00
|
|
|
|
2014-08-27 04:58:00 -06:00
|
|
|
status = copy_to_user(OutPutBuff, read_buff, read_bytes);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad,
|
2014-03-13 02:34:19 -06:00
|
|
|
DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:57:43 -06:00
|
|
|
"Copy to use failed with status :%d", status);
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:58 -06:00
|
|
|
kfree(read_buff);
|
2014-02-13 12:47:18 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-27 04:58:15 -06:00
|
|
|
nob = nob - read_bytes;
|
|
|
|
if (nob) {
|
2014-08-27 04:58:10 -06:00
|
|
|
read_offset = read_offset + read_bytes;
|
2014-08-27 04:58:00 -06:00
|
|
|
OutPutBuff = OutPutBuff + read_bytes;
|
2014-02-13 12:47:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:58 -06:00
|
|
|
kfree(read_buff);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:18 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_flash2x_section_write(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:23 -07:00
|
|
|
{
|
|
|
|
struct bcm_flash2x_readwrite sFlash2xWrite = {0};
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:58:02 -06:00
|
|
|
PUCHAR write_buff;
|
2014-08-27 04:58:03 -06:00
|
|
|
void __user *input_addr;
|
2014-08-27 04:58:15 -06:00
|
|
|
UINT nob = 0;
|
2014-08-27 04:57:59 -06:00
|
|
|
UINT buff_size = 0;
|
2014-08-27 04:58:04 -06:00
|
|
|
UINT write_off = 0;
|
2014-08-27 04:58:01 -06:00
|
|
|
UINT write_bytes = 0;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsFlash2x(ad) != TRUE) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Flash Does not have 2.x map");
|
2014-02-13 12:47:23 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
/* First make this False so that we can enable the Sector
|
|
|
|
* Permission Check in BeceemFlashBulkWrite
|
|
|
|
*/
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bAllDSDWriteAllow = false;
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"IOCTL_BCM_FLASH2X_SECTION_WRITE Called");
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:47:23 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
/* Reading FLASH 2.x READ structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&sFlash2xWrite, io_buff.InputBuffer,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_flash2x_readwrite)))
|
2014-02-13 12:47:23 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-18 04:38:31 -06:00
|
|
|
"\nsFlash2xWrite.Section :%x", sFlash2xWrite.Section);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-18 04:38:31 -06:00
|
|
|
"\nsFlash2xWrite.offset :%d", sFlash2xWrite.offset);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-18 04:38:31 -06:00
|
|
|
"\nsFlash2xWrite.numOfBytes :%x", sFlash2xWrite.numOfBytes);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-18 04:38:31 -06:00
|
|
|
"\nsFlash2xWrite.bVerify :%x\n", sFlash2xWrite.bVerify);
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
if ((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1)
|
|
|
|
&& (sFlash2xWrite.Section != VSA2)) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Only VSA write is allowed");
|
2014-02-13 12:47:23 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (validateFlash2xReadWrite(ad, &sFlash2xWrite) == false)
|
2014-02-13 12:47:23 -07:00
|
|
|
return STATUS_FAILURE;
|
|
|
|
|
2014-08-27 04:58:03 -06:00
|
|
|
input_addr = sFlash2xWrite.pDataBuff;
|
2014-08-27 04:58:04 -06:00
|
|
|
write_off = sFlash2xWrite.offset;
|
2014-08-27 04:58:15 -06:00
|
|
|
nob = sFlash2xWrite.numOfBytes;
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:58:15 -06:00
|
|
|
if (nob > ad->uiSectorSize)
|
2014-08-27 04:57:59 -06:00
|
|
|
buff_size = ad->uiSectorSize;
|
2014-02-13 12:47:23 -07:00
|
|
|
else
|
2014-08-27 04:58:15 -06:00
|
|
|
buff_size = nob;
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:58:02 -06:00
|
|
|
write_buff = kmalloc(buff_size, GFP_KERNEL);
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:58:02 -06:00
|
|
|
if (write_buff == NULL)
|
2014-02-13 12:47:23 -07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* extracting the remainder of the given offset. */
|
2014-08-27 04:58:01 -06:00
|
|
|
write_bytes = ad->uiSectorSize;
|
2014-08-27 04:58:04 -06:00
|
|
|
if (write_off % ad->uiSectorSize) {
|
2014-08-27 04:58:01 -06:00
|
|
|
write_bytes = ad->uiSectorSize -
|
2014-08-27 04:58:04 -06:00
|
|
|
(write_off % ad->uiSectorSize);
|
2014-05-22 04:17:25 -06:00
|
|
|
}
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:58:15 -06:00
|
|
|
if (nob < write_bytes)
|
|
|
|
write_bytes = nob;
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:58:02 -06:00
|
|
|
kfree(write_buff);
|
2014-02-13 12:47:23 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BcmFlash2xCorruptSig(ad, sFlash2xWrite.Section);
|
2014-02-13 12:47:23 -07:00
|
|
|
do {
|
2014-08-27 04:58:03 -06:00
|
|
|
status = copy_from_user(write_buff, input_addr, write_bytes);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:43 -06:00
|
|
|
"Copy to user failed with status :%d", status);
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:58:02 -06:00
|
|
|
kfree(write_buff);
|
2014-02-13 12:47:23 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS,
|
2014-08-27 04:58:02 -06:00
|
|
|
OSAL_DBG, DBG_LVL_ALL, write_buff, write_bytes);
|
2014-02-13 12:47:23 -07:00
|
|
|
|
|
|
|
/* Writing the data from Flash 2.x */
|
2014-08-27 04:58:02 -06:00
|
|
|
status = BcmFlash2xBulkWrite(ad, (PUINT)write_buff,
|
2014-05-22 04:17:28 -06:00
|
|
|
sFlash2xWrite.Section,
|
2014-08-27 04:58:04 -06:00
|
|
|
write_off,
|
2014-08-27 04:58:01 -06:00
|
|
|
write_bytes,
|
2014-05-22 04:17:28 -06:00
|
|
|
sFlash2xWrite.bVerify);
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:43 -06:00
|
|
|
"Flash 2x read err with status :%d", status);
|
2014-02-13 12:47:23 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:15 -06:00
|
|
|
nob = nob - write_bytes;
|
|
|
|
if (nob) {
|
2014-08-27 04:58:04 -06:00
|
|
|
write_off = write_off + write_bytes;
|
2014-08-27 04:58:03 -06:00
|
|
|
input_addr = input_addr + write_bytes;
|
2014-08-27 04:58:15 -06:00
|
|
|
if (nob > ad->uiSectorSize)
|
2014-08-27 04:58:01 -06:00
|
|
|
write_bytes = ad->uiSectorSize;
|
2014-02-13 12:47:23 -07:00
|
|
|
else
|
2014-08-27 04:58:15 -06:00
|
|
|
write_bytes = nob;
|
2014-02-13 12:47:23 -07:00
|
|
|
}
|
2014-08-27 04:58:15 -06:00
|
|
|
} while (nob > 0);
|
2014-02-13 12:47:23 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BcmFlash2xWriteSig(ad, sFlash2xWrite.Section);
|
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:58:02 -06:00
|
|
|
kfree(write_buff);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:23 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_flash2x_section_bitmap(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:28 -07:00
|
|
|
{
|
2014-08-27 04:58:05 -06:00
|
|
|
struct bcm_flash2x_bitmap *flash_2x_bit_map;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:47:28 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called");
|
2014-02-13 12:47:28 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:47:28 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength != sizeof(struct bcm_flash2x_bitmap))
|
2014-02-13 12:47:28 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:58:05 -06:00
|
|
|
flash_2x_bit_map = kzalloc(sizeof(struct bcm_flash2x_bitmap),
|
2014-05-22 04:17:25 -06:00
|
|
|
GFP_KERNEL);
|
|
|
|
|
2014-08-27 04:58:05 -06:00
|
|
|
if (flash_2x_bit_map == NULL) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Memory is not available");
|
2014-02-13 12:47:28 -07:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reading the Flash Sectio Bit map */
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:28 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:47:28 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:58:05 -06:00
|
|
|
kfree(flash_2x_bit_map);
|
2014-02-13 12:47:28 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:05 -06:00
|
|
|
BcmGetFlash2xSectionalBitMap(ad, flash_2x_bit_map);
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:58:05 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, flash_2x_bit_map,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_flash2x_bitmap))) {
|
2014-08-27 04:58:05 -06:00
|
|
|
kfree(flash_2x_bit_map);
|
2014-02-13 12:47:28 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:05 -06:00
|
|
|
kfree(flash_2x_bit_map);
|
2014-05-26 08:08:50 -06:00
|
|
|
return STATUS_FAILURE;
|
2014-02-13 12:47:28 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_set_active_section(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:33 -07:00
|
|
|
{
|
2014-08-27 04:58:06 -06:00
|
|
|
enum bcm_flash2x_section_val flash_2x_section_val = 0;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:47:33 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"IOCTL_BCM_SET_ACTIVE_SECTION Called");
|
2014-02-13 12:47:33 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsFlash2x(ad) != TRUE) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Flash Does not have 2.x map");
|
2014-02-13 12:47:33 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = copy_from_user(&io_buff, argp,
|
2014-05-22 04:17:28 -06:00
|
|
|
sizeof(struct bcm_ioctl_buffer));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Copy of IOCTL BUFFER failed");
|
2014-02-13 12:47:33 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:06 -06:00
|
|
|
status = copy_from_user(&flash_2x_section_val,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.InputBuffer, sizeof(INT));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-03-13 02:34:19 -06:00
|
|
|
"Copy of flash section val failed");
|
2014-02-13 12:47:33 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:33 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:47:33 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:33 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:06 -06:00
|
|
|
status = BcmSetActiveSection(ad, flash_2x_section_val);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status)
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:43 -06:00
|
|
|
"Failed to make it's priority Highest. status %d",
|
|
|
|
status);
|
2014-02-13 12:47:33 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:33 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:33 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_copy_section(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:43 -07:00
|
|
|
{
|
2014-08-27 04:58:07 -06:00
|
|
|
struct bcm_flash2x_copy_section copy_sect_strut = {0};
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_SUCCESS;
|
2014-02-13 12:47:43 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"IOCTL_BCM_COPY_SECTION Called");
|
2014-02-13 12:47:43 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bAllDSDWriteAllow = false;
|
|
|
|
if (IsFlash2x(ad) != TRUE) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Flash Does not have 2.x map");
|
2014-02-13 12:47:43 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = copy_from_user(&io_buff, argp,
|
2014-05-22 04:17:28 -06:00
|
|
|
sizeof(struct bcm_ioctl_buffer));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:43 -06:00
|
|
|
"Copy of IOCTL BUFFER failed status :%d",
|
|
|
|
status);
|
2014-02-13 12:47:43 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:07 -06:00
|
|
|
status = copy_from_user(©_sect_strut, io_buff.InputBuffer,
|
2014-05-22 04:17:28 -06:00
|
|
|
sizeof(struct bcm_flash2x_copy_section));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:43 -06:00
|
|
|
"Copy of Copy_Section_Struct failed with status :%d",
|
|
|
|
status);
|
2014-02-13 12:47:43 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:58:07 -06:00
|
|
|
"Source SEction :%x", copy_sect_strut.SrcSection);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:58:07 -06:00
|
|
|
"Destination SEction :%x", copy_sect_strut.DstSection);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:58:07 -06:00
|
|
|
"offset :%x", copy_sect_strut.offset);
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:58:15 -06:00
|
|
|
"nob :%x", copy_sect_strut.numOfBytes);
|
2014-02-13 12:47:43 -07:00
|
|
|
|
2014-08-27 04:58:07 -06:00
|
|
|
if (IsSectionExistInFlash(ad, copy_sect_strut.SrcSection) == false) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Source Section<%x> does not exist in Flash ",
|
2014-08-27 04:58:07 -06:00
|
|
|
copy_sect_strut.SrcSection);
|
2014-02-13 12:47:43 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:07 -06:00
|
|
|
if (IsSectionExistInFlash(ad, copy_sect_strut.DstSection) == false) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Destinatio Section<%x> does not exist in Flash ",
|
2014-08-27 04:58:07 -06:00
|
|
|
copy_sect_strut.DstSection);
|
2014-02-13 12:47:43 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:07 -06:00
|
|
|
if (copy_sect_strut.SrcSection == copy_sect_strut.DstSection) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Source and Destination section should be different");
|
2014-02-13 12:47:43 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:43 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:47:43 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:43 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:07 -06:00
|
|
|
if (copy_sect_strut.SrcSection == ISO_IMAGE1 ||
|
|
|
|
copy_sect_strut.SrcSection == ISO_IMAGE2) {
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsNonCDLessDevice(ad)) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Device is Non-CDLess hence won't have ISO !!");
|
2014-08-27 04:57:43 -06:00
|
|
|
status = -EINVAL;
|
2014-08-27 04:58:07 -06:00
|
|
|
} else if (copy_sect_strut.numOfBytes == 0) {
|
|
|
|
status = BcmCopyISO(ad, copy_sect_strut);
|
2014-02-13 12:47:43 -07:00
|
|
|
} else {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Partial Copy of ISO section is not Allowed..");
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_FAILURE;
|
2014-02-13 12:47:43 -07:00
|
|
|
}
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:43 -07:00
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:07 -06:00
|
|
|
status = BcmCopySection(ad, copy_sect_strut.SrcSection,
|
|
|
|
copy_sect_strut.DstSection,
|
|
|
|
copy_sect_strut.offset,
|
|
|
|
copy_sect_strut.numOfBytes);
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:43 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_get_flash_cs_info(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:48 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_SUCCESS;
|
2014-02-13 12:47:48 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
" IOCTL_BCM_GET_FLASH_CS_INFO Called");
|
2014-02-13 12:47:48 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = copy_from_user(&io_buff, argp,
|
2014-05-22 04:17:25 -06:00
|
|
|
sizeof(struct bcm_ioctl_buffer));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Copy of IOCTL BUFFER failed");
|
2014-02-13 12:47:48 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->eNVMType != NVM_FLASH) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Connected device does not have flash");
|
2014-02-13 12:47:48 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsFlash2x(ad) == TRUE) {
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength < sizeof(struct bcm_flash2x_cs_info))
|
2014-02-13 12:47:48 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer,
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->psFlash2xCSInfo,
|
2014-05-22 04:17:28 -06:00
|
|
|
sizeof(struct bcm_flash2x_cs_info)))
|
2014-02-13 12:47:48 -07:00
|
|
|
return -EFAULT;
|
|
|
|
} else {
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength < sizeof(struct bcm_flash_cs_info))
|
2014-02-13 12:47:48 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, ad->psFlashCSInfo,
|
2014-05-22 04:17:28 -06:00
|
|
|
sizeof(struct bcm_flash_cs_info)))
|
2014-02-13 12:47:48 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:48 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_select_dsd(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:53 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-08-27 04:58:08 -06:00
|
|
|
UINT sect_offset = 0;
|
2014-08-27 04:58:06 -06:00
|
|
|
enum bcm_flash2x_section_val flash_2x_section_val;
|
2014-02-13 12:47:53 -07:00
|
|
|
|
2014-08-27 04:58:06 -06:00
|
|
|
flash_2x_section_val = NO_SECTION_VAL;
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"IOCTL_BCM_SELECT_DSD Called");
|
2014-02-13 12:47:53 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IsFlash2x(ad) != TRUE) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Flash Does not have 2.x map");
|
2014-02-13 12:47:53 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = copy_from_user(&io_buff, argp,
|
2014-05-22 04:17:28 -06:00
|
|
|
sizeof(struct bcm_ioctl_buffer));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Copy of IOCTL BUFFER failed");
|
2014-02-13 12:47:53 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-27 04:58:06 -06:00
|
|
|
status = copy_from_user(&flash_2x_section_val, io_buff.InputBuffer,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(INT));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Copy of flash section val failed");
|
2014-02-13 12:47:53 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-08-27 04:58:06 -06:00
|
|
|
"Read Section :%d", flash_2x_section_val);
|
|
|
|
if ((flash_2x_section_val != DSD0) &&
|
|
|
|
(flash_2x_section_val != DSD1) &&
|
|
|
|
(flash_2x_section_val != DSD2)) {
|
2014-02-13 12:47:53 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Passed section<%x> is not DSD section",
|
2014-08-27 04:58:06 -06:00
|
|
|
flash_2x_section_val);
|
2014-02-13 12:47:53 -07:00
|
|
|
return STATUS_FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:08 -06:00
|
|
|
sect_offset = BcmGetSectionValStartOffset(ad, flash_2x_section_val);
|
|
|
|
if (sect_offset == INVALID_OFFSET) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Provided Section val <%d> does not exist in Flash 2.x",
|
2014-08-27 04:58:06 -06:00
|
|
|
flash_2x_section_val);
|
2014-02-13 12:47:53 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bAllDSDWriteAllow = TRUE;
|
2014-08-27 04:58:08 -06:00
|
|
|
ad->ulFlashCalStart = sect_offset;
|
2014-08-27 04:58:06 -06:00
|
|
|
ad->eActiveDSD = flash_2x_section_val;
|
2014-02-13 12:47:53 -07:00
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2014-02-13 12:47:02 -07:00
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_nvm_raw_read(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:47:59 -07:00
|
|
|
{
|
2014-08-27 04:58:09 -06:00
|
|
|
struct bcm_nvm_readwrite nvm_read;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:58:15 -06:00
|
|
|
unsigned int nob;
|
2014-08-27 04:57:59 -06:00
|
|
|
INT buff_size;
|
2014-08-27 04:58:10 -06:00
|
|
|
INT read_offset = 0;
|
2014-08-27 04:58:00 -06:00
|
|
|
UINT read_bytes = 0;
|
2014-08-27 04:57:58 -06:00
|
|
|
PUCHAR read_buff;
|
2014-02-13 12:47:59 -07:00
|
|
|
void __user *OutPutBuff;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-02-13 12:47:59 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->eNVMType != NVM_FLASH) {
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"NVM TYPE is not Flash");
|
2014-02-13 12:47:59 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"copy_from_user 1 failed\n");
|
2014-02-13 12:47:59 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:58:09 -06:00
|
|
|
if (copy_from_user(&nvm_read, io_buff.OutputBuffer,
|
2014-03-13 02:34:19 -06:00
|
|
|
sizeof(struct bcm_nvm_readwrite)))
|
2014-02-13 12:47:59 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:58:15 -06:00
|
|
|
nob = nvm_read.uiNumBytes;
|
2014-02-13 12:47:59 -07:00
|
|
|
/* In Raw-Read max Buff size : 64MB */
|
|
|
|
|
2014-08-27 04:58:15 -06:00
|
|
|
if (nob > DEFAULT_BUFF_SIZE)
|
2014-08-27 04:57:59 -06:00
|
|
|
buff_size = DEFAULT_BUFF_SIZE;
|
2014-02-13 12:47:59 -07:00
|
|
|
else
|
2014-08-27 04:58:15 -06:00
|
|
|
buff_size = nob;
|
2014-02-13 12:47:59 -07:00
|
|
|
|
2014-08-27 04:58:10 -06:00
|
|
|
read_offset = nvm_read.uiOffset;
|
2014-08-27 04:58:09 -06:00
|
|
|
OutPutBuff = nvm_read.pBuffer;
|
2014-02-13 12:47:59 -07:00
|
|
|
|
2014-08-27 04:57:59 -06:00
|
|
|
read_buff = kzalloc(buff_size , GFP_KERNEL);
|
2014-08-27 04:57:58 -06:00
|
|
|
if (read_buff == NULL) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Memory allocation failed for Flash 2.x Read Structure");
|
2014-02-13 12:47:59 -07:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2014-08-27 04:57:38 -06:00
|
|
|
down(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:59 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((ad->IdleMode == TRUE) ||
|
|
|
|
(ad->bShutStatus == TRUE) ||
|
|
|
|
(ad->bPreparingForLowPowerMode == TRUE)) {
|
2014-02-13 12:47:59 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Device is in Idle/Shutdown Mode\n");
|
2014-08-27 04:57:58 -06:00
|
|
|
kfree(read_buff);
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-02-13 12:47:59 -07:00
|
|
|
return -EACCES;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bFlashRawRead = TRUE;
|
2014-02-13 12:47:59 -07:00
|
|
|
|
2014-08-27 04:58:15 -06:00
|
|
|
while (nob) {
|
|
|
|
if (nob > DEFAULT_BUFF_SIZE)
|
2014-08-27 04:58:00 -06:00
|
|
|
read_bytes = DEFAULT_BUFF_SIZE;
|
2014-02-13 12:47:59 -07:00
|
|
|
else
|
2014-08-27 04:58:15 -06:00
|
|
|
read_bytes = nob;
|
2014-02-13 12:47:59 -07:00
|
|
|
|
|
|
|
/* Reading the data from Flash 2.x */
|
2014-08-27 04:57:58 -06:00
|
|
|
status = BeceemNVMRead(ad, (PUINT)read_buff,
|
2014-08-27 04:58:10 -06:00
|
|
|
read_offset, read_bytes);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-08-27 04:57:43 -06:00
|
|
|
"Flash 2x read err with status :%d",
|
|
|
|
status);
|
2014-02-13 12:47:59 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS, OSAL_DBG,
|
2014-08-27 04:58:00 -06:00
|
|
|
DBG_LVL_ALL, read_buff, read_bytes);
|
2014-02-13 12:47:59 -07:00
|
|
|
|
2014-08-27 04:58:00 -06:00
|
|
|
status = copy_to_user(OutPutBuff, read_buff, read_bytes);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Copy to use failed with status :%d",
|
2014-08-27 04:57:43 -06:00
|
|
|
status);
|
2014-08-27 04:57:38 -06:00
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:58 -06:00
|
|
|
kfree(read_buff);
|
2014-02-13 12:47:59 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-27 04:58:15 -06:00
|
|
|
nob = nob - read_bytes;
|
|
|
|
if (nob) {
|
2014-08-27 04:58:10 -06:00
|
|
|
read_offset = read_offset + read_bytes;
|
2014-08-27 04:58:00 -06:00
|
|
|
OutPutBuff = OutPutBuff + read_bytes;
|
2014-02-13 12:47:59 -07:00
|
|
|
}
|
|
|
|
}
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bFlashRawRead = false;
|
|
|
|
up(&ad->NVMRdmWrmLock);
|
2014-08-27 04:57:58 -06:00
|
|
|
kfree(read_buff);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:47:59 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_cntrlmsg_mask(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad,
|
2014-08-27 04:58:14 -06:00
|
|
|
struct bcm_tarang_data *tarang)
|
2014-02-13 12:48:04 -07:00
|
|
|
{
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2014-08-27 04:58:11 -06:00
|
|
|
ULONG rx_cntrl_msg_bit_mask = 0;
|
2014-02-13 12:48:04 -07:00
|
|
|
|
|
|
|
/* Copy Ioctl Buffer structure */
|
2014-08-27 04:57:43 -06:00
|
|
|
status = copy_from_user(&io_buff, argp,
|
2014-05-22 04:17:25 -06:00
|
|
|
sizeof(struct bcm_ioctl_buffer));
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"copy of Ioctl buffer is failed from user space");
|
2014-02-13 12:48:04 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.InputLength != sizeof(unsigned long))
|
2014-02-13 12:48:04 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:58:11 -06:00
|
|
|
status = copy_from_user(&rx_cntrl_msg_bit_mask, io_buff.InputBuffer,
|
2014-08-27 04:57:40 -06:00
|
|
|
io_buff.InputLength);
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status) {
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"copy of control bit mask failed from user space");
|
2014-02-13 12:48:04 -07:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"\n Got user defined cntrl msg bit mask :%lx",
|
2014-08-27 04:58:11 -06:00
|
|
|
rx_cntrl_msg_bit_mask);
|
2014-08-27 04:58:14 -06:00
|
|
|
tarang->RxCntrlMsgBitMask = rx_cntrl_msg_bit_mask;
|
2014-02-13 12:48:04 -07:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2014-02-13 12:48:04 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_get_device_driver_info(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:48:09 -07:00
|
|
|
{
|
2014-08-27 04:58:12 -06:00
|
|
|
struct bcm_driver_info dev_info;
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:48:09 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n");
|
2014-02-13 12:48:09 -07:00
|
|
|
|
2014-08-27 04:58:12 -06:00
|
|
|
memset(&dev_info, 0, sizeof(dev_info));
|
|
|
|
dev_info.MaxRDMBufferSize = BUFFER_4K;
|
|
|
|
dev_info.u32DSDStartOffset = EEPROM_CALPARAM_START;
|
|
|
|
dev_info.u32RxAlignmentCorrection = 0;
|
|
|
|
dev_info.u32NVMType = ad->eNVMType;
|
|
|
|
dev_info.u32InterfaceType = BCM_USB;
|
2014-02-13 12:48:09 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:48:09 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:58:12 -06:00
|
|
|
if (io_buff.OutputLength < sizeof(dev_info))
|
2014-02-13 12:48:09 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:58:12 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, &dev_info, sizeof(dev_info)))
|
2014-02-13 12:48:09 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:34:19 -06:00
|
|
|
static int bcm_char_ioctl_time_since_net_entry(void __user *argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
struct bcm_mini_adapter *ad)
|
2014-02-13 12:48:14 -07:00
|
|
|
{
|
2014-08-27 04:58:13 -06:00
|
|
|
struct bcm_time_elapsed time_elapsed_since_net_entry = {0};
|
2014-08-27 04:57:40 -06:00
|
|
|
struct bcm_ioctl_buffer io_buff;
|
2014-02-13 12:48:14 -07:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"IOCTL_BCM_TIME_SINCE_NET_ENTRY called");
|
2014-02-13 12:48:14 -07:00
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
|
2014-02-13 12:48:14 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:40 -06:00
|
|
|
if (io_buff.OutputLength < sizeof(struct bcm_time_elapsed))
|
2014-02-13 12:48:14 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-27 04:58:13 -06:00
|
|
|
time_elapsed_since_net_entry.ul64TimeElapsedSinceNetEntry =
|
2014-08-27 04:57:38 -06:00
|
|
|
get_seconds() - ad->liTimeSinceLastNetEntry;
|
2014-02-13 12:48:14 -07:00
|
|
|
|
2014-08-27 04:58:13 -06:00
|
|
|
if (copy_to_user(io_buff.OutputBuffer, &time_elapsed_since_net_entry,
|
2014-05-22 04:17:28 -06:00
|
|
|
sizeof(struct bcm_time_elapsed)))
|
2014-02-13 12:48:14 -07:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-02-13 12:47:59 -07:00
|
|
|
|
2010-09-30 02:24:11 -06:00
|
|
|
static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2014-08-27 04:58:14 -06:00
|
|
|
struct bcm_tarang_data *tarang = filp->private_data;
|
2010-11-01 07:26:47 -06:00
|
|
|
void __user *argp = (void __user *)arg;
|
2014-08-27 04:58:14 -06:00
|
|
|
struct bcm_mini_adapter *ad = tarang->Adapter;
|
2014-08-27 04:57:43 -06:00
|
|
|
INT status = STATUS_FAILURE;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2013-11-09 18:53:21 -07:00
|
|
|
"Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX",
|
|
|
|
cmd, arg);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
if (_IOC_TYPE(cmd) != BCM_IOCTL)
|
2010-09-08 15:46:36 -06:00
|
|
|
return -EFAULT;
|
2011-08-15 20:07:41 -06:00
|
|
|
if (_IOC_DIR(cmd) & _IOC_READ)
|
2014-08-27 04:57:43 -06:00
|
|
|
status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd));
|
2010-09-08 15:46:36 -06:00
|
|
|
else if (_IOC_DIR(cmd) & _IOC_WRITE)
|
2014-08-27 04:57:43 -06:00
|
|
|
status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd));
|
2010-09-08 15:46:36 -06:00
|
|
|
else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE))
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
if (status)
|
2010-09-08 15:46:36 -06:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->device_removed)
|
2010-09-08 15:46:36 -06:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (false == ad->fw_download_done) {
|
2011-08-15 20:07:41 -06:00
|
|
|
switch (cmd) {
|
|
|
|
case IOCTL_MAC_ADDR_REQ:
|
|
|
|
case IOCTL_LINK_REQ:
|
|
|
|
case IOCTL_CM_REQUEST:
|
|
|
|
case IOCTL_SS_INFO_REQ:
|
|
|
|
case IOCTL_SEND_CONTROL_MESSAGE:
|
|
|
|
case IOCTL_IDLE_REQ:
|
|
|
|
case IOCTL_BCM_GPIO_SET_REQUEST:
|
|
|
|
case IOCTL_BCM_GPIO_STATUS_REQUEST:
|
|
|
|
return -EACCES;
|
|
|
|
default:
|
|
|
|
break;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = vendorextnIoctl(ad, cmd, arg);
|
|
|
|
if (status != CONTINUE_COMMON_PATH)
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
/* Rdms for Swin Idle... */
|
2014-02-13 12:45:05 -07:00
|
|
|
case IOCTL_BCM_REGISTER_READ_PRIVATE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_reg_read_private(argp, ad);
|
|
|
|
return status;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2014-02-13 12:45:11 -07:00
|
|
|
case IOCTL_BCM_REGISTER_WRITE_PRIVATE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_reg_write_private(argp, ad);
|
|
|
|
return status;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
case IOCTL_BCM_REGISTER_READ:
|
2014-02-13 12:45:16 -07:00
|
|
|
case IOCTL_BCM_EEPROM_REGISTER_READ:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_eeprom_reg_read(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
|
|
|
case IOCTL_BCM_REGISTER_WRITE:
|
2014-02-13 12:45:21 -07:00
|
|
|
case IOCTL_BCM_EEPROM_REGISTER_WRITE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_eeprom_reg_write(argp, ad, cmd);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:45:26 -07:00
|
|
|
case IOCTL_BCM_GPIO_SET_REQUEST:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_gpio_set_request(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:45:31 -07:00
|
|
|
case BCM_LED_THREAD_STATE_CHANGE_REQ:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_led_thread_state_change_req(argp,
|
2014-08-27 04:57:38 -06:00
|
|
|
ad);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2014-02-13 12:45:36 -07:00
|
|
|
case IOCTL_BCM_GPIO_STATUS_REQUEST:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_gpio_status_request(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:45:41 -07:00
|
|
|
case IOCTL_BCM_GPIO_MULTI_REQUEST:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_gpio_multi_request(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:45:47 -07:00
|
|
|
case IOCTL_BCM_GPIO_MODE_REQUEST:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_gpio_mode_request(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
|
|
|
case IOCTL_MAC_ADDR_REQ:
|
|
|
|
case IOCTL_LINK_REQ:
|
|
|
|
case IOCTL_CM_REQUEST:
|
|
|
|
case IOCTL_SS_INFO_REQ:
|
|
|
|
case IOCTL_SEND_CONTROL_MESSAGE:
|
2014-02-13 12:45:52 -07:00
|
|
|
case IOCTL_IDLE_REQ:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_misc_request(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:45:57 -07:00
|
|
|
case IOCTL_BCM_BUFFER_DOWNLOAD_START:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_buffer_download_start(ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:46:02 -07:00
|
|
|
case IOCTL_BCM_BUFFER_DOWNLOAD:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_buffer_download(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:46:07 -07:00
|
|
|
case IOCTL_BCM_BUFFER_DOWNLOAD_STOP:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_buffer_download_stop(argp, ad);
|
|
|
|
return status;
|
2014-02-13 12:46:07 -07:00
|
|
|
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
case IOCTL_BE_BUCKET_SIZE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = 0;
|
2014-08-27 04:57:38 -06:00
|
|
|
if (get_user(ad->BEBucketSize,
|
2014-05-22 04:17:28 -06:00
|
|
|
(unsigned long __user *)arg))
|
2014-08-27 04:57:43 -06:00
|
|
|
status = -EFAULT;
|
2011-08-15 20:07:41 -06:00
|
|
|
break;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
case IOCTL_RTPS_BUCKET_SIZE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = 0;
|
2014-08-27 04:57:38 -06:00
|
|
|
if (get_user(ad->rtPSBucketSize,
|
2014-05-22 04:17:28 -06:00
|
|
|
(unsigned long __user *)arg))
|
2014-08-27 04:57:43 -06:00
|
|
|
status = -EFAULT;
|
2011-08-15 20:07:41 -06:00
|
|
|
break;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2014-02-13 12:46:12 -07:00
|
|
|
case IOCTL_CHIP_RESET:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_chip_reset(ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:46:17 -07:00
|
|
|
case IOCTL_QOS_THRESHOLD:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_qos_threshold(arg, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
case IOCTL_DUMP_PACKET_INFO:
|
2014-08-27 04:57:38 -06:00
|
|
|
DumpPackInfo(ad);
|
|
|
|
DumpPhsRules(&ad->stBCMPhsContext);
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2011-08-15 20:07:41 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IOCTL_GET_PACK_INFO:
|
2014-08-27 04:57:38 -06:00
|
|
|
if (copy_to_user(argp, &ad->PackInfo,
|
2014-05-22 04:17:28 -06:00
|
|
|
sizeof(struct bcm_packet_info)*NO_OF_QUEUES))
|
2011-08-15 20:07:41 -06:00
|
|
|
return -EFAULT;
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2011-08-15 20:07:41 -06:00
|
|
|
break;
|
|
|
|
|
2014-02-13 12:46:22 -07:00
|
|
|
case IOCTL_BCM_SWITCH_TRANSFER_MODE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_switch_transfer_mode(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:46:27 -07:00
|
|
|
case IOCTL_BCM_GET_DRIVER_VERSION:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_get_driver_version(argp);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:46:32 -07:00
|
|
|
case IOCTL_BCM_GET_CURRENT_STATUS:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_get_current_status(argp, ad);
|
|
|
|
return status;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2014-02-13 12:46:37 -07:00
|
|
|
case IOCTL_BCM_SET_MAC_TRACING:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_set_mac_tracing(argp, ad);
|
|
|
|
return status;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2014-02-13 12:46:42 -07:00
|
|
|
case IOCTL_BCM_GET_DSX_INDICATION:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_get_dsx_indication(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:46:47 -07:00
|
|
|
case IOCTL_BCM_GET_HOST_MIBS:
|
2014-08-27 04:58:14 -06:00
|
|
|
status = bcm_char_ioctl_get_host_mibs(argp, ad, tarang);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
|
|
|
case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE:
|
2014-08-27 04:57:38 -06:00
|
|
|
if ((false == ad->bTriedToWakeUpFromlowPowerMode) &&
|
|
|
|
(TRUE == ad->IdleMode)) {
|
|
|
|
ad->usIdleModePattern = ABORT_IDLE_MODE;
|
|
|
|
ad->bWakeUpDevice = TRUE;
|
|
|
|
wake_up(&ad->process_rx_cntrlpkt);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2010-10-20 23:46:58 -06:00
|
|
|
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2011-08-15 20:07:41 -06:00
|
|
|
break;
|
|
|
|
|
2014-02-13 12:46:52 -07:00
|
|
|
case IOCTL_BCM_BULK_WRM:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_bulk_wrm(argp, ad, cmd);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
|
|
|
case IOCTL_BCM_GET_NVM_SIZE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_get_nvm_size(argp, ad);
|
|
|
|
return status;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2014-02-13 12:47:02 -07:00
|
|
|
case IOCTL_BCM_CAL_INIT:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_cal_init(argp, ad);
|
|
|
|
return status;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
case IOCTL_BCM_SET_DEBUG:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_set_debug(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
|
|
|
case IOCTL_BCM_NVM_READ:
|
2014-02-13 12:47:13 -07:00
|
|
|
case IOCTL_BCM_NVM_WRITE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_nvm_rw(argp, ad, cmd);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:47:18 -07:00
|
|
|
case IOCTL_BCM_FLASH2X_SECTION_READ:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_flash2x_section_read(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:47:23 -07:00
|
|
|
case IOCTL_BCM_FLASH2X_SECTION_WRITE:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_flash2x_section_write(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:47:28 -07:00
|
|
|
case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_flash2x_section_bitmap(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:47:33 -07:00
|
|
|
case IOCTL_BCM_SET_ACTIVE_SECTION:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_set_active_section(argp, ad);
|
|
|
|
return status;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2014-02-13 12:47:38 -07:00
|
|
|
case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION:
|
2011-08-15 20:07:41 -06:00
|
|
|
/* Right Now we are taking care of only DSD */
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->bAllDSDWriteAllow = false;
|
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called");
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_SUCCESS;
|
2014-02-13 12:47:38 -07:00
|
|
|
break;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:47:43 -07:00
|
|
|
case IOCTL_BCM_COPY_SECTION:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_copy_section(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:47:48 -07:00
|
|
|
case IOCTL_BCM_GET_FLASH_CS_INFO:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_get_flash_cs_info(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:47:53 -07:00
|
|
|
case IOCTL_BCM_SELECT_DSD:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_select_dsd(argp, ad);
|
|
|
|
return status;
|
2011-08-15 20:07:41 -06:00
|
|
|
|
2014-02-13 12:47:59 -07:00
|
|
|
case IOCTL_BCM_NVM_RAW_READ:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_nvm_raw_read(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:48:04 -07:00
|
|
|
case IOCTL_BCM_CNTRLMSG_MASK:
|
2014-08-27 04:58:14 -06:00
|
|
|
status = bcm_char_ioctl_cntrlmsg_mask(argp, ad, tarang);
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:48:09 -07:00
|
|
|
case IOCTL_BCM_GET_DEVICE_DRIVER_INFO:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_get_device_driver_info(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-02-13 12:48:14 -07:00
|
|
|
case IOCTL_BCM_TIME_SINCE_NET_ENTRY:
|
2014-08-27 04:57:43 -06:00
|
|
|
status = bcm_char_ioctl_time_since_net_entry(argp, ad);
|
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
case IOCTL_CLOSE_NOTIFICATION:
|
2014-08-27 04:57:38 -06:00
|
|
|
BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
|
2014-05-22 04:17:28 -06:00
|
|
|
"IOCTL_CLOSE_NOTIFICATION");
|
2011-08-15 20:07:41 -06:00
|
|
|
break;
|
2010-11-01 07:26:47 -06:00
|
|
|
|
2011-08-15 20:07:41 -06:00
|
|
|
default:
|
|
|
|
pr_info(DRV_NAME ": unknown ioctl cmd=%#x\n", cmd);
|
2014-08-27 04:57:43 -06:00
|
|
|
status = STATUS_FAILURE;
|
2011-08-15 20:07:41 -06:00
|
|
|
break;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2014-08-27 04:57:43 -06:00
|
|
|
return status;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-11 20:38:25 -07:00
|
|
|
static const struct file_operations bcm_fops = {
|
2010-09-30 02:24:11 -06:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = bcm_char_open,
|
|
|
|
.release = bcm_char_release,
|
|
|
|
.read = bcm_char_read,
|
|
|
|
.unlocked_ioctl = bcm_char_ioctl,
|
2010-09-30 02:24:07 -06:00
|
|
|
.llseek = no_llseek,
|
2010-09-08 15:46:36 -06:00
|
|
|
};
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
int register_control_device_interface(struct bcm_mini_adapter *ad)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2010-11-01 08:17:54 -06:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->major > 0)
|
|
|
|
return ad->major;
|
2010-11-01 08:17:54 -06:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->major = register_chrdev(0, DEV_NAME, &bcm_fops);
|
|
|
|
if (ad->major < 0) {
|
2010-11-01 08:17:54 -06:00
|
|
|
pr_err(DRV_NAME ": could not created character device\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
return ad->major;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2010-11-01 08:17:54 -06:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
ad->pstCreatedClassDevice = device_create(bcm_class, NULL,
|
|
|
|
MKDEV(ad->major, 0),
|
|
|
|
ad, DEV_NAME);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
if (IS_ERR(ad->pstCreatedClassDevice)) {
|
2010-11-01 08:17:54 -06:00
|
|
|
pr_err(DRV_NAME ": class device create failed\n");
|
2014-08-27 04:57:38 -06:00
|
|
|
unregister_chrdev(ad->major, DEV_NAME);
|
|
|
|
return PTR_ERR(ad->pstCreatedClassDevice);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
2011-02-11 20:38:25 -07:00
|
|
|
|
2010-11-01 08:17:54 -06:00
|
|
|
return 0;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2014-08-27 04:57:38 -06:00
|
|
|
void unregister_control_device_interface(struct bcm_mini_adapter *ad)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2014-08-27 04:57:38 -06:00
|
|
|
if (ad->major > 0) {
|
|
|
|
device_destroy(bcm_class, MKDEV(ad->major, 0));
|
|
|
|
unregister_chrdev(ad->major, DEV_NAME);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
}
|
2011-08-15 20:07:41 -06:00
|
|
|
|