Beispiel #1
0
/**
 * rsi_init_dbgfs() - This function initializes the dbgfs entry.
 * @adapter: Pointer to the adapter structure.
 *
 * Return: 0 on success, -1 on failure.
 */
int rsi_init_dbgfs(struct rsi_hw *adapter)
{
	struct rsi_common *common = adapter->priv;
	struct rsi_debugfs *dev_dbgfs;
	char devdir[6];
	int ii;
	const struct rsi_dbg_files *files;

	dev_dbgfs = kzalloc(sizeof(*dev_dbgfs), GFP_KERNEL);
	if (!dev_dbgfs)
		return -ENOMEM;

	adapter->dfsentry = dev_dbgfs;

	snprintf(devdir, sizeof(devdir), "%s",
		 wiphy_name(adapter->hw->wiphy));

	dev_dbgfs->subdir = debugfs_create_dir(devdir, NULL);

	if (!dev_dbgfs->subdir) {
		kfree(dev_dbgfs);
		return -ENOMEM;
	}

	for (ii = 0; ii < adapter->num_debugfs_entries; ii++) {
		files = &dev_debugfs_files[ii];
		dev_dbgfs->rsi_files[ii] =
		debugfs_create_file(files->name,
				    files->perms,
				    dev_dbgfs->subdir,
				    common,
				    &files->fops);
	}
	return 0;
}
Beispiel #2
0
void ath9k_init_leds(struct ath9k_htc_priv *priv)
{
	int ret;

	if (AR_SREV_9287(priv->ah))
		priv->ah->led_pin = ATH_LED_PIN_9287;
	else if (AR_SREV_9271(priv->ah))
		priv->ah->led_pin = ATH_LED_PIN_9271;
	else if (AR_DEVID_7010(priv->ah))
		priv->ah->led_pin = ATH_LED_PIN_7010;
	else
		priv->ah->led_pin = ATH_LED_PIN_DEF;

	/* Configure gpio 1 for output */
	ath9k_hw_cfg_output(priv->ah, priv->ah->led_pin,
			    AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
	/* LED off, active low */
	ath9k_hw_set_gpio(priv->ah, priv->ah->led_pin, 1);

	snprintf(priv->led_name, sizeof(priv->led_name),
		"ath9k_htc-%s", wiphy_name(priv->hw->wiphy));
	priv->led_cdev.name = priv->led_name;
	priv->led_cdev.brightness_set = ath9k_led_brightness;

	ret = led_classdev_register(wiphy_dev(priv->hw->wiphy), &priv->led_cdev);
	if (ret < 0)
		return;

	INIT_WORK(&priv->led_work, ath9k_led_work);
	priv->led_registered = true;

	return;
}
Beispiel #3
0
static int mt76_led_init(struct mt76_dev *dev)
{
	struct device_node *np = dev->dev->of_node;
	struct ieee80211_hw *hw = dev->hw;
	int led_pin;

	if (!dev->led_cdev.brightness_set && !dev->led_cdev.blink_set)
		return 0;

	snprintf(dev->led_name, sizeof(dev->led_name),
		 "mt76-%s", wiphy_name(hw->wiphy));

	dev->led_cdev.name = dev->led_name;
	dev->led_cdev.default_trigger =
		ieee80211_create_tpt_led_trigger(hw,
					IEEE80211_TPT_LEDTRIG_FL_RADIO,
					mt76_tpt_blink,
					ARRAY_SIZE(mt76_tpt_blink));

	np = of_get_child_by_name(np, "led");
	if (np) {
		if (!of_property_read_u32(np, "led-sources", &led_pin))
			dev->led_pin = led_pin;
		dev->led_al = of_property_read_bool(np, "led-active-low");
	}

	return devm_led_classdev_register(dev->dev, &dev->led_cdev);
}
Beispiel #4
0
void ath_printk(const char *level, const struct ath_common* common,
		const char *fmt, ...)
{
	struct timeval tv;
	struct va_format vaf;
	va_list args;

	va_start(args, fmt);

	vaf.fmt = fmt;
	vaf.va = &args;

	do_gettimeofday(&tv);

	if (common && common->hw && common->hw->wiphy) {
		printk("%sath: %lu.%lu %s: %pV",
		       level, tv.tv_sec, tv.tv_usec,
		       wiphy_name(common->hw->wiphy), &vaf);
		trace_ath_log(common->hw->wiphy, &vaf);
	} else {
		printk("%sath: %lu.%lu %pV",
		       level, tv.tv_sec, tv.tv_usec, &vaf);
	}

	va_end(args);
}
Beispiel #5
0
static int cw1200_register_common(struct ieee80211_hw *dev)
{
	struct cw1200_common *priv = dev->priv;
	int err;

#ifdef CONFIG_PM
	err = cw1200_pm_init(&priv->pm_state, priv);
	if (err) {
		pr_err("Cannot init PM. (%d).\n",
		       err);
		return err;
	}
#endif

	err = ieee80211_register_hw(dev);
	if (err) {
		pr_err("Cannot register device (%d).\n",
		       err);
#ifdef CONFIG_PM
		cw1200_pm_deinit(&priv->pm_state);
#endif
		return err;
	}

	cw1200_debug_init(priv);

	pr_info("Registered as '%s'\n", wiphy_name(dev->wiphy));
	return 0;
}
static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
{
	struct mac80211_hwsim_data *data = hw->priv;
	int ack;
	struct ieee80211_tx_info *txi;

	mac80211_hwsim_monitor_rx(hw, skb);

	if (skb->len < 10) {
		/* Should not happen; just a sanity check for addr1 use */
		dev_kfree_skb(skb);
		return NETDEV_TX_OK;
	}

	if (!data->radio_enabled) {
		printk(KERN_DEBUG "%s: dropped TX frame since radio "
		       "disabled\n", wiphy_name(hw->wiphy));
		dev_kfree_skb(skb);
		return NETDEV_TX_OK;
	}

	ack = mac80211_hwsim_tx_frame(hw, skb);

	txi = IEEE80211_SKB_CB(skb);
	memset(&txi->status, 0, sizeof(txi->status));
	if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) {
		if (ack)
			txi->flags |= IEEE80211_TX_STAT_ACK;
		else
			txi->status.excessive_retries = 1;
	}
	ieee80211_tx_status_irqsafe(hw, skb);
	return NETDEV_TX_OK;
}
Beispiel #7
0
int iwl_mvm_leds_init(struct iwl_mvm *mvm)
{
	int mode = iwlwifi_mod_params.led_mode;
	int ret;

	switch (mode) {
	case IWL_LED_DEFAULT:
	case IWL_LED_RF_STATE:
		mode = IWL_LED_RF_STATE;
		break;
	case IWL_LED_DISABLE:
		IWL_INFO(mvm, "Led disabled\n");
		return 0;
	default:
		return -EINVAL;
	}

	mvm->led.name = kasprintf(GFP_KERNEL, "%s-led",
				   wiphy_name(mvm->hw->wiphy));
	mvm->led.brightness_set = iwl_led_brightness_set;
	mvm->led.max_brightness = 1;

	if (mode == IWL_LED_RF_STATE)
		mvm->led.default_trigger =
			ieee80211_get_radio_led_name(mvm->hw);

	ret = led_classdev_register(mvm->trans->dev, &mvm->led);
	if (ret) {
		kfree(mvm->led.name);
		IWL_INFO(mvm, "Failed to enable led\n");
		return ret;
	}

	return 0;
}
Beispiel #8
0
static int rtl8180_init_tx_ring(struct ieee80211_hw *dev,
				unsigned int prio, unsigned int entries)
{
	struct rtl8180_priv *priv = dev->priv;
	struct rtl8180_tx_desc *ring;
	dma_addr_t dma;
	int i;

	ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma);
	if (!ring || (unsigned long)ring & 0xFF) {
		printk(KERN_ERR "%s: Cannot allocate TX ring (prio = %d)\n",
		       wiphy_name(dev->wiphy), prio);
		return -ENOMEM;
	}

	memset(ring, 0, sizeof(*ring)*entries);
	priv->tx_ring[prio].desc = ring;
	priv->tx_ring[prio].dma = dma;
	priv->tx_ring[prio].idx = 0;
	priv->tx_ring[prio].entries = entries;
	skb_queue_head_init(&priv->tx_ring[prio].queue);

	for (i = 0; i < entries; i++)
		ring[i].next_tx_desc =
			cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring));

	return 0;
}
Beispiel #9
0
int r92su_register(struct r92su *r92su)
{
	int err;

	err = wiphy_register(r92su->wdev.wiphy);
	if (err)
		return err;

	err = register_netdev(r92su->wdev.netdev);
	if (err)
		return err;

	err = r92su_register_debugfs(r92su);
	if (err)
		return err;

	err = r92su_register_wps_button(r92su);
	if (err)
		return err;

	dev_info(wiphy_dev(r92su->wdev.wiphy),
		 "Realtek RTL81XX rev %s, rf:%s is registered as '%s'.\n",
		 rev_to_string[r92su->chip_rev],
		 rf_to_string(r92su->rf_type),
		 wiphy_name(r92su->wdev.wiphy));

	r92su_set_state(r92su, R92SU_STOP);
	return 0;
}
Beispiel #10
0
char *__ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
				unsigned int flags,
				const struct ieee80211_tpt_blink *blink_table,
				unsigned int blink_table_len)
{
	struct ieee80211_local *local = hw_to_local(hw);
	struct tpt_led_trigger *tpt_trig;

	if (WARN_ON(local->tpt_led_trigger))
		return NULL;

	tpt_trig = kzalloc(sizeof(struct tpt_led_trigger), GFP_KERNEL);
	if (!tpt_trig)
		return NULL;

	snprintf(tpt_trig->name, sizeof(tpt_trig->name),
		 "%stpt", wiphy_name(local->hw.wiphy));

	tpt_trig->trig.name = tpt_trig->name;

	tpt_trig->blink_table = blink_table;
	tpt_trig->blink_table_len = blink_table_len;
	tpt_trig->want = flags;

	setup_timer(&tpt_trig->timer, tpt_trig_timer, (unsigned long)local);

	local->tpt_led_trigger = tpt_trig;

	return tpt_trig->name;
}
Beispiel #11
0
static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
{
	struct ieee80211_sub_if_data *sdata;
	struct ieee80211_sta *sta;
	int ret;

	assert_key_lock();
	might_sleep();

	if (!key->local->ops->set_key)
		return;

	sta = get_sta_for_key(key);

	sdata = key->sdata;
	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
		sdata = container_of(sdata->bss,
				     struct ieee80211_sub_if_data,
				     u.ap);

	ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf);

	if (!ret) {
		spin_lock(&todo_lock);
		key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
		spin_unlock(&todo_lock);
	}

	if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
		printk(KERN_ERR "mac80211-%s: failed to set key "
		       "(%d, %pM) to hardware (%d)\n",
		       wiphy_name(key->local->hw.wiphy),
		       key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
}
static int mac80211_hwsim_start(struct ieee80211_hw *hw)
{
	struct mac80211_hwsim_data *data = hw->priv;
	printk(KERN_DEBUG "%s:%s\n", wiphy_name(hw->wiphy), __func__);
	data->started = 1;
	return 0;
}
Beispiel #13
0
static int orinoco_change_vif(struct wiphy *wiphy, struct net_device *dev,
			      enum nl80211_iftype type, u32 *flags,
			      struct vif_params *params)
{
	struct orinoco_private *priv = wiphy_priv(wiphy);
	int err = 0;
	unsigned long lock;

	if (orinoco_lock(priv, &lock) != 0)
		return -EBUSY;

	switch (type) {
	case NL80211_IFTYPE_ADHOC:
		if (!priv->has_ibss && !priv->has_port3)
			err = -EINVAL;
		break;

	case NL80211_IFTYPE_STATION:
		break;

	case NL80211_IFTYPE_MONITOR:
		if (priv->broken_monitor && !force_monitor) {
<<<<<<< HEAD
			wiphy_warn(wiphy,
				   "Monitor mode support is buggy in this firmware, not enabling\n");
=======
			printk(KERN_WARNING "%s: Monitor mode support is "
			       "buggy in this firmware, not enabling\n",
			       wiphy_name(wiphy));
>>>>>>> 296c66da8a02d52243f45b80521febece5ed498a
int cw1200_register_common(struct ieee80211_hw *dev)
{
	struct cw1200_common *priv = dev->priv;
	int err;

	err = cw1200_pm_init(&priv->pm_state, priv);
	if (err) {
		cw1200_dbg(CW1200_DBG_ERROR, "Cannot init PM. (%d).\n",
				err);
		return err;
	}

	err = ieee80211_register_hw(dev);
	if (err) {
		cw1200_dbg(CW1200_DBG_ERROR, "Cannot register device (%d).\n",
				err);
		cw1200_pm_deinit(&priv->pm_state);
		return err;
	}

#ifdef CONFIG_CW1200_LEDS
	err = cw1200_init_leds(priv);
	if (err) {
		cw1200_pm_deinit(&priv->pm_state);
		ieee80211_unregister_hw(dev);
		return err;
	}
#endif /* CONFIG_CW1200_LEDS */

	cw1200_debug_init(priv);

	cw1200_dbg(CW1200_DBG_MSG, "is registered as '%s'\n",
			wiphy_name(dev->wiphy));
	return 0;
}
Beispiel #15
0
/*
 * ath9k version of ieee80211_tx_status() for TX frames that are generated
 * internally in the driver.
 */
void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
{
	struct ath_wiphy *aphy = hw->priv;
	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
	struct ath_tx_info_priv *tx_info_priv = ATH_TX_INFO_PRIV(tx_info);

	if (tx_info_priv && tx_info_priv->frame_type == ATH9K_INT_PAUSE &&
	    aphy->state == ATH_WIPHY_PAUSING) {
		if (!(info->flags & IEEE80211_TX_STAT_ACK)) {
			printk(KERN_DEBUG "ath9k: %s: no ACK for pause "
			       "frame\n", wiphy_name(hw->wiphy));
			/*
			 * The AP did not reply; ignore this to allow us to
			 * continue.
			 */
		}
		aphy->state = ATH_WIPHY_PAUSED;
		if (!ath9k_wiphy_pausing(aphy->sc)) {
			/*
			 * Drop from tasklet to work to allow mutex for channel
			 * change.
			 */
			queue_work(aphy->sc->hw->workqueue,
				   &aphy->sc->chan_work);
		}
	}

	kfree(tx_info_priv);
	tx_info->rate_driver_data[0] = NULL;

	dev_kfree_skb(skb);
}
Beispiel #16
0
/*
 * ath9k version of ieee80211_tx_status() for TX frames that are generated
 * internally in the driver.
 */
void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, int ftype)
{
	struct ath_wiphy *aphy = hw->priv;
	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);

	if (ftype == ATH9K_IFT_PAUSE && aphy->state == ATH_WIPHY_PAUSING) {
		if (!(tx_info->flags & IEEE80211_TX_STAT_ACK)) {
			printk(KERN_DEBUG "ath9k: %s: no ACK for pause "
			       "frame\n", wiphy_name(hw->wiphy));
			/*
			 * The AP did not reply; ignore this to allow us to
			 * continue.
			 */
		}
		aphy->state = ATH_WIPHY_PAUSED;
		if (!ath9k_wiphy_pausing(aphy->sc)) {
			/*
			 * Drop from tasklet to work to allow mutex for channel
			 * change.
			 */
			ieee80211_queue_work(aphy->sc->hw,
				   &aphy->sc->chan_work);
		}
	}

	dev_kfree_skb(skb);
}
Beispiel #17
0
static int carl9170_led_register_led(struct ar9170 *ar, int i, char *name,
				     char *trigger)
{
	int err;

	snprintf(ar->leds[i].name, sizeof(ar->leds[i].name),
		 "carl9170-%s::%s", wiphy_name(ar->hw->wiphy), name);

	ar->leds[i].ar = ar;
	ar->leds[i].l.name = ar->leds[i].name;
	ar->leds[i].l.brightness_set = carl9170_led_set_brightness;
	ar->leds[i].l.brightness = 0;
	ar->leds[i].l.default_trigger = trigger;

	err = led_classdev_register(wiphy_dev(ar->hw->wiphy),
				    &ar->leds[i].l);
	if (err) {
		wiphy_err(ar->hw->wiphy, "failed to register %s LED (%d).\n",
			ar->leds[i].name, err);
	} else {
		ar->leds[i].registered = true;
	}

	return err;
}
Beispiel #18
0
Datei: key.c Projekt: DINKIN/tuo
static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
{
	const u8 *addr;
	int ret;
	DECLARE_MAC_BUF(mac);

	assert_key_lock();
	might_sleep();

	if (!key || !key->local->ops->set_key)
		return;

	spin_lock(&todo_lock);
	if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
		spin_unlock(&todo_lock);
		return;
	}
	spin_unlock(&todo_lock);

