Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be9d0d3f authored by Lubomir Rintel's avatar Lubomir Rintel Committed by Kalle Valo
Browse files

libertas_tf: move hardware callbacks to a separate structure



We'll need to talk to the firmware to get a hardware address before
device is registered with ieee80211 subsystem at the end of
lbtf_add_card(). Hooking the callbacks after that is too late.

Signed-off-by: default avatarLubomir Rintel <lkundrak@v3.sk>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent e0a8ef4d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -256,7 +256,7 @@ static void lbtf_submit_command(struct lbtf_private *priv,
		     command, le16_to_cpu(cmd->seqnum), cmdsize);
		     command, le16_to_cpu(cmd->seqnum), cmdsize);
	lbtf_deb_hex(LBTF_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsize);
	lbtf_deb_hex(LBTF_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsize);


	ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);
	ret = priv->ops->hw_host_to_card(priv, MVMS_CMD, (u8 *)cmd, cmdsize);
	spin_unlock_irqrestore(&priv->driver_lock, flags);
	spin_unlock_irqrestore(&priv->driver_lock, flags);


	if (ret) {
	if (ret) {
+7 −5
Original line number Original line Diff line number Diff line
@@ -131,6 +131,12 @@ static void if_usb_fw_timeo(struct timer_list *t)
	lbtf_deb_leave(LBTF_DEB_USB);
	lbtf_deb_leave(LBTF_DEB_USB);
}
}


static const struct lbtf_ops if_usb_ops = {
	.hw_host_to_card = if_usb_host_to_card,
	.hw_prog_firmware = if_usb_prog_firmware,
	.hw_reset_device = if_usb_reset_device,
};

/**
/**
 *  if_usb_probe - sets the configuration values
 *  if_usb_probe - sets the configuration values
 *
 *
@@ -216,15 +222,11 @@ static int if_usb_probe(struct usb_interface *intf,
		goto dealloc;
		goto dealloc;
	}
	}


	priv = lbtf_add_card(cardp, &udev->dev);
	priv = lbtf_add_card(cardp, &udev->dev, &if_usb_ops);
	if (!priv)
	if (!priv)
		goto dealloc;
		goto dealloc;


	cardp->priv = priv;
	cardp->priv = priv;

	priv->hw_host_to_card = if_usb_host_to_card;
	priv->hw_prog_firmware = if_usb_prog_firmware;
	priv->hw_reset_device = if_usb_reset_device;
	cardp->boot2_version = udev->descriptor.bcdDevice;
	cardp->boot2_version = udev->descriptor.bcdDevice;


	usb_get_dev(udev);
	usb_get_dev(udev);
+11 −6
Original line number Original line Diff line number Diff line
@@ -173,10 +173,19 @@ struct channel_range {


struct if_usb_card;
struct if_usb_card;


struct lbtf_ops {
	/** Hardware access */
	int (*hw_host_to_card)(struct lbtf_private *priv, u8 type,
			       u8 *payload, u16 nb);
	int (*hw_prog_firmware)(struct if_usb_card *cardp);
	int (*hw_reset_device)(struct if_usb_card *cardp);
};

/** Private structure for the MV device */
/** Private structure for the MV device */
struct lbtf_private {
struct lbtf_private {
	void *card;
	void *card;
	struct ieee80211_hw *hw;
	struct ieee80211_hw *hw;
	const struct lbtf_ops *ops;


	/* Command response buffer */
	/* Command response buffer */
	u8 cmd_resp_buff[LBS_UPLD_SIZE];
	u8 cmd_resp_buff[LBS_UPLD_SIZE];
@@ -188,11 +197,6 @@ struct lbtf_private {


	struct work_struct cmd_work;
	struct work_struct cmd_work;
	struct work_struct tx_work;
	struct work_struct tx_work;
	/** Hardware access */
	int (*hw_host_to_card) (struct lbtf_private *priv, u8 type, u8 *payload, u16 nb);
	int (*hw_prog_firmware) (struct if_usb_card *cardp);
	int (*hw_reset_device) (struct if_usb_card *cardp);



	/** Wlan adapter data structure*/
	/** Wlan adapter data structure*/
	/** STATUS variables */
	/** STATUS variables */
@@ -486,7 +490,8 @@ void lbtf_cmd_response_rx(struct lbtf_private *priv);
/* main.c */
/* main.c */
struct chan_freq_power *lbtf_get_region_cfp_table(u8 region,
struct chan_freq_power *lbtf_get_region_cfp_table(u8 region,
	int *cfp_no);
	int *cfp_no);
struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev);
struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev,
				   const struct lbtf_ops *ops);
int lbtf_remove_card(struct lbtf_private *priv);
int lbtf_remove_card(struct lbtf_private *priv);
int lbtf_start_card(struct lbtf_private *priv);
int lbtf_start_card(struct lbtf_private *priv);
int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb);
int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb);
+6 −4
Original line number Original line Diff line number Diff line
@@ -281,7 +281,7 @@ static void lbtf_tx_work(struct work_struct *work)
	BUG_ON(priv->tx_skb);
	BUG_ON(priv->tx_skb);
	spin_lock_irq(&priv->driver_lock);
	spin_lock_irq(&priv->driver_lock);
	priv->tx_skb = skb;
	priv->tx_skb = skb;
	err = priv->hw_host_to_card(priv, MVMS_DAT, skb->data, skb->len);
	err = priv->ops->hw_host_to_card(priv, MVMS_DAT, skb->data, skb->len);
	spin_unlock_irq(&priv->driver_lock);
	spin_unlock_irq(&priv->driver_lock);
	if (err) {
	if (err) {
		dev_kfree_skb_any(skb);
		dev_kfree_skb_any(skb);
@@ -301,7 +301,7 @@ static int lbtf_op_start(struct ieee80211_hw *hw)


	if (!priv->fw_ready)
	if (!priv->fw_ready)
		/* Upload firmware */
		/* Upload firmware */
		if (priv->hw_prog_firmware(card))
		if (priv->ops->hw_prog_firmware(card))
			goto err_prog_firmware;
			goto err_prog_firmware;


	/* poke the firmware */
	/* poke the firmware */
@@ -322,7 +322,7 @@ static int lbtf_op_start(struct ieee80211_hw *hw)
	return 0;
	return 0;


err_prog_firmware:
err_prog_firmware:
	priv->hw_reset_device(card);
	priv->ops->hw_reset_device(card);
	lbtf_deb_leave_args(LBTF_DEB_MACOPS, "error programming fw; ret=%d", ret);
	lbtf_deb_leave_args(LBTF_DEB_MACOPS, "error programming fw; ret=%d", ret);
	return ret;
	return ret;
}
}
@@ -603,7 +603,8 @@ EXPORT_SYMBOL_GPL(lbtf_rx);
 *
 *
 *  Returns: pointer to struct lbtf_priv.
 *  Returns: pointer to struct lbtf_priv.
 */
 */
struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev)
struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev,
				   const struct lbtf_ops *ops)
{
{
	struct ieee80211_hw *hw;
	struct ieee80211_hw *hw;
	struct lbtf_private *priv = NULL;
	struct lbtf_private *priv = NULL;
@@ -620,6 +621,7 @@ struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev)


	priv->hw = hw;
	priv->hw = hw;
	priv->card = card;
	priv->card = card;
	priv->ops = ops;
	priv->tx_skb = NULL;
	priv->tx_skb = NULL;


	hw->queues = 1;
	hw->queues = 1;