Commit 2e02b581 authored by Rajat Jain's avatar Rajat Jain Committed by Kalle Valo

mwifiex: Allow mwifiex early access to device structure

Today all the interface drivers (usb/pcie/sdio) assign the
adapter->dev in the register_dev() callback, although they
have this piece of info well before hand.

This patch makes the device structure available for mwifiex
right at the beginning, so that it can be used for early
initialization if needed.

This is needed for subsequent patches in this patchset that
intend to unify and consolidate some of the code that would
otherwise have to be duplicated among the interface drivers
(sdio, pcie, usb).
Signed-off-by: default avatarRajat Jain <rajatja@google.com>
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 6b4480d1
...@@ -1567,7 +1567,8 @@ EXPORT_SYMBOL_GPL(mwifiex_do_flr); ...@@ -1567,7 +1567,8 @@ EXPORT_SYMBOL_GPL(mwifiex_do_flr);
*/ */
int int
mwifiex_add_card(void *card, struct semaphore *sem, mwifiex_add_card(void *card, struct semaphore *sem,
struct mwifiex_if_ops *if_ops, u8 iface_type) struct mwifiex_if_ops *if_ops, u8 iface_type,
struct device *dev)
{ {
struct mwifiex_adapter *adapter; struct mwifiex_adapter *adapter;
...@@ -1579,6 +1580,7 @@ mwifiex_add_card(void *card, struct semaphore *sem, ...@@ -1579,6 +1580,7 @@ mwifiex_add_card(void *card, struct semaphore *sem,
goto err_init_sw; goto err_init_sw;
} }
adapter->dev = dev;
adapter->iface_type = iface_type; adapter->iface_type = iface_type;
adapter->card_sem = sem; adapter->card_sem = sem;
......
...@@ -1412,7 +1412,9 @@ static inline u8 mwifiex_is_tdls_link_setup(u8 status) ...@@ -1412,7 +1412,9 @@ static inline u8 mwifiex_is_tdls_link_setup(u8 status)
int mwifiex_init_shutdown_fw(struct mwifiex_private *priv, int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
u32 func_init_shutdown); u32 func_init_shutdown);
int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8); int mwifiex_add_card(void *card, struct semaphore *sem,
struct mwifiex_if_ops *if_ops, u8 iface_type,
struct device *dev);
int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *); int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version, void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
......
...@@ -231,7 +231,7 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev, ...@@ -231,7 +231,7 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
} }
if (mwifiex_add_card(card, &add_remove_card_sem, &pcie_ops, if (mwifiex_add_card(card, &add_remove_card_sem, &pcie_ops,
MWIFIEX_PCIE)) { MWIFIEX_PCIE, &pdev->dev)) {
pr_err("%s failed\n", __func__); pr_err("%s failed\n", __func__);
return -1; return -1;
} }
...@@ -2992,11 +2992,9 @@ static void mwifiex_pcie_get_fw_name(struct mwifiex_adapter *adapter) ...@@ -2992,11 +2992,9 @@ static void mwifiex_pcie_get_fw_name(struct mwifiex_adapter *adapter)
static int mwifiex_register_dev(struct mwifiex_adapter *adapter) static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
{ {
struct pcie_service_card *card = adapter->card; struct pcie_service_card *card = adapter->card;
struct pci_dev *pdev = card->dev;
/* save adapter pointer in card */ /* save adapter pointer in card */
card->adapter = adapter; card->adapter = adapter;
adapter->dev = &pdev->dev;
if (mwifiex_pcie_request_irq(adapter)) if (mwifiex_pcie_request_irq(adapter))
return -1; return -1;
......
...@@ -206,7 +206,7 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) ...@@ -206,7 +206,7 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
} }
ret = mwifiex_add_card(card, &add_remove_card_sem, &sdio_ops, ret = mwifiex_add_card(card, &add_remove_card_sem, &sdio_ops,
MWIFIEX_SDIO); MWIFIEX_SDIO, &func->dev);
if (ret) { if (ret) {
dev_err(&func->dev, "add card failed\n"); dev_err(&func->dev, "add card failed\n");
goto err_disable; goto err_disable;
...@@ -2104,9 +2104,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) ...@@ -2104,9 +2104,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
return ret; return ret;
} }
adapter->dev = &func->dev;
strcpy(adapter->fw_name, card->firmware); strcpy(adapter->fw_name, card->firmware);
if (card->fw_dump_enh) { if (card->fw_dump_enh) {
adapter->mem_type_mapping_tbl = generic_mem_type_map; adapter->mem_type_mapping_tbl = generic_mem_type_map;
......
...@@ -476,7 +476,7 @@ static int mwifiex_usb_probe(struct usb_interface *intf, ...@@ -476,7 +476,7 @@ static int mwifiex_usb_probe(struct usb_interface *intf,
usb_set_intfdata(intf, card); usb_set_intfdata(intf, card);
ret = mwifiex_add_card(card, &add_remove_card_sem, &usb_ops, ret = mwifiex_add_card(card, &add_remove_card_sem, &usb_ops,
MWIFIEX_USB); MWIFIEX_USB, &card->udev->dev);
if (ret) { if (ret) {
pr_err("%s: mwifiex_add_card failed: %d\n", __func__, ret); pr_err("%s: mwifiex_add_card failed: %d\n", __func__, ret);
usb_reset_device(udev); usb_reset_device(udev);
...@@ -927,7 +927,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) ...@@ -927,7 +927,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; struct usb_card_rec *card = (struct usb_card_rec *)adapter->card;
card->adapter = adapter; card->adapter = adapter;
adapter->dev = &card->udev->dev;
switch (le16_to_cpu(card->udev->descriptor.idProduct)) { switch (le16_to_cpu(card->udev->descriptor.idProduct)) {
case USB8997_PID_1: case USB8997_PID_1:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment