Skip to content

Commit

Permalink
net: ipa: don't save the platform device
Browse files Browse the repository at this point in the history
The IPA platform device is now only used as the structure containing
the IPA device structure.  Replace the platform device pointer with
a pointer to the device structure.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alex Elder authored and David S. Miller committed Mar 4, 2024
1 parent 81d65f3 commit 5245f4f
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 79 deletions.
5 changes: 2 additions & 3 deletions drivers/net/ipa/ipa.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
struct clk;
struct icc_path;
struct net_device;
struct platform_device;

struct ipa_power;
struct ipa_smp2p;
Expand All @@ -31,7 +30,7 @@ struct ipa_interrupt;
* struct ipa - IPA information
* @gsi: Embedded GSI structure
* @version: IPA hardware version
* @pdev: Platform device
* @dev: IPA device pointer
* @completion: Used to signal pipeline clear transfer complete
* @nb: Notifier block used for remoteproc SSR
* @notifier: Remoteproc SSR notifier
Expand Down Expand Up @@ -79,7 +78,7 @@ struct ipa_interrupt;
struct ipa {
struct gsi gsi;
enum ipa_version version;
struct platform_device *pdev;
struct device *dev;
struct completion completion;
struct notifier_block nb;
void *notifier;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ipa/ipa_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem,
u32 offset_max = field_max(IP_FLTRT_FLAGS_NHASH_ADDR_FMASK);
u32 size_max = field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK);
const char *table = route ? "route" : "filter";
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
u32 size;

