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

staging/bcm: move IOCTL_BCM_GPIO_SET_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 4d4b00a9
......@@ -374,81 +374,16 @@ static int bcm_char_ioctl_eeprom_reg_write(void __user *argp, struct bcm_mini_ad
return Status;
}
static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
static int bcm_char_ioctl_gpio_set_request(void __user *argp, struct bcm_mini_adapter *Adapter)
{
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_gpio_info gpio_info = {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: {
UCHAR ucResetValue[4];
UINT value = 0;
UINT uiBit = 0;
UINT uiOperation = 0;
struct bcm_gpio_info gpio_info = {0};
INT Status;
int bytes;
if ((Adapter->IdleMode == TRUE) ||
(Adapter->bShutStatus == TRUE) ||
......@@ -478,8 +413,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
DBG_LVL_ALL,
"Sorry, Requested GPIO<0x%X> is not correspond to LED !!!",
value);
Status = -EINVAL;
break;
return -EINVAL;
}
/* Set - setting 1 */
......@@ -498,7 +432,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
OSAL_DBG, DBG_LVL_ALL,
"Failed to set the %dth GPIO\n",
uiBit);
break;
return Status;
}
} else {
/* Set the gpio output register */
......@@ -515,7 +449,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
OSAL_DBG, DBG_LVL_ALL,
"Failed to clear the %dth GPIO\n",
uiBit);
break;
return Status;
}
}
......@@ -525,7 +459,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Status = bytes;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
"GPIO_MODE_REGISTER read failed");
break;
return Status;
} else {
Status = STATUS_SUCCESS;
}
......@@ -543,10 +477,83 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG,
DBG_LVL_ALL,
"Failed to put GPIO in Output Mode\n");
}
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: {
struct bcm_user_thread_req threadReq = {0};
......
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