From d88aecfc00fb3b2dccf28a0098de4fc50aae975f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 15 Nov 2020 15:12:01 +1100 Subject: [PATCH] [core] mark the configuration table as const --- src/amd/common.c | 2 +- src/amd/common.h | 2 +- src/device-db.h | 2 +- src/hook.c | 2 +- src/ioctl.c | 2 +- src/vendor-reset-dev.c | 10 ++++++---- src/vendor-reset-dev.h | 11 ++++++----- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/amd/common.c b/src/amd/common.c index 80e80ab..57563df 100644 --- a/src/amd/common.c +++ b/src/amd/common.c @@ -28,7 +28,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "common.h" #include "compat.h" -int amd_common_probe(struct vendor_reset_cfg *cfg, struct pci_dev *dev) +int amd_common_probe(const struct vendor_reset_cfg *cfg, struct pci_dev *dev) { /* disable bus reset for the card, seems to be an issue with all of them */ dev->dev_flags |= PCI_DEV_FLAGS_NO_BUS_RESET; diff --git a/src/amd/common.h b/src/amd/common.h index e7c0047..b999809 100644 --- a/src/amd/common.h +++ b/src/amd/common.h @@ -123,7 +123,7 @@ static inline struct amd_vendor_private *amd_private(struct vendor_reset_dev *vd return vdev->vendor_private; } -int amd_common_probe(struct vendor_reset_cfg *cfg, struct pci_dev *dev); +int amd_common_probe(const struct vendor_reset_cfg *cfg, struct pci_dev *dev); int amd_common_pre_reset(struct vendor_reset_dev *); int amd_common_post_reset(struct vendor_reset_dev *); diff --git a/src/device-db.h b/src/device-db.h index cf23e47..ab926c2 100644 --- a/src/device-db.h +++ b/src/device-db.h @@ -102,7 +102,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA {PCI_VENDOR_ID_ATI, 0x7360, op, DEVICE_INFO(AMD_NAVI12)}, \ {PCI_VENDOR_ID_ATI, 0x7362, op, DEVICE_INFO(AMD_NAVI12)} -static struct vendor_reset_cfg vendor_reset_devices[] = { +static const struct vendor_reset_cfg vendor_reset_devices[] = { _AMD_POLARIS10(&amd_polaris10_ops), _AMD_POLARIS11(&amd_polaris10_ops), _AMD_POLARIS12(&amd_polaris10_ops), diff --git a/src/hook.c b/src/hook.c index 4d780b2..7f31b48 100644 --- a/src/hook.c +++ b/src/hook.c @@ -32,7 +32,7 @@ static int (*orig_pci_dev_specific_reset)(struct pci_dev *dev, int probe); static int hooked_pci_dev_specific_reset(struct pci_dev *dev, int probe) { int ret; - struct vendor_reset_cfg *cfg; + const struct vendor_reset_cfg *cfg; cfg = vendor_reset_cfg_find(dev->vendor, dev->device); if (!cfg) diff --git a/src/ioctl.c b/src/ioctl.c index cf54ecb..ec2ce31 100644 --- a/src/ioctl.c +++ b/src/ioctl.c @@ -27,7 +27,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA static long vendor_reset_ioctl_reset(struct file * filp, unsigned long arg) { struct vendor_reset_ioctl iodev; - struct vendor_reset_cfg *cfg; + const struct vendor_reset_cfg *cfg; struct pci_dev * dev; int ret; diff --git a/src/vendor-reset-dev.c b/src/vendor-reset-dev.c index 0de3015..64e9e5f 100644 --- a/src/vendor-reset-dev.c +++ b/src/vendor-reset-dev.c @@ -20,10 +20,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "vendor-reset-dev.h" #include "device-db.h" -struct vendor_reset_cfg * vendor_reset_cfg_find(unsigned int vendor, +const struct vendor_reset_cfg * vendor_reset_cfg_find(unsigned int vendor, unsigned int device) { - struct vendor_reset_cfg * cfg; + const struct vendor_reset_cfg * cfg; for(cfg = vendor_reset_devices; cfg->vendor; ++cfg) { @@ -40,7 +40,8 @@ struct vendor_reset_cfg * vendor_reset_cfg_find(unsigned int vendor, return cfg; } -long vendor_reset_dev_locked(struct vendor_reset_cfg *cfg, struct pci_dev *dev) +long vendor_reset_dev_locked(const struct vendor_reset_cfg *cfg, + struct pci_dev *dev) { struct vendor_reset_dev vdev = { @@ -78,7 +79,8 @@ long vendor_reset_dev_locked(struct vendor_reset_cfg *cfg, struct pci_dev *dev) return ret; } -long vendor_reset_dev(struct vendor_reset_cfg *cfg, struct pci_dev *dev) +long vendor_reset_dev(const struct vendor_reset_cfg *cfg, + struct pci_dev *dev) { int ret; diff --git a/src/vendor-reset-dev.h b/src/vendor-reset-dev.h index f05df21..df39b53 100644 --- a/src/vendor-reset-dev.h +++ b/src/vendor-reset-dev.h @@ -26,7 +26,7 @@ struct vendor_reset_cfg; struct vendor_reset_dev { - struct vendor_reset_cfg *cfg; + const struct vendor_reset_cfg *cfg; struct pci_dev *pdev; unsigned long info; @@ -46,7 +46,7 @@ struct vendor_reset_ops /* version of the reset operations for logging */ const struct vendor_reset_ver version; /* called when the kernel is probing for a working reset function */ - int (*probe)(struct vendor_reset_cfg *, struct pci_dev *); + int (*probe)(const struct vendor_reset_cfg *, struct pci_dev *); /* any pre-reset ops to do, i.e., common code between devices */ int (*pre_reset)(struct vendor_reset_dev *); /* the reset method for the device at the specified address */ @@ -74,12 +74,13 @@ struct vendor_reset_cfg }; /* search the device table for the specified vendor and device id and return it */ -struct vendor_reset_cfg * vendor_reset_cfg_find(unsigned int vendor, +const struct vendor_reset_cfg * vendor_reset_cfg_find(unsigned int vendor, unsigned int device); /* perform the device reset */ -long vendor_reset_dev_locked(struct vendor_reset_cfg *cfg, struct pci_dev *dev); -long vendor_reset_dev(struct vendor_reset_cfg *cfg, struct pci_dev *dev); +long vendor_reset_dev_locked(const struct vendor_reset_cfg *cfg, + struct pci_dev *dev); +long vendor_reset_dev(const struct vendor_reset_cfg *cfg, struct pci_dev *dev); #define vr_info(vdev, fmt, arg...) \ pci_info ((vdev)->pdev, "%s: " fmt, (vdev)->cfg->info_str, ##arg)