From 1be0593f05e25d56a8f65586ea6d9afa601743bc Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Apr 2017 09:49:22 +0200 Subject: HSI: nokia-modem: Use devm_kcalloc() in nokia_modem_gpio_probe() * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/hsi/clients/nokia-modem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/hsi') diff --git a/drivers/hsi/clients/nokia-modem.c b/drivers/hsi/clients/nokia-modem.c index c000780d931f..f6c97a0e1fcd 100644 --- a/drivers/hsi/clients/nokia-modem.c +++ b/drivers/hsi/clients/nokia-modem.c @@ -102,8 +102,8 @@ static int nokia_modem_gpio_probe(struct device *dev) return -EINVAL; } - modem->gpios = devm_kzalloc(dev, gpio_count * - sizeof(struct nokia_modem_gpio), GFP_KERNEL); + modem->gpios = devm_kcalloc(dev, gpio_count, sizeof(*modem->gpios), + GFP_KERNEL); if (!modem->gpios) { dev_err(dev, "Could not allocate memory for gpios\n"); return -ENOMEM; -- cgit v1.2.3-58-ga151 From 4e3b9baa2f798a6cc9865d451269251378067f3a Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Apr 2017 10:17:06 +0200 Subject: HSI: nokia-modem: Delete error messages for a failed memory allocation in two functions The script "checkpatch.pl" pointed information out like the following. WARNING: Possible unnecessary 'out of memory' message Thus remove such statements here. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/hsi/clients/nokia-modem.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/hsi') diff --git a/drivers/hsi/clients/nokia-modem.c b/drivers/hsi/clients/nokia-modem.c index f6c97a0e1fcd..a774ca7839e1 100644 --- a/drivers/hsi/clients/nokia-modem.c +++ b/drivers/hsi/clients/nokia-modem.c @@ -104,10 +104,8 @@ static int nokia_modem_gpio_probe(struct device *dev) modem->gpios = devm_kcalloc(dev, gpio_count, sizeof(*modem->gpios), GFP_KERNEL); - if (!modem->gpios) { - dev_err(dev, "Could not allocate memory for gpios\n"); + if (!modem->gpios) return -ENOMEM; - } modem->gpio_amount = gpio_count; @@ -156,10 +154,9 @@ static int nokia_modem_probe(struct device *dev) } modem = devm_kzalloc(dev, sizeof(*modem), GFP_KERNEL); - if (!modem) { - dev_err(dev, "Could not allocate memory for nokia_modem_device\n"); + if (!modem) return -ENOMEM; - } + dev_set_drvdata(dev, modem); modem->device = dev; -- cgit v1.2.3-58-ga151 From 34b2486def90f3487cbac2d00a6c4aad0834a331 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Apr 2017 10:20:37 +0200 Subject: HSI: nokia-modem: Add a space character for better code readability in nokia_modem_probe() The script "checkpatch.pl" pointed information out like the following. ERROR: space required before the open parenthesis '(' Thus fix the affected source code place. Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/hsi/clients/nokia-modem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/hsi') diff --git a/drivers/hsi/clients/nokia-modem.c b/drivers/hsi/clients/nokia-modem.c index a774ca7839e1..f78cca98266f 100644 --- a/drivers/hsi/clients/nokia-modem.c +++ b/drivers/hsi/clients/nokia-modem.c @@ -179,7 +179,7 @@ static int nokia_modem_probe(struct device *dev) } enable_irq_wake(irq); - if(pm) { + if (pm) { err = nokia_modem_gpio_probe(dev); if (err < 0) { dev_err(dev, "Could not probe GPIOs\n"); -- cgit v1.2.3-58-ga151 From 4a8557de7fb0be63e4e783ad4ad77463afb0d611 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Apr 2017 11:20:41 +0200 Subject: HSI: omap_ssi: Use devm_kcalloc() in ssi_add_controller() * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/hsi/controllers/omap_ssi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/hsi') diff --git a/drivers/hsi/controllers/omap_ssi_core.c b/drivers/hsi/controllers/omap_ssi_core.c index 9a29b34ed2c8..464db6d33afb 100644 --- a/drivers/hsi/controllers/omap_ssi_core.c +++ b/drivers/hsi/controllers/omap_ssi_core.c @@ -421,8 +421,8 @@ static int ssi_add_controller(struct hsi_controller *ssi, goto out_err; } - omap_ssi->port = devm_kzalloc(&ssi->device, - sizeof(struct omap_ssi_port *) * ssi->num_ports, GFP_KERNEL); + omap_ssi->port = devm_kcalloc(&ssi->device, ssi->num_ports, + sizeof(*omap_ssi->port), GFP_KERNEL); if (!omap_ssi->port) { err = -ENOMEM; goto out_err; -- cgit v1.2.3-58-ga151 From 8621e620c172232ec949f962ab3c977a058c516f Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Apr 2017 11:35:11 +0200 Subject: HSI: omap_ssi: Fix a typo in a comment line Add a missing character in this description for a function call. Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/hsi/controllers/omap_ssi_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/hsi') diff --git a/drivers/hsi/controllers/omap_ssi_core.c b/drivers/hsi/controllers/omap_ssi_core.c index 464db6d33afb..fb7ed8fce83a 100644 --- a/drivers/hsi/controllers/omap_ssi_core.c +++ b/drivers/hsi/controllers/omap_ssi_core.c @@ -467,7 +467,7 @@ static int ssi_hw_init(struct hsi_controller *ssi) dev_err(&ssi->device, "runtime PM failed %d\n", err); return err; } - /* Reseting GDD */ + /* Resetting GDD */ writel_relaxed(SSI_SWRESET, omap_ssi->gdd + SSI_GDD_GRST_REG); /* Get FCK rate in KHz */ omap_ssi->fck_rate = DIV_ROUND_CLOSEST(ssi_get_clk_rate(ssi), 1000); -- cgit v1.2.3-58-ga151 From 0fbad7c8e2def6a1aa84c3efff23f79539ba530a Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Apr 2017 12:42:14 +0200 Subject: HSI: omap_ssi: Delete an error message for a failed memory allocation in ssi_add_controller() The script "checkpatch.pl" pointed information out like the following. WARNING: Possible unnecessary 'out of memory' message Thus remove such a statement here. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/hsi/controllers/omap_ssi_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/hsi') diff --git a/drivers/hsi/controllers/omap_ssi_core.c b/drivers/hsi/controllers/omap_ssi_core.c index fb7ed8fce83a..88e48b346916 100644 --- a/drivers/hsi/controllers/omap_ssi_core.c +++ b/drivers/hsi/controllers/omap_ssi_core.c @@ -384,10 +384,8 @@ static int ssi_add_controller(struct hsi_controller *ssi, int err; omap_ssi = devm_kzalloc(&ssi->device, sizeof(*omap_ssi), GFP_KERNEL); - if (!omap_ssi) { - dev_err(&pd->dev, "not enough memory for omap ssi\n"); + if (!omap_ssi) return -ENOMEM; - } err = ida_simple_get(&platform_omap_ssi_ida, 0, 0, GFP_KERNEL); if (err < 0) -- cgit v1.2.3-58-ga151 From de7c98eb7c6f72bbfa87afc5b7e2d3b0188a8d83 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Apr 2017 13:56:08 +0200 Subject: HSI: Use kcalloc() in hsi_register_board_info() A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/hsi/hsi_boardinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/hsi') diff --git a/drivers/hsi/hsi_boardinfo.c b/drivers/hsi/hsi_boardinfo.c index e56bc6da5f98..e381cb4c962e 100644 --- a/drivers/hsi/hsi_boardinfo.c +++ b/drivers/hsi/hsi_boardinfo.c @@ -49,7 +49,7 @@ int __init hsi_register_board_info(struct hsi_board_info const *info, { struct hsi_cl_info *cl_info; - cl_info = kzalloc(sizeof(*cl_info) * len, GFP_KERNEL); + cl_info = kcalloc(len, sizeof(*cl_info), GFP_KERNEL); if (!cl_info) return -ENOMEM; -- cgit v1.2.3-58-ga151 From 67ddd75771b6b860bc0cebb3b7fd4cbebeda9cd4 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Apr 2017 14:17:50 +0200 Subject: HSI: core: Use kcalloc() in two functions Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/hsi/hsi_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/hsi') diff --git a/drivers/hsi/hsi_core.c b/drivers/hsi/hsi_core.c index c2a2a9795b0b..9065efd21851 100644 --- a/drivers/hsi/hsi_core.c +++ b/drivers/hsi/hsi_core.c @@ -267,14 +267,13 @@ static void hsi_add_client_from_dt(struct hsi_port *port, cl->rx_cfg.num_channels = cells; cl->tx_cfg.num_channels = cells; - - cl->rx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL); + cl->rx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL); if (!cl->rx_cfg.channels) { err = -ENOMEM; goto err; } - cl->tx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL); + cl->tx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL); if (!cl->tx_cfg.channels) { err = -ENOMEM; goto err2; @@ -485,7 +484,7 @@ struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags) hsi = kzalloc(sizeof(*hsi), flags); if (!hsi) return NULL; - port = kzalloc(sizeof(*port)*n_ports, flags); + port = kcalloc(n_ports, sizeof(*port), flags); if (!port) { kfree(hsi); return NULL; -- cgit v1.2.3-58-ga151