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.

Merge tag 'driver-core-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg Kroah-Hartman:
"Here is the big driver core update for 5.4-rc1.

There was a bit of a churn in here, with a number of core and OF
platform patches being added to the tree, and then after much
discussion and review and a day-long in-person meeting, they were
decided to be reverted and a new set of patches is currently being
reviewed on the mailing list.

Other than that churn, there are two "persistent" branches in here
that other trees will be pulling in as well during the merge window.
One branch to add support for drivers to have the driver core
automatically add sysfs attribute files when a driver is bound to a
device so that the driver doesn't have to manually do it (and then
clean it up, as it always gets it wrong).

There's another branch in here for generic lookup helpers for the
driver core that lots of busses are starting to use. That's the
majority of the non-driver-core changes in this patch series.

There's also some on-going debugfs file creation cleanup that has been
slowly happening over the past few releases, with the goal to
hopefully get that done sometime next year.

All of these have been in linux-next for a while now with no reported
issues"

[ Note that the above-mentioned generic lookup helpers branch was
already brought in by the LED merge (commit 4feaab05dc1e) that had
shared it.

Also note that that common branch introduced an i2c bug due to a bad
conversion, which got fixed here. - Linus ]

* tag 'driver-core-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (49 commits)
coccinelle: platform_get_irq: Fix parse error
driver-core: add include guard to linux/container.h
sysfs: add BIN_ATTR_WO() macro
driver core: platform: Export platform_get_irq_optional()
hwmon: pwm-fan: Use platform_get_irq_optional()
driver core: platform: Introduce platform_get_irq_optional()
Revert "driver core: Add support for linking devices during device addition"
Revert "driver core: Add edit_links() callback for drivers"
Revert "of/platform: Add functional dependency link from DT bindings"
Revert "driver core: Add sync_state driver/bus callback"
Revert "of/platform: Pause/resume sync state during init and of_platform_populate()"
Revert "of/platform: Create device links for all child-supplier depencencies"
Revert "of/platform: Don't create device links for default busses"
Revert "of/platform: Fix fn definitons for of_link_is_valid() and of_link_property()"
Revert "of/platform: Fix device_links_supplier_sync_state_resume() warning"
Revert "of/platform: Disable generic device linking code for PowerPC"
devcoredump: fix typo in comment
devcoredump: use memory_read_from_buffer
of/platform: Disable generic device linking code for PowerPC
device.h: Fix warnings for mismatched parameter names in comments
...

