Message ID | 20211119003803.2333-3-kelvin.cao@microchip.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Bjorn Helgaas |
Headers | show |
Series | Add Switchtec Gen4 automotive device IDs and a tweak | expand |
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c index 6e2d6c5ea4b5..c36c1238c604 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c @@ -122,7 +122,7 @@ static void stuser_set_state(struct switchtec_user *stuser, { /* requires the mrpc_mutex to already be held when called */ - const char * const state_names[] = { + static const char * const state_names[] = { [MRPC_IDLE] = "IDLE", [MRPC_QUEUED] = "QUEUED", [MRPC_RUNNING] = "RUNNING",
When a MRPC command is being executed, the function stuser_set_state() will be called several times to set the command execution state. During each run of stuser_set_state(), the local array state_names is allocated and populated. The array contains a constant mapping of the state enum values to the text strings, so repeated allocation and initialization is just a wait of CPU cycles. Therefore, declare the array as static. See the link below for the discussion. https://lore.kernel.org/r/20211014141859.11444-1-kelvin.cao@microchip.com/ Suggested-by: Krzysztof WilczyĆski <kw@linux.com> Signed-off-by: Kelvin Cao <kelvin.cao@microchip.com> --- drivers/pci/switch/switchtec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)