Skip to content

Commit ec4e290

Browse files
ukleinekgregkh
authored andcommitted
driver core: simplify definitions of platform_get_irq*
platform_get_irq_optional is just a wrapper for __platform_get_irq. So rename __platform_get_irq to platform_get_irq_optional and drop platform_get_irq_optional's previous implementation. This way there is one function and one indirection less without loss of functionality. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://lore.kernel.org/r/20191009093746.12095-1-uwe@kleine-koenig.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c31e731 commit ec4e290

1 file changed

Lines changed: 21 additions & 26 deletions

File tree

‎drivers/base/platform.c‎

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,24 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
8080
EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
8181
#endif /* CONFIG_HAS_IOMEM */
8282

83-
static int __platform_get_irq(struct platform_device *dev, unsigned int num)
83+
/**
84+
* platform_get_irq_optional - get an optional IRQ for a device
85+
* @dev: platform device
86+
* @num: IRQ number index
87+
*
88+
* Gets an IRQ for a platform device. Device drivers should check the return
89+
* value for errors so as to not pass a negative integer value to the
90+
* request_irq() APIs. This is the same as platform_get_irq(), except that it
91+
* does not print an error message if an IRQ can not be obtained.
92+
*
93+
* Example:
94+
* int irq = platform_get_irq_optional(pdev, 0);
95+
* if (irq < 0)
96+
* return irq;
97+
*
98+
* Return: IRQ number on success, negative error number on failure.
99+
*/
100+
int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
84101
{
85102
#ifdef CONFIG_SPARC
86103
/* sparc does not have irqs represented as IORESOURCE_IRQ resources */
@@ -144,6 +161,7 @@ static int __platform_get_irq(struct platform_device *dev, unsigned int num)
144161
return -ENXIO;
145162
#endif
146163
}
164+
EXPORT_SYMBOL_GPL(platform_get_irq_optional);
147165

148166
/**
149167
* platform_get_irq - get an IRQ for a device
@@ -165,37 +183,14 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
165183
{
166184
int ret;
167185

168-
ret = __platform_get_irq(dev, num);
186+
ret = platform_get_irq_optional(dev, num);
169187
if (ret < 0 && ret != -EPROBE_DEFER)
170188
dev_err(&dev->dev, "IRQ index %u not found\n", num);
171189

172190
return ret;
173191
}
174192
EXPORT_SYMBOL_GPL(platform_get_irq);
175193

176-
/**
177-
* platform_get_irq_optional - get an optional IRQ for a device
178-
* @dev: platform device
179-
* @num: IRQ number index
180-
*
181-
* Gets an IRQ for a platform device. Device drivers should check the return
182-
* value for errors so as to not pass a negative integer value to the
183-
* request_irq() APIs. This is the same as platform_get_irq(), except that it
184-
* does not print an error message if an IRQ can not be obtained.
185-
*
186-
* Example:
187-
* int irq = platform_get_irq_optional(pdev, 0);
188-
* if (irq < 0)
189-
* return irq;
190-
*
191-
* Return: IRQ number on success, negative error number on failure.
192-
*/
193-
int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
194-
{
195-
return __platform_get_irq(dev, num);
196-
}
197-
EXPORT_SYMBOL_GPL(platform_get_irq_optional);
198-
199194
/**
200195
* platform_irq_count - Count the number of IRQs a platform device uses
201196
* @dev: platform device
@@ -206,7 +201,7 @@ int platform_irq_count(struct platform_device *dev)
206201
{
207202
int ret, nr = 0;
208203

209-
while ((ret = __platform_get_irq(dev, nr)) >= 0)
204+
while ((ret = platform_get_irq_optional(dev, nr)) >= 0)
210205
nr++;
211206

212207
if (ret == -EPROBE_DEFER)

0 commit comments

Comments
 (0)