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

Driver Core: Make PM operations a const pointer

They are not supposed to be modified by drivers, so make them const.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

authored by

Dmitry Torokhov and committed by
Rafael J. Wysocki
d9ab7716 511647ff

+19 -16
+1 -1
drivers/base/platform.c
··· 889 889 890 890 #endif /* !CONFIG_HIBERNATION */ 891 891 892 - static struct dev_pm_ops platform_dev_pm_ops = { 892 + static const struct dev_pm_ops platform_dev_pm_ops = { 893 893 .prepare = platform_pm_prepare, 894 894 .complete = platform_pm_complete, 895 895 .suspend = platform_pm_suspend,
+5 -3
drivers/base/power/main.c
··· 157 157 * @ops: PM operations to choose from. 158 158 * @state: PM transition of the system being carried out. 159 159 */ 160 - static int pm_op(struct device *dev, struct dev_pm_ops *ops, 161 - pm_message_t state) 160 + static int pm_op(struct device *dev, 161 + const struct dev_pm_ops *ops, 162 + pm_message_t state) 162 163 { 163 164 int error = 0; 164 165 ··· 221 220 * The operation is executed with interrupts disabled by the only remaining 222 221 * functional CPU in the system. 223 222 */ 224 - static int pm_noirq_op(struct device *dev, struct dev_pm_ops *ops, 223 + static int pm_noirq_op(struct device *dev, 224 + const struct dev_pm_ops *ops, 225 225 pm_message_t state) 226 226 { 227 227 int error = 0;
+8 -8
drivers/pci/pci-driver.c
··· 575 575 static int pci_pm_suspend(struct device *dev) 576 576 { 577 577 struct pci_dev *pci_dev = to_pci_dev(dev); 578 - struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 578 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 579 579 580 580 if (pci_has_legacy_pm_support(pci_dev)) 581 581 return pci_legacy_suspend(dev, PMSG_SUSPEND); ··· 613 613 static int pci_pm_suspend_noirq(struct device *dev) 614 614 { 615 615 struct pci_dev *pci_dev = to_pci_dev(dev); 616 - struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 616 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 617 617 618 618 if (pci_has_legacy_pm_support(pci_dev)) 619 619 return pci_legacy_suspend_late(dev, PMSG_SUSPEND); ··· 672 672 static int pci_pm_resume(struct device *dev) 673 673 { 674 674 struct pci_dev *pci_dev = to_pci_dev(dev); 675 - struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 675 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 676 676 int error = 0; 677 677 678 678 /* ··· 711 711 static int pci_pm_freeze(struct device *dev) 712 712 { 713 713 struct pci_dev *pci_dev = to_pci_dev(dev); 714 - struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 714 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 715 715 716 716 if (pci_has_legacy_pm_support(pci_dev)) 717 717 return pci_legacy_suspend(dev, PMSG_FREEZE); ··· 780 780 static int pci_pm_thaw(struct device *dev) 781 781 { 782 782 struct pci_dev *pci_dev = to_pci_dev(dev); 783 - struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 783 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 784 784 int error = 0; 785 785 786 786 if (pci_has_legacy_pm_support(pci_dev)) ··· 799 799 static int pci_pm_poweroff(struct device *dev) 800 800 { 801 801 struct pci_dev *pci_dev = to_pci_dev(dev); 802 - struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 802 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 803 803 804 804 if (pci_has_legacy_pm_support(pci_dev)) 805 805 return pci_legacy_suspend(dev, PMSG_HIBERNATE); ··· 872 872 static int pci_pm_restore(struct device *dev) 873 873 { 874 874 struct pci_dev *pci_dev = to_pci_dev(dev); 875 - struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 875 + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 876 876 int error = 0; 877 877 878 878 /* ··· 910 910 911 911 #endif /* !CONFIG_HIBERNATION */ 912 912 913 - struct dev_pm_ops pci_dev_pm_ops = { 913 + const struct dev_pm_ops pci_dev_pm_ops = { 914 914 .prepare = pci_pm_prepare, 915 915 .complete = pci_pm_complete, 916 916 .suspend = pci_pm_suspend,
+5 -4
include/linux/device.h
··· 62 62 int (*suspend)(struct device *dev, pm_message_t state); 63 63 int (*resume)(struct device *dev); 64 64 65 - struct dev_pm_ops *pm; 65 + const struct dev_pm_ops *pm; 66 66 67 67 struct bus_type_private *p; 68 68 }; ··· 132 132 int (*resume) (struct device *dev); 133 133 struct attribute_group **groups; 134 134 135 - struct dev_pm_ops *pm; 135 + const struct dev_pm_ops *pm; 136 136 137 137 struct driver_private *p; 138 138 }; ··· 200 200 int (*suspend)(struct device *dev, pm_message_t state); 201 201 int (*resume)(struct device *dev); 202 202 203 - struct dev_pm_ops *pm; 203 + const struct dev_pm_ops *pm; 204 + 204 205 struct class_private *p; 205 206 }; 206 207 ··· 292 291 char *(*nodename)(struct device *dev); 293 292 void (*release)(struct device *dev); 294 293 295 - struct dev_pm_ops *pm; 294 + const struct dev_pm_ops *pm; 296 295 }; 297 296 298 297 /* interface for exporting device attributes */