From 99ee67351bedf23fe6b969dd94cc2847b397cd20 Mon Sep 17 00:00:00 2001 From: LABBE Corentin Date: Fri, 13 Nov 2015 13:31:51 +0100 Subject: ipmi: constify some struct and char arrays Lots of char arrays could be set as const since they contain only literal char arrays. We could in the same time make const some struct members who are pointer to those const char arrays. Signed-off-by: LABBE Corentin Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_msghandler.c | 7 ++++--- drivers/char/ipmi/ipmi_si_intf.c | 27 ++++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index e3536da..94fb407 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -472,9 +472,10 @@ static DEFINE_MUTEX(smi_watchers_mutex); #define ipmi_get_stat(intf, stat) \ ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat])) -static char *addr_src_to_str[] = { "invalid", "hotmod", "hardcoded", "SPMI", - "ACPI", "SMBIOS", "PCI", - "device-tree", "default" }; +static const char * const addr_src_to_str[] = { + "invalid", "hotmod", "hardcoded", "SPMI", "ACPI", "SMBIOS", "PCI", + "device-tree", "default" +}; const char *ipmi_addr_src_to_str(enum ipmi_addr_src src) { diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 4cc72fa..440574d 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -105,7 +105,8 @@ enum si_intf_state { enum si_type { SI_KCS, SI_SMIC, SI_BT }; -static char *si_to_str[] = { "kcs", "smic", "bt" }; + +static const char * const si_to_str[] = { "kcs", "smic", "bt" }; #define DEVICE_NAME "ipmi_si" @@ -1341,7 +1342,7 @@ static unsigned int num_slave_addrs; #define IPMI_IO_ADDR_SPACE 0 #define IPMI_MEM_ADDR_SPACE 1 -static char *addr_space_to_str[] = { "i/o", "mem" }; +static const char * const addr_space_to_str[] = { "i/o", "mem" }; static int hotmod_handler(const char *val, struct kernel_param *kp); @@ -1723,27 +1724,31 @@ static int mem_setup(struct smi_info *info) */ enum hotmod_op { HM_ADD, HM_REMOVE }; struct hotmod_vals { - char *name; - int val; + const char *name; + const int val; }; -static struct hotmod_vals hotmod_ops[] = { + +static const struct hotmod_vals hotmod_ops[] = { { "add", HM_ADD }, { "remove", HM_REMOVE }, { NULL } }; -static struct hotmod_vals hotmod_si[] = { + +static const struct hotmod_vals hotmod_si[] = { { "kcs", SI_KCS }, { "smic", SI_SMIC }, { "bt", SI_BT }, { NULL } }; -static struct hotmod_vals hotmod_as[] = { + +static const struct hotmod_vals hotmod_as[] = { { "mem", IPMI_MEM_ADDR_SPACE }, { "i/o", IPMI_IO_ADDR_SPACE }, { NULL } }; -static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr) +static int parse_str(const struct hotmod_vals *v, int *val, char *name, + char **curr) { char *s; int i; @@ -2870,7 +2875,7 @@ static int ipmi_parisc_remove(struct parisc_device *dev) return 0; } -static struct parisc_device_id ipmi_parisc_tbl[] = { +static const struct parisc_device_id ipmi_parisc_tbl[] = { { HPHW_MC, HVERSION_REV_ANY_ID, 0x004, 0xC0 }, { 0, } }; @@ -3444,8 +3449,8 @@ static inline void wait_for_timer_and_thread(struct smi_info *smi_info) static const struct ipmi_default_vals { - int type; - int port; + const int type; + const int port; } ipmi_defaults[] = { { .type = SI_KCS, .port = 0xca2 }, -- cgit v1.1 From aad756f869c445488f814a2bff9211d81c46535e Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 19 Nov 2015 12:56:39 +0900 Subject: char: ipmi: Drop owner assignment from i2c_driver i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski --- drivers/char/ipmi/ipmi_ssif.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 90e6246..5f1c3d0 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -1959,7 +1959,6 @@ MODULE_DEVICE_TABLE(i2c, ssif_id); static struct i2c_driver ssif_i2c_driver = { .class = I2C_CLASS_HWMON, .driver = { - .owner = THIS_MODULE, .name = DEVICE_NAME }, .probe = ssif_probe, -- cgit v1.1 From bb0dcebef99fd024c0fb2703179bc7d1fd5ee995 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 19 Nov 2015 19:24:33 -0500 Subject: ipmi: Remove unnecessary pci_disable_device. We call cleanup_one_si from ipmi_pci_remove, which calls ->addr_source_cleanup, which gets set to point to ipmi_pci_cleanup, which does a pci_disable_device. On return from this, we do a second pci_disable_device, which results in the trace below. ipmi_si 0000:00:16.0: disabling already-disabled device Call Trace: [] dump_stack+0x45/0x57 [] warn_slowpath_common+0x97/0xe0 [] warn_slowpath_fmt+0x46/0x50 [] pci_disable_device+0xb1/0xc0 [] ipmi_pci_remove+0x25/0x30 [ipmi_si] [] pci_device_remove+0x46/0xc0 [] __device_release_driver+0x7f/0xf0 [] driver_detach+0xb8/0xc0 [] bus_remove_driver+0x50/0xa0 [] driver_unregister+0x2e/0x60 [] pci_unregister_driver+0x25/0x90 [] cleanup_ipmi_si+0xd4/0xf0 [ipmi_si] [] SyS_delete_module+0x12a/0x200 [] system_call_fastpath+0x12/0x17 Signed-off-by: Dave Jones --- drivers/char/ipmi/ipmi_si_intf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 440574d..9fda22e 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -2559,7 +2559,6 @@ static void ipmi_pci_remove(struct pci_dev *pdev) { struct smi_info *info = pci_get_drvdata(pdev); cleanup_one_si(info); - pci_disable_device(pdev); } static const struct pci_device_id ipmi_pci_devices[] = { -- cgit v1.1