Skip to content

Commit c0ece64

Browse files
andy-shevKAGA-KOKO
authored andcommitted
irqdomain: Clarify checks for bus_token
The code uses if (bus_token) and if (bus_token == DOMAIN_BUS_ANY). Since bus_token is an enum, the latter is more robust against changes. Convert all !bus_token checks to explicitely check for DOMAIN_BUS_ANY. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 46c3e31 commit c0ece64

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

kernel/irq/irqdomain.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ EXPORT_SYMBOL_GPL(irq_domain_free_fwnode);
130130

131131
static int alloc_name(struct irq_domain *domain, char *base, enum irq_domain_bus_token bus_token)
132132
{
133-
domain->name = bus_token ? kasprintf(GFP_KERNEL, "%s-%d", base, bus_token) :
134-
kasprintf(GFP_KERNEL, "%s", base);
133+
if (bus_token == DOMAIN_BUS_ANY)
134+
domain->name = kasprintf(GFP_KERNEL, "%s", base);
135+
else
136+
domain->name = kasprintf(GFP_KERNEL, "%s-%d", base, bus_token);
135137
if (!domain->name)
136138
return -ENOMEM;
137139

@@ -146,8 +148,10 @@ static int alloc_fwnode_name(struct irq_domain *domain, const struct fwnode_hand
146148
const char *suf = suffix ? : "";
147149
char *name;
148150

149-
name = bus_token ? kasprintf(GFP_KERNEL, "%pfw-%s%s%d", fwnode, suf, sep, bus_token) :
150-
kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, suf);
151+
if (bus_token == DOMAIN_BUS_ANY)
152+
name = kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, suf);
153+
else
154+
name = kasprintf(GFP_KERNEL, "%pfw-%s%s%d", fwnode, suf, sep, bus_token);
151155
if (!name)
152156
return -ENOMEM;
153157

@@ -166,11 +170,13 @@ static int alloc_unknown_name(struct irq_domain *domain, enum irq_domain_bus_tok
166170
static atomic_t unknown_domains;
167171
int id = atomic_inc_return(&unknown_domains);
168172

169-
domain->name = bus_token ? kasprintf(GFP_KERNEL, "unknown-%d-%d", id, bus_token) :
170-
kasprintf(GFP_KERNEL, "unknown-%d", id);
171-
173+
if (bus_token == DOMAIN_BUS_ANY)
174+
domain->name = kasprintf(GFP_KERNEL, "unknown-%d", id);
175+
else
176+
domain->name = kasprintf(GFP_KERNEL, "unknown-%d-%d", id, bus_token);
172177
if (!domain->name)
173178
return -ENOMEM;
179+
174180
domain->flags |= IRQ_DOMAIN_NAME_ALLOCATED;
175181
return 0;
176182
}
@@ -200,7 +206,7 @@ static int irq_domain_set_name(struct irq_domain *domain, const struct irq_domai
200206
return alloc_name(domain, fwid->name, bus_token);
201207
default:
202208
domain->name = fwid->name;
203-
if (bus_token)
209+
if (bus_token != DOMAIN_BUS_ANY)
204210
return alloc_name(domain, fwid->name, bus_token);
205211
}
206212

0 commit comments

Comments
 (0)