+495 -514
+2 -2
Documentation/driver-api/device_link.rst
··· 78 78 driver is compiled as a module, the device link is added on module load and 79 79 orderly deleted on unload. The same restrictions that apply to device link 80 80 addition (e.g. exclusion of a parallel suspend/resume transition) apply equally 81 - to deletion. Device links with ``DL_FLAG_STATELESS`` unset (i.e. managed 82 - device links) are deleted automatically by the driver core. 81 + to deletion. Device links managed by the driver core are deleted automatically 82 + by it. 83 83 84 84 Several flags may be specified on device link addition, two of which 85 85 have already been mentioned above: ``DL_FLAG_STATELESS`` to express that no
+7 -10
arch/x86/platform/olpc/olpc-xo1-sci.c
··· 157 157 static DEVICE_ATTR(lid_wake_mode, S_IWUSR | S_IRUGO, lid_wake_mode_show, 158 158 lid_wake_mode_set); 159 159 160 + static struct attribute *lid_attrs[] = { 161 + &dev_attr_lid_wake_mode.attr, 162 + NULL, 163 + }; 164 + ATTRIBUTE_GROUPS(lid); 165 + 160 166 /* 161 167 * Process all items in the EC's SCI queue. 162 168 * ··· 516 510 goto err_register; 517 511 } 518 512 519 - r = device_create_file(&lid_switch_idev->dev, &dev_attr_lid_wake_mode); 520 - if (r) { 521 - dev_err(&pdev->dev, "failed to create wake mode attr: %d\n", r); 522 - goto err_create_attr; 523 - } 524 - 525 513 return 0; 526 514 527 - err_create_attr: 528 - input_unregister_device(lid_switch_idev); 529 - lid_switch_idev = NULL; 530 515 err_register: 531 516 input_free_device(lid_switch_idev); 532 517 return r; ··· 525 528 526 529 static void free_lid_switch(void) 527 530 { 528 - device_remove_file(&lid_switch_idev->dev, &dev_attr_lid_wake_mode); 529 531 input_unregister_device(lid_switch_idev); 530 532 } 531 533 ··· 620 624 static struct platform_driver xo1_sci_driver = { 621 625 .driver = { 622 626 .name = "olpc-xo1-sci-acpi", 627 + .dev_groups = lid_groups, 623 628 }, 624 629 .probe = xo1_sci_probe, 625 630 .remove = xo1_sci_remove,
+102 -78
drivers/base/core.c
··· 136 136 return ret; 137 137 } 138 138 139 + static void device_link_init_status(struct device_link *link, 140 + struct device *consumer, 141 + struct device *supplier) 142 + { 143 + switch (supplier->links.status) { 144 + case DL_DEV_PROBING: 145 + switch (consumer->links.status) { 146 + case DL_DEV_PROBING: 147 + /* 148 + * A consumer driver can create a link to a supplier 149 + * that has not completed its probing yet as long as it 150 + * knows that the supplier is already functional (for 151 + * example, it has just acquired some resources from the 152 + * supplier). 153 + */ 154 + link->status = DL_STATE_CONSUMER_PROBE; 155 + break; 156 + default: 157 + link->status = DL_STATE_DORMANT; 158 + break; 159 + } 160 + break; 161 + case DL_DEV_DRIVER_BOUND: 162 + switch (consumer->links.status) { 163 + case DL_DEV_PROBING: 164 + link->status = DL_STATE_CONSUMER_PROBE; 165 + break; 166 + case DL_DEV_DRIVER_BOUND: 167 + link->status = DL_STATE_ACTIVE; 168 + break; 169 + default: 170 + link->status = DL_STATE_AVAILABLE; 171 + break; 172 + } 173 + break; 174 + case DL_DEV_UNBINDING: 175 + link->status = DL_STATE_SUPPLIER_UNBIND; 176 + break; 177 + default: 178 + link->status = DL_STATE_DORMANT; 179 + break; 180 + } 181 + } 182 + 139 183 static int device_reorder_to_tail(struct device *dev, void *not_used) 140 184 { 141 185 struct device_link *link; ··· 221 177 device_links_read_unlock(idx); 222 178 } 223 179 180 + #define DL_MANAGED_LINK_FLAGS (DL_FLAG_AUTOREMOVE_CONSUMER | \ 181 + DL_FLAG_AUTOREMOVE_SUPPLIER | \ 182 + DL_FLAG_AUTOPROBE_CONSUMER) 183 + 184 + #define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \ 185 + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE) 186 + 224 187 /** 225 188 * device_link_add - Create a link between two devices. 226 189 * @consumer: Consumer end of the link. ··· 242 191 * of the link. If DL_FLAG_PM_RUNTIME is not set, DL_FLAG_RPM_ACTIVE will be 243 192 * ignored. 244 193 * 245 - * If DL_FLAG_STATELESS is set in @flags, the link is not going to be managed by 246 - * the driver core and, in particular, the caller of this function is expected 247 - * to drop the reference to the link acquired by it directly. 194 + * If DL_FLAG_STATELESS is set in @flags, the caller of this function is 195 + * expected to release the link returned by it directly with the help of either 196 + * device_link_del() or device_link_remove(). 248 197 * 249 198 * If that flag is not set, however, the caller of this function is handing the 250 199 * management of the link over to the driver core entirely and its return value ··· 264 213 * be used to request the driver core to automaticall probe for a consmer 265 214 * driver after successfully binding a driver to the supplier device. 266 215 * 267 - * The combination of DL_FLAG_STATELESS and either DL_FLAG_AUTOREMOVE_CONSUMER 268 - * or DL_FLAG_AUTOREMOVE_SUPPLIER set in @flags at the same time is invalid and 269 - * will cause NULL to be returned upfront. 216 + * The combination of DL_FLAG_STATELESS and one of DL_FLAG_AUTOREMOVE_CONSUMER, 217 + * DL_FLAG_AUTOREMOVE_SUPPLIER, or DL_FLAG_AUTOPROBE_CONSUMER set in @flags at 218 + * the same time is invalid and will cause NULL to be returned upfront. 219 + * However, if a device link between the given @consumer and @supplier pair 220 + * exists already when this function is called for them, the existing link will 221 + * be returned regardless of its current type and status (the link's flags may 222 + * be modified then). The caller of this function is then expected to treat 223 + * the link as though it has just been created, so (in particular) if 224 + * DL_FLAG_STATELESS was passed in @flags, the link needs to be released 225 + * explicitly when not needed any more (as stated above). 270 226 * 271 227 * A side effect of the link creation is re-ordering of dpm_list and the 272 228 * devices_kset list by moving the consumer device and all devices depending ··· 289 231 { 290 232 struct device_link *link; 291 233 292 - if (!consumer || !supplier || 293 - (flags & DL_FLAG_STATELESS && 294 - flags & (DL_FLAG_AUTOREMOVE_CONSUMER | 295 - DL_FLAG_AUTOREMOVE_SUPPLIER | 296 - DL_FLAG_AUTOPROBE_CONSUMER)) || 234 + if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS || 235 + (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) || 297 236 (flags & DL_FLAG_AUTOPROBE_CONSUMER && 298 237 flags & (DL_FLAG_AUTOREMOVE_CONSUMER | 299 238 DL_FLAG_AUTOREMOVE_SUPPLIER))) ··· 302 247 return NULL; 303 248 } 304 249 } 250 + 251 + if (!(flags & DL_FLAG_STATELESS)) 252 + flags |= DL_FLAG_MANAGED; 305 253 306 254 device_links_write_lock(); 307 255 device_pm_lock(); ··· 332 274 if (link->consumer != consumer) 333 275 continue; 334 276 335 - /* 336 - * Don't return a stateless link if the caller wants a stateful 337 - * one and vice versa. 338 - */ 339 - if (WARN_ON((flags & DL_FLAG_STATELESS) != (link->flags & DL_FLAG_STATELESS))) { 340 - link = NULL; 341 - goto out; 342 - } 343 - 344 277 if (flags & DL_FLAG_PM_RUNTIME) { 345 278 if (!(link->flags & DL_FLAG_PM_RUNTIME)) { 346 279 pm_runtime_new_link(consumer); ··· 342 293 } 343 294 344 295 if (flags & DL_FLAG_STATELESS) { 296 + link->flags |= DL_FLAG_STATELESS; 345 297 kref_get(&link->kref); 346 298 goto out; 347 299 } ··· 360 310 } else if (!(flags & DL_FLAG_AUTOREMOVE_CONSUMER)) { 361 311 link->flags &= ~(DL_FLAG_AUTOREMOVE_CONSUMER | 362 312 DL_FLAG_AUTOREMOVE_SUPPLIER); 313 + } 314 + if (!(link->flags & DL_FLAG_MANAGED)) { 315 + kref_get(&link->kref); 316 + link->flags |= DL_FLAG_MANAGED; 317 + device_link_init_status(link, consumer, supplier); 363 318 } 364 319 goto out; 365 320 } ··· 392 337 kref_init(&link->kref); 393 338 394 339 /* Determine the initial link state. */ 395 - if (flags & DL_FLAG_STATELESS) { 340 + if (flags & DL_FLAG_STATELESS) 396 341 link->status = DL_STATE_NONE; 397 - } else { 398 - switch (supplier->links.status) { 399 - case DL_DEV_PROBING: 400 - switch (consumer->links.status) { 401 - case DL_DEV_PROBING: 402 - /* 403 - * A consumer driver can create a link to a 404 - * supplier that has not completed its probing 405 - * yet as long as it knows that the supplier is 406 - * already functional (for example, it has just 407 - * acquired some resources from the supplier). 408 - */ 409 - link->status = DL_STATE_CONSUMER_PROBE; 410 - break; 411 - default: 412 - link->status = DL_STATE_DORMANT; 413 - break; 414 - } 415 - break; 416 - case DL_DEV_DRIVER_BOUND: 417 - switch (consumer->links.status) { 418 - case DL_DEV_PROBING: 419 - link->status = DL_STATE_CONSUMER_PROBE; 420 - break; 421 - case DL_DEV_DRIVER_BOUND: 422 - link->status = DL_STATE_ACTIVE; 423 - break; 424 - default: 425 - link->status = DL_STATE_AVAILABLE; 426 - break; 427 - } 428 - break; 429 - case DL_DEV_UNBINDING: 430 - link->status = DL_STATE_SUPPLIER_UNBIND; 431 - break; 432 - default: 433 - link->status = DL_STATE_DORMANT; 434 - break; 435 - } 436 - } 342 + else 343 + device_link_init_status(link, consumer, supplier); 437 344 438 345 /* 439 346 * Some callers expect the link creation during consumer driver probe to ··· 557 540 * mark the link as "consumer probe in progress" to make the supplier removal 558 541 * wait for us to complete (or bad things may happen). 559 542 * 560 - * Links with the DL_FLAG_STATELESS flag set are ignored. 543 + * Links without the DL_FLAG_MANAGED flag set are ignored. 561 544 */ 562 545 int device_links_check_suppliers(struct device *dev) 563 546 { ··· 567 550 device_links_write_lock(); 568 551 569 552 list_for_each_entry(link, &dev->links.suppliers, c_node) { 570 - if (link->flags & DL_FLAG_STATELESS) 553 + if (!(link->flags & DL_FLAG_MANAGED)) 571 554 continue; 572 555 573 556 if (link->status != DL_STATE_AVAILABLE) { ··· 592 575 * 593 576 * Also change the status of @dev's links to suppliers to "active". 594 577 * 595 - * Links with the DL_FLAG_STATELESS flag set are ignored. 578 + * Links without the DL_FLAG_MANAGED flag set are ignored. 596 579 */ 597 580 void device_links_driver_bound(struct device *dev) 598 581 { ··· 601 584 device_links_write_lock(); 602 585 603 586 list_for_each_entry(link, &dev->links.consumers, s_node) { 604 - if (link->flags & DL_FLAG_STATELESS) 587 + if (!(link->flags & DL_FLAG_MANAGED)) 605 588 continue; 606 589 607 590 /* ··· 622 605 } 623 606 624 607 list_for_each_entry(link, &dev->links.suppliers, c_node) { 625 - if (link->flags & DL_FLAG_STATELESS) 608 + if (!(link->flags & DL_FLAG_MANAGED)) 626 609 continue; 627 610 628 611 WARN_ON(link->status != DL_STATE_CONSUMER_PROBE); ··· 632 615 dev->links.status = DL_DEV_DRIVER_BOUND; 633 616 634 617 device_links_write_unlock(); 618 + } 619 + 620 + static void device_link_drop_managed(struct device_link *link) 621 + { 622 + link->flags &= ~DL_FLAG_MANAGED; 623 + WRITE_ONCE(link->status, DL_STATE_NONE); 624 + kref_put(&link->kref, __device_link_del); 635 625 } 636 626 637 627 /** ··· 651 627 * unless they already are in the "supplier unbind in progress" state in which 652 628 * case they need not be updated. 653 629 * 654 - * Links with the DL_FLAG_STATELESS flag set are ignored. 630 + * Links without the DL_FLAG_MANAGED flag set are ignored. 655 631 */ 656 632 static void __device_links_no_driver(struct device *dev) 657 633 { 658 634 struct device_link *link, *ln; 659 635 660 636 list_for_each_entry_safe_reverse(link, ln, &dev->links.suppliers, c_node) { 661 - if (link->flags & DL_FLAG_STATELESS) 637 + if (!(link->flags & DL_FLAG_MANAGED)) 662 638 continue; 663 639 664 640 if (link->flags & DL_FLAG_AUTOREMOVE_CONSUMER) 665 - __device_link_del(&link->kref); 641 + device_link_drop_managed(link); 666 642 else if (link->status == DL_STATE_CONSUMER_PROBE || 667 643 link->status == DL_STATE_ACTIVE) 668 644 WRITE_ONCE(link->status, DL_STATE_AVAILABLE); ··· 679 655 * %__device_links_no_driver() to update links to suppliers for it as 680 656 * appropriate. 681 657 * 682 - * Links with the DL_FLAG_STATELESS flag set are ignored. 658 + * Links without the DL_FLAG_MANAGED flag set are ignored. 683 659 */ 684 660 void device_links_no_driver(struct device *dev) 685 661 { ··· 688 664 device_links_write_lock(); 689 665 690 666 list_for_each_entry(link, &dev->links.consumers, s_node) { 691 - if (link->flags & DL_FLAG_STATELESS) 667 + if (!(link->flags & DL_FLAG_MANAGED)) 692 668 continue; 693 669 694 670 /* ··· 716 692 * invoke %__device_links_no_driver() to update links to suppliers for it as 717 693 * appropriate. 718 694 * 719 - * Links with the DL_FLAG_STATELESS flag set are ignored. 695 + * Links without the DL_FLAG_MANAGED flag set are ignored. 720 696 */ 721 697 void device_links_driver_cleanup(struct device *dev) 722 698 { ··· 725 701 device_links_write_lock(); 726 702 727 703 list_for_each_entry_safe(link, ln, &dev->links.consumers, s_node) { 728 - if (link->flags & DL_FLAG_STATELESS) 704 + if (!(link->flags & DL_FLAG_MANAGED)) 729 705 continue; 730 706 731 707 WARN_ON(link->flags & DL_FLAG_AUTOREMOVE_CONSUMER); ··· 738 714 */ 739 715 if (link->status == DL_STATE_SUPPLIER_UNBIND && 740 716 link->flags & DL_FLAG_AUTOREMOVE_SUPPLIER) 741 - __device_link_del(&link->kref); 717 + device_link_drop_managed(link); 742 718 743 719 WRITE_ONCE(link->status, DL_STATE_DORMANT); 744 720 } ··· 760 736 * 761 737 * Return 'false' if there are no probing or active consumers. 762 738 * 763 - * Links with the DL_FLAG_STATELESS flag set are ignored. 739 + * Links without the DL_FLAG_MANAGED flag set are ignored. 764 740 */ 765 741 bool device_links_busy(struct device *dev) 766 742 { ··· 770 746 device_links_write_lock(); 771 747 772 748 list_for_each_entry(link, &dev->links.consumers, s_node) { 773 - if (link->flags & DL_FLAG_STATELESS) 749 + if (!(link->flags & DL_FLAG_MANAGED)) 774 750 continue; 775 751 776 752 if (link->status == DL_STATE_CONSUMER_PROBE ··· 800 776 * driver to unbind and start over (the consumer will not re-probe as we have 801 777 * changed the state of the link already). 802 778 * 803 - * Links with the DL_FLAG_STATELESS flag set are ignored. 779 + * Links without the DL_FLAG_MANAGED flag set are ignored. 804 780 */ 805 781 void device_links_unbind_consumers(struct device *dev) 806 782 { ··· 812 788 list_for_each_entry(link, &dev->links.consumers, s_node) { 813 789 enum device_link_state status; 814 790 815 - if (link->flags & DL_FLAG_STATELESS) 791 + if (!(link->flags & DL_FLAG_MANAGED)) 816 792 continue; 817 793 818 794 status = link->status;
+14
drivers/base/dd.c
··· 554 554 goto probe_failed; 555 555 } 556 556 557 + if (device_add_groups(dev, drv->dev_groups)) { 558 + dev_err(dev, "device_add_groups() failed\n"); 559 + goto dev_groups_failed; 560 + } 561 + 557 562 if (test_remove) { 558 563 test_remove = false; 564 + 565 + device_remove_groups(dev, drv->dev_groups); 559 566 560 567 if (dev->bus->remove) 561 568 dev->bus->remove(dev); ··· 591 584 drv->bus->name, __func__, dev_name(dev), drv->name); 592 585 goto done; 593 586 587 + dev_groups_failed: 588 + if (dev->bus->remove) 589 + dev->bus->remove(dev); 590 + else if (drv->remove) 591 + drv->remove(dev); 594 592 probe_failed: 595 593 if (dev->bus) 596 594 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, ··· 1125 1113 dev); 1126 1114 1127 1115 pm_runtime_put_sync(dev); 1116 + 1117 + device_remove_groups(dev, drv->dev_groups); 1128 1118 1129 1119 if (dev->bus && dev->bus->remove) 1130 1120 dev->bus->remove(dev);
+2 -11
drivers/base/devcoredump.c
··· 164 164 static ssize_t devcd_readv(char *buffer, loff_t offset, size_t count, 165 165 void *data, size_t datalen) 166 166 { 167 - if (offset > datalen) 168 - return -EINVAL; 169 - 170 - if (offset + count > datalen) 171 - count = datalen - offset; 172 - 173 - if (count) 174 - memcpy(buffer, ((u8 *)data) + offset, count); 175 - 176 - return count; 167 + return memory_read_from_buffer(buffer, count, &offset, data, datalen); 177 168 } 178 169 179 170 static void devcd_freev(void *data) ··· 314 323 EXPORT_SYMBOL_GPL(dev_coredumpm); 315 324 316 325 /** 317 - * dev_coredumpmsg - create device coredump that uses scatterlist as data 326 + * dev_coredumpsg - create device coredump that uses scatterlist as data 318 327 * parameter 319 328 * @dev: the struct device for the crashed device 320 329 * @table: the dump data
+57 -8
drivers/base/platform.c
··· 99 99 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource); 100 100 #endif /* CONFIG_HAS_IOMEM */ 101 101 102 - /** 103 - * platform_get_irq - get an IRQ for a device 104 - * @dev: platform device 105 - * @num: IRQ number index 106 - */ 107 - int platform_get_irq(struct platform_device *dev, unsigned int num) 102 + static int __platform_get_irq(struct platform_device *dev, unsigned int num) 108 103 { 109 104 #ifdef CONFIG_SPARC 110 105 /* sparc does not have irqs represented as IORESOURCE_IRQ resources */ ··· 163 168 return -ENXIO; 164 169 #endif 165 170 } 171 + 172 + /** 173 + * platform_get_irq - get an IRQ for a device 174 + * @dev: platform device 175 + * @num: IRQ number index 176 + * 177 + * Gets an IRQ for a platform device and prints an error message if finding the 178 + * IRQ fails. Device drivers should check the return value for errors so as to 179 + * not pass a negative integer value to the request_irq() APIs. 180 + * 181 + * Example: 182 + * int irq = platform_get_irq(pdev, 0); 183 + * if (irq < 0) 184 + * return irq; 185 + * 186 + * Return: IRQ number on success, negative error number on failure. 187 + */ 188 + int platform_get_irq(struct platform_device *dev, unsigned int num) 189 + { 190 + int ret; 191 + 192 + ret = __platform_get_irq(dev, num); 193 + if (ret < 0 && ret != -EPROBE_DEFER) 194 + dev_err(&dev->dev, "IRQ index %u not found\n", num); 195 + 196 + return ret; 197 + } 166 198 EXPORT_SYMBOL_GPL(platform_get_irq); 199 + 200 + /** 201 + * platform_get_irq_optional - get an optional IRQ for a device 202 + * @dev: platform device 203 + * @num: IRQ number index 204 + * 205 + * Gets an IRQ for a platform device. Device drivers should check the return 206 + * value for errors so as to not pass a negative integer value to the 207 + * request_irq() APIs. This is the same as platform_get_irq(), except that it 208 + * does not print an error message if an IRQ can not be obtained. 209 + * 210 + * Example: 211 + * int irq = platform_get_irq_optional(pdev, 0); 212 + * if (irq < 0) 213 + * return irq; 214 + * 215 + * Return: IRQ number on success, negative error number on failure. 216 + */ 217 + int platform_get_irq_optional(struct platform_device *dev, unsigned int num) 218 + { 219 + return __platform_get_irq(dev, num); 220 + } 221 + EXPORT_SYMBOL_GPL(platform_get_irq_optional); 167 222 168 223 /** 169 224 * platform_irq_count - Count the number of IRQs a platform device uses ··· 225 180 { 226 181 int ret, nr = 0; 227 182 228 - while ((ret = platform_get_irq(dev, nr)) >= 0) 183 + while ((ret = __platform_get_irq(dev, nr)) >= 0) 229 184 nr++; 230 185 231 186 if (ret == -EPROBE_DEFER) ··· 278 233 } 279 234 280 235 r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); 281 - return r ? r->start : -ENXIO; 236 + if (r) 237 + return r->start; 238 + 239 + dev_err(&dev->dev, "IRQ %s not found\n", name); 240 + return -ENXIO; 282 241 } 283 242 EXPORT_SYMBOL_GPL(platform_get_irq_byname); 284 243
+2 -2
drivers/base/power/runtime.c
··· 1626 1626 * runtime PM references to the device, drop the usage counter of the device 1627 1627 * (as many times as needed). 1628 1628 * 1629 - * Links with the DL_FLAG_STATELESS flag set are ignored. 1629 + * Links with the DL_FLAG_MANAGED flag unset are ignored. 1630 1630 * 1631 1631 * Since the device is guaranteed to be runtime-active at the point this is 1632 1632 * called, nothing else needs to be done here. ··· 1644 1644 1645 1645 list_for_each_entry_rcu(link, &dev->links.consumers, s_node, 1646 1646 device_links_read_lock_held()) { 1647 - if (link->flags & DL_FLAG_STATELESS) 1647 + if (!(link->flags & DL_FLAG_MANAGED)) 1648 1648 continue; 1649 1649 1650 1650 while (refcount_dec_not_one(&link->rpm_active))
+1 -4
drivers/firmware/arm_scpi.c
··· 1011 1011 scpi_info->firmware_version)); 1012 1012 scpi_info->scpi_ops = &scpi_ops; 1013 1013 1014 - ret = devm_device_add_groups(dev, versions_groups); 1015 - if (ret) 1016 - dev_err(dev, "unable to create sysfs version group\n"); 1017 - 1018 1014 return devm_of_platform_populate(dev); 1019 1015 } 1020 1016 ··· 1026 1030 .driver = { 1027 1031 .name = "scpi_protocol", 1028 1032 .of_match_table = scpi_of_match, 1033 + .dev_groups = versions_groups, 1029 1034 }, 1030 1035 .probe = scpi_probe, 1031 1036 .remove = scpi_remove,
+1 -1
drivers/hwmon/pwm-fan.c
··· 304 304 305 305 platform_set_drvdata(pdev, ctx); 306 306 307 - ctx->irq = platform_get_irq(pdev, 0); 307 + ctx->irq = platform_get_irq_optional(pdev, 0); 308 308 if (ctx->irq == -EPROBE_DEFER) 309 309 return ctx->irq; 310 310
+14 -1
drivers/i2c/i2c-core-acpi.c
··· 344 344 } 345 345 EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed); 346 346 347 + static int i2c_acpi_find_match_adapter(struct device *dev, const void *data) 348 + { 349 + struct i2c_adapter *adapter = i2c_verify_adapter(dev); 350 + 351 + if (!adapter) 352 + return 0; 353 + 354 + return ACPI_HANDLE(dev) == (acpi_handle)data; 355 + } 356 + 347 357 struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle) 348 358 { 349 - struct device *dev = bus_find_device_by_acpi_dev(&i2c_bus_type, handle); 359 + struct device *dev; 360 + 361 + dev = bus_find_device(&i2c_bus_type, NULL, handle, 362 + i2c_acpi_find_match_adapter); 350 363 351 364 return dev ? i2c_verify_adapter(dev) : NULL; 352 365 }
+2 -11
drivers/mfd/aat2870-core.c
··· 321 321 static void aat2870_init_debugfs(struct aat2870_data *aat2870) 322 322 { 323 323 aat2870->dentry_root = debugfs_create_dir("aat2870", NULL); 324 - if (!aat2870->dentry_root) { 325 - dev_warn(aat2870->dev, 326 - "Failed to create debugfs root directory\n"); 327 - return; 328 - } 329 324 330 - aat2870->dentry_reg = debugfs_create_file("regs", 0644, 331 - aat2870->dentry_root, 332 - aat2870, &aat2870_reg_fops); 333 - if (!aat2870->dentry_reg) 334 - dev_warn(aat2870->dev, 335 - "Failed to create debugfs register file\n"); 325 + debugfs_create_file("regs", 0644, aat2870->dentry_root, aat2870, 326 + &aat2870_reg_fops); 336 327 } 337 328 338 329 #else
+7 -38
drivers/mfd/ab3100-core.c
··· 575 575 .llseek = noop_llseek, 576 576 }; 577 577 578 - static struct dentry *ab3100_dir; 579 - static struct dentry *ab3100_reg_file; 580 578 static struct ab3100_get_set_reg_priv ab3100_get_priv; 581 - static struct dentry *ab3100_get_reg_file; 582 579 static struct ab3100_get_set_reg_priv ab3100_set_priv; 583 - static struct dentry *ab3100_set_reg_file; 584 580 585 581 static void ab3100_setup_debugfs(struct ab3100 *ab3100) 586 582 { 587 - int err; 583 + struct dentry *ab3100_dir; 588 584 589 585 ab3100_dir = debugfs_create_dir("ab3100", NULL); 590 - if (!ab3100_dir) 591 - goto exit_no_debugfs; 592 586 593 - ab3100_reg_file = debugfs_create_file("registers", 594 - S_IRUGO, ab3100_dir, ab3100, 595 - &ab3100_registers_fops); 596 - if (!ab3100_reg_file) { 597 - err = -ENOMEM; 598 - goto exit_destroy_dir; 599 - } 587 + debugfs_create_file("registers", S_IRUGO, ab3100_dir, ab3100, 588 + &ab3100_registers_fops); 600 589 601 590 ab3100_get_priv.ab3100 = ab3100; 602 591 ab3100_get_priv.mode = false; 603 - ab3100_get_reg_file = debugfs_create_file("get_reg", 604 - S_IWUSR, ab3100_dir, &ab3100_get_priv, 605 - &ab3100_get_set_reg_fops); 606 - if (!ab3100_get_reg_file) { 607 - err = -ENOMEM; 608 - goto exit_destroy_reg; 609 - } 592 + debugfs_create_file("get_reg", S_IWUSR, ab3100_dir, &ab3100_get_priv, 593 + &ab3100_get_set_reg_fops); 610 594 611 595 ab3100_set_priv.ab3100 = ab3100; 612 596 ab3100_set_priv.mode = true; 613 - ab3100_set_reg_file = debugfs_create_file("set_reg", 614 - S_IWUSR, ab3100_dir, &ab3100_set_priv, 615 - &ab3100_get_set_reg_fops); 616 - if (!ab3100_set_reg_file) { 617 - err = -ENOMEM; 618 - goto exit_destroy_get_reg; 619 - } 620 - return; 621 - 622 - exit_destroy_get_reg: 623 - debugfs_remove(ab3100_get_reg_file); 624 - exit_destroy_reg: 625 - debugfs_remove(ab3100_reg_file); 626 - exit_destroy_dir: 627 - debugfs_remove(ab3100_dir); 628 - exit_no_debugfs: 629 - return; 597 + debugfs_create_file("set_reg", S_IWUSR, ab3100_dir, &ab3100_set_priv, 598 + &ab3100_get_set_reg_fops); 630 599 } 631 600 #else 632 601 static inline void ab3100_setup_debugfs(struct ab3100 *ab3100)
+6 -15
drivers/mfd/ab3100-otp.c
··· 122 122 .release = single_release, 123 123 }; 124 124 125 - static int __init ab3100_otp_init_debugfs(struct device *dev, 126 - struct ab3100_otp *otp) 125 + static void __init ab3100_otp_init_debugfs(struct device *dev, 126 + struct ab3100_otp *otp) 127 127 { 128 128 otp->debugfs = debugfs_create_file("ab3100_otp", S_IFREG | S_IRUGO, 129 - NULL, otp, 130 - &ab3100_otp_operations); 131 - if (!otp->debugfs) { 132 - dev_err(dev, "AB3100 debugfs OTP file registration failed!\n"); 133 - return -ENOENT; 134 - } 135 - return 0; 129 + NULL, otp, &ab3100_otp_operations); 136 130 } 137 131 138 132 static void __exit ab3100_otp_exit_debugfs(struct ab3100_otp *otp) ··· 135 141 } 136 142 #else 137 143 /* Compile this out if debugfs not selected */ 138 - static inline int __init ab3100_otp_init_debugfs(struct device *dev, 139 - struct ab3100_otp *otp) 144 + static inline void __init ab3100_otp_init_debugfs(struct device *dev, 145 + struct ab3100_otp *otp) 140 146 { 141 - return 0; 142 147 } 143 148 144 149 static inline void __exit ab3100_otp_exit_debugfs(struct ab3100_otp *otp) ··· 204 211 } 205 212 206 213 /* debugfs entries */ 207 - err = ab3100_otp_init_debugfs(&pdev->dev, otp); 208 - if (err) 209 - goto err; 214 + ab3100_otp_init_debugfs(&pdev->dev, otp); 210 215 211 216 return 0; 212 217
+97 -225
drivers/mfd/ab8500-debugfs.c
··· 2644 2644 .owner = THIS_MODULE, 2645 2645 }; 2646 2646 2647 - static struct dentry *ab8500_dir; 2648 - static struct dentry *ab8500_gpadc_dir; 2649 - 2650 2647 static int ab8500_debug_probe(struct platform_device *plf) 2651 2648 { 2652 - struct dentry *file; 2649 + struct dentry *ab8500_dir; 2650 + struct dentry *ab8500_gpadc_dir; 2653 2651 struct ab8500 *ab8500; 2654 2652 struct resource *res; 2655 2653 ··· 2692 2694 } 2693 2695 2694 2696 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); 2695 - if (!ab8500_dir) 2696 - goto err; 2697 2697 2698 2698 ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING, 2699 2699 ab8500_dir); 2700 - if (!ab8500_gpadc_dir) 2701 - goto err; 2702 2700 2703 - file = debugfs_create_file("all-bank-registers", S_IRUGO, ab8500_dir, 2704 - &plf->dev, &ab8500_bank_registers_fops); 2705 - if (!file) 2706 - goto err; 2707 - 2708 - file = debugfs_create_file("all-banks", S_IRUGO, ab8500_dir, 2709 - &plf->dev, &ab8500_all_banks_fops); 2710 - if (!file) 2711 - goto err; 2712 - 2713 - file = debugfs_create_file("register-bank", 2714 - (S_IRUGO | S_IWUSR | S_IWGRP), 2715 - ab8500_dir, &plf->dev, &ab8500_bank_fops); 2716 - if (!file) 2717 - goto err; 2718 - 2719 - file = debugfs_create_file("register-address", 2720 - (S_IRUGO | S_IWUSR | S_IWGRP), 2721 - ab8500_dir, &plf->dev, &ab8500_address_fops); 2722 - if (!file) 2723 - goto err; 2724 - 2725 - file = debugfs_create_file("register-value", 2726 - (S_IRUGO | S_IWUSR | S_IWGRP), 2727 - ab8500_dir, &plf->dev, &ab8500_val_fops); 2728 - if (!file) 2729 - goto err; 2730 - 2731 - file = debugfs_create_file("irq-subscribe", 2732 - (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir, 2733 - &plf->dev, &ab8500_subscribe_fops); 2734 - if (!file) 2735 - goto err; 2701 + debugfs_create_file("all-bank-registers", S_IRUGO, ab8500_dir, 2702 + &plf->dev, &ab8500_bank_registers_fops); 2703 + debugfs_create_file("all-banks", S_IRUGO, ab8500_dir, 2704 + &plf->dev, &ab8500_all_banks_fops); 2705 + debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR | S_IWGRP), 2706 + ab8500_dir, &plf->dev, &ab8500_bank_fops); 2707 + debugfs_create_file("register-address", (S_IRUGO | S_IWUSR | S_IWGRP), 2708 + ab8500_dir, &plf->dev, &ab8500_address_fops); 2709 + debugfs_create_file("register-value", (S_IRUGO | S_IWUSR | S_IWGRP), 2710 + ab8500_dir, &plf->dev, &ab8500_val_fops); 2711 + debugfs_create_file("irq-subscribe", (S_IRUGO | S_IWUSR | S_IWGRP), 2712 + ab8500_dir, &plf->dev, &ab8500_subscribe_fops); 2736 2713 2737 2714 if (is_ab8500(ab8500)) { 2738 2715 debug_ranges = ab8500_debug_ranges; ··· 2723 2750 num_interrupt_lines = AB8540_NR_IRQS; 2724 2751 } 2725 2752 2726 - file = debugfs_create_file("interrupts", (S_IRUGO), ab8500_dir, 2727 - &plf->dev, &ab8500_interrupts_fops); 2728 - if (!file) 2729 - goto err; 2730 - 2731 - file = debugfs_create_file("irq-unsubscribe", 2732 - (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir, 2733 - &plf->dev, &ab8500_unsubscribe_fops); 2734 - if (!file) 2735 - goto err; 2736 - 2737 - file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP), 2738 - ab8500_dir, &plf->dev, &ab8500_hwreg_fops); 2739 - if (!file) 2740 - goto err; 2741 - 2742 - file = debugfs_create_file("all-modem-registers", 2743 - (S_IRUGO | S_IWUSR | S_IWGRP), 2744 - ab8500_dir, &plf->dev, &ab8500_modem_fops); 2745 - if (!file) 2746 - goto err; 2747 - 2748 - file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR | S_IWGRP), 2749 - ab8500_gpadc_dir, &plf->dev, 2750 - &ab8500_gpadc_bat_ctrl_fops); 2751 - if (!file) 2752 - goto err; 2753 - 2754 - file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR | S_IWGRP), 2755 - ab8500_gpadc_dir, 2756 - &plf->dev, &ab8500_gpadc_btemp_ball_fops); 2757 - if (!file) 2758 - goto err; 2759 - 2760 - file = debugfs_create_file("main_charger_v", 2761 - (S_IRUGO | S_IWUSR | S_IWGRP), 2762 - ab8500_gpadc_dir, &plf->dev, 2763 - &ab8500_gpadc_main_charger_v_fops); 2764 - if (!file) 2765 - goto err; 2766 - 2767 - file = debugfs_create_file("acc_detect1", 2768 - (S_IRUGO | S_IWUSR | S_IWGRP), 2769 - ab8500_gpadc_dir, &plf->dev, 2770 - &ab8500_gpadc_acc_detect1_fops); 2771 - if (!file) 2772 - goto err; 2773 - 2774 - file = debugfs_create_file("acc_detect2", 2775 - (S_IRUGO | S_IWUSR | S_IWGRP), 2776 - ab8500_gpadc_dir, &plf->dev, 2777 - &ab8500_gpadc_acc_detect2_fops); 2778 - if (!file) 2779 - goto err; 2780 - 2781 - file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP), 2782 - ab8500_gpadc_dir, &plf->dev, 2783 - &ab8500_gpadc_aux1_fops); 2784 - if (!file) 2785 - goto err; 2786 - 2787 - file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP), 2788 - ab8500_gpadc_dir, &plf->dev, 2789 - &ab8500_gpadc_aux2_fops); 2790 - if (!file) 2791 - goto err; 2792 - 2793 - file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP), 2794 - ab8500_gpadc_dir, &plf->dev, 2795 - &ab8500_gpadc_main_bat_v_fops); 2796 - if (!file) 2797 - goto err; 2798 - 2799 - file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP), 2800 - ab8500_gpadc_dir, &plf->dev, 2801 - &ab8500_gpadc_vbus_v_fops); 2802 - if (!file) 2803 - goto err; 2804 - 2805 - file = debugfs_create_file("main_charger_c", 2806 - (S_IRUGO | S_IWUSR | S_IWGRP), 2807 - ab8500_gpadc_dir, &plf->dev, 2808 - &ab8500_gpadc_main_charger_c_fops); 2809 - if (!file) 2810 - goto err; 2811 - 2812 - file = debugfs_create_file("usb_charger_c", 2813 - (S_IRUGO | S_IWUSR | S_IWGRP), 2814 - ab8500_gpadc_dir, 2815 - &plf->dev, &ab8500_gpadc_usb_charger_c_fops); 2816 - if (!file) 2817 - goto err; 2818 - 2819 - file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP), 2820 - ab8500_gpadc_dir, &plf->dev, 2821 - &ab8500_gpadc_bk_bat_v_fops); 2822 - if (!file) 2823 - goto err; 2824 - 2825 - file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP), 2826 - ab8500_gpadc_dir, &plf->dev, 2827 - &ab8500_gpadc_die_temp_fops); 2828 - if (!file) 2829 - goto err; 2830 - 2831 - file = debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP), 2832 - ab8500_gpadc_dir, &plf->dev, 2833 - &ab8500_gpadc_usb_id_fops); 2834 - if (!file) 2835 - goto err; 2836 - 2753 + debugfs_create_file("interrupts", (S_IRUGO), ab8500_dir, &plf->dev, 2754 + &ab8500_interrupts_fops); 2755 + debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR | S_IWGRP), 2756 + ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops); 2757 + debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir, 2758 + &plf->dev, &ab8500_hwreg_fops); 2759 + debugfs_create_file("all-modem-registers", (S_IRUGO | S_IWUSR | S_IWGRP), 2760 + ab8500_dir, &plf->dev, &ab8500_modem_fops); 2761 + debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR | S_IWGRP), 2762 + ab8500_gpadc_dir, &plf->dev, 2763 + &ab8500_gpadc_bat_ctrl_fops); 2764 + debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR | S_IWGRP), 2765 + ab8500_gpadc_dir, &plf->dev, 2766 + &ab8500_gpadc_btemp_ball_fops); 2767 + debugfs_create_file("main_charger_v", (S_IRUGO | S_IWUSR | S_IWGRP), 2768 + ab8500_gpadc_dir, &plf->dev, 2769 + &ab8500_gpadc_main_charger_v_fops); 2770 + debugfs_create_file("acc_detect1", (S_IRUGO | S_IWUSR | S_IWGRP), 2771 + ab8500_gpadc_dir, &plf->dev, 2772 + &ab8500_gpadc_acc_detect1_fops); 2773 + debugfs_create_file("acc_detect2", (S_IRUGO | S_IWUSR | S_IWGRP), 2774 + ab8500_gpadc_dir, &plf->dev, 2775 + &ab8500_gpadc_acc_detect2_fops); 2776 + debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP), 2777 + ab8500_gpadc_dir, &plf->dev, 2778 + &ab8500_gpadc_aux1_fops); 2779 + debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP), 2780 + ab8500_gpadc_dir, &plf->dev, 2781 + &ab8500_gpadc_aux2_fops); 2782 + debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP), 2783 + ab8500_gpadc_dir, &plf->dev, 2784 + &ab8500_gpadc_main_bat_v_fops); 2785 + debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP), 2786 + ab8500_gpadc_dir, &plf->dev, 2787 + &ab8500_gpadc_vbus_v_fops); 2788 + debugfs_create_file("main_charger_c", (S_IRUGO | S_IWUSR | S_IWGRP), 2789 + ab8500_gpadc_dir, &plf->dev, 2790 + &ab8500_gpadc_main_charger_c_fops); 2791 + debugfs_create_file("usb_charger_c", (S_IRUGO | S_IWUSR | S_IWGRP), 2792 + ab8500_gpadc_dir, &plf->dev, 2793 + &ab8500_gpadc_usb_charger_c_fops); 2794 + debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP), 2795 + ab8500_gpadc_dir, &plf->dev, 2796 + &ab8500_gpadc_bk_bat_v_fops); 2797 + debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP), 2798 + ab8500_gpadc_dir, &plf->dev, 2799 + &ab8500_gpadc_die_temp_fops); 2800 + debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP), 2801 + ab8500_gpadc_dir, &plf->dev, 2802 + &ab8500_gpadc_usb_id_fops); 2837 2803 if (is_ab8540(ab8500)) { 2838 - file = debugfs_create_file("xtal_temp", 2839 - (S_IRUGO | S_IWUSR | S_IWGRP), 2840 - ab8500_gpadc_dir, &plf->dev, 2841 - &ab8540_gpadc_xtal_temp_fops); 2842 - if (!file) 2843 - goto err; 2844 - file = debugfs_create_file("vbattruemeas", 2845 - (S_IRUGO | S_IWUSR | S_IWGRP), 2846 - ab8500_gpadc_dir, &plf->dev, 2847 - &ab8540_gpadc_vbat_true_meas_fops); 2848 - if (!file) 2849 - goto err; 2850 - file = debugfs_create_file("batctrl_and_ibat", 2851 - (S_IRUGO | S_IWUGO), 2852 - ab8500_gpadc_dir, 2853 - &plf->dev, 2854 - &ab8540_gpadc_bat_ctrl_and_ibat_fops); 2855 - if (!file) 2856 - goto err; 2857 - file = debugfs_create_file("vbatmeas_and_ibat", 2858 - (S_IRUGO | S_IWUGO), 2859 - ab8500_gpadc_dir, &plf->dev, 2860 - &ab8540_gpadc_vbat_meas_and_ibat_fops); 2861 - if (!file) 2862 - goto err; 2863 - file = debugfs_create_file("vbattruemeas_and_ibat", 2864 - (S_IRUGO | S_IWUGO), 2865 - ab8500_gpadc_dir, 2866 - &plf->dev, 2867 - &ab8540_gpadc_vbat_true_meas_and_ibat_fops); 2868 - if (!file) 2869 - goto err; 2870 - file = debugfs_create_file("battemp_and_ibat", 2871 - (S_IRUGO | S_IWUGO), 2872 - ab8500_gpadc_dir, 2873 - &plf->dev, &ab8540_gpadc_bat_temp_and_ibat_fops); 2874 - if (!file) 2875 - goto err; 2876 - file = debugfs_create_file("otp_calib", 2877 - (S_IRUGO | S_IWUSR | S_IWGRP), 2878 - ab8500_gpadc_dir, 2879 - &plf->dev, &ab8540_gpadc_otp_calib_fops); 2880 - if (!file) 2881 - goto err; 2804 + debugfs_create_file("xtal_temp", (S_IRUGO | S_IWUSR | S_IWGRP), 2805 + ab8500_gpadc_dir, &plf->dev, 2806 + &ab8540_gpadc_xtal_temp_fops); 2807 + debugfs_create_file("vbattruemeas", (S_IRUGO | S_IWUSR | S_IWGRP), 2808 + ab8500_gpadc_dir, &plf->dev, 2809 + &ab8540_gpadc_vbat_true_meas_fops); 2810 + debugfs_create_file("batctrl_and_ibat", (S_IRUGO | S_IWUGO), 2811 + ab8500_gpadc_dir, &plf->dev, 2812 + &ab8540_gpadc_bat_ctrl_and_ibat_fops); 2813 + debugfs_create_file("vbatmeas_and_ibat", (S_IRUGO | S_IWUGO), 2814 + ab8500_gpadc_dir, &plf->dev, 2815 + &ab8540_gpadc_vbat_meas_and_ibat_fops); 2816 + debugfs_create_file("vbattruemeas_and_ibat", (S_IRUGO | S_IWUGO), 2817 + ab8500_gpadc_dir, &plf->dev, 2818 + &ab8540_gpadc_vbat_true_meas_and_ibat_fops); 2819 + debugfs_create_file("battemp_and_ibat", (S_IRUGO | S_IWUGO), 2820 + ab8500_gpadc_dir, &plf->dev, 2821 + &ab8540_gpadc_bat_temp_and_ibat_fops); 2822 + debugfs_create_file("otp_calib", (S_IRUGO | S_IWUSR | S_IWGRP), 2823 + ab8500_gpadc_dir, &plf->dev, 2824 + &ab8540_gpadc_otp_calib_fops); 2882 2825 } 2883 - file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP), 2884 - ab8500_gpadc_dir, &plf->dev, 2885 - &ab8500_gpadc_avg_sample_fops); 2886 - if (!file) 2887 - goto err; 2888 - 2889 - file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP), 2890 - ab8500_gpadc_dir, &plf->dev, 2891 - &ab8500_gpadc_trig_edge_fops); 2892 - if (!file) 2893 - goto err; 2894 - 2895 - file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP), 2896 - ab8500_gpadc_dir, &plf->dev, 2897 - &ab8500_gpadc_trig_timer_fops); 2898 - if (!file) 2899 - goto err; 2900 - 2901 - file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP), 2902 - ab8500_gpadc_dir, &plf->dev, 2903 - &ab8500_gpadc_conv_type_fops); 2904 - if (!file) 2905 - goto err; 2826 + debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP), 2827 + ab8500_gpadc_dir, &plf->dev, 2828 + &ab8500_gpadc_avg_sample_fops); 2829 + debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP), 2830 + ab8500_gpadc_dir, &plf->dev, 2831 + &ab8500_gpadc_trig_edge_fops); 2832 + debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP), 2833 + ab8500_gpadc_dir, &plf->dev, 2834 + &ab8500_gpadc_trig_timer_fops); 2835 + debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP), 2836 + ab8500_gpadc_dir, &plf->dev, 2837 + &ab8500_gpadc_conv_type_fops); 2906 2838 2907 2839 return 0; 2908 - 2909 - err: 2910 - debugfs_remove_recursive(ab8500_dir); 2911 - dev_err(&plf->dev, "failed to create debugfs entries.\n"); 2912 - 2913 - return -ENOMEM; 2914 2840 } 2915 2841 2916 2842 static struct platform_driver ab8500_debug_driver = {
+12 -35
drivers/platform/x86/hp-wmi.c
··· 502 502 static DEVICE_ATTR_RO(tablet); 503 503 static DEVICE_ATTR_RW(postcode); 504 504 505 + static struct attribute *hp_wmi_attrs[] = { 506 + &dev_attr_display.attr, 507 + &dev_attr_hddtemp.attr, 508 + &dev_attr_als.attr, 509 + &dev_attr_dock.attr, 510 + &dev_attr_tablet.attr, 511 + &dev_attr_postcode.attr, 512 + NULL, 513 + }; 514 + ATTRIBUTE_GROUPS(hp_wmi); 515 + 505 516 static void hp_wmi_notify(u32 value, void *context) 506 517 { 507 518 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; ··· 689 678 input_unregister_device(hp_wmi_input_dev); 690 679 } 691 680 692 - static void cleanup_sysfs(struct platform_device *device) 693 - { 694 - device_remove_file(&device->dev, &dev_attr_display); 695 - device_remove_file(&device->dev, &dev_attr_hddtemp); 696 - device_remove_file(&device->dev, &dev_attr_als); 697 - device_remove_file(&device->dev, &dev_attr_dock); 698 - device_remove_file(&device->dev, &dev_attr_tablet); 699 - device_remove_file(&device->dev, &dev_attr_postcode); 700 - } 701 - 702 681 static int __init hp_wmi_rfkill_setup(struct platform_device *device) 703 682 { 704 683 int err, wireless; ··· 859 858 860 859 static int __init hp_wmi_bios_setup(struct platform_device *device) 861 860 { 862 - int err; 863 - 864 861 /* clear detected rfkill devices */ 865 862 wifi_rfkill = NULL; 866 863 bluetooth_rfkill = NULL; ··· 868 869 if (hp_wmi_rfkill_setup(device)) 869 870 hp_wmi_rfkill2_setup(device); 870 871 871 - err = device_create_file(&device->dev, &dev_attr_display); 872 - if (err) 873 - goto add_sysfs_error; 874 - err = device_create_file(&device->dev, &dev_attr_hddtemp); 875 - if (err) 876 - goto add_sysfs_error; 877 - err = device_create_file(&device->dev, &dev_attr_als); 878 - if (err) 879 - goto add_sysfs_error; 880 - err = device_create_file(&device->dev, &dev_attr_dock); 881 - if (err) 882 - goto add_sysfs_error; 883 - err = device_create_file(&device->dev, &dev_attr_tablet); 884 - if (err) 885 - goto add_sysfs_error; 886 - err = device_create_file(&device->dev, &dev_attr_postcode); 887 - if (err) 888 - goto add_sysfs_error; 889 872 return 0; 890 - 891 - add_sysfs_error: 892 - cleanup_sysfs(device); 893 - return err; 894 873 } 895 874 896 875 static int __exit hp_wmi_bios_remove(struct platform_device *device) 897 876 { 898 877 int i; 899 - cleanup_sysfs(device); 900 878 901 879 for (i = 0; i < rfkill2_count; i++) { 902 880 rfkill_unregister(rfkill2[i].rfkill); ··· 942 966 .driver = { 943 967 .name = "hp-wmi", 944 968 .pm = &hp_wmi_pm_ops, 969 + .dev_groups = hp_wmi_groups, 945 970 }, 946 971 .remove = __exit_p(hp_wmi_bios_remove), 947 972 };
+8 -15
drivers/uio/uio_fsl_elbc_gpcm.c
··· 71 71 static DEVICE_ATTR(reg_br, 0664, reg_show, reg_store); 72 72 static DEVICE_ATTR(reg_or, 0664, reg_show, reg_store); 73 73 74 + static struct attribute *uio_fsl_elbc_gpcm_attrs[] = { 75 + &dev_attr_reg_br.attr, 76 + &dev_attr_reg_or.attr, 77 + NULL, 78 + }; 79 + ATTRIBUTE_GROUPS(uio_fsl_elbc_gpcm); 80 + 74 81 static ssize_t reg_show(struct device *dev, struct device_attribute *attr, 75 82 char *buf) 76 83 { ··· 418 411 /* store private data */ 419 412 platform_set_drvdata(pdev, info); 420 413 421 - /* create sysfs files */ 422 - ret = device_create_file(priv->dev, &dev_attr_reg_br); 423 - if (ret) 424 - goto out_err3; 425 - ret = device_create_file(priv->dev, &dev_attr_reg_or); 426 - if (ret) 427 - goto out_err4; 428 - 429 414 dev_info(priv->dev, 430 415 "eLBC/GPCM device (%s) at 0x%llx, bank %d, irq=%d\n", 431 416 priv->name, (unsigned long long)res.start, priv->bank, 432 417 irq != NO_IRQ ? irq : -1); 433 418 434 419 return 0; 435 - out_err4: 436 - device_remove_file(priv->dev, &dev_attr_reg_br); 437 - out_err3: 438 - platform_set_drvdata(pdev, NULL); 439 - uio_unregister_device(info); 440 420 out_err2: 441 421 if (priv->shutdown) 442 422 priv->shutdown(info, true); ··· 442 448 struct uio_info *info = platform_get_drvdata(pdev); 443 449 struct fsl_elbc_gpcm *priv = info->priv; 444 450 445 - device_remove_file(priv->dev, &dev_attr_reg_or); 446 - device_remove_file(priv->dev, &dev_attr_reg_br); 447 451 platform_set_drvdata(pdev, NULL); 448 452 uio_unregister_device(info); 449 453 if (priv->shutdown) ··· 466 474 .driver = { 467 475 .name = "fsl,elbc-gpcm-uio", 468 476 .of_match_table = uio_fsl_elbc_gpcm_match, 477 + .dev_groups = uio_fsl_elbc_gpcm_groups, 469 478 }, 470 479 .probe = uio_fsl_elbc_gpcm_probe, 471 480 .remove = uio_fsl_elbc_gpcm_remove,
+9 -28
drivers/video/fbdev/sm501fb.c
··· 1271 1271 1272 1272 static DEVICE_ATTR(fbregs_pnl, 0444, sm501fb_debug_show_pnl, NULL); 1273 1273 1274 + static struct attribute *sm501fb_attrs[] = { 1275 + &dev_attr_crt_src.attr, 1276 + &dev_attr_fbregs_pnl.attr, 1277 + &dev_attr_fbregs_crt.attr, 1278 + NULL, 1279 + }; 1280 + ATTRIBUTE_GROUPS(sm501fb); 1281 + 1274 1282 /* acceleration operations */ 1275 1283 static int sm501fb_sync(struct fb_info *info) 1276 1284 { ··· 2019 2011 goto err_started_crt; 2020 2012 } 2021 2013 2022 - /* create device files */ 2023 - 2024 - ret = device_create_file(dev, &dev_attr_crt_src); 2025 - if (ret) 2026 - goto err_started_panel; 2027 - 2028 - ret = device_create_file(dev, &dev_attr_fbregs_pnl); 2029 - if (ret) 2030 - goto err_attached_crtsrc_file; 2031 - 2032 - ret = device_create_file(dev, &dev_attr_fbregs_crt); 2033 - if (ret) 2034 - goto err_attached_pnlregs_file; 2035 - 2036 2014 /* we registered, return ok */ 2037 2015 return 0; 2038 - 2039 - err_attached_pnlregs_file: 2040 - device_remove_file(dev, &dev_attr_fbregs_pnl); 2041 - 2042 - err_attached_crtsrc_file: 2043 - device_remove_file(dev, &dev_attr_crt_src); 2044 - 2045 - err_started_panel: 2046 - unregister_framebuffer(info->fb[HEAD_PANEL]); 2047 - sm501_free_init_fb(info, HEAD_PANEL); 2048 2016 2049 2017 err_started_crt: 2050 2018 unregister_framebuffer(info->fb[HEAD_CRT]); ··· 2050 2066 struct sm501fb_info *info = platform_get_drvdata(pdev); 2051 2067 struct fb_info *fbinfo_crt = info->fb[0]; 2052 2068 struct fb_info *fbinfo_pnl = info->fb[1]; 2053 - 2054 - device_remove_file(&pdev->dev, &dev_attr_fbregs_crt); 2055 - device_remove_file(&pdev->dev, &dev_attr_fbregs_pnl); 2056 - device_remove_file(&pdev->dev, &dev_attr_crt_src); 2057 2069 2058 2070 sm501_free_init_fb(info, HEAD_CRT); 2059 2071 sm501_free_init_fb(info, HEAD_PANEL); ··· 2214 2234 .resume = sm501fb_resume, 2215 2235 .driver = { 2216 2236 .name = "sm501-fb", 2237 + .dev_groups = sm501fb_groups, 2217 2238 }, 2218 2239 }; 2219 2240
+10 -13
drivers/video/fbdev/w100fb.c
··· 164 164 165 165 static DEVICE_ATTR_RW(fastpllclk); 166 166 167 + static struct attribute *w100fb_attrs[] = { 168 + &dev_attr_fastpllclk.attr, 169 + &dev_attr_reg_read.attr, 170 + &dev_attr_reg_write.attr, 171 + &dev_attr_flip.attr, 172 + NULL, 173 + }; 174 + ATTRIBUTE_GROUPS(w100fb); 175 + 167 176 /* 168 177 * Some touchscreens need hsync information from the video driver to 169 178 * function correctly. We export it here. ··· 761 752 goto out; 762 753 } 763 754 764 - err = device_create_file(&pdev->dev, &dev_attr_fastpllclk); 765 - err |= device_create_file(&pdev->dev, &dev_attr_reg_read); 766 - err |= device_create_file(&pdev->dev, &dev_attr_reg_write); 767 - err |= device_create_file(&pdev->dev, &dev_attr_flip); 768 - 769 - if (err != 0) 770 - fb_warn(info, "failed to register attributes (%d)\n", err); 771 - 772 755 fb_info(info, "%s frame buffer device\n", info->fix.id); 773 756 return 0; 774 757 out: ··· 784 783 { 785 784 struct fb_info *info = platform_get_drvdata(pdev); 786 785 struct w100fb_par *par=info->par; 787 - 788 - device_remove_file(&pdev->dev, &dev_attr_fastpllclk); 789 - device_remove_file(&pdev->dev, &dev_attr_reg_read); 790 - device_remove_file(&pdev->dev, &dev_attr_reg_write); 791 - device_remove_file(&pdev->dev, &dev_attr_flip); 792 786 793 787 unregister_framebuffer(info); 794 788 ··· 1621 1625 .resume = w100fb_resume, 1622 1626 .driver = { 1623 1627 .name = "w100fb", 1628 + .dev_groups = w100fb_groups, 1624 1629 }, 1625 1630 }; 1626 1631
+7 -6
drivers/video/fbdev/wm8505fb.c
··· 176 176 177 177 static DEVICE_ATTR_RW(contrast); 178 178 179 + static struct attribute *wm8505fb_attrs[] = { 180 + &dev_attr_contrast.attr, 181 + NULL, 182 + }; 183 + ATTRIBUTE_GROUPS(wm8505fb); 184 + 179 185 static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf) 180 186 { 181 187 chan &= 0xffff; ··· 367 361 return ret; 368 362 } 369 363 370 - ret = device_create_file(&pdev->dev, &dev_attr_contrast); 371 - if (ret < 0) 372 - fb_warn(&fbi->fb, "failed to register attributes (%d)\n", ret); 373 - 374 364 fb_info(&fbi->fb, "%s frame buffer at 0x%lx-0x%lx\n", 375 365 fbi->fb.fix.id, fbi->fb.fix.smem_start, 376 366 fbi->fb.fix.smem_start + fbi->fb.fix.smem_len - 1); ··· 377 375 static int wm8505fb_remove(struct platform_device *pdev) 378 376 { 379 377 struct wm8505fb_info *fbi = platform_get_drvdata(pdev); 380 - 381 - device_remove_file(&pdev->dev, &dev_attr_contrast); 382 378 383 379 unregister_framebuffer(&fbi->fb); 384 380 ··· 399 399 .driver = { 400 400 .name = DRIVER_NAME, 401 401 .of_match_table = wmt_dt_ids, 402 + .dev_groups = wm8505fb_groups, 402 403 }, 403 404 }; 404 405
+5 -4
fs/kernfs/dir.c
··· 137 137 if (kn_from == kn_to) 138 138 return strlcpy(buf, "/", buflen); 139 139 140 + if (!buf) 141 + return -EINVAL; 142 + 140 143 common = kernfs_common_ancestor(kn_from, kn_to); 141 144 if (WARN_ON(!common)) 142 145 return -EINVAL; ··· 147 144 depth_to = kernfs_depth(common, kn_to); 148 145 depth_from = kernfs_depth(common, kn_from); 149 146 150 - if (buf) 151 - buf[0] = '\0'; 147 + buf[0] = '\0'; 152 148 153 149 for (i = 0; i < depth_from; i++) 154 150 len += strlcpy(buf + len, parent_str, ··· 432 430 */ 433 431 void kernfs_put_active(struct kernfs_node *kn) 434 432 { 435 - struct kernfs_root *root = kernfs_root(kn); 436 433 int v; 437 434 438 435 if (unlikely(!kn)) ··· 443 442 if (likely(v != KN_DEACTIVATED_BIAS)) 444 443 return; 445 444 446 - wake_up_all(&root->deactivate_waitq); 445 + wake_up_all(&kernfs_root(kn)->deactivate_waitq); 447 446 } 448 447 449 448 /**
+5
include/linux/container.h
··· 6 6 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 7 7 */ 8 8 9 + #ifndef _LINUX_CONTAINER_H 10 + #define _LINUX_CONTAINER_H 11 + 9 12 #include <linux/device.h> 10 13 11 14 /* drivers/base/power/container.c */ ··· 23 20 { 24 21 return container_of(dev, struct container_dev, dev); 25 22 } 23 + 24 + #endif /* _LINUX_CONTAINER_H */
+13 -6
include/linux/device.h
··· 229 229 /** 230 230 * bus_find_next_device - Find the next device after a given device in a 231 231 * given bus. 232 + * @bus: bus type 233 + * @cur: device to begin the search with. 232 234 */ 233 235 static inline struct device * 234 236 bus_find_next_device(struct bus_type *bus,struct device *cur) ··· 348 346 * @resume: Called to bring a device from sleep mode. 349 347 * @groups: Default attributes that get created by the driver core 350 348 * automatically. 349 + * @dev_groups: Additional attributes attached to device instance once the 350 + * it is bound to the driver. 351 351 * @pm: Power management operations of the device which matched 352 352 * this driver. 353 353 * @coredump: Called when sysfs entry is written to. The device driver ··· 384 380 int (*suspend) (struct device *dev, pm_message_t state); 385 381 int (*resume) (struct device *dev); 386 382 const struct attribute_group **groups; 383 + const struct attribute_group **dev_groups; 387 384 388 385 const struct dev_pm_ops *pm; 389 386 void (*coredump) (struct device *dev); ··· 434 429 /** 435 430 * driver_find_device_by_name - device iterator for locating a particular device 436 431 * of a specific name. 437 - * @driver: the driver we're iterating 432 + * @drv: the driver we're iterating 438 433 * @name: name of the device to match 439 434 */ 440 435 static inline struct device *driver_find_device_by_name(struct device_driver *drv, ··· 446 441 /** 447 442 * driver_find_device_by_of_node- device iterator for locating a particular device 448 443 * by of_node pointer. 449 - * @driver: the driver we're iterating 444 + * @drv: the driver we're iterating 450 445 * @np: of_node pointer to match. 451 446 */ 452 447 static inline struct device * ··· 459 454 /** 460 455 * driver_find_device_by_fwnode- device iterator for locating a particular device 461 456 * by fwnode pointer. 462 - * @driver: the driver we're iterating 457 + * @drv: the driver we're iterating 463 458 * @fwnode: fwnode pointer to match. 464 459 */ 465 460 static inline struct device * ··· 472 467 /** 473 468 * driver_find_device_by_devt- device iterator for locating a particular device 474 469 * by devt. 475 - * @driver: the driver we're iterating 470 + * @drv: the driver we're iterating 476 471 * @devt: devt pointer to match. 477 472 */ 478 473 static inline struct device *driver_find_device_by_devt(struct device_driver *drv, ··· 491 486 /** 492 487 * driver_find_device_by_acpi_dev : device iterator for locating a particular 493 488 * device matching the ACPI_COMPANION device. 494 - * @driver: the driver we're iterating 489 + * @drv: the driver we're iterating 495 490 * @adev: ACPI_COMPANION device to match. 496 491 */ 497 492 static inline struct device * ··· 1069 1064 /* 1070 1065 * Device link flags. 1071 1066 * 1072 - * STATELESS: The core won't track the presence of supplier/consumer drivers. 1067 + * STATELESS: The core will not remove this link automatically. 1073 1068 * AUTOREMOVE_CONSUMER: Remove the link automatically on consumer driver unbind. 1074 1069 * PM_RUNTIME: If set, the runtime PM framework will use this link. 1075 1070 * RPM_ACTIVE: Run pm_runtime_get_sync() on the supplier during link creation. 1076 1071 * AUTOREMOVE_SUPPLIER: Remove the link automatically on supplier driver unbind. 1077 1072 * AUTOPROBE_CONSUMER: Probe consumer driver automatically after supplier binds. 1073 + * MANAGED: The core tracks presence of supplier/consumer drivers (internal). 1078 1074 */ 1079 1075 #define DL_FLAG_STATELESS BIT(0) 1080 1076 #define DL_FLAG_AUTOREMOVE_CONSUMER BIT(1) ··· 1083 1077 #define DL_FLAG_RPM_ACTIVE BIT(3) 1084 1078 #define DL_FLAG_AUTOREMOVE_SUPPLIER BIT(4) 1085 1079 #define DL_FLAG_AUTOPROBE_CONSUMER BIT(5) 1080 + #define DL_FLAG_MANAGED BIT(6) 1086 1081 1087 1082 /** 1088 1083 * struct device_link - Device link representation.
-1
include/linux/mfd/aat2870.h
··· 136 136 137 137 /* for debugfs */ 138 138 struct dentry *dentry_root; 139 - struct dentry *dentry_reg; 140 139 }; 141 140 142 141 struct aat2870_subdev_info {
+1
include/linux/platform_device.h
··· 58 58 devm_platform_ioremap_resource(struct platform_device *pdev, 59 59 unsigned int index); 60 60 extern int platform_get_irq(struct platform_device *, unsigned int); 61 + extern int platform_get_irq_optional(struct platform_device *, unsigned int); 61 62 extern int platform_irq_count(struct platform_device *); 62 63 extern struct resource *platform_get_resource_byname(struct platform_device *, 63 64 unsigned int,
+9
include/linux/sysfs.h
··· 196 196 .size = _size, \ 197 197 } 198 198 199 + #define __BIN_ATTR_WO(_name) { \ 200 + .attr = { .name = __stringify(_name), .mode = 0200 }, \ 201 + .store = _name##_store, \ 202 + .size = _size, \ 203 + } 204 + 199 205 #define __BIN_ATTR_RW(_name, _size) \ 200 206 __BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size) 201 207 ··· 213 207 214 208 #define BIN_ATTR_RO(_name, _size) \ 215 209 struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size) 210 + 211 + #define BIN_ATTR_WO(_name, _size) \ 212 + struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size) 216 213 217 214 #define BIN_ATTR_RW(_name, _size) \ 218 215 struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
+102
scripts/coccinelle/api/platform_get_irq.cocci
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /// Remove dev_err() messages after platform_get_irq*() failures 3 + // 4 + // Confidence: Medium 5 + // Options: --include-headers 6 + 7 + virtual patch 8 + virtual context 9 + virtual org 10 + virtual report 11 + 12 + @depends on context@ 13 + expression ret; 14 + struct platform_device *E; 15 + @@ 16 + 17 + ret = 18 + ( 19 + platform_get_irq 20 + | 21 + platform_get_irq_byname 22 + )(E, ...); 23 + 24 + if ( \( ret < 0 \| ret <= 0 \) ) 25 + { 26 + ( 27 + if (ret != -EPROBE_DEFER) 28 + { ... 29 + *dev_err(...); 30 + ... } 31 + | 32 + ... 33 + *dev_err(...); 34 + ) 35 + ... 36 + } 37 + 38 + @depends on patch@ 39 + expression ret; 40 + struct platform_device *E; 41 + @@ 42 + 43 + ret = 44 + ( 45 + platform_get_irq 46 + | 47 + platform_get_irq_byname 48 + )(E, ...); 49 + 50 + if ( \( ret < 0 \| ret <= 0 \) ) 51 + { 52 + ( 53 + -if (ret != -EPROBE_DEFER) 54 + -{ ... 55 + -dev_err(...); 56 + -... } 57 + | 58 + ... 59 + -dev_err(...); 60 + ) 61 + ... 62 + } 63 + 64 + @r depends on org || report@ 65 + position p1; 66 + expression ret; 67 + struct platform_device *E; 68 + @@ 69 + 70 + ret = 71 + ( 72 + platform_get_irq 73 + | 74 + platform_get_irq_byname 75 + )(E, ...); 76 + 77 + if ( \( ret < 0 \| ret <= 0 \) ) 78 + { 79 + ( 80 + if (ret != -EPROBE_DEFER) 81 + { ... 82 + dev_err@p1(...); 83 + ... } 84 + | 85 + ... 86 + dev_err@p1(...); 87 + ) 88 + ... 89 + } 90 + 91 + @script:python depends on org@ 92 + p1 << r.p1; 93 + @@ 94 + 95 + cocci.print_main(p1) 96 + 97 + @script:python depends on report@ 98 + p1 << r.p1; 99 + @@ 100 + 101 + msg = "line %s is redundant because platform_get_irq() already prints an error" % (p1[0].line) 102 + coccilib.report.print_report(p1[0],msg)