	addr = get_mac_for_key(key);

	ret = key->local->ops->set_key(local_to_hw(key->local), DISABLE_KEY,
				       key->sdata->dev->dev_addr, addr,
				       &key->conf);

	if (ret)
		printk(KERN_ERR "mac80211-%s: failed to remove key "
		       "(%d, %s) from hardware (%d)\n",
		       wiphy_name(key->local->hw.wiphy),
		       key->conf.keyidx, print_mac(mac, addr), ret);

	spin_lock(&todo_lock);
	key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
	spin_unlock(&todo_lock);
}
Beispiel #19
0
Datei: key.c Projekt: DINKIN/tuo
static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
{
	const u8 *addr;
	int ret;
	DECLARE_MAC_BUF(mac);

	assert_key_lock();
	might_sleep();

	if (!key->local->ops->set_key)
		return;

	addr = get_mac_for_key(key);

	ret = key->local->ops->set_key(local_to_hw(key->local), SET_KEY,
				       key->sdata->dev->dev_addr, addr,
				       &key->conf);

	if (!ret) {
		spin_lock(&todo_lock);
		key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
		spin_unlock(&todo_lock);
	}

	if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
		printk(KERN_ERR "mac80211-%s: failed to set key "
		       "(%d, %s) to hardware (%d)\n",
		       wiphy_name(key->local->hw.wiphy),
		       key->conf.keyidx, print_mac(mac, addr), ret);
}
Beispiel #20
0
static int p54_register_led(struct p54_common *priv,
			    unsigned int led_index,
			    char *name, char *trigger)
{
	struct p54_led_dev *led = &priv->leds[led_index];
	int err;

	if (led->registered)
		return -EEXIST;

	snprintf(led->name, sizeof(led->name), "p54-%s::%s",
		 wiphy_name(priv->hw->wiphy), name);
	led->hw_dev = priv->hw;
	led->index = led_index;
	led->led_dev.name = led->name;
	led->led_dev.default_trigger = trigger;
	led->led_dev.brightness_set = p54_led_brightness_set;

	err = led_classdev_register(wiphy_dev(priv->hw->wiphy), &led->led_dev);
	if (err)
		wiphy_err(priv->hw->wiphy,
			  "failed to register %s led.\n", name);
	else
		led->registered = 1;

	return err;
}
Beispiel #21
0
static int p54p_open(struct ieee80211_hw *dev)
{
	struct p54p_priv *priv = dev->priv;
	int err;

	init_completion(&priv->boot_comp);
	err = request_irq(priv->pdev->irq, p54p_interrupt,
			  IRQF_SHARED, "p54pci", dev);
	if (err) {
		dev_err(&priv->pdev->dev, "failed to register IRQ handler\n");
		return err;
	}

	memset(priv->ring_control, 0, sizeof(*priv->ring_control));
	err = p54p_upload_firmware(dev);
	if (err) {
		free_irq(priv->pdev->irq, dev);
		return err;
	}
	priv->rx_idx_data = priv->tx_idx_data = 0;
	priv->rx_idx_mgmt = priv->tx_idx_mgmt = 0;

	p54p_refill_rx_ring(dev, 0, priv->ring_control->rx_data,
		ARRAY_SIZE(priv->ring_control->rx_data), priv->rx_buf_data);

	p54p_refill_rx_ring(dev, 2, priv->ring_control->rx_mgmt,
		ARRAY_SIZE(priv->ring_control->rx_mgmt), priv->rx_buf_mgmt);

	P54P_WRITE(ring_control_base, cpu_to_le32(priv->ring_control_dma));
	P54P_READ(ring_control_base);
	wmb();
	udelay(10);

	P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_INIT));
	P54P_READ(int_enable);
	wmb();
	udelay(10);

	P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
	P54P_READ(dev_int);

	if (!wait_for_completion_interruptible_timeout(&priv->boot_comp, HZ)) {
		printk(KERN_ERR "%s: Cannot boot firmware!\n",
		       wiphy_name(dev->wiphy));
		p54p_stop(dev);
		return -ETIMEDOUT;
	}

	P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_UPDATE));
	P54P_READ(int_enable);
	wmb();
	udelay(10);

	P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
	P54P_READ(dev_int);
	wmb();
	udelay(10);

	return 0;
}
static void mac80211_hwsim_remove_interface(
	struct ieee80211_hw *hw, struct ieee80211_if_init_conf *conf)
{
	DECLARE_MAC_BUF(mac);
	printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n",
	       wiphy_name(hw->wiphy), __func__, conf->type,
	       print_mac(mac, conf->mac_addr));
}
Beispiel #23
0
void ieee80211_led_init(struct ieee80211_local *local)
{
	local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
	if (local->rx_led) {
		snprintf(local->rx_led_name, sizeof(local->rx_led_name),
			 "%srx", wiphy_name(local->hw.wiphy));
		local->rx_led->name = local->rx_led_name;
		if (led_trigger_register(local->rx_led)) {
			kfree(local->rx_led);
			local->rx_led = NULL;
		}
	}

	local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
	if (local->tx_led) {
		snprintf(local->tx_led_name, sizeof(local->tx_led_name),
			 "%stx", wiphy_name(local->hw.wiphy));
		local->tx_led->name = local->tx_led_name;
		if (led_trigger_register(local->tx_led)) {
			kfree(local->tx_led);
			local->tx_led = NULL;
		}
	}

	local->assoc_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
	if (local->assoc_led) {
		snprintf(local->assoc_led_name, sizeof(local->assoc_led_name),
			 "%sassoc", wiphy_name(local->hw.wiphy));
		local->assoc_led->name = local->assoc_led_name;
		if (led_trigger_register(local->assoc_led)) {
			kfree(local->assoc_led);
			local->assoc_led = NULL;
		}
	}

	local->radio_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
	if (local->radio_led) {
		snprintf(local->radio_led_name, sizeof(local->radio_led_name),
			 "%sradio", wiphy_name(local->hw.wiphy));
		local->radio_led->name = local->radio_led_name;
		if (led_trigger_register(local->radio_led)) {
			kfree(local->radio_led);
			local->radio_led = NULL;
		}
	}
}
void rt2x00leds_register(struct rt2x00_dev *rt2x00dev)
{
	char dev_name[16];
	char name[32];
	int retval;
	unsigned long on_period;
	unsigned long off_period;

	snprintf(dev_name, sizeof(dev_name), "%s-%s",
		 rt2x00dev->ops->name, wiphy_name(rt2x00dev->hw->wiphy));

	if (rt2x00dev->led_radio.flags & LED_INITIALIZED) {
		snprintf(name, sizeof(name), "%s::radio", dev_name);

		retval = rt2x00leds_register_led(rt2x00dev,
						 &rt2x00dev->led_radio,
						 name);
		if (retval)
			goto exit_fail;
	}

	if (rt2x00dev->led_assoc.flags & LED_INITIALIZED) {
		snprintf(name, sizeof(name), "%s::assoc", dev_name);

		retval = rt2x00leds_register_led(rt2x00dev,
						 &rt2x00dev->led_assoc,
						 name);
		if (retval)
			goto exit_fail;
	}

	if (rt2x00dev->led_qual.flags & LED_INITIALIZED) {
		snprintf(name, sizeof(name), "%s::quality", dev_name);

		retval = rt2x00leds_register_led(rt2x00dev,
						 &rt2x00dev->led_qual,
						 name);
		if (retval)
			goto exit_fail;
	}

	/*
	 * Initialize blink time to default value:
	 * On period: 70ms
	 * Off period: 30ms
	 */
	if (rt2x00dev->led_radio.led_dev.blink_set) {
		on_period = 70;
		off_period = 30;
		rt2x00dev->led_radio.led_dev.blink_set(
		    &rt2x00dev->led_radio.led_dev, &on_period, &off_period);
	}

	return;

exit_fail:
	rt2x00leds_unregister(rt2x00dev);
}
Beispiel #25
0
int ath9k_init_debug(struct ath_hw *ah)
{
	struct ath_common *common = ath9k_hw_common(ah);
	struct ath_softc *sc = (struct ath_softc *) common->priv;

	if (!ath9k_debugfs_root)
		return -ENOENT;

	sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
						      ath9k_debugfs_root);
	if (!sc->debug.debugfs_phy)
		goto err;

#ifdef CONFIG_ATH_DEBUG
	sc->debug.debugfs_debug = debugfs_create_file("debug",
		S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug);
	if (!sc->debug.debugfs_debug)
		goto err;
#endif

	sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR,
				       sc->debug.debugfs_phy, sc, &fops_dma);
	if (!sc->debug.debugfs_dma)
		goto err;

	sc->debug.debugfs_interrupt = debugfs_create_file("interrupt",
						     S_IRUSR,
						     sc->debug.debugfs_phy,
						     sc, &fops_interrupt);
	if (!sc->debug.debugfs_interrupt)
		goto err;

	sc->debug.debugfs_rcstat = debugfs_create_file("rcstat",
						  S_IRUSR,
						  sc->debug.debugfs_phy,
						  sc, &fops_rcstat);
	if (!sc->debug.debugfs_rcstat)
		goto err;

	sc->debug.debugfs_wiphy = debugfs_create_file(
		"wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc,
		&fops_wiphy);
	if (!sc->debug.debugfs_wiphy)
		goto err;

	sc->debug.debugfs_xmit = debugfs_create_file("xmit",
						     S_IRUSR,
						     sc->debug.debugfs_phy,
						     sc, &fops_xmit);
	if (!sc->debug.debugfs_xmit)
		goto err;

	return 0;
err:
	ath9k_exit_debug(ah);
	return -ENOMEM;
}
Beispiel #26
0
/* caller must hold wiphy_lock */
void ath9k_set_wiphy_idle(struct ath_wiphy *aphy, bool idle)
{
	struct ath_softc *sc = aphy->sc;

	aphy->idle = idle;
	ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
		"Marking %s as %sidle\n",
		wiphy_name(aphy->hw->wiphy), idle ? "" : "not-");
}
Beispiel #27
0
int ath9k_init_debug(struct ath_softc *sc)
{
    sc->debug.debug_mask = ath9k_debug;

    if (!ath9k_debugfs_root)
        return -ENOENT;

    sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
                            ath9k_debugfs_root);
    if (!sc->debug.debugfs_phy)
        goto err;

    sc->debug.debugfs_debug = debugfs_create_file("debug",
                              S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug);
    if (!sc->debug.debugfs_debug)
        goto err;

    sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR,
                            sc->debug.debugfs_phy, sc, &fops_dma);
    if (!sc->debug.debugfs_dma)
        goto err;

    sc->debug.debugfs_interrupt = debugfs_create_file("interrupt",
                                  S_IRUSR,
                                  sc->debug.debugfs_phy,
                                  sc, &fops_interrupt);
    if (!sc->debug.debugfs_interrupt)
        goto err;

    sc->debug.debugfs_rcstat = debugfs_create_file("rcstat",
                               S_IRUSR,
                               sc->debug.debugfs_phy,
                               sc, &fops_rcstat);
    if (!sc->debug.debugfs_rcstat)
        goto err;

    sc->debug.debugfs_wiphy = debugfs_create_file(
                                  "wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc,
                                  &fops_wiphy);
    if (!sc->debug.debugfs_wiphy)
        goto err;

    sc->debug.debugfs_xmit = debugfs_create_file("xmit",
                             S_IRUSR,
                             sc->debug.debugfs_phy,
                             sc, &fops_xmit);
    if (!sc->debug.debugfs_xmit)
        goto err;

    return 0;
err:
    ath9k_exit_debug(sc);
    return -ENOMEM;
}
Beispiel #28
0
int ath5k_init_leds(struct ath5k_hw *ah)
{
	int ret = 0;
	struct ieee80211_hw *hw = ah->hw;
#ifndef CONFIG_ATHEROS_AR231X
	struct pci_dev *pdev = ah->pdev;
#endif
	char name[ATH5K_LED_MAX_NAME_LEN + 1];
	const struct pci_device_id *match;

	if (!ah->pdev)
		return 0;

#ifdef CONFIG_ATHEROS_AR231X
	match = NULL;
#else
	match = pci_match_id(&ath5k_led_devices[0], pdev);
#endif
	if (match) {
		__set_bit(ATH_STAT_LEDSOFT, ah->status);
		ah->led_pin = ATH_PIN(match->driver_data);
		ah->led_on = ATH_POLARITY(match->driver_data);
	}

	if (!test_bit(ATH_STAT_LEDSOFT, ah->status))
		goto out;

	ath5k_led_enable(ah);

	snprintf(name, sizeof(name), "ath5k-%s::rx", wiphy_name(hw->wiphy));
	ret = ath5k_register_led(ah, &ah->rx_led, name,
		ieee80211_get_rx_led_name(hw));
	if (ret)
		goto out;

	snprintf(name, sizeof(name), "ath5k-%s::tx", wiphy_name(hw->wiphy));
	ret = ath5k_register_led(ah, &ah->tx_led, name,
		ieee80211_get_tx_led_name(hw));
out:
	return ret;
}
Beispiel #29
0
int ar9170_write_mem(struct ar9170 *ar, const __le32 *data, size_t len)
{
	int err;

	if (unlikely(!IS_ACCEPTING_CMD(ar)))
		return 0;

	err = ar->exec_cmd(ar, AR9170_CMD_WMEM, len, (u8 *) data, 0, NULL);
	if (err)
		printk(KERN_DEBUG "%s: writing memory failed\n",
		       wiphy_name(ar->hw->wiphy));
	return err;
}
Beispiel #30
0
static int r92su_register_wps_button(struct r92su *r92su)
{
#ifdef CONFIG_R92SU_WPC
	struct input_dev *input;
	char *name, *phys;
	int err;

	name = devm_kzalloc(&r92su->wdev.wiphy->dev, NAME_LEN, GFP_KERNEL);
	phys = devm_kzalloc(&r92su->wdev.wiphy->dev, NAME_LEN, GFP_KERNEL);

	input = input_allocate_device();
	if (!input || !name || !phys)
		return -ENOMEM;

	snprintf(name, NAME_LEN, "%s WPS Button",
		 wiphy_name(r92su->wdev.wiphy));

	snprintf(phys, NAME_LEN, "ieee80211/%s/input0",
		 wiphy_name(r92su->wdev.wiphy));

	input->name = name;
	input->name = phys;
	input->id.bustype = BUS_USB; /* SDIO */
	input->dev.parent = &r92su->wdev.wiphy->dev;

	input_set_capability(input, EV_KEY, KEY_WPS_BUTTON);

	err = input_register_device(input);
	if (err) {
		input_free_device(input);
		return err;
	}
	r92su->wps_pbc = input;
#endif /* CONFIG_R92SU_WPC */

	return 0;
}