📄 ipw2200.c
字号:
static ssize_t store_scan_age(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *priv = dev_get_drvdata(d); struct net_device *dev = priv->net_dev; char buffer[] = "00000000"; unsigned long len = (sizeof(buffer) - 1) > count ? count : sizeof(buffer) - 1; unsigned long val; char *p = buffer; IPW_DEBUG_INFO("enter\n"); strncpy(buffer, buf, len); buffer[len] = 0; if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') { p++; if (p[0] == 'x' || p[0] == 'X') p++; val = simple_strtoul(p, &p, 16); } else val = simple_strtoul(p, &p, 10); if (p == buffer) { IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev->name); } else { priv->ieee->scan_age = val; IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age); } IPW_DEBUG_INFO("exit\n"); return len;}static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age);static ssize_t show_led(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ struct ipw_priv *priv = dev_get_drvdata(d); return sprintf(buf, "%d\n", (priv->config & CFG_NO_LED) ? 0 : 1);}static ssize_t store_led(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *priv = dev_get_drvdata(d); IPW_DEBUG_INFO("enter\n"); if (count == 0) return 0; if (*buf == 0) { IPW_DEBUG_LED("Disabling LED control.\n"); priv->config |= CFG_NO_LED; ipw_led_shutdown(priv); } else { IPW_DEBUG_LED("Enabling LED control.\n"); priv->config &= ~CFG_NO_LED; ipw_led_init(priv); } IPW_DEBUG_INFO("exit\n"); return count;}static DEVICE_ATTR(led, S_IWUSR | S_IRUGO, show_led, store_led);static ssize_t show_status(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ struct ipw_priv *p = d->driver_data; return sprintf(buf, "0x%08x\n", (int)p->status);}static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);static ssize_t show_cfg(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ struct ipw_priv *p = d->driver_data; return sprintf(buf, "0x%08x\n", (int)p->config);}static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL);static ssize_t show_nic_type(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ struct ipw_priv *priv = d->driver_data; return sprintf(buf, "TYPE: %d\n", priv->nic_type);}static DEVICE_ATTR(nic_type, S_IRUGO, show_nic_type, NULL);static ssize_t show_ucode_version(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ u32 len = sizeof(u32), tmp = 0; struct ipw_priv *p = d->driver_data; if (ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len)) return 0; return sprintf(buf, "0x%08x\n", tmp);}static DEVICE_ATTR(ucode_version, S_IWUSR | S_IRUGO, show_ucode_version, NULL);static ssize_t show_rtc(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ u32 len = sizeof(u32), tmp = 0; struct ipw_priv *p = d->driver_data; if (ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len)) return 0; return sprintf(buf, "0x%08x\n", tmp);}static DEVICE_ATTR(rtc, S_IWUSR | S_IRUGO, show_rtc, NULL);/* * Add a device attribute to view/control the delay between eeprom * operations. */static ssize_t show_eeprom_delay(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ int n = ((struct ipw_priv *)d->driver_data)->eeprom_delay; return sprintf(buf, "%i\n", n);}static ssize_t store_eeprom_delay(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *p = d->driver_data; sscanf(buf, "%i", &p->eeprom_delay); return strnlen(buf, count);}static DEVICE_ATTR(eeprom_delay, S_IWUSR | S_IRUGO, show_eeprom_delay, store_eeprom_delay);static ssize_t show_command_event_reg(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ u32 reg = 0; struct ipw_priv *p = d->driver_data; reg = ipw_read_reg32(p, IPW_INTERNAL_CMD_EVENT); return sprintf(buf, "0x%08x\n", reg);}static ssize_t store_command_event_reg(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ u32 reg; struct ipw_priv *p = d->driver_data; sscanf(buf, "%x", ®); ipw_write_reg32(p, IPW_INTERNAL_CMD_EVENT, reg); return strnlen(buf, count);}static DEVICE_ATTR(command_event_reg, S_IWUSR | S_IRUGO, show_command_event_reg, store_command_event_reg);static ssize_t show_mem_gpio_reg(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ u32 reg = 0; struct ipw_priv *p = d->driver_data; reg = ipw_read_reg32(p, 0x301100); return sprintf(buf, "0x%08x\n", reg);}static ssize_t store_mem_gpio_reg(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ u32 reg; struct ipw_priv *p = d->driver_data; sscanf(buf, "%x", ®); ipw_write_reg32(p, 0x301100, reg); return strnlen(buf, count);}static DEVICE_ATTR(mem_gpio_reg, S_IWUSR | S_IRUGO, show_mem_gpio_reg, store_mem_gpio_reg);static ssize_t show_indirect_dword(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ u32 reg = 0; struct ipw_priv *priv = d->driver_data; if (priv->status & STATUS_INDIRECT_DWORD) reg = ipw_read_reg32(priv, priv->indirect_dword); else reg = 0; return sprintf(buf, "0x%08x\n", reg);}static ssize_t store_indirect_dword(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *priv = d->driver_data; sscanf(buf, "%x", &priv->indirect_dword); priv->status |= STATUS_INDIRECT_DWORD; return strnlen(buf, count);}static DEVICE_ATTR(indirect_dword, S_IWUSR | S_IRUGO, show_indirect_dword, store_indirect_dword);static ssize_t show_indirect_byte(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ u8 reg = 0; struct ipw_priv *priv = d->driver_data; if (priv->status & STATUS_INDIRECT_BYTE) reg = ipw_read_reg8(priv, priv->indirect_byte); else reg = 0; return sprintf(buf, "0x%02x\n", reg);}static ssize_t store_indirect_byte(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *priv = d->driver_data; sscanf(buf, "%x", &priv->indirect_byte); priv->status |= STATUS_INDIRECT_BYTE; return strnlen(buf, count);}static DEVICE_ATTR(indirect_byte, S_IWUSR | S_IRUGO, show_indirect_byte, store_indirect_byte);static ssize_t show_direct_dword(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ u32 reg = 0; struct ipw_priv *priv = d->driver_data; if (priv->status & STATUS_DIRECT_DWORD) reg = ipw_read32(priv, priv->direct_dword); else reg = 0; return sprintf(buf, "0x%08x\n", reg);}static ssize_t store_direct_dword(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *priv = d->driver_data; sscanf(buf, "%x", &priv->direct_dword); priv->status |= STATUS_DIRECT_DWORD; return strnlen(buf, count);}static DEVICE_ATTR(direct_dword, S_IWUSR | S_IRUGO, show_direct_dword, store_direct_dword);static int rf_kill_active(struct ipw_priv *priv){ if (0 == (ipw_read32(priv, 0x30) & 0x10000)) priv->status |= STATUS_RF_KILL_HW; else priv->status &= ~STATUS_RF_KILL_HW; return (priv->status & STATUS_RF_KILL_HW) ? 1 : 0;}static ssize_t show_rf_kill(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ /* 0 - RF kill not enabled 1 - SW based RF kill active (sysfs) 2 - HW based RF kill active 3 - Both HW and SW baed RF kill active */ struct ipw_priv *priv = d->driver_data; int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | (rf_kill_active(priv) ? 0x2 : 0x0); return sprintf(buf, "%i\n", val);}static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio){ if ((disable_radio ? 1 : 0) == ((priv->status & STATUS_RF_KILL_SW) ? 1 : 0)) return 0; IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n", disable_radio ? "OFF" : "ON"); if (disable_radio) { priv->status |= STATUS_RF_KILL_SW; if (priv->workqueue) cancel_delayed_work(&priv->request_scan); queue_work(priv->workqueue, &priv->down); } else { priv->status &= ~STATUS_RF_KILL_SW; if (rf_kill_active(priv)) { IPW_DEBUG_RF_KILL("Can not turn radio back on - " "disabled by HW switch\n"); /* Make sure the RF_KILL check timer is running */ cancel_delayed_work(&priv->rf_kill); queue_delayed_work(priv->workqueue, &priv->rf_kill, 2 * HZ); } else queue_work(priv->workqueue, &priv->up); } return 1;}static ssize_t store_rf_kill(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *priv = d->driver_data; ipw_radio_kill_sw(priv, buf[0] == '1'); return count;}static DEVICE_ATTR(rf_kill, S_IWUSR | S_IRUGO, show_rf_kill, store_rf_kill);static ssize_t show_speed_scan(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; int pos = 0, len = 0; if (priv->config & CFG_SPEED_SCAN) { while (priv->speed_scan[pos] != 0) len += sprintf(&buf[len], "%d ", priv->speed_scan[pos++]); return len + sprintf(&buf[len], "\n"); } return sprintf(buf, "0\n");}static ssize_t store_speed_scan(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; int channel, pos = 0; const char *p = buf; /* list of space separated channels to scan, optionally ending with 0 */ while ((channel = simple_strtol(p, NULL, 0))) { if (pos == MAX_SPEED_SCAN - 1) { priv->speed_scan[pos] = 0; break; } if (ipw_is_valid_channel(priv->ieee, channel)) priv->speed_scan[pos++] = channel; else IPW_WARNING("Skipping invalid channel request: %d\n", channel); p = strchr(p, ' '); if (!p) break; while (*p == ' ' || *p == '\t') p++; } if (pos == 0) priv->config &= ~CFG_SPEED_SCAN; else { priv->speed_scan_pos = 0; priv->config |= CFG_SPEED_SCAN; } return count;}static DEVICE_ATTR(speed_scan, S_IWUSR | S_IRUGO, show_speed_scan, store_speed_scan);static ssize_t show_net_stats(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif char *buf){ struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; return sprintf(buf, "%c\n", (priv->config & CFG_NET_STATS) ? '1' : '0');}static ssize_t store_net_stats(struct device *d,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) struct device_attribute *attr,#endif const char *buf, size_t count){ struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; if (buf[0] == '1') priv->config |= CFG_NET_STATS; else priv->config &= ~CFG_NET_STATS; return count;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -