Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

driver core: platform: Make platform_get_irq_optional() optional

Currently the platform_get_irq_optional() returns an error code even
if IRQ resource sumply has not been found. It prevents caller to be
error code agnostic in their error handling.

Now:
ret = platform_get_irq_optional(...);
if (ret != -ENXIO)
return ret; // respect deferred probe
if (ret > 0)
...we get an IRQ...

After proposed change:
ret = platform_get_irq_optional(...);
if (ret < 0)
return ret;
if (ret > 0)
...we get an IRQ...

Reported-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210331144526.19439-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
ed7027fd 318c3e00

+34 -21
+34 -21
drivers/base/platform.c
··· 168 168 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname); 169 169 #endif /* CONFIG_HAS_IOMEM */ 170 170 171 - /** 172 - * platform_get_irq_optional - get an optional IRQ for a device 173 - * @dev: platform device 174 - * @num: IRQ number index 175 - * 176 - * Gets an IRQ for a platform device. Device drivers should check the return 177 - * value for errors so as to not pass a negative integer value to the 178 - * request_irq() APIs. This is the same as platform_get_irq(), except that it 179 - * does not print an error message if an IRQ can not be obtained. 180 - * 181 - * For example:: 182 - * 183 - * int irq = platform_get_irq_optional(pdev, 0); 184 - * if (irq < 0) 185 - * return irq; 186 - * 187 - * Return: non-zero IRQ number on success, negative error number on failure. 188 - */ 189 - int platform_get_irq_optional(struct platform_device *dev, unsigned int num) 171 + static int platform_do_get_irq(struct platform_device *dev, unsigned int num) 190 172 { 191 173 int ret; 192 174 #ifdef CONFIG_SPARC ··· 236 254 WARN(ret == 0, "0 is an invalid IRQ number\n"); 237 255 return ret; 238 256 } 257 + 258 + /** 259 + * platform_get_irq_optional - get an optional IRQ for a device 260 + * @dev: platform device 261 + * @num: IRQ number index 262 + * 263 + * Gets an IRQ for a platform device. Device drivers should check the return 264 + * value for errors so as to not pass a negative integer value to the 265 + * request_irq() APIs. This is the same as platform_get_irq(), except that it 266 + * does not print an error message if an IRQ can not be obtained and returns 267 + * 0 when IRQ resource has not been found. 268 + * 269 + * For example:: 270 + * 271 + * int irq = platform_get_irq_optional(pdev, 0); 272 + * if (irq < 0) 273 + * return irq; 274 + * if (irq > 0) 275 + * ...we have IRQ line defined... 276 + * 277 + * Return: non-zero IRQ number on success, negative error number on failure. 278 + */ 279 + int platform_get_irq_optional(struct platform_device *dev, unsigned int num) 280 + { 281 + int ret; 282 + 283 + ret = platform_do_get_irq(dev, num); 284 + if (ret == -ENXIO) 285 + return 0; 286 + return ret; 287 + } 239 288 EXPORT_SYMBOL_GPL(platform_get_irq_optional); 240 289 241 290 /** ··· 290 277 { 291 278 int ret; 292 279 293 - ret = platform_get_irq_optional(dev, num); 280 + ret = platform_do_get_irq(dev, num); 294 281 if (ret < 0 && ret != -EPROBE_DEFER) 295 282 dev_err(&dev->dev, "IRQ index %u not found\n", num); 296 283 ··· 308 295 { 309 296 int ret, nr = 0; 310 297 311 - while ((ret = platform_get_irq_optional(dev, nr)) >= 0) 298 + while ((ret = platform_do_get_irq(dev, nr)) >= 0) 312 299 nr++; 313 300 314 301 if (ret == -EPROBE_DEFER)