size = route ? ipa->route_count : ipa->filter_count + 1;
Expand Down Expand Up @@ -204,7 +204,7 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem,
/* Validate the memory region that holds headers */
static bool ipa_cmd_header_init_local_valid(struct ipa *ipa)
{
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
const struct ipa_mem *mem;
u32 offset_max;
u32 size_max;
Expand Down Expand Up @@ -256,7 +256,7 @@ static bool ipa_cmd_register_write_offset_valid(struct ipa *ipa,
const char *name, u32 offset)
{
struct ipa_cmd_register_write *payload;
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
u32 offset_max;
u32 bit_count;

Expand Down
29 changes: 14 additions & 15 deletions drivers/net/ipa/ipa_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ static bool ipa_endpoint_data_valid_one(struct ipa *ipa, u32 count,
const struct ipa_gsi_endpoint_data *data)
{
const struct ipa_gsi_endpoint_data *other_data;
struct device *dev = &ipa->pdev->dev;
enum ipa_endpoint_name other_name;
struct device *dev = ipa->dev;

if (ipa_gsi_endpoint_data_empty(data))
return true;
Expand Down Expand Up @@ -388,7 +388,7 @@ static u32 ipa_endpoint_max(struct ipa *ipa, u32 count,
const struct ipa_gsi_endpoint_data *data)
{
const struct ipa_gsi_endpoint_data *dp = data;
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
enum ipa_endpoint_name name;
u32 max;

Expand Down Expand Up @@ -606,7 +606,7 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa)
count = ipa->modem_tx_count + ipa_cmd_pipeline_clear_count();
trans = ipa_cmd_trans_alloc(ipa, count);
if (!trans) {
dev_err(&ipa->pdev->dev,
dev_err(ipa->dev,
"no transaction to reset modem exception endpoints\n");
return -EBUSY;
}
Expand Down Expand Up @@ -1498,8 +1498,7 @@ ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, const void *data)
if (endpoint_id == command_endpoint->endpoint_id) {
complete(&ipa->completion);
} else {
dev_err(&ipa->pdev->dev,
"unexpected tagged packet from endpoint %u\n",
dev_err(ipa->dev, "unexpected tagged packet from endpoint %u\n",
endpoint_id);
}

Expand Down Expand Up @@ -1536,6 +1535,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
void *data = page_address(page) + NET_SKB_PAD;
u32 unused = buffer_size - total_len;
struct ipa *ipa = endpoint->ipa;
struct device *dev = ipa->dev;
u32 resid = total_len;

while (resid) {
Expand All @@ -1544,7 +1544,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
u32 len;

if (resid < IPA_STATUS_SIZE) {
dev_err(&endpoint->ipa->pdev->dev,
dev_err(dev,
"short message (%u bytes < %zu byte status)\n",
resid, IPA_STATUS_SIZE);
break;
Expand Down Expand Up @@ -1666,8 +1666,8 @@ void ipa_endpoint_default_route_clear(struct ipa *ipa)
*/
static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint)
{
struct device *dev = &endpoint->ipa->pdev->dev;
struct ipa *ipa = endpoint->ipa;
struct device *dev = ipa->dev;
struct gsi *gsi = &ipa->gsi;
bool suspended = false;
dma_addr_t addr;
Expand Down Expand Up @@ -1769,7 +1769,7 @@ static void ipa_endpoint_reset(struct ipa_endpoint *endpoint)
gsi_channel_reset(&ipa->gsi, channel_id, true);

if (ret)
dev_err(&ipa->pdev->dev,
dev_err(ipa->dev,
"error %d resetting channel %u for endpoint %u\n",
ret, endpoint->channel_id, endpoint->endpoint_id);
}
Expand Down Expand Up @@ -1817,7 +1817,7 @@ int ipa_endpoint_enable_one(struct ipa_endpoint *endpoint)

ret = gsi_channel_start(gsi, endpoint->channel_id);
if (ret) {
dev_err(&ipa->pdev->dev,
dev_err(ipa->dev,
"error %d starting %cX channel %u for endpoint %u\n",
ret, endpoint->toward_ipa ? 'T' : 'R',
endpoint->channel_id, endpoint_id);
Expand Down Expand Up @@ -1854,14 +1854,13 @@ void ipa_endpoint_disable_one(struct ipa_endpoint *endpoint)
/* Note that if stop fails, the channel's state is not well-defined */
ret = gsi_channel_stop(gsi, endpoint->channel_id);
if (ret)
dev_err(&ipa->pdev->dev,
"error %d attempting to stop endpoint %u\n", ret,
endpoint_id);
dev_err(ipa->dev, "error %d attempting to stop endpoint %u\n",
ret, endpoint_id);
}

void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint)
{
struct device *dev = &endpoint->ipa->pdev->dev;
struct device *dev = endpoint->ipa->dev;
struct gsi *gsi = &endpoint->ipa->gsi;
int ret;

Expand All @@ -1881,7 +1880,7 @@ void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint)

void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint)
{
struct device *dev = &endpoint->ipa->pdev->dev;
struct device *dev = endpoint->ipa->dev;
struct gsi *gsi = &endpoint->ipa->gsi;
int ret;

Expand Down Expand Up @@ -1983,7 +1982,7 @@ void ipa_endpoint_deconfig(struct ipa *ipa)

int ipa_endpoint_config(struct ipa *ipa)
{
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
const struct reg *reg;
u32 endpoint_id;
u32 hw_limit;
Expand Down
7 changes: 3 additions & 4 deletions drivers/net/ipa/ipa_interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,13 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)
struct ipa_interrupt *interrupt = dev_id;
struct ipa *ipa = interrupt->ipa;
u32 enabled = interrupt->enabled;
struct device *dev = ipa->dev;
const struct reg *reg;
struct device *dev;
u32 pending;
u32 offset;
u32 mask;
int ret;

dev = &ipa->pdev->dev;
ret = pm_runtime_get_sync(dev);
if (WARN_ON(ret < 0))
goto out_power_put;
Expand Down Expand Up @@ -240,8 +239,8 @@ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt)
int ipa_interrupt_config(struct ipa *ipa)
{
struct ipa_interrupt *interrupt = ipa->interrupt;
struct device *dev = &ipa->pdev->dev;
unsigned int irq = interrupt->irq;
struct device *dev = ipa->dev;
const struct reg *reg;
int ret;

Expand Down Expand Up @@ -281,7 +280,7 @@ int ipa_interrupt_config(struct ipa *ipa)
void ipa_interrupt_deconfig(struct ipa *ipa)
{
struct ipa_interrupt *interrupt = ipa->interrupt;
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;

ipa->interrupt = NULL;

Expand Down
13 changes: 8 additions & 5 deletions drivers/net/ipa/ipa_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <linux/types.h>
#include <linux/atomic.h>
#include <linux/bitfield.h>
#include <linux/device.h>
#include <linux/bug.h>
#include <linux/io.h>
#include <linux/firmware.h>
Expand Down Expand Up @@ -114,7 +113,7 @@ int ipa_setup(struct ipa *ipa)
{
struct ipa_endpoint *exception_endpoint;
struct ipa_endpoint *command_endpoint;
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
int ret;

ret = gsi_setup(&ipa->gsi);
Expand Down Expand Up @@ -858,7 +857,7 @@ static int ipa_probe(struct platform_device *pdev)
goto err_power_exit;
}

ipa->pdev = pdev;
ipa->dev = dev;
dev_set_drvdata(dev, ipa);
ipa->interrupt = interrupt;
ipa->power = power;
Expand Down Expand Up @@ -953,12 +952,16 @@ static int ipa_probe(struct platform_device *pdev)

static void ipa_remove(struct platform_device *pdev)
{
struct ipa *ipa = dev_get_drvdata(&pdev->dev);
struct device *dev = &pdev->dev;
struct ipa_interrupt *interrupt;
struct ipa_power *power;
struct device *dev;
struct ipa *ipa;
int ret;

ipa = dev_get_drvdata(&pdev->dev);
dev = ipa->dev;
WARN_ON(dev != &pdev->dev);

power = ipa->power;
interrupt = ipa->interrupt;

Expand Down
24 changes: 11 additions & 13 deletions drivers/net/ipa/ipa_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int ipa_mem_setup(struct ipa *ipa)
*/
trans = ipa_cmd_trans_alloc(ipa, 4);
if (!trans) {
dev_err(&ipa->pdev->dev, "no transaction for memory setup\n");
dev_err(ipa->dev, "no transaction for memory setup\n");
return -EBUSY;
}

Expand Down Expand Up @@ -218,8 +218,8 @@ static bool ipa_mem_id_required(struct ipa *ipa, enum ipa_mem_id mem_id)

static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem)
{
struct device *dev = &ipa->pdev->dev;
enum ipa_mem_id mem_id = mem->id;
struct device *dev = ipa->dev;
u16 size_multiple;

/* Make sure the memory region is valid for this version of IPA */
Expand Down Expand Up @@ -255,7 +255,7 @@ static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem)
static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data)
{
DECLARE_BITMAP(regions, IPA_MEM_COUNT) = { };
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
enum ipa_mem_id mem_id;
u32 i;

Expand Down Expand Up @@ -291,7 +291,7 @@ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data)
/* Do all memory regions fit within the IPA local memory? */
static bool ipa_mem_size_valid(struct ipa *ipa)
{
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
u32 limit = ipa->mem_size;
u32 i;

Expand All @@ -318,7 +318,7 @@ static bool ipa_mem_size_valid(struct ipa *ipa)
*/
int ipa_mem_config(struct ipa *ipa)
{
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
const struct ipa_mem *mem;
const struct reg *reg;
dma_addr_t addr;
Expand Down Expand Up @@ -394,7 +394,7 @@ int ipa_mem_config(struct ipa *ipa)
/* Inverse of ipa_mem_config() */
void ipa_mem_deconfig(struct ipa *ipa)
{
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;

dma_free_coherent(dev, ipa->zero_size, ipa->zero_virt, ipa->zero_addr);
ipa->zero_size = 0;
Expand All @@ -421,8 +421,7 @@ int ipa_mem_zero_modem(struct ipa *ipa)
*/
trans = ipa_cmd_trans_alloc(ipa, 3);
if (!trans) {
dev_err(&ipa->pdev->dev,
"no transaction to zero modem memory\n");
dev_err(ipa->dev, "no transaction to zero modem memory\n");
return -EBUSY;
}

Expand Down Expand Up @@ -453,7 +452,7 @@ int ipa_mem_zero_modem(struct ipa *ipa)
*/
static int ipa_imem_init(struct ipa *ipa, unsigned long addr, size_t size)
{
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
struct iommu_domain *domain;
unsigned long iova;
phys_addr_t phys;
Expand Down Expand Up @@ -486,13 +485,12 @@ static int ipa_imem_init(struct ipa *ipa, unsigned long addr, size_t size)

static void ipa_imem_exit(struct ipa *ipa)
{
struct device *dev = ipa->dev;
struct iommu_domain *domain;
struct device *dev;

if (!ipa->imem_size)
return;

dev = &ipa->pdev->dev;
domain = iommu_get_domain_for_dev(dev);
if (domain) {
size_t size;
Expand Down Expand Up @@ -528,7 +526,7 @@ static void ipa_imem_exit(struct ipa *ipa)
*/
static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size)
{
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
struct iommu_domain *domain;
unsigned long iova;
phys_addr_t phys;
Expand Down Expand Up @@ -595,7 +593,7 @@ static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size)

static void ipa_smem_exit(struct ipa *ipa)
{
struct device *dev = &ipa->pdev->dev;
struct device *dev = ipa->dev;
struct iommu_domain *domain;

domain = iommu_get_domain_for_dev(dev);
Expand Down
Loading

0 comments on commit 5245f4f

Please sign in to comment.