Skip to content

Commit 6170b6d

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: introduce gsi_channel_initialized()
Create a simple helper function that indicates whether a channel has been initialized. This abstacts/hides the details of how this is determined. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a266ad6 commit 6170b6d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

drivers/net/ipa/gsi.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ static u32 gsi_channel_id(struct gsi_channel *channel)
175175
return channel - &channel->gsi->channel[0];
176176
}
177177

178+
/* An initialized channel has a non-null GSI pointer */
179+
static bool gsi_channel_initialized(struct gsi_channel *channel)
180+
{
181+
return !!channel->gsi;
182+
}
183+
178184
/* Update the GSI IRQ type register with the cached value */
179185
static void gsi_irq_type_update(struct gsi *gsi, u32 val)
180186
{
@@ -1638,8 +1644,8 @@ static int gsi_channel_setup_one(struct gsi *gsi, u32 channel_id)
16381644
u32 evt_ring_id = channel->evt_ring_id;
16391645
int ret;
16401646

1641-
if (!channel->gsi)
1642-
return 0; /* Ignore uninitialized channels */
1647+
if (!gsi_channel_initialized(channel))
1648+
return 0;
16431649

16441650
ret = gsi_evt_ring_alloc_command(gsi, evt_ring_id);
16451651
if (ret)
@@ -1675,8 +1681,8 @@ static void gsi_channel_teardown_one(struct gsi *gsi, u32 channel_id)
16751681
struct gsi_channel *channel = &gsi->channel[channel_id];
16761682
u32 evt_ring_id = channel->evt_ring_id;
16771683

1678-
if (!channel->gsi)
1679-
return; /* Ignore uninitialized channels */
1684+
if (!gsi_channel_initialized(channel))
1685+
return;
16801686

16811687
netif_napi_del(&channel->napi);
16821688

@@ -1770,8 +1776,8 @@ static int gsi_channel_setup(struct gsi *gsi)
17701776
while (channel_id < GSI_CHANNEL_COUNT_MAX) {
17711777
struct gsi_channel *channel = &gsi->channel[channel_id++];
17721778

1773-
if (!channel->gsi)
1774-
continue; /* Ignore uninitialized channels */
1779+
if (!gsi_channel_initialized(channel))
1780+
continue;
17751781

17761782
ret = -EINVAL;
17771783
dev_err(gsi->dev, "channel %u not supported by hardware\n",
@@ -2089,8 +2095,8 @@ static int gsi_channel_init_one(struct gsi *gsi,
20892095
/* Inverse of gsi_channel_init_one() */
20902096
static void gsi_channel_exit_one(struct gsi_channel *channel)
20912097
{
2092-
if (!channel->gsi)
2093-
return; /* Ignore uninitialized channels */
2098+
if (!gsi_channel_initialized(channel))
2099+
return;
20942100

20952101
if (channel->command)
20962102
ipa_cmd_pool_exit(channel);

0 commit comments

Comments
 (0)