コード例 #1
0
/** 
 *  @brief config proc write function
 *
 *  @param f	   file pointer
 *  @param buf     pointer to data buffer
 *  @param cnt     data number to write
 *  @param data    data to write
 *  @return 	   number of data
 */
static int
woal_config_write(struct file *f, const char *buf, unsigned long cnt,
                  void *data)
{
    char databuf[100];
    char *line;
    t_u32 config_data = 0;
    moal_handle *handle = (moal_handle *) data;

    MODULE_GET;
    if (cnt > sizeof(databuf)) {
        MODULE_PUT;
        return cnt;
    }
    memset(databuf, 0, sizeof(databuf));
    if (copy_from_user(databuf, buf, cnt)) {
        MODULE_PUT;
        return 0;
    }
    line = databuf;
    if (!strncmp(databuf, "soft_reset", strlen("soft_reset"))) {
        line += strlen("soft_reset") + 1;
        config_data = (t_u32) woal_string_to_number(line);
        PRINTM(MINFO, "soft_reset: %d\n", (int) config_data);
        woal_request_soft_reset(handle);
        handle->hardware_status = HardwareStatusReset;
    }
    if (!strncmp(databuf, "drv_mode", strlen("drv_mode"))) {
        line += strlen("drv_mode") + 1;
        config_data = (t_u32) woal_string_to_number(line);
        PRINTM(MINFO, "drv_mode: %d\n", (int) config_data);
        if (config_data != (t_u32) drv_mode)
            woal_switch_drv_mode(handle, config_data);
    }
    MODULE_PUT;
    return cnt;
}
コード例 #2
0
/** 
 *  @brief config proc write function
 *
 *  @param f	   file pointer
 *  @param buf     pointer to data buffer
 *  @param cnt     data number to write
 *  @param data    data to write
 *  @return 	   number of data
 */
static int
woal_config_write(struct file *f, const char *buf, unsigned long cnt,
                  void *data)
{
    char databuf[101];
    char *line;
    t_u32 config_data = 0;
    moal_handle *handle = (moal_handle *) data;
    int func, reg, val;
    int copy_len;
    moal_private *priv = NULL;

    ENTER();
    if (!MODULE_GET) {
        LEAVE();
        return 0;
    }

    if (cnt >= sizeof(databuf)) {
        MODULE_PUT;
        LEAVE();
        return (int) cnt;
    }
    memset(databuf, 0, sizeof(databuf));
    copy_len = MIN((sizeof(databuf) - 1), cnt);
    if (copy_from_user(databuf, buf, copy_len)) {
        MODULE_PUT;
        LEAVE();
        return 0;
    }
    line = databuf;
    if (!strncmp(databuf, "soft_reset", strlen("soft_reset"))) {
        line += strlen("soft_reset") + 1;
        config_data = (t_u32) woal_string_to_number(line);
        PRINTM(MINFO, "soft_reset: %d\n", (int) config_data);
        if (woal_request_soft_reset(handle) == MLAN_STATUS_SUCCESS) {
            handle->hardware_status = HardwareStatusReset;
        } else {
            PRINTM(MERROR, "Could not perform soft reset\n");
        }
    }
    if (!strncmp(databuf, "drv_mode", strlen("drv_mode"))) {
        line += strlen("drv_mode") + 1;
        config_data = (t_u32) woal_string_to_number(line);
        PRINTM(MINFO, "drv_mode: %d\n", (int) config_data);
        if (config_data != (t_u32) drv_mode)
            if (woal_switch_drv_mode(handle, config_data) !=
                MLAN_STATUS_SUCCESS) {
                PRINTM(MERROR, "Could not switch drv mode\n");
            }
    }
    if (!strncmp(databuf, "sdcmd52rw=", strlen("sdcmd52rw="))) {
        parse_cmd52_string(databuf, (size_t) cnt, &func, &reg, &val);
        woal_sdio_read_write_cmd52(handle, func, reg, val);
    }
    if (!strncmp(databuf, "debug_dump", strlen("debug_dump"))) {
        priv = woal_get_priv(handle, MLAN_BSS_ROLE_ANY);
        if (priv) {
            woal_mlan_debug_info(priv);
            woal_moal_debug_info(priv, NULL, MFALSE);
            woal_dump_firmware_info(priv);
        }
    }

    MODULE_PUT;
    LEAVE();
    return (int) cnt;
}