CQueryWindowOptionsDialog::query_config_options CQueryWindowOptionsDialog::readConfig(CConfig *cfg) { #ifdef DEBUG qDebug("static query_config_options::readConfig(CMySQLServer *)"); #endif query_config_options opt; opt.force = strtobool(cfg->readStringEntry("Force Queries", "true")); opt.silent = !strtobool(cfg->readStringEntry("Silent", "false")); opt.use_history_file = strtobool(cfg->readStringEntry("Append Queries to History", "true")); add_option(&opt.options, cfg, "sql_auto_is_null"); add_option(&opt.options, cfg, "big_tables"); add_option(&opt.options, cfg, "sql_buffer_result"); add_option(&opt.options, cfg, "query_cache_type"); add_option(&opt.options, cfg, "sql_log_off"); add_option(&opt.options, cfg, "sql_quote_show_create"); add_option(&opt.options, cfg, "autocommit"); add_option(&opt.options, cfg, "sql_big_selects"); add_option(&opt.options, cfg, "low_priority_updates"); add_option(&opt.options, cfg, "sql_safe_updates"); add_option(&opt.options, cfg, "sql_log_update"); return opt; }
void CQueryWindowOptionsTab::setDefaultValues(CConfig *cfg) { queryNewTab->setChecked(strtobool(cfg->readStringEntry("Query New Tab", "true"))); followQueryTab->setChecked(strtobool(cfg->readStringEntry("Follow Query Tab", "true"))); followResultsTab->setChecked(strtobool(cfg->readStringEntry("Follow Results Tab", "false"))); maxResults->setValue(cfg->readNumberEntry("Max Results to Save", 10)); ((QRadioButton *)multipleQueries->find(cfg->readNumberEntry("Multiple Query Options", 1)))->setChecked(true); }
static ssize_t tool_link_event_write(struct file *filep, const char __user *ubuf, size_t size, loff_t *offp) { struct tool_ctx *tc = filep->private_data; char buf[32]; size_t buf_size; bool val; int rc; buf_size = min(size, (sizeof(buf) - 1)); if (copy_from_user(buf, ubuf, buf_size)) return -EFAULT; buf[buf_size] = '\0'; rc = strtobool(buf, &val); if (rc) return rc; if (wait_event_interruptible(tc->link_wq, ntb_link_is_up(tc->ntb, NULL, NULL) == val)) return -ERESTART; return size; }
static ssize_t tool_link_write(struct file *filep, const char __user *ubuf, size_t size, loff_t *offp) { struct tool_ctx *tc = filep->private_data; char buf[32]; size_t buf_size; bool val; int rc; buf_size = min(size, (sizeof(buf) - 1)); if (copy_from_user(buf, ubuf, buf_size)) return -EFAULT; buf[buf_size] = '\0'; rc = strtobool(buf, &val); if (rc) return rc; if (val) rc = ntb_link_enable(tc->ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO); else rc = ntb_link_disable(tc->ntb); if (rc) return rc; return size; }
static ssize_t display_enabled_store(struct omap_dss_device *dssdev, const char *buf, size_t size) { int r; bool enable; r = strtobool(buf, &enable); if (r) return r; if (enable == omapdss_device_is_enabled(dssdev)) return size; if (omapdss_device_is_connected(dssdev) == false) return -ENODEV; if (enable) { r = dssdev->driver->enable(dssdev); if (r) return r; } else { dssdev->driver->disable(dssdev); } return size; }
static ssize_t iwl_dbgfs_reduced_txp_write(struct ieee80211_vif *vif, char *buf, size_t count, loff_t *ppos) { struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm *mvm = mvmvif->mvm; struct iwl_mvm_sta *mvmsta; bool reduced_tx_power; int ret; if (mvmvif->ap_sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id)) return -ENOTCONN; if (strtobool(buf, &reduced_tx_power) != 0) return -EINVAL; mutex_lock(&mvm->mutex); mvmsta = iwl_mvm_sta_from_staid_protected(mvm, mvmvif->ap_sta_id); if (IS_ERR_OR_NULL(mvmsta)) { mutex_unlock(&mvm->mutex); return -ENOTCONN; } mvmsta->bt_reduced_txpower_dbg = false; ret = iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, reduced_tx_power); if (!ret) mvmsta->bt_reduced_txpower_dbg = true; mutex_unlock(&mvm->mutex); return ret ? : count; }
static ssize_t usb2_hardware_lpm_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_device *udev = to_usb_device(dev); bool value; int ret; ret = usb_lock_device_interruptible(udev); if (ret < 0) return -EINTR; ret = strtobool(buf, &value); if (!ret) { udev->usb2_hw_lpm_allowed = value; if (value) ret = usb_enable_usb2_hardware_lpm(udev); else ret = usb_disable_usb2_hardware_lpm(udev); } usb_unlock_device(udev); if (!ret) return count; return ret; }
static int grok_node_flag(int *flags, const char *key, const char *value) { uint i; int set, code = -1; set = strtobool(value); for (i = 0; i < ARRAY_SIZE(node_config_flags); i++) { if (!strcasecmp(key, node_config_flags[i].key)) { code = node_config_flags[i].code; break; } } if (code == -1) { return -1; } /* set or unset this flag */ if (set) { *flags |= code; } else { *flags = *flags & ~code; } return 0; }
static ssize_t DisplayEnabledWrite(struct file *psFile, const char __user *psUserBuffer, size_t uiCount, loff_t *puiPosition) { IMG_UINT32 *pui32PDPEnabled = psFile->private_data; char pszBuffer[3]; bool bPDPEnabled; int iErr; uiCount = min(uiCount, ARRAY_SIZE(pszBuffer) - 1); iErr = copy_from_user(pszBuffer, psUserBuffer, uiCount); if (iErr) { return -EFAULT; } pszBuffer[uiCount] = '\0'; if (strtobool(pszBuffer, &bPDPEnabled) == 0) { *pui32PDPEnabled = bPDPEnabled ? 1 : 0; DCPDPEnableMemoryRequest(g_psDeviceData, bPDPEnabled); } return uiCount; }
static ssize_t mwifiex_timeshare_coex_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { bool timeshare_coex; struct mwifiex_private *priv = file->private_data; char kbuf[16]; int ret; if (priv->adapter->fw_api_ver != MWIFIEX_FW_V15) return -EOPNOTSUPP; memset(kbuf, 0, sizeof(kbuf)); if (copy_from_user(&kbuf, ubuf, min_t(size_t, sizeof(kbuf) - 1, count))) return -EFAULT; if (strtobool(kbuf, ×hare_coex)) return -EINVAL; ret = mwifiex_send_cmd(priv, HostCmd_CMD_ROBUST_COEX, HostCmd_ACT_GEN_SET, 0, ×hare_coex, true); if (ret) return ret; else return count; }
static ssize_t sc_prefetch_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { char buf[32]; ssize_t buf_size; bool enabled; int err; buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; buf[buf_size] = '\0'; err = strtobool(buf, &enabled); if (err) return err; if (enabled) bc_prefetch_enable(); else bc_prefetch_disable(); return count; }
static int set_enable(const char *arg, const struct kernel_param *kp) { int ret; bool old_val = *((bool *) kp->arg); bool new_val; if (!arg) arg = "1"; ret = strtobool(arg, &new_val); if (ret) return ret; if (!old_val && new_val) { if (start_monitoring()) { pr_err("L2PM counters already in use.\n"); return ret; } else { pr_info("Enabling CPU BW monitoring\n"); } } else if (old_val && !new_val) { pr_info("Disabling CPU BW monitoring\n"); stop_monitoring(); } *(bool *) kp->arg = new_val; return 0; }
/* Default and user configuration */ void default_configuration(configuration_t *config) { char *scan, buffer[MAXLINELEN] ; #define GETINISTRING(key, value) \ GetPrivateProfileString("XFer", (key), (value), buffer, MAXLINELEN, "XFer.ini") if ( GETINISTRING("comport", "com1:") ) { if ( (config->comport = strdup(buffer)) == NULL ) error("Out of memory storing comport %s in ini file", buffer) ; } else /* comport must be set, regardless whether from profile or not */ config->comport = "com1:" ; if ( GETINISTRING("baudrate", "") ) { if ( !itobaud(strtol(buffer, &scan, 10), &config->baudrate) || *scan != '\0' ) error("Invalid baud rate %s in ini file", buffer) ; } if ( GETINISTRING("timeoutdelay", "") ) { config->timeoutdelay = strtol(buffer, &scan, 10) ; if ( *scan != '\0' ) error("Invalid timeout %s in ini file", buffer) ; } if ( GETINISTRING("wildcards", "") ) { if ( !strtobool(buffer, &config->wildcards) ) error("Invalid wildcards flag %s in ini file", buffer) ; } if ( GETINISTRING("directories", "") ) { if ( !strtobool(buffer, &config->directories) ) error("Invalid directories flag %s in ini file", buffer) ; } if ( GETINISTRING("handshake", "") ) { if ( !strtohandshake(buffer, &config->handshake) ) error("Invalid handshake type %s in ini file", buffer) ; } if ( GETINISTRING("basic", "") ) { if ( (config->basic = strdup(buffer)) == NULL ) error("Out of memory storing basic filename %s in ini file", buffer) ; } }
void grok_db_compound(struct cfg_comp *c) { unsigned int vi; use_database = 1; for (vi = 0; vi < c->vars; vi++) { struct cfg_var *v = c->vlist[vi]; if (!strcmp(v->key, "log_report_data")) { db_log_reports = strtobool(v->value); } else if (!prefixcmp(v->key, "log_notification")) { db_log_notifications = strtobool(v->value); } else if (!prefixcmp(v->key, "track_current")) { lwarn("Option '%s' in the database compound is deprecated", v->key); } else if (!strcmp(v->key, "enabled")) { use_database = strtobool(v->value); } else { sql_config(v->key, v->value); } } }
static ssize_t tfa9890_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { bool value; if (strtobool(buf, &value)) return -EINVAL; if(reset_gpio >0) gpio_set_value(reset_gpio,((value > 0) ? 1: 0)); pr_debug("Reset the tfa9890.... %d\n",value); return size; }
void CQueryOptionsTab::setDefaultValues(CConfig *cfg) { #ifdef DEBUG qDebug("CQueryOptionsTab::setDefaultValues()"); #endif force->setChecked(strtobool(cfg->readStringEntry("Force Queries", "true"))); silent->setChecked(strtobool(cfg->readStringEntry("Silent", "false"))); use_history_file->setChecked(strtobool(cfg->readStringEntry("Append Queries to History", "true"))); sql_auto_is_null->setCurrentItem(cfg->readNumberEntry("sql_auto_is_null")); big_tables->setCurrentItem(cfg->readNumberEntry("big_tables")); sql_buffer_result->setCurrentItem(cfg->readNumberEntry("sql_buffer_result")); query_cache_type->setCurrentItem(cfg->readNumberEntry("query_cache_type")); sql_log_off->setCurrentItem(cfg->readNumberEntry("sql_log_off")); sql_quote_show_create->setCurrentItem(cfg->readNumberEntry("sql_quote_show_create")); autocommit->setCurrentItem(cfg->readNumberEntry("autocommit")); sql_big_selects->setCurrentItem(cfg->readNumberEntry("sql_big_selects")); low_priority_updates->setCurrentItem(cfg->readNumberEntry("low_priority_updates")); sql_safe_updates->setCurrentItem(cfg->readNumberEntry("sql_safe_updates")); sql_log_update->setCurrentItem(cfg->readNumberEntry("sql_log_update")); }
static int __init early_fsl_a008585_cfg(char *buf) { int ret; bool val; ret = strtobool(buf, &val); if (ret) return ret; fsl_a008585_enable = val; return 0; }
static ssize_t read_only_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { bool ro; int rc = strtobool(buf, &ro); struct nd_region *nd_region = to_nd_region(dev); if (rc) return rc; nd_region->ro = ro; return len; }
static ssize_t write_file_tx99(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { struct ath_softc *sc = file->private_data; struct ath_common *common = ath9k_hw_common(sc->sc_ah); char buf[32]; bool start; ssize_t len; int r; if (count < 1) return -EINVAL; if (sc->cur_chan->nvifs > 1) return -EOPNOTSUPP; len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; buf[len] = '\0'; if (strtobool(buf, &start)) return -EINVAL; mutex_lock(&sc->mutex); if (start == sc->tx99_state) { if (!start) goto out; ath_dbg(common, XMIT, "Resetting TX99\n"); ath9k_tx99_deinit(sc); } if (!start) { ath9k_tx99_deinit(sc); goto out; } r = ath9k_tx99_init(sc); if (r) { mutex_unlock(&sc->mutex); return r; } out: mutex_unlock(&sc->mutex); return count; }
/* * interface_authorized_store - authorize or deauthorize an USB interface */ static ssize_t interface_authorized_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); bool val; if (strtobool(buf, &val) != 0) return -EINVAL; if (val) usb_authorize_interface(intf); else usb_deauthorize_interface(intf); return count; }
static ssize_t hall_device_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct hall_device_chip *chip = dev_get_drvdata(dev); bool value; if (strtobool(buf, &value)) return -EINVAL; mutex_lock(&chip->lock); chip->enabled = (value>0) ? true : false; hall_device_enable(chip, chip->enabled); mutex_unlock(&chip->lock); return size; }
static void __init xen_parse_512gb(void) { bool val = false; char *arg; arg = strstr(xen_start_info->cmd_line, "xen_512gb_limit"); if (!arg) return; arg = strstr(xen_start_info->cmd_line, "xen_512gb_limit="); if (!arg) val = true; else if (strtobool(arg + strlen("xen_512gb_limit="), &val)) return; xen_512gb_limit = val; }
static ssize_t write_file_bool(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { char buf[32]; size_t buf_size; bool bv; u32 *val = file->private_data; buf_size = min(count, (sizeof(buf)-1)); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (strtobool(buf, &bv) == 0) *val = bv; return count; }
ssize_t Factory_UMIP_store(struct device *dev, struct device_attribute *attr, const char *buffer, size_t count) { int ret = 0; u8 data_write; u8 yes; u8 no; bool bv; if (strlen(buffer) != 2) { pr_err("The length must be 1\n"); ret = -EINVAL; goto error; } ret = strtobool(buffer, &bv); if (ret) { pr_err("Not expected value [Y|y|1|N|n|0]\n"); goto error; } if (intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_PENWELL) { ret = intel_scu_ipc_read_mip(&data_write, 1, FACTORY_UMIP_OFFSET, 0); data_write &= ~(1 << FACTORY_BIT_OFFSET); data_write |= bv; ret = intel_scu_ipc_write_umip(&data_write, 1, FACTORY_UMIP_OFFSET); if (ret) { pr_err("Could not write to UMIP for Factory\n"); goto error; } } return count; error: return ret; }
static ssize_t display_mirror_store(struct omap_dss_device *dssdev, const char *buf, size_t size) { int r; bool mirror; if (!dssdev->driver->set_mirror || !dssdev->driver->get_mirror) return -ENOENT; r = strtobool(buf, &mirror); if (r) return r; r = dssdev->driver->set_mirror(dssdev, mirror); if (r) return r; return size; }
static ssize_t raw_ip_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len) { struct usbnet *dev = netdev_priv(to_net_dev(d)); struct qmi_wwan_state *info = (void *)&dev->data; bool enable; int ret; if (strtobool(buf, &enable)) return -EINVAL; /* no change? */ if (enable == (info->flags & QMI_WWAN_FLAG_RAWIP)) return len; if (!rtnl_trylock()) return restart_syscall(); /* we don't want to modify a running netdev */ if (netif_running(dev->net)) { netdev_err(dev->net, "Cannot change a running device\n"); ret = -EBUSY; goto err; } /* let other drivers deny the change */ ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev->net); ret = notifier_to_errno(ret); if (ret) { netdev_err(dev->net, "Type change was refused\n"); goto err; } if (enable) info->flags |= QMI_WWAN_FLAG_RAWIP; else info->flags &= ~QMI_WWAN_FLAG_RAWIP; qmi_wwan_netdev_setup(dev->net); call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev->net); ret = len; err: rtnl_unlock(); return ret; }
static ssize_t compass_int_pin_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { bool value; if (strtobool(buf, &value)) return -EINVAL; if (value) { SENSOR_LOG_INFO("set to be 1\n"); gpio_set_value(COMPASS_INT_PIN, 1); } else { SENSOR_LOG_INFO("set to be 0\n"); gpio_set_value(COMPASS_INT_PIN, 0); } return size; }
static inline ssize_t ad7152_start_calib(struct device *dev, struct device_attribute *attr, const char *buf, size_t len, u8 regval) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7152_chip_info *chip = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); bool doit; int ret, timeout = 10; ret = strtobool(buf, &doit); if (ret < 0) return ret; if (!doit) return 0; if (this_attr->address == 0) regval |= AD7152_CONF_CH1EN; else regval |= AD7152_CONF_CH2EN; mutex_lock(&indio_dev->mlock); ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG, regval); if (ret < 0) { mutex_unlock(&indio_dev->mlock); return ret; } do { mdelay(20); ret = i2c_smbus_read_byte_data(chip->client, AD7152_REG_CFG); if (ret < 0) { mutex_unlock(&indio_dev->mlock); return ret; } } while ((ret == regval) && timeout--); mutex_unlock(&indio_dev->mlock); return len; }
static ssize_t display_tear_store(struct omap_dss_device *dssdev, const char *buf, size_t size) { int r; bool te; if (!dssdev->driver->enable_te || !dssdev->driver->get_te) return -ENOENT; r = strtobool(buf, &te); if (r) return r; r = dssdev->driver->enable_te(dssdev, te); if (r) return r; return size; }
/* Actually could be a bool or an int, for historical reasons. */ int param_set_bool(const char *val, const struct kernel_param *kp) { bool v; int ret; /* No equals means "set"... */ if (!val) val = "1"; /* One of =[yYnN01] */ ret = strtobool(val, &v); if (ret) return ret; if (kp->flags & KPARAM_ISBOOL) *(bool *)kp->arg = v; else *(int *)kp->arg = v; return 0; }