Skip to content

Commit 71564a2

Browse files
andy-shevgregkh
authored andcommitted
driver core: platform: Declare ret variable only once
We may define ret variable only once and avoid adding it each time platform_get_irq_optional() get extended. For the sake of consistency do the same in __platform_get_irq_byname(). Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent edb44e8 commit 71564a2

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/base/platform.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
143143
return dev->archdata.irqs[num];
144144
#else
145145
struct resource *r;
146-
if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) {
147-
int ret;
146+
int ret;
148147

148+
if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) {
149149
ret = of_irq_get(dev->dev.of_node, num);
150150
if (ret > 0 || ret == -EPROBE_DEFER)
151151
return ret;
@@ -154,8 +154,6 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
154154
r = platform_get_resource(dev, IORESOURCE_IRQ, num);
155155
if (has_acpi_companion(&dev->dev)) {
156156
if (r && r->flags & IORESOURCE_DISABLED) {
157-
int ret;
158-
159157
ret = acpi_irq_get(ACPI_HANDLE(&dev->dev), num, r);
160158
if (ret)
161159
return ret;
@@ -188,8 +186,7 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
188186
* allows a common code path across either kind of resource.
189187
*/
190188
if (num == 0 && has_acpi_companion(&dev->dev)) {
191-
int ret = acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num);
192-
189+
ret = acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num);
193190
/* Our callers expect -ENXIO for missing IRQs. */
194191
if (ret >= 0 || ret == -EPROBE_DEFER)
195192
return ret;
@@ -277,10 +274,9 @@ static int __platform_get_irq_byname(struct platform_device *dev,
277274
const char *name)
278275
{
279276
struct resource *r;
277+
int ret;
280278

281279
if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) {
282-
int ret;
283-
284280
ret = of_irq_get_byname(dev->dev.of_node, name);
285281
if (ret > 0 || ret == -EPROBE_DEFER)
286282
return ret;

0 commit comments

Comments
 (0)