qcacld-3.0: Add support to save and get interface device

A bus can have multiple sub interfaces or pipes.
USB bus for example has endpoints grouped into interfaces.
WLAN uses one of these interfaces.
Each interface has its own "struct device". Add support to save
and retrieve this "struct device".
Also pass interface dev to pld_usb_wlan_enable() as CNSS expects
interface device.

Change-Id: I5800bde107157c35efed848a23b95696bd7f793a
CRs-Fixed: 2371440
This commit is contained in:
Ajit Pal Singh
2018-12-20 17:47:36 +05:30
committed by nshrivas
parent 844da097fc
commit 5e618aa8c4
6 changed files with 57 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for * Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the * any purpose with or without fee is hereby granted, provided that the
@@ -116,13 +116,15 @@ struct pld_context *pld_get_global_context(void)
* pld_add_dev() - Add dev node to global context * pld_add_dev() - Add dev node to global context
* @pld_context: PLD global context * @pld_context: PLD global context
* @dev: device * @dev: device
* @ifdev: interface device
* @type: Bus type * @type: Bus type
* *
* Return: 0 for success * Return: 0 for success
* Non zero failure code for errors * Non zero failure code for errors
*/ */
int pld_add_dev(struct pld_context *pld_context, int pld_add_dev(struct pld_context *pld_context,
struct device *dev, enum pld_bus_type type) struct device *dev, struct device *ifdev,
enum pld_bus_type type)
{ {
unsigned long flags; unsigned long flags;
struct dev_node *dev_node; struct dev_node *dev_node;
@@ -132,6 +134,7 @@ int pld_add_dev(struct pld_context *pld_context,
return -ENOMEM; return -ENOMEM;
dev_node->dev = dev; dev_node->dev = dev;
dev_node->ifdev = ifdev;
dev_node->bus_type = type; dev_node->bus_type = type;
spin_lock_irqsave(&pld_context->pld_lock, flags); spin_lock_irqsave(&pld_context->pld_lock, flags);
@@ -164,13 +167,7 @@ void pld_del_dev(struct pld_context *pld_context,
spin_unlock_irqrestore(&pld_context->pld_lock, flags); spin_unlock_irqrestore(&pld_context->pld_lock, flags);
} }
/** static struct dev_node *pld_get_dev_node(struct device *dev)
* pld_get_bus_type() - Bus type of the device
* @dev: device
*
* Return: PLD bus type
*/
static enum pld_bus_type pld_get_bus_type(struct device *dev)
{ {
struct pld_context *pld_context; struct pld_context *pld_context;
struct dev_node *dev_node; struct dev_node *dev_node;
@@ -181,19 +178,51 @@ static enum pld_bus_type pld_get_bus_type(struct device *dev)
if (dev == NULL || pld_context == NULL) { if (dev == NULL || pld_context == NULL) {
pr_err("Invalid info: dev %pK, context %pK\n", pr_err("Invalid info: dev %pK, context %pK\n",
dev, pld_context); dev, pld_context);
return PLD_BUS_TYPE_NONE; return NULL;
} }
spin_lock_irqsave(&pld_context->pld_lock, flags); spin_lock_irqsave(&pld_context->pld_lock, flags);
list_for_each_entry(dev_node, &pld_context->dev_list, list) { list_for_each_entry(dev_node, &pld_context->dev_list, list) {
if (dev_node->dev == dev) { if (dev_node->dev == dev) {
spin_unlock_irqrestore(&pld_context->pld_lock, flags); spin_unlock_irqrestore(&pld_context->pld_lock, flags);
return dev_node->bus_type; return dev_node;
} }
} }
spin_unlock_irqrestore(&pld_context->pld_lock, flags); spin_unlock_irqrestore(&pld_context->pld_lock, flags);
return PLD_BUS_TYPE_NONE; return NULL;
}
/**
* pld_get_bus_type() - Bus type of the device
* @dev: device
*
* Return: PLD bus type
*/
static enum pld_bus_type pld_get_bus_type(struct device *dev)
{
struct dev_node *dev_node = pld_get_dev_node(dev);
if (dev_node)
return dev_node->bus_type;
else
return PLD_BUS_TYPE_NONE;
}
/**
* pld_get_if_dev() - Bus interface/pipe dev of the device
* @dev: device
*
* Return: Bus sub-interface or pipe dev.
*/
static struct device *pld_get_if_dev(struct device *dev)
{
struct dev_node *dev_node = pld_get_dev_node(dev);
if (dev_node)
return dev_node->ifdev;
else
return NULL;
} }
/** /**
@@ -332,6 +361,7 @@ int pld_wlan_enable(struct device *dev, struct pld_wlan_enable_cfg *config,
enum pld_driver_mode mode, const char *host_version) enum pld_driver_mode mode, const char *host_version)
{ {
int ret = 0; int ret = 0;
struct device *ifdev;
switch (pld_get_bus_type(dev)) { switch (pld_get_bus_type(dev)) {
case PLD_BUS_TYPE_PCIE: case PLD_BUS_TYPE_PCIE:
@@ -343,7 +373,8 @@ int pld_wlan_enable(struct device *dev, struct pld_wlan_enable_cfg *config,
case PLD_BUS_TYPE_SDIO: case PLD_BUS_TYPE_SDIO:
break; break;
case PLD_BUS_TYPE_USB: case PLD_BUS_TYPE_USB:
ret = pld_usb_wlan_enable(dev, config, mode, host_version); ifdev = pld_get_if_dev(dev);
ret = pld_usb_wlan_enable(ifdev, config, mode, host_version);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016 The Linux Foundation. All rights reserved. * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for * Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the * any purpose with or without fee is hereby granted, provided that the
@@ -23,6 +23,7 @@
struct dev_node { struct dev_node {
struct device *dev; struct device *dev;
struct device *ifdev;
struct list_head list; struct list_head list;
enum pld_bus_type bus_type; enum pld_bus_type bus_type;
}; };
@@ -36,7 +37,8 @@ struct pld_context {
struct pld_context *pld_get_global_context(void); struct pld_context *pld_get_global_context(void);
int pld_add_dev(struct pld_context *pld_context, int pld_add_dev(struct pld_context *pld_context,
struct device *dev, enum pld_bus_type type); struct device *dev, struct device *ifdev,
enum pld_bus_type type);
void pld_del_dev(struct pld_context *pld_context, void pld_del_dev(struct pld_context *pld_context,
struct device *dev); struct device *dev);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for * Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the * any purpose with or without fee is hereby granted, provided that the
@@ -59,7 +59,7 @@ static int pld_pcie_probe(struct pci_dev *pdev,
goto out; goto out;
} }
ret = pld_add_dev(pld_context, &pdev->dev, PLD_BUS_TYPE_PCIE); ret = pld_add_dev(pld_context, &pdev->dev, NULL, PLD_BUS_TYPE_PCIE);
if (ret) if (ret)
goto out; goto out;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for * Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the * any purpose with or without fee is hereby granted, provided that the
@@ -85,7 +85,7 @@ static int pld_sdio_probe(struct sdio_func *sdio_func,
} }
dev = &sdio_func->dev; dev = &sdio_func->dev;
ret = pld_add_dev(pld_context, dev, PLD_BUS_TYPE_SDIO); ret = pld_add_dev(pld_context, dev, NULL, PLD_BUS_TYPE_SDIO);
if (ret) if (ret)
goto out; goto out;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for * Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the * any purpose with or without fee is hereby granted, provided that the
@@ -49,7 +49,7 @@ static int pld_snoc_probe(struct device *dev)
goto out; goto out;
} }
ret = pld_add_dev(pld_context, dev, PLD_BUS_TYPE_SNOC); ret = pld_add_dev(pld_context, dev, NULL, PLD_BUS_TYPE_SNOC);
if (ret) if (ret)
goto out; goto out;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for * Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the * any purpose with or without fee is hereby granted, provided that the
@@ -59,7 +59,8 @@ static int pld_usb_probe(struct usb_interface *interface,
goto out; goto out;
} }
ret = pld_add_dev(pld_context, &pdev->dev, PLD_BUS_TYPE_USB); ret = pld_add_dev(pld_context, &pdev->dev, &interface->dev,
PLD_BUS_TYPE_USB);
if (ret) if (ret)
goto out; goto out;