Commit 3903246c authored by Dave Jones's avatar Dave Jones Committed by Greg Kroah-Hartman

staging/bcm: move IOCTL_BCM_GPIO_MULTI_REQUEST case out to its own function.

bcm_char_ioctl is one of the longest non-generated functions in the kernel,
at 1906 lines.  Splitting it up into multiple functions should simplify
this a lot.
Signed-off-by: default avatarDave Jones <davej@fedoraproject.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3eedb5fa
...@@ -569,92 +569,14 @@ static int bcm_char_ioctl_gpio_status_request(void __user *argp, struct bcm_mini ...@@ -569,92 +569,14 @@ static int bcm_char_ioctl_gpio_status_request(void __user *argp, struct bcm_mini
return Status; return Status;
} }
static int bcm_char_ioctl_gpio_multi_request(void __user *argp, struct bcm_mini_adapter *Adapter)
static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
{ {
struct bcm_tarang_data *pTarang = filp->private_data;
void __user *argp = (void __user *)arg;
struct bcm_mini_adapter *Adapter = pTarang->Adapter;
INT Status = STATUS_FAILURE;
int timeout = 0;
struct bcm_ioctl_buffer IoBuffer;
int bytes;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
"Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX",
cmd, arg);
if (_IOC_TYPE(cmd) != BCM_IOCTL)
return -EFAULT;
if (_IOC_DIR(cmd) & _IOC_READ)
Status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd));
else if (_IOC_DIR(cmd) & _IOC_WRITE)
Status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd));
else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE))
Status = STATUS_SUCCESS;
if (Status)
return -EFAULT;
if (Adapter->device_removed)
return -EFAULT;
if (false == Adapter->fw_download_done) {
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;
}
}
Status = vendorextnIoctl(Adapter, cmd, arg);
if (Status != CONTINUE_COMMON_PATH)
return Status;
switch (cmd) {
/* Rdms for Swin Idle... */
case IOCTL_BCM_REGISTER_READ_PRIVATE:
Status = bcm_char_ioctl_reg_read_private(argp, Adapter);
return Status;
case IOCTL_BCM_REGISTER_WRITE_PRIVATE:
Status = bcm_char_ioctl_reg_write_private(argp, Adapter);
return Status;
case IOCTL_BCM_REGISTER_READ:
case IOCTL_BCM_EEPROM_REGISTER_READ:
Status = bcm_char_ioctl_eeprom_reg_read(argp, Adapter);
return Status;
case IOCTL_BCM_REGISTER_WRITE:
case IOCTL_BCM_EEPROM_REGISTER_WRITE:
Status = bcm_char_ioctl_eeprom_reg_write(argp, Adapter, cmd);
return Status;
case IOCTL_BCM_GPIO_SET_REQUEST:
Status = bcm_char_ioctl_gpio_set_request(argp, Adapter);
return Status;
case BCM_LED_THREAD_STATE_CHANGE_REQ:
Status = bcm_char_ioctl_led_thread_state_change_req(argp, Adapter);
return Status;
case IOCTL_BCM_GPIO_STATUS_REQUEST:
Status = bcm_char_ioctl_gpio_status_request(argp, Adapter);
return Status;
case IOCTL_BCM_GPIO_MULTI_REQUEST: {
UCHAR ucResetValue[4];
struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX]; struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX];
struct bcm_gpio_multi_info *pgpio_multi_info = (struct bcm_gpio_multi_info *)gpio_multi_info; struct bcm_gpio_multi_info *pgpio_multi_info = (struct bcm_gpio_multi_info *)gpio_multi_info;
struct bcm_ioctl_buffer IoBuffer;
UCHAR ucResetValue[4];
INT Status = STATUS_FAILURE;
int bytes;
memset(pgpio_multi_info, 0, MAX_IDX * sizeof(struct bcm_gpio_multi_info)); memset(pgpio_multi_info, 0, MAX_IDX * sizeof(struct bcm_gpio_multi_info));
...@@ -678,8 +600,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -678,8 +600,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
"Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",
pgpio_multi_info[WIMAX_IDX].uiGPIOMask, pgpio_multi_info[WIMAX_IDX].uiGPIOMask,
Adapter->gpioBitMap); Adapter->gpioBitMap);
Status = -EINVAL; return -EINVAL;
break;
} }
/* Set the gpio output register */ /* Set the gpio output register */
...@@ -737,8 +658,94 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -737,8 +658,94 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
"Failed while copying Content to IOBufer for user space err:%d", Status); "Failed while copying Content to IOBufer for user space err:%d", Status);
return -EFAULT; return -EFAULT;
} }
} return Status;
}
static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
{
struct bcm_tarang_data *pTarang = filp->private_data;
void __user *argp = (void __user *)arg;
struct bcm_mini_adapter *Adapter = pTarang->Adapter;
INT Status = STATUS_FAILURE;
int timeout = 0;
struct bcm_ioctl_buffer IoBuffer;
int bytes;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
"Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX",
cmd, arg);
if (_IOC_TYPE(cmd) != BCM_IOCTL)
return -EFAULT;
if (_IOC_DIR(cmd) & _IOC_READ)
Status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd));
else if (_IOC_DIR(cmd) & _IOC_WRITE)
Status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd));
else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE))
Status = STATUS_SUCCESS;
if (Status)
return -EFAULT;
if (Adapter->device_removed)
return -EFAULT;
if (false == Adapter->fw_download_done) {
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; break;
}
}
Status = vendorextnIoctl(Adapter, cmd, arg);
if (Status != CONTINUE_COMMON_PATH)
return Status;
switch (cmd) {
/* Rdms for Swin Idle... */
case IOCTL_BCM_REGISTER_READ_PRIVATE:
Status = bcm_char_ioctl_reg_read_private(argp, Adapter);
return Status;
case IOCTL_BCM_REGISTER_WRITE_PRIVATE:
Status = bcm_char_ioctl_reg_write_private(argp, Adapter);
return Status;
case IOCTL_BCM_REGISTER_READ:
case IOCTL_BCM_EEPROM_REGISTER_READ:
Status = bcm_char_ioctl_eeprom_reg_read(argp, Adapter);
return Status;
case IOCTL_BCM_REGISTER_WRITE:
case IOCTL_BCM_EEPROM_REGISTER_WRITE:
Status = bcm_char_ioctl_eeprom_reg_write(argp, Adapter, cmd);
return Status;
case IOCTL_BCM_GPIO_SET_REQUEST:
Status = bcm_char_ioctl_gpio_set_request(argp, Adapter);
return Status;
case BCM_LED_THREAD_STATE_CHANGE_REQ:
Status = bcm_char_ioctl_led_thread_state_change_req(argp, Adapter);
return Status;
case IOCTL_BCM_GPIO_STATUS_REQUEST:
Status = bcm_char_ioctl_gpio_status_request(argp, Adapter);
return Status;
case IOCTL_BCM_GPIO_MULTI_REQUEST:
Status = bcm_char_ioctl_gpio_multi_request(argp, Adapter);
return Status;
case IOCTL_BCM_GPIO_MODE_REQUEST: { case IOCTL_BCM_GPIO_MODE_REQUEST: {
UCHAR ucResetValue[4]; UCHAR ucResetValue[4];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment