Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1852974imj; Sun, 10 Feb 2019 11:54:08 -0800 (PST) X-Google-Smtp-Source: AHgI3IafM/hSntf9y9uDgOhshpPPQwYLMu0pSTcJZkIUZ9BmnQdk41qLJw2FoKyNiONmj8mayKLi X-Received: by 2002:a62:4d45:: with SMTP id a66mr14673043pfb.52.1549828448803; Sun, 10 Feb 2019 11:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549828448; cv=none; d=google.com; s=arc-20160816; b=IhT2AcW3K8SQEiQL5gyeXI9uPEni3ETVV9bdZS/tuCueY04sh+4IMIzwYRZ1c7vxU9 Qg2kdJEJ373ZycfxgG1Zcmc1AU38HwtP8RPLt+9QwjTZp/Wy4vdzk9497+v29wd76Q6Q Jl31TwVn5B+mvmkzUMpuwARcUDlrJm13JuNikTYPMKKvTjfhy/L29uIhwryGwrX2GeKq BNKgZZ1GZZj1/TaO5YD2/pi0wj5JgQLr07kfxmAStRXkHnnDeyAVHgLgtSE0K+wsveSs GSTOScUs7pKQ7IcSw8ZQGr1/y7SwAG/pQh+hREbJSSnI6CuvjYO6+oli8uQsVlQ4/B2i 4NDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GK6Kzp0/bDtHIrrKCrgYLpfM0oFU15LZpOr9gfSgPiE=; b=ZsEyN0Mq+EPbvCdjOhThaFOOrJ1tP7/1VyU4zl08feZfjJ9YzAzWZ1FwXbSSeOp9CY Fj2XZT11vTklfXkL7bSxZX2Mr0RcrwsIJUQAWDKZGocTGXDfQysJgVdCPstI3ZoQQ1iX 9OImX+bh94qZIGepABytmH5c4VXHWFliijmaLYEpNsjnkhzkHdDgQ2tgEwdin096AzD0 4hobEAXB6JU6u5cK2qOvEwgoYHjJo5cmGgOMhLhsEtGncaj2vC7YFJ/ecvCv42xIgKq2 8222RElZc/HHTyp4XG67ZPvk0aFjbDJ4wHCQ1Lyo/CgJOqeXRYJPb08hXAgL5bBCdgTc Mkog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c63si8486507pfa.121.2019.02.10.11.53.52; Sun, 10 Feb 2019 11:54:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727059AbfBJTwq (ORCPT + 99 others); Sun, 10 Feb 2019 14:52:46 -0500 Received: from shell.v3.sk ([90.176.6.54]:42522 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbfBJTwd (ORCPT ); Sun, 10 Feb 2019 14:52:33 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 918D3CE834; Sun, 10 Feb 2019 20:52:30 +0100 (CET) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id NQQVbHELpq97; Sun, 10 Feb 2019 20:52:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 4749ECE838; Sun, 10 Feb 2019 20:52:21 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id P_nI234joZzG; Sun, 10 Feb 2019 20:52:20 +0100 (CET) Received: from nedofet.lan (ip-89-102-31-34.net.upcbroadband.cz [89.102.31.34]) by zimbra.v3.sk (Postfix) with ESMTPSA id 45EEDCE832; Sun, 10 Feb 2019 20:52:20 +0100 (CET) From: Lubomir Rintel To: Kalle Valo Cc: "David S. Miller" , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Lubomir Rintel Subject: [PATCH 1/3] libertas_tf: move hardware callbacks to a separate structure Date: Sun, 10 Feb 2019 20:52:15 +0100 Message-Id: <20190210195217.18817-2-lkundrak@v3.sk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210195217.18817-1-lkundrak@v3.sk> References: <20190210195217.18817-1-lkundrak@v3.sk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Lubomir Rintel --- drivers/net/wireless/marvell/libertas_tf/cmd.c | 2 +- .../net/wireless/marvell/libertas_tf/if_usb.c | 12 +++++++----- .../wireless/marvell/libertas_tf/libertas_tf.h | 17 +++++++++++------ drivers/net/wireless/marvell/libertas_tf/main.c | 10 ++++++---- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas_tf/cmd.c b/drivers/net= /wireless/marvell/libertas_tf/cmd.c index 64b147dd2432..130f578daafd 100644 --- a/drivers/net/wireless/marvell/libertas_tf/cmd.c +++ b/drivers/net/wireless/marvell/libertas_tf/cmd.c @@ -256,7 +256,7 @@ static void lbtf_submit_command(struct lbtf_private *= priv, command, le16_to_cpu(cmd->seqnum), cmdsize); lbtf_deb_hex(LBTF_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsiz= e); =20 - ret =3D priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize); + ret =3D priv->ops->hw_host_to_card(priv, MVMS_CMD, (u8 *)cmd, cmdsize); spin_unlock_irqrestore(&priv->driver_lock, flags); =20 if (ret) { diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/= net/wireless/marvell/libertas_tf/if_usb.c index 6ede6168bd85..7a5a1a85dcf7 100644 --- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c +++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c @@ -131,6 +131,12 @@ static void if_usb_fw_timeo(struct timer_list *t) lbtf_deb_leave(LBTF_DEB_USB); } =20 +static const struct lbtf_ops if_usb_ops =3D { + .hw_host_to_card =3D if_usb_host_to_card, + .hw_prog_firmware =3D if_usb_prog_firmware, + .hw_reset_device =3D if_usb_reset_device, +}; + /** * if_usb_probe - sets the configuration values * @@ -216,15 +222,11 @@ static int if_usb_probe(struct usb_interface *intf, goto dealloc; } =20 - priv =3D lbtf_add_card(cardp, &udev->dev); + priv =3D lbtf_add_card(cardp, &udev->dev, &if_usb_ops); if (!priv) goto dealloc; =20 cardp->priv =3D priv; - - priv->hw_host_to_card =3D if_usb_host_to_card; - priv->hw_prog_firmware =3D if_usb_prog_firmware; - priv->hw_reset_device =3D if_usb_reset_device; cardp->boot2_version =3D udev->descriptor.bcdDevice; =20 usb_get_dev(udev); diff --git a/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h b/dri= vers/net/wireless/marvell/libertas_tf/libertas_tf.h index ad77b92d0b41..11d5ff68bc5e 100644 --- a/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h +++ b/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h @@ -173,10 +173,19 @@ struct channel_range { =20 struct if_usb_card; =20 +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 */ struct lbtf_private { void *card; struct ieee80211_hw *hw; + const struct lbtf_ops *ops; =20 /* Command response buffer */ u8 cmd_resp_buff[LBS_UPLD_SIZE]; @@ -188,11 +197,6 @@ struct lbtf_private { =20 struct work_struct cmd_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); - =20 /** Wlan adapter data structure*/ /** STATUS variables */ @@ -486,7 +490,8 @@ void lbtf_cmd_response_rx(struct lbtf_private *priv); /* main.c */ struct chan_freq_power *lbtf_get_region_cfp_table(u8 region, 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_start_card(struct lbtf_private *priv); int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb); diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c b/drivers/ne= t/wireless/marvell/libertas_tf/main.c index f93b400db949..8ed3cd158cf5 100644 --- a/drivers/net/wireless/marvell/libertas_tf/main.c +++ b/drivers/net/wireless/marvell/libertas_tf/main.c @@ -281,7 +281,7 @@ static void lbtf_tx_work(struct work_struct *work) BUG_ON(priv->tx_skb); spin_lock_irq(&priv->driver_lock); priv->tx_skb =3D skb; - err =3D priv->hw_host_to_card(priv, MVMS_DAT, skb->data, skb->len); + err =3D priv->ops->hw_host_to_card(priv, MVMS_DAT, skb->data, skb->len)= ; spin_unlock_irq(&priv->driver_lock); if (err) { dev_kfree_skb_any(skb); @@ -301,7 +301,7 @@ static int lbtf_op_start(struct ieee80211_hw *hw) =20 if (!priv->fw_ready) /* Upload firmware */ - if (priv->hw_prog_firmware(card)) + if (priv->ops->hw_prog_firmware(card)) goto err_prog_firmware; =20 /* poke the firmware */ @@ -322,7 +322,7 @@ static int lbtf_op_start(struct ieee80211_hw *hw) return 0; =20 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=3D%d", = ret); return ret; } @@ -605,7 +605,8 @@ EXPORT_SYMBOL_GPL(lbtf_rx); * * 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 lbtf_private *priv =3D NULL; @@ -622,6 +623,7 @@ struct lbtf_private *lbtf_add_card(void *card, struct= device *dmdev) =20 priv->hw =3D hw; priv->card =3D card; + priv->ops =3D ops; priv->tx_skb =3D NULL; =20 hw->queues =3D 1; --=20 2.20.1