treewide: devm_kzalloc() -> devm_kcalloc()
authorKees Cook <keescook@chromium.org>
Tue, 12 Jun 2018 21:07:58 +0000 (14:07 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 12 Jun 2018 23:19:22 +0000 (16:19 -0700)
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
This patch replaces cases of:

        devm_kzalloc(handle, a * b, gfp)

with:
        devm_kcalloc(handle, a * b, gfp)

as well as handling cases of:

        devm_kzalloc(handle, a * b * c, gfp)

with:

        devm_kzalloc(handle, array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        devm_kcalloc(handle, array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        devm_kzalloc(handle, 4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

Some manual whitespace fixes were needed in this patch, as Coccinelle
really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
expression HANDLE;
type TYPE;
expression THING, E;
@@

(
  devm_kzalloc(HANDLE,
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
  , ...)
|
  devm_kzalloc(HANDLE,
- (sizeof(THING)) * E
+ sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression HANDLE;
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  devm_kzalloc(HANDLE,
- sizeof(u8) * (COUNT)
+ COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(__u8) * (COUNT)
+ COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(char) * (COUNT)
+ COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(unsigned char) * (COUNT)
+ COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(u8) * COUNT
+ COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(__u8) * COUNT
+ COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(char) * COUNT
+ COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(unsigned char) * COUNT
+ COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
expression HANDLE;
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
expression HANDLE;
identifier SIZE, COUNT;
@@

- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- SIZE * COUNT
+ COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression HANDLE;
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  devm_kzalloc(HANDLE,
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression HANDLE;
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
expression HANDLE;
identifier STRIDE, SIZE, COUNT;
@@

(
  devm_kzalloc(HANDLE,
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression HANDLE;
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE,
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression HANDLE;
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
|
  devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
|
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE, C1 * C2, ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- sizeof(THING) * E2
+ E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- (E1) * E2
+ E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- (E1) * (E2)
+ E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
- E1 * E2
+ E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
229 files changed:
drivers/acpi/fan.c
drivers/acpi/nfit/core.c
drivers/ata/sata_mv.c
drivers/bus/fsl-mc/fsl-mc-allocator.c
drivers/char/tpm/tpm2-cmd.c
drivers/clk/bcm/clk-bcm2835.c
drivers/clk/ti/adpll.c
drivers/cpufreq/brcmstb-avs-cpufreq.c
drivers/cpufreq/imx6q-cpufreq.c
drivers/crypto/marvell/cesa.c
drivers/crypto/talitos.c
drivers/devfreq/devfreq.c
drivers/devfreq/event/exynos-ppmu.c
drivers/dma/k3dma.c
drivers/dma/mv_xor_v2.c
drivers/dma/s3c24xx-dma.c
drivers/dma/zx_dma.c
drivers/firmware/arm_scpi.c
drivers/firmware/ti_sci.c
drivers/gpio/gpio-adnp.c
drivers/gpio/gpio-aspeed.c
drivers/gpio/gpio-bcm-kona.c
drivers/gpio/gpio-davinci.c
drivers/gpio/gpio-htc-egpio.c
drivers/gpio/gpio-thunderx.c
drivers/gpu/drm/exynos/exynos_drm_dsi.c
drivers/gpu/drm/exynos/exynos_drm_fimc.c
drivers/gpu/drm/exynos/exynos_drm_gsc.c
drivers/gpu/drm/exynos/exynos_hdmi.c
drivers/gpu/drm/msm/hdmi/hdmi.c
drivers/gpu/drm/msm/hdmi/hdmi_phy.c
drivers/hid/hid-sensor-hub.c
drivers/hid/intel-ish-hid/ishtp-hid-client.c
drivers/hid/wacom_sys.c
drivers/hwmon/aspeed-pwm-tacho.c
drivers/hwmon/gpio-fan.c
drivers/hwmon/ibmpowernv.c
drivers/hwmon/iio_hwmon.c
drivers/hwmon/nct6683.c
drivers/hwmon/nct6775.c
drivers/hwmon/pmbus/pmbus_core.c
drivers/hwmon/pmbus/ucd9000.c
drivers/hwmon/pwm-fan.c
drivers/hwtracing/coresight/coresight-etb10.c
drivers/hwtracing/coresight/of_coresight.c
drivers/i2c/busses/i2c-qup.c
drivers/i2c/muxes/i2c-mux-gpio.c
drivers/i2c/muxes/i2c-mux-reg.c
drivers/iio/adc/at91_adc.c
drivers/iio/adc/max1363.c
drivers/iio/adc/twl6030-gpadc.c
drivers/iio/dac/ad5592r-base.c
drivers/iio/multiplexer/iio-mux.c
drivers/input/keyboard/clps711x-keypad.c
drivers/input/keyboard/matrix_keypad.c
drivers/input/keyboard/samsung-keypad.c
drivers/input/matrix-keymap.c
drivers/input/misc/rotary_encoder.c
drivers/input/rmi4/rmi_driver.c
drivers/input/rmi4/rmi_f11.c
drivers/input/rmi4/rmi_f12.c
drivers/input/rmi4/rmi_f54.c
drivers/input/rmi4/rmi_spi.c
drivers/iommu/arm-smmu.c
drivers/iommu/rockchip-iommu.c
drivers/irqchip/irq-imgpdc.c
drivers/irqchip/irq-mvebu-gicp.c
drivers/leds/leds-adp5520.c
drivers/leds/leds-apu.c
drivers/leds/leds-da9052.c
drivers/leds/leds-lp5521.c
drivers/leds/leds-lp5523.c
drivers/leds/leds-lp5562.c
drivers/leds/leds-lp55xx-common.c
drivers/leds/leds-lp8501.c
drivers/leds/leds-lt3593.c
drivers/leds/leds-mc13783.c
drivers/leds/leds-mlxcpld.c
drivers/leds/leds-netxbig.c
drivers/leds/leds-ns2.c
drivers/leds/leds-pca955x.c
drivers/leds/leds-pca963x.c
drivers/leds/leds-tca6507.c
drivers/mailbox/hi6220-mailbox.c
drivers/mailbox/mailbox-sti.c
drivers/mailbox/omap-mailbox.c
drivers/mailbox/ti-msgmgr.c
drivers/media/i2c/s5k5baf.c
drivers/media/platform/am437x/am437x-vpfe.c
drivers/media/platform/davinci/vpif_capture.c
drivers/media/platform/qcom/camss-8x16/camss-csid.c
drivers/media/platform/qcom/camss-8x16/camss-csiphy.c
drivers/media/platform/qcom/camss-8x16/camss-ispif.c
drivers/media/platform/qcom/camss-8x16/camss-vfe.c
drivers/media/platform/qcom/camss-8x16/camss.c
drivers/media/platform/vsp1/vsp1_entity.c
drivers/media/platform/xilinx/xilinx-vipp.c
drivers/media/v4l2-core/v4l2-flash-led-class.c
drivers/memory/of_memory.c
drivers/mfd/ab8500-debugfs.c
drivers/mfd/htc-i2cpld.c
drivers/mfd/motorola-cpcap.c
drivers/mfd/sprd-sc27xx-spi.c
drivers/mfd/twl-core.c
drivers/mfd/wm8994-core.c
drivers/misc/sram.c
drivers/mmc/host/sdhci-omap.c
drivers/mtd/devices/docg3.c
drivers/mtd/nand/raw/qcom_nandc.c
drivers/mtd/nand/raw/s3c2410.c
drivers/net/dsa/b53/b53_common.c
drivers/net/ethernet/amazon/ena/ena_ethtool.c
drivers/net/ethernet/ethoc.c
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
drivers/net/ethernet/ni/nixge.c
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
drivers/net/ethernet/ti/cpsw.c
drivers/net/ethernet/ti/netcp_ethss.c
drivers/net/phy/phy_led_triggers.c
drivers/net/wireless/mediatek/mt76/mac80211.c
drivers/pci/cadence/pcie-cadence-ep.c
drivers/pci/dwc/pci-dra7xx.c
drivers/pci/dwc/pcie-designware-ep.c
drivers/pci/host/pcie-rockchip-ep.c
drivers/pinctrl/berlin/berlin.c
drivers/pinctrl/freescale/pinctrl-imx.c
drivers/pinctrl/freescale/pinctrl-imx1-core.c
drivers/pinctrl/freescale/pinctrl-mxs.c
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
drivers/pinctrl/mvebu/pinctrl-mvebu.c
drivers/pinctrl/pinctrl-at91-pio4.c
drivers/pinctrl/pinctrl-at91.c
drivers/pinctrl/pinctrl-axp209.c
drivers/pinctrl/pinctrl-digicolor.c
drivers/pinctrl/pinctrl-ingenic.c
drivers/pinctrl/pinctrl-lpc18xx.c
drivers/pinctrl/pinctrl-ocelot.c
drivers/pinctrl/pinctrl-rockchip.c
drivers/pinctrl/pinctrl-single.c
drivers/pinctrl/pinctrl-st.c
drivers/pinctrl/pinctrl-xway.c
drivers/pinctrl/samsung/pinctrl-exynos.c
drivers/pinctrl/samsung/pinctrl-samsung.c
drivers/pinctrl/sh-pfc/core.c
drivers/pinctrl/sh-pfc/gpio.c
drivers/pinctrl/sh-pfc/pinctrl.c
drivers/pinctrl/spear/pinctrl-plgpio.c
drivers/pinctrl/sprd/pinctrl-sprd.c
drivers/pinctrl/sunxi/pinctrl-sunxi.c
drivers/pinctrl/tegra/pinctrl-tegra.c
drivers/pinctrl/ti/pinctrl-ti-iodelay.c
drivers/pinctrl/zte/pinctrl-zx.c
drivers/platform/mellanox/mlxreg-hotplug.c
drivers/power/supply/charger-manager.c
drivers/power/supply/power_supply_core.c
drivers/pwm/pwm-lp3943.c
drivers/regulator/act8865-regulator.c
drivers/regulator/as3711-regulator.c
drivers/regulator/bcm590xx-regulator.c
drivers/regulator/da9063-regulator.c
drivers/regulator/gpio-regulator.c
drivers/regulator/max1586.c
drivers/regulator/max8660.c
drivers/regulator/max8997-regulator.c
drivers/regulator/max8998.c
drivers/regulator/mc13xxx-regulator-core.c
drivers/regulator/pbias-regulator.c
drivers/regulator/rc5t583-regulator.c
drivers/regulator/s5m8767.c
drivers/regulator/ti-abb-regulator.c
drivers/regulator/tps65090-regulator.c
drivers/regulator/tps65217-regulator.c
drivers/regulator/tps65218-regulator.c
drivers/regulator/tps65910-regulator.c
drivers/regulator/tps80031-regulator.c
drivers/reset/reset-ti-syscon.c
drivers/scsi/isci/init.c
drivers/scsi/ufs/ufshcd-pltfrm.c
drivers/scsi/ufs/ufshcd.c
drivers/soc/bcm/raspberrypi-power.c
drivers/soc/mediatek/mtk-scpsys.c
drivers/soc/ti/knav_qmss_acc.c
drivers/spi/spi-davinci.c
drivers/spi/spi-ep93xx.c
drivers/spi/spi-gpio.c
drivers/spi/spi-imx.c
drivers/spi/spi-oc-tiny.c
drivers/spi/spi-pl022.c
drivers/spi/spi.c
drivers/staging/greybus/audio_topology.c
drivers/staging/media/imx/imx-media-dev.c
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
drivers/thermal/tegra/soctherm.c
drivers/thermal/thermal-generic-adc.c
drivers/tty/serial/rp2.c
drivers/usb/gadget/udc/atmel_usba_udc.c
drivers/usb/gadget/udc/renesas_usb3.c
drivers/video/backlight/adp8860_bl.c
drivers/video/backlight/adp8870_bl.c
drivers/video/backlight/lp855x_bl.c
drivers/video/fbdev/au1100fb.c
drivers/video/fbdev/mxsfb.c
drivers/video/fbdev/omap2/omapfb/vrfb.c
sound/soc/au1x/dbdma2.c
sound/soc/codecs/hdmi-codec.c
sound/soc/codecs/rt5645.c
sound/soc/codecs/wm8994.c
sound/soc/davinci/davinci-mcasp.c
sound/soc/generic/audio-graph-card.c
sound/soc/generic/audio-graph-scu-card.c
sound/soc/generic/simple-card.c
sound/soc/generic/simple-scu-card.c
sound/soc/img/img-i2s-in.c
sound/soc/img/img-i2s-out.c
sound/soc/intel/skylake/skl-topology.c
sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
sound/soc/pxa/mmp-sspa.c
sound/soc/rockchip/rk3399_gru_sound.c
sound/soc/sh/rcar/cmd.c
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/ctu.c
sound/soc/sh/rcar/dvc.c
sound/soc/sh/rcar/mix.c
sound/soc/sh/rcar/src.c
sound/soc/sh/rcar/ssi.c
sound/soc/sh/rcar/ssiu.c
sound/soc/soc-core.c
sound/soc/uniphier/aio-cpu.c

index 3563103..fe0183d 100644 (file)
@@ -298,8 +298,8 @@ static int acpi_fan_get_fps(struct acpi_device *device)
        }
 
        fan->fps_count = obj->package.count - 1; /* minus revision field */
-       fan->fps = devm_kzalloc(&device->dev,
-                               fan->fps_count * sizeof(struct acpi_fan_fps),
+       fan->fps = devm_kcalloc(&device->dev,
+                               fan->fps_count, sizeof(struct acpi_fan_fps),
                                GFP_KERNEL);
        if (!fan->fps) {
                dev_err(&device->dev, "Not enough memory\n");
index b87252b..d15814e 100644 (file)
@@ -1082,9 +1082,10 @@ static int __nfit_mem_init(struct acpi_nfit_desc *acpi_desc,
                                continue;
                        nfit_mem->nfit_flush = nfit_flush;
                        flush = nfit_flush->flush;
-                       nfit_mem->flush_wpq = devm_kzalloc(acpi_desc->dev,
-                                       flush->hint_count
-                                       * sizeof(struct resource), GFP_KERNEL);
+                       nfit_mem->flush_wpq = devm_kcalloc(acpi_desc->dev,
+                                       flush->hint_count,
+                                       sizeof(struct resource),
+                                       GFP_KERNEL);
                        if (!nfit_mem->flush_wpq)
                                return -ENOMEM;
                        for (i = 0; i < flush->hint_count; i++) {
index cddf96f..73ba8e1 100644 (file)
@@ -4114,13 +4114,13 @@ static int mv_platform_probe(struct platform_device *pdev)
 
        if (!host || !hpriv)
                return -ENOMEM;
-       hpriv->port_clks = devm_kzalloc(&pdev->dev,
-                                       sizeof(struct clk *) * n_ports,
+       hpriv->port_clks = devm_kcalloc(&pdev->dev,
+                                       n_ports, sizeof(struct clk *),
                                        GFP_KERNEL);
        if (!hpriv->port_clks)
                return -ENOMEM;
-       hpriv->port_phys = devm_kzalloc(&pdev->dev,
-                                       sizeof(struct phy *) * n_ports,
+       hpriv->port_phys = devm_kcalloc(&pdev->dev,
+                                       n_ports, sizeof(struct phy *),
                                        GFP_KERNEL);
        if (!hpriv->port_phys)
                return -ENOMEM;
index fb1442b..e906ecf 100644 (file)
@@ -354,8 +354,8 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
        if (error < 0)
                return error;
 
-       irq_resources = devm_kzalloc(&mc_bus_dev->dev,
-                                    sizeof(*irq_resources) * irq_count,
+       irq_resources = devm_kcalloc(&mc_bus_dev->dev,
+                                    irq_count, sizeof(*irq_resources),
                                     GFP_KERNEL);
        if (!irq_resources) {
                error = -ENOMEM;
@@ -455,7 +455,7 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev)
                return -ENOSPC;
        }
 
-       irqs = devm_kzalloc(&mc_dev->dev, irq_count * sizeof(irqs[0]),
+       irqs = devm_kcalloc(&mc_dev->dev, irq_count, sizeof(irqs[0]),
                            GFP_KERNEL);
        if (!irqs)
                return -ENOMEM;
index 96c77c8..d31b090 100644 (file)
@@ -980,7 +980,7 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip)
                goto out;
        }
 
-       chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands,
+       chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands,
                                          GFP_KERNEL);
 
        rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY);
index 9e0b2f2..7bef066 100644 (file)
@@ -734,7 +734,7 @@ static void bcm2835_pll_debug_init(struct clk_hw *hw,
        const struct bcm2835_pll_data *data = pll->data;
        struct debugfs_reg32 *regs;
 
-       regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
+       regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL);
        if (!regs)
                return;
 
@@ -865,7 +865,7 @@ static void bcm2835_pll_divider_debug_init(struct clk_hw *hw,
        const struct bcm2835_pll_divider_data *data = divider->data;
        struct debugfs_reg32 *regs;
 
-       regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
+       regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL);
        if (!regs)
                return;
 
index d6036c7..688e403 100644 (file)
@@ -501,8 +501,9 @@ static int ti_adpll_init_dco(struct ti_adpll_data *d)
        const char *postfix;
        int width, err;
 
-       d->outputs.clks = devm_kzalloc(d->dev, sizeof(struct clk *) *
+       d->outputs.clks = devm_kcalloc(d->dev,
                                       MAX_ADPLL_OUTPUTS,
+                                      sizeof(struct clk *),
                                       GFP_KERNEL);
        if (!d->outputs.clks)
                return -ENOMEM;
@@ -915,8 +916,9 @@ static int ti_adpll_probe(struct platform_device *pdev)
        if (err)
                return err;
 
-       d->clocks = devm_kzalloc(d->dev, sizeof(struct ti_adpll_clock) *
+       d->clocks = devm_kcalloc(d->dev,
                                 TI_ADPLL_NR_CLOCKS,
+                                sizeof(struct ti_adpll_clock),
                                 GFP_KERNEL);
        if (!d->clocks)
                return -ENOMEM;
index b07559b..e6f9cbe 100644 (file)
@@ -410,7 +410,7 @@ brcm_avs_get_freq_table(struct device *dev, struct private_data *priv)
        if (ret)
                return ERR_PTR(ret);
 
-       table = devm_kzalloc(dev, (AVS_PSTATE_MAX + 1) * sizeof(*table),
+       table = devm_kcalloc(dev, AVS_PSTATE_MAX + 1, sizeof(*table),
                             GFP_KERNEL);
        if (!table)
                return ERR_PTR(-ENOMEM);
index 83cf631..7091210 100644 (file)
@@ -377,7 +377,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
        }
 
        /* Make imx6_soc_volt array's size same as arm opp number */
-       imx6_soc_volt = devm_kzalloc(cpu_dev, sizeof(*imx6_soc_volt) * num, GFP_KERNEL);
+       imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt),
+                                    GFP_KERNEL);
        if (imx6_soc_volt == NULL) {
                ret = -ENOMEM;
                goto free_freq_table;
index f81fa4a..a4aa681 100644 (file)
@@ -471,7 +471,7 @@ static int mv_cesa_probe(struct platform_device *pdev)
                sram_size = CESA_SA_MIN_SRAM_SIZE;
 
        cesa->sram_size = sram_size;
-       cesa->engines = devm_kzalloc(dev, caps->nengines * sizeof(*engines),
+       cesa->engines = devm_kcalloc(dev, caps->nengines, sizeof(*engines),
                                     GFP_KERNEL);
        if (!cesa->engines)
                return -ENOMEM;
index 7cebf0a..cf14f09 100644 (file)
@@ -3393,8 +3393,10 @@ static int talitos_probe(struct platform_device *ofdev)
                }
        }
 
-       priv->chan = devm_kzalloc(dev, sizeof(struct talitos_channel) *
-                                      priv->num_channels, GFP_KERNEL);
+       priv->chan = devm_kcalloc(dev,
+                                 priv->num_channels,
+                                 sizeof(struct talitos_channel),
+                                 GFP_KERNEL);
        if (!priv->chan) {
                dev_err(dev, "failed to allocate channel management space\n");
                err = -ENOMEM;
@@ -3411,9 +3413,10 @@ static int talitos_probe(struct platform_device *ofdev)
                spin_lock_init(&priv->chan[i].head_lock);
                spin_lock_init(&priv->chan[i].tail_lock);
 
-               priv->chan[i].fifo = devm_kzalloc(dev,
-                                               sizeof(struct talitos_request) *
-                                               priv->fifo_len, GFP_KERNEL);
+               priv->chan[i].fifo = devm_kcalloc(dev,
+                                               priv->fifo_len,
+                                               sizeof(struct talitos_request),
+                                               GFP_KERNEL);
                if (!priv->chan[i].fifo) {
                        dev_err(dev, "failed to allocate request fifo %d\n", i);
                        err = -ENOMEM;
index fe2af6a..0b5b3ab 100644 (file)
@@ -628,14 +628,15 @@ struct devfreq *devfreq_add_device(struct device *dev,
                goto err_dev;
        }
 
-       devfreq->trans_table =  devm_kzalloc(&devfreq->dev,
-                                               sizeof(unsigned int) *
-                                               devfreq->profile->max_state *
-                                               devfreq->profile->max_state,
-                                               GFP_KERNEL);
-       devfreq->time_in_state = devm_kzalloc(&devfreq->dev,
-                                               sizeof(unsigned long) *
+       devfreq->trans_table =
+               devm_kzalloc(&devfreq->dev,
+                            array3_size(sizeof(unsigned int),
+                                        devfreq->profile->max_state,
+                                        devfreq->profile->max_state),
+                            GFP_KERNEL);
+       devfreq->time_in_state = devm_kcalloc(&devfreq->dev,
                                                devfreq->profile->max_state,
+                                               sizeof(unsigned long),
                                                GFP_KERNEL);
        devfreq->last_stat_updated = jiffies;
 
index d96e3dc..3cd6a18 100644 (file)
@@ -518,7 +518,7 @@ static int of_get_devfreq_events(struct device_node *np,
        event_ops = exynos_bus_get_ops(np);
 
        count = of_get_child_count(events_np);
-       desc = devm_kzalloc(dev, sizeof(*desc) * count, GFP_KERNEL);
+       desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL);
        if (!desc)
                return -ENOMEM;
        info->num_events = count;
index 26b6745..fa31ccc 100644 (file)
@@ -848,8 +848,8 @@ static int k3_dma_probe(struct platform_device *op)
                return -ENOMEM;
 
        /* init phy channel */
-       d->phy = devm_kzalloc(&op->dev,
-               d->dma_channels * sizeof(struct k3_dma_phy), GFP_KERNEL);
+       d->phy = devm_kcalloc(&op->dev,
+               d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL);
        if (d->phy == NULL)
                return -ENOMEM;
 
@@ -879,8 +879,8 @@ static int k3_dma_probe(struct platform_device *op)
        d->slave.copy_align = DMAENGINE_ALIGN_8_BYTES;
 
        /* init virtual channel */
-       d->chans = devm_kzalloc(&op->dev,
-               d->dma_requests * sizeof(struct k3_dma_chan), GFP_KERNEL);
+       d->chans = devm_kcalloc(&op->dev,
+               d->dma_requests, sizeof(struct k3_dma_chan), GFP_KERNEL);
        if (d->chans == NULL)
                return -ENOMEM;
 
index 3548caa..c6589cc 100644 (file)
@@ -809,8 +809,9 @@ static int mv_xor_v2_probe(struct platform_device *pdev)
        }
 
        /* alloc memory for the SW descriptors */
-       xor_dev->sw_desq = devm_kzalloc(&pdev->dev, sizeof(*sw_desc) *
-                                       MV_XOR_V2_DESC_NUM, GFP_KERNEL);
+       xor_dev->sw_desq = devm_kcalloc(&pdev->dev,
+                                       MV_XOR_V2_DESC_NUM, sizeof(*sw_desc),
+                                       GFP_KERNEL);
        if (!xor_dev->sw_desq) {
                ret = -ENOMEM;
                goto free_hw_desq;
index cd92d69..7056fe7 100644 (file)
@@ -1223,9 +1223,9 @@ static int s3c24xx_dma_probe(struct platform_device *pdev)
        if (IS_ERR(s3cdma->base))
                return PTR_ERR(s3cdma->base);
 
-       s3cdma->phy_chans = devm_kzalloc(&pdev->dev,
-                                             sizeof(struct s3c24xx_dma_phy) *
-                                                       pdata->num_phy_channels,
+       s3cdma->phy_chans = devm_kcalloc(&pdev->dev,
+                                             pdata->num_phy_channels,
+                                             sizeof(struct s3c24xx_dma_phy),
                                              GFP_KERNEL);
        if (!s3cdma->phy_chans)
                return -ENOMEM;
index 2bb6953..2571bc7 100644 (file)
@@ -798,8 +798,8 @@ static int zx_dma_probe(struct platform_device *op)
                return -ENOMEM;
 
        /* init phy channel */
-       d->phy = devm_kzalloc(&op->dev,
-               d->dma_channels * sizeof(struct zx_dma_phy), GFP_KERNEL);
+       d->phy = devm_kcalloc(&op->dev,
+               d->dma_channels, sizeof(struct zx_dma_phy), GFP_KERNEL);
        if (!d->phy)
                return -ENOMEM;
 
@@ -834,8 +834,8 @@ static int zx_dma_probe(struct platform_device *op)
        d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
 
        /* init virtual channel */
-       d->chans = devm_kzalloc(&op->dev,
-               d->dma_requests * sizeof(struct zx_dma_chan), GFP_KERNEL);
+       d->chans = devm_kcalloc(&op->dev,
+               d->dma_requests, sizeof(struct zx_dma_chan), GFP_KERNEL);
        if (!d->chans)
                return -ENOMEM;
 
index 6d7a6c0..c7d06a3 100644 (file)
@@ -890,7 +890,7 @@ static int scpi_alloc_xfer_list(struct device *dev, struct scpi_chan *ch)
        int i;
        struct scpi_xfer *xfers;
 
-       xfers = devm_kzalloc(dev, MAX_SCPI_XFERS * sizeof(*xfers), GFP_KERNEL);
+       xfers = devm_kcalloc(dev, MAX_SCPI_XFERS, sizeof(*xfers), GFP_KERNEL);
        if (!xfers)
                return -ENOMEM;
 
index 5229036..a7d9a20 100644 (file)
@@ -1862,9 +1862,9 @@ static int ti_sci_probe(struct platform_device *pdev)
        if (!minfo->xfer_block)
                return -ENOMEM;
 
-       minfo->xfer_alloc_table = devm_kzalloc(dev,
-                                              BITS_TO_LONGS(desc->max_msgs)
-                                              sizeof(unsigned long),
+       minfo->xfer_alloc_table = devm_kcalloc(dev,
+                                              BITS_TO_LONGS(desc->max_msgs),
+                                              sizeof(unsigned long),
                                               GFP_KERNEL);
        if (!minfo->xfer_alloc_table)
                return -ENOMEM;
index 44c0990..91b90c0 100644 (file)
@@ -427,7 +427,7 @@ static int adnp_irq_setup(struct adnp *adnp)
         * is chosen to match the register layout of the hardware in that
         * each segment contains the corresponding bits for all interrupts.
         */
-       adnp->irq_enable = devm_kzalloc(chip->parent, num_regs * 6,
+       adnp->irq_enable = devm_kcalloc(chip->parent, num_regs, 6,
                                        GFP_KERNEL);
        if (!adnp->irq_enable)
                return -ENOMEM;
index 5e89f1c..b31ae16 100644 (file)
@@ -897,8 +897,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
 
        /* Allocate a cache of the output registers */
        banks = gpio->config->nr_gpios >> 5;
-       gpio->dcache = devm_kzalloc(&pdev->dev,
-                                   sizeof(u32) * banks, GFP_KERNEL);
+       gpio->dcache = devm_kcalloc(&pdev->dev,
+                                   banks, sizeof(u32), GFP_KERNEL);
        if (!gpio->dcache)
                return -ENOMEM;
 
index eb8369b..00272fa 100644 (file)
@@ -601,9 +601,10 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
                        GPIO_MAX_BANK_NUM);
                return -ENXIO;
        }
-       kona_gpio->banks = devm_kzalloc(dev,
-                                       kona_gpio->num_bank *
-                                       sizeof(*kona_gpio->banks), GFP_KERNEL);
+       kona_gpio->banks = devm_kcalloc(dev,
+                                       kona_gpio->num_bank,
+                                       sizeof(*kona_gpio->banks),
+                                       GFP_KERNEL);
        if (!kona_gpio->banks)
                return -ENOMEM;
 
index b574ecf..035a454 100644 (file)
@@ -198,8 +198,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
                ngpio = ARCH_NR_GPIOS;
 
        nbank = DIV_ROUND_UP(ngpio, 32);
-       chips = devm_kzalloc(dev,
-                            nbank * sizeof(struct davinci_gpio_controller),
+       chips = devm_kcalloc(dev,
+                            nbank, sizeof(struct davinci_gpio_controller),
                             GFP_KERNEL);
        if (!chips)
                return -ENOMEM;
index 5163839..ad6e5b5 100644 (file)
@@ -321,8 +321,8 @@ static int __init egpio_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, ei);
 
        ei->nchips = pdata->num_chips;
-       ei->chip = devm_kzalloc(&pdev->dev,
-                               sizeof(struct egpio_chip) * ei->nchips,
+       ei->chip = devm_kcalloc(&pdev->dev,
+                               ei->nchips, sizeof(struct egpio_chip),
                                GFP_KERNEL);
        if (!ei->chip) {
                ret = -ENOMEM;
index d16e9d4..1306722 100644 (file)
@@ -504,16 +504,17 @@ static int thunderx_gpio_probe(struct pci_dev *pdev,
                txgpio->base_msi = (c >> 8) & 0xff;
        }
 
-       txgpio->msix_entries = devm_kzalloc(dev,
-                                         sizeof(struct msix_entry) * ngpio,
+       txgpio->msix_entries = devm_kcalloc(dev,
+                                         ngpio, sizeof(struct msix_entry),
                                          GFP_KERNEL);
        if (!txgpio->msix_entries) {
                err = -ENOMEM;
                goto out;
        }
 
-       txgpio->line_entries = devm_kzalloc(dev,
-                                           sizeof(struct thunderx_line) * ngpio,
+       txgpio->line_entries = devm_kcalloc(dev,
+                                           ngpio,
+                                           sizeof(struct thunderx_line),
                                            GFP_KERNEL);
        if (!txgpio->line_entries) {
                err = -ENOMEM;
index 7c3030b..6d29777 100644 (file)
@@ -1723,8 +1723,8 @@ static int exynos_dsi_probe(struct platform_device *pdev)
                return -EPROBE_DEFER;
        }
 
-       dsi->clks = devm_kzalloc(dev,
-                       sizeof(*dsi->clks) * dsi->driver_data->num_clks,
+       dsi->clks = devm_kcalloc(dev,
+                       dsi->driver_data->num_clks, sizeof(*dsi->clks),
                        GFP_KERNEL);
        if (!dsi->clks)
                return -ENOMEM;
index 5ce8402..6127ef2 100644 (file)
@@ -1271,7 +1271,8 @@ static int fimc_probe(struct platform_device *pdev)
 
        /* construct formats/limits array */
        num_formats = ARRAY_SIZE(fimc_formats) + ARRAY_SIZE(fimc_tiled_formats);
-       formats = devm_kzalloc(dev, sizeof(*formats) * num_formats, GFP_KERNEL);
+       formats = devm_kcalloc(dev, num_formats, sizeof(*formats),
+                              GFP_KERNEL);
        if (!formats)
                return -ENOMEM;
 
index e99dd1e..35ac667 100644 (file)
@@ -1202,8 +1202,9 @@ static int gsc_probe(struct platform_device *pdev)
        if (!ctx)
                return -ENOMEM;
 
-       formats = devm_kzalloc(dev, sizeof(*formats) *
-                              (ARRAY_SIZE(gsc_formats)), GFP_KERNEL);
+       formats = devm_kcalloc(dev,
+                              ARRAY_SIZE(gsc_formats), sizeof(*formats),
+                              GFP_KERNEL);
        if (!formats)
                return -ENOMEM;
 
index 09c4bc0..db91932 100644 (file)
@@ -1692,7 +1692,7 @@ static int hdmi_clk_init(struct hdmi_context *hdata)
        if (!count)
                return 0;
 
-       clks = devm_kzalloc(dev, sizeof(*clks) * count, GFP_KERNEL);
+       clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL);
        if (!clks)
                return -ENOMEM;
 
index e63dc0f..c79659c 100644 (file)
@@ -157,8 +157,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
                hdmi->qfprom_mmio = NULL;
        }
 
-       hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) *
-                       config->hpd_reg_cnt, GFP_KERNEL);
+       hdmi->hpd_regs = devm_kcalloc(&pdev->dev,
+                                     config->hpd_reg_cnt,
+                                     sizeof(hdmi->hpd_regs[0]),
+                                     GFP_KERNEL);
        if (!hdmi->hpd_regs) {
                ret = -ENOMEM;
                goto fail;
@@ -178,8 +180,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
                hdmi->hpd_regs[i] = reg;
        }
 
-       hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) *
-                       config->pwr_reg_cnt, GFP_KERNEL);
+       hdmi->pwr_regs = devm_kcalloc(&pdev->dev,
+                                     config->pwr_reg_cnt,
+                                     sizeof(hdmi->pwr_regs[0]),
+                                     GFP_KERNEL);
        if (!hdmi->pwr_regs) {
                ret = -ENOMEM;
                goto fail;
@@ -199,8 +203,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
                hdmi->pwr_regs[i] = reg;
        }
 
-       hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) *
-                       config->hpd_clk_cnt, GFP_KERNEL);
+       hdmi->hpd_clks = devm_kcalloc(&pdev->dev,
+                                     config->hpd_clk_cnt,
+                                     sizeof(hdmi->hpd_clks[0]),
+                                     GFP_KERNEL);
        if (!hdmi->hpd_clks) {
                ret = -ENOMEM;
                goto fail;
@@ -219,8 +225,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
                hdmi->hpd_clks[i] = clk;
        }
 
-       hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) *
-                       config->pwr_clk_cnt, GFP_KERNEL);
+       hdmi->pwr_clks = devm_kcalloc(&pdev->dev,
+                                     config->pwr_clk_cnt,
+                                     sizeof(hdmi->pwr_clks[0]),
+                                     GFP_KERNEL);
        if (!hdmi->pwr_clks) {
                ret = -ENOMEM;
                goto fail;
index 5e63139..4157722 100644 (file)
@@ -21,12 +21,12 @@ static int msm_hdmi_phy_resource_init(struct hdmi_phy *phy)
        struct device *dev = &phy->pdev->dev;
        int i, ret;
 
-       phy->regs = devm_kzalloc(dev, sizeof(phy->regs[0]) * cfg->num_regs,
+       phy->regs = devm_kcalloc(dev, cfg->num_regs, sizeof(phy->regs[0]),
                                 GFP_KERNEL);
        if (!phy->regs)
                return -ENOMEM;
 
-       phy->clks = devm_kzalloc(dev, sizeof(phy->clks[0]) * cfg->num_clks,
+       phy->clks = devm_kcalloc(dev, cfg->num_clks, sizeof(phy->clks[0]),
                                 GFP_KERNEL);
        if (!phy->clks)
                return -ENOMEM;
index 25363fc..50af72b 100644 (file)
@@ -624,7 +624,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
                ret = -EINVAL;
                goto err_stop_hw;
        }
-       sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt *
+       sd->hid_sensor_hub_client_devs = devm_kcalloc(&hdev->dev,
+                                                     dev_cnt,
                                                      sizeof(struct mfd_cell),
                                                      GFP_KERNEL);
        if (sd->hid_sensor_hub_client_devs == NULL) {
index acc2536..2d28cff 100644 (file)
@@ -121,9 +121,9 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf,
                        }
                        client_data->hid_dev_count = (unsigned int)*payload;
                        if (!client_data->hid_devices)
-                               client_data->hid_devices = devm_kzalloc(
+                               client_data->hid_devices = devm_kcalloc(
                                                &client_data->cl_device->dev,
-                                               client_data->hid_dev_count *
+                                               client_data->hid_dev_count,
                                                sizeof(struct device_info),
                                                GFP_KERNEL);
                        if (!client_data->hid_devices) {
index ee7a37e..c101369 100644 (file)
@@ -1363,7 +1363,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev,
        if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL))
                return -ENOMEM;
 
-       leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL);
+       leds = devm_kcalloc(dev, count, sizeof(struct wacom_led), GFP_KERNEL);
        if (!leds) {
                error = -ENOMEM;
                goto err;
@@ -1463,7 +1463,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count)
        struct wacom_group_leds *groups;
        int error;
 
-       groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count,
+       groups = devm_kcalloc(dev, count, sizeof(struct wacom_group_leds),
                              GFP_KERNEL);
        if (!groups)
                return -ENOMEM;
index 693a3d5..5e449ea 100644 (file)
@@ -894,7 +894,7 @@ static int aspeed_create_fan(struct device *dev,
        count = of_property_count_u8_elems(child, "aspeed,fan-tach-ch");
        if (count < 1)
                return -EINVAL;
-       fan_tach_ch = devm_kzalloc(dev, sizeof(*fan_tach_ch) * count,
+       fan_tach_ch = devm_kcalloc(dev, count, sizeof(*fan_tach_ch),
                                   GFP_KERNEL);
        if (!fan_tach_ch)
                return -ENOMEM;
index 5c9a525..a3974cd 100644 (file)
@@ -441,8 +441,8 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data)
                dev_err(dev, "DT properties empty / missing");
                return -ENODEV;
        }
-       gpios = devm_kzalloc(dev,
-                            fan_data->num_gpios * sizeof(struct gpio_desc *),
+       gpios = devm_kcalloc(dev,
+                            fan_data->num_gpios, sizeof(struct gpio_desc *),
                             GFP_KERNEL);
        if (!gpios)
                return -ENOMEM;
@@ -471,8 +471,8 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data)
         * Speed map is in the form <RPM ctrl_val RPM ctrl_val ...>
         * this needs splitting into pairs to create gpio_fan_speed structs
         */
-       speed = devm_kzalloc(dev,
-                       fan_data->num_speed * sizeof(struct gpio_fan_speed),
+       speed = devm_kcalloc(dev,
+                       fan_data->num_speed, sizeof(struct gpio_fan_speed),
                        GFP_KERNEL);
        if (!speed)
                return -ENOMEM;
index 0298745..f829dad 100644 (file)
@@ -326,9 +326,9 @@ static int populate_attr_groups(struct platform_device *pdev)
        of_node_put(opal);
 
        for (type = 0; type < MAX_SENSOR_TYPE; type++) {
-               sensor_groups[type].group.attrs = devm_kzalloc(&pdev->dev,
-                                       sizeof(struct attribute *) *
-                                       (sensor_groups[type].attr_count + 1),
+               sensor_groups[type].group.attrs = devm_kcalloc(&pdev->dev,
+                                       sensor_groups[type].attr_count + 1,
+                                       sizeof(struct attribute *),
                                        GFP_KERNEL);
                if (!sensor_groups[type].group.attrs)
                        return -ENOMEM;
@@ -409,7 +409,8 @@ static int create_device_attrs(struct platform_device *pdev)
        int err = 0;
 
        opal = of_find_node_by_path("/ibm,opal/sensors");
-       sdata = devm_kzalloc(&pdev->dev, pdata->sensors_count * sizeof(*sdata),
+       sdata = devm_kcalloc(&pdev->dev,
+                            pdata->sensors_count, sizeof(*sdata),
                             GFP_KERNEL);
        if (!sdata) {
                err = -ENOMEM;
index 5e5b32a..69031a0 100644 (file)
@@ -92,8 +92,8 @@ static int iio_hwmon_probe(struct platform_device *pdev)
        while (st->channels[st->num_channels].indio_dev)
                st->num_channels++;
 
-       st->attrs = devm_kzalloc(dev,
-                                sizeof(*st->attrs) * (st->num_channels + 1),
+       st->attrs = devm_kcalloc(dev,
+                                st->num_channels + 1, sizeof(*st->attrs),
                                 GFP_KERNEL);
        if (st->attrs == NULL) {
                ret = -ENOMEM;
index b0bc77b..a753464 100644 (file)
@@ -426,12 +426,12 @@ nct6683_create_attr_group(struct device *dev,
        if (group == NULL)
                return ERR_PTR(-ENOMEM);
 
-       attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
+       attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
                             GFP_KERNEL);
        if (attrs == NULL)
                return ERR_PTR(-ENOMEM);
 
-       su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
+       su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
                          GFP_KERNEL);
        if (su == NULL)
                return ERR_PTR(-ENOMEM);
index aebce56..155d4d1 100644 (file)
@@ -1190,12 +1190,12 @@ nct6775_create_attr_group(struct device *dev,
        if (group == NULL)
                return ERR_PTR(-ENOMEM);
 
-       attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
+       attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
                             GFP_KERNEL);
        if (attrs == NULL)
                return ERR_PTR(-ENOMEM);
 
-       su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
+       su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
                               GFP_KERNEL);
        if (su == NULL)
                return ERR_PTR(-ENOMEM);
index f7c47d7..82c3754 100644 (file)
@@ -2176,8 +2176,8 @@ static int pmbus_init_debugfs(struct i2c_client *client,
        }
 
        /* Allocate the max possible entries we need. */
-       entries = devm_kzalloc(data->dev,
-                              sizeof(*entries) * (data->info->pages * 10),
+       entries = devm_kcalloc(data->dev,
+                              data->info->pages * 10, sizeof(*entries),
                               GFP_KERNEL);
        if (!entries)
                return -ENOMEM;
index 70cecb0..ae93885 100644 (file)
@@ -454,8 +454,8 @@ static int ucd9000_init_debugfs(struct i2c_client *client,
         */
        if (mid->driver_data == ucd9090 || mid->driver_data == ucd90160 ||
            mid->driver_data == ucd90910) {
-               entries = devm_kzalloc(&client->dev,
-                                      sizeof(*entries) * UCD9000_GPI_COUNT,
+               entries = devm_kcalloc(&client->dev,
+                                      UCD9000_GPI_COUNT, sizeof(*entries),
                                       GFP_KERNEL);
                if (!entries)
                        return -ENOMEM;
index 70cc0d1..7838af5 100644 (file)
@@ -180,7 +180,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev,
        }
 
        num = ret;
-       ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+       ctx->pwm_fan_cooling_levels = devm_kcalloc(dev, num, sizeof(u32),
                                                   GFP_KERNEL);
        if (!ctx->pwm_fan_cooling_levels)
                return -ENOMEM;
index 9b6c555..320d29d 100644 (file)
@@ -683,8 +683,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
        if (drvdata->buffer_depth & 0x80000000)
                return -EINVAL;
 
-       drvdata->buf = devm_kzalloc(dev,
-                                   drvdata->buffer_depth * 4, GFP_KERNEL);
+       drvdata->buf = devm_kcalloc(dev,
+                                   drvdata->buffer_depth, 4, GFP_KERNEL);
        if (!drvdata->buf)
                return -ENOMEM;
 
index a33a92e..6880bee 100644 (file)
@@ -71,21 +71,24 @@ static int of_coresight_alloc_memory(struct device *dev,
                        struct coresight_platform_data *pdata)
 {
        /* List of output port on this component */
-       pdata->outports = devm_kzalloc(dev, pdata->nr_outport *
+       pdata->outports = devm_kcalloc(dev,
+                                      pdata->nr_outport,
                                       sizeof(*pdata->outports),
                                       GFP_KERNEL);
        if (!pdata->outports)
                return -ENOMEM;
 
        /* Children connected to this component via @outports */
-       pdata->child_names = devm_kzalloc(dev, pdata->nr_outport *
+       pdata->child_names = devm_kcalloc(dev,
+                                         pdata->nr_outport,
                                          sizeof(*pdata->child_names),
                                          GFP_KERNEL);
        if (!pdata->child_names)
                return -ENOMEM;
 
        /* Port number on the child this component is connected to */
-       pdata->child_ports = devm_kzalloc(dev, pdata->nr_outport *
+       pdata->child_ports = devm_kcalloc(dev,
+                                         pdata->nr_outport,
                                          sizeof(*pdata->child_ports),
                                          GFP_KERNEL);
        if (!pdata->child_ports)
index 904dfec..ebbf9cd 100644 (file)
@@ -1691,8 +1691,8 @@ static int qup_i2c_probe(struct platform_device *pdev)
 
                qup->max_xfer_sg_len = (MX_BLOCKS << 1);
                blocks = (MX_DMA_BLOCKS << 1) + 1;
-               qup->btx.sg = devm_kzalloc(&pdev->dev,
-                                          sizeof(*qup->btx.sg) * blocks,
+               qup->btx.sg = devm_kcalloc(&pdev->dev,
+                                          blocks, sizeof(*qup->btx.sg),
                                           GFP_KERNEL);
                if (!qup->btx.sg) {
                        ret = -ENOMEM;
@@ -1700,8 +1700,8 @@ static int qup_i2c_probe(struct platform_device *pdev)
                }
                sg_init_table(qup->btx.sg, blocks);
 
-               qup->brx.sg = devm_kzalloc(&pdev->dev,
-                                          sizeof(*qup->brx.sg) * blocks,
+               qup->brx.sg = devm_kcalloc(&pdev->dev,
+                                          blocks, sizeof(*qup->brx.sg),
                                           GFP_KERNEL);
                if (!qup->brx.sg) {
                        ret = -ENOMEM;
index 1a9973e..ddc4bd4 100644 (file)
@@ -88,8 +88,8 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
 
        mux->data.n_values = of_get_child_count(np);
 
-       values = devm_kzalloc(&pdev->dev,
-                             sizeof(*mux->data.values) * mux->data.n_values,
+       values = devm_kcalloc(&pdev->dev,
+                             mux->data.n_values, sizeof(*mux->data.values),
                              GFP_KERNEL);
        if (!values) {
                dev_err(&pdev->dev, "Cannot allocate values array");
@@ -111,8 +111,9 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
                return -EINVAL;
        }
 
-       gpios = devm_kzalloc(&pdev->dev,
-                            sizeof(*mux->data.gpios) * mux->data.n_gpios, GFP_KERNEL);
+       gpios = devm_kcalloc(&pdev->dev,
+                            mux->data.n_gpios, sizeof(*mux->data.gpios),
+                            GFP_KERNEL);
        if (!gpios) {
                dev_err(&pdev->dev, "Cannot allocate gpios array");
                return -ENOMEM;
index c948e5a..f583f80 100644 (file)
@@ -124,8 +124,8 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux,
        }
        mux->data.write_only = of_property_read_bool(np, "write-only");
 
-       values = devm_kzalloc(&pdev->dev,
-                             sizeof(*mux->data.values) * mux->data.n_values,
+       values = devm_kcalloc(&pdev->dev,
+                             mux->data.n_values, sizeof(*mux->data.values),
                              GFP_KERNEL);
        if (!values) {
                dev_err(&pdev->dev, "Cannot allocate values array");
index 71a5ee6..44b5168 100644 (file)
@@ -624,8 +624,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
        struct at91_adc_state *st = iio_priv(idev);
        int i, ret;
 
-       st->trig = devm_kzalloc(&idev->dev,
-                               st->trigger_number * sizeof(*st->trig),
+       st->trig = devm_kcalloc(&idev->dev,
+                               st->trigger_number, sizeof(*st->trig),
                                GFP_KERNEL);
 
        if (st->trig == NULL) {
@@ -908,7 +908,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
        st->registers = &st->caps->registers;
        st->num_channels = st->caps->num_channels;
        st->trigger_number = of_get_child_count(node);
-       st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number *
+       st->trigger_list = devm_kcalloc(&idev->dev,
+                                       st->trigger_number,
                                        sizeof(struct at91_adc_trigger),
                                        GFP_KERNEL);
        if (!st->trigger_list) {
index 7f1848d..7fb4f52 100644 (file)
@@ -1453,8 +1453,10 @@ static int max1363_alloc_scan_masks(struct iio_dev *indio_dev)
        int i;
 
        masks = devm_kzalloc(&indio_dev->dev,
-                       BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) *
-                       (st->chip_info->num_modes + 1), GFP_KERNEL);
+                       array3_size(BITS_TO_LONGS(MAX1363_MAX_CHANNELS),
+                                   sizeof(long),
+                                   st->chip_info->num_modes + 1),
+                       GFP_KERNEL);
        if (!masks)
                return -ENOMEM;
 
index dc83f8f..e470510 100644 (file)
@@ -898,9 +898,10 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
 
        gpadc = iio_priv(indio_dev);
 
-       gpadc->twl6030_cal_tbl = devm_kzalloc(dev,
-                                       sizeof(*gpadc->twl6030_cal_tbl) *
-                                       pdata->nchannels, GFP_KERNEL);
+       gpadc->twl6030_cal_tbl = devm_kcalloc(dev,
+                                       pdata->nchannels,
+                                       sizeof(*gpadc->twl6030_cal_tbl),
+                                       GFP_KERNEL);
        if (!gpadc->twl6030_cal_tbl)
                return -ENOMEM;
 
index 9234c6a..095530c 100644 (file)
@@ -536,8 +536,9 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
                        st->channel_offstate[reg] = tmp;
        }
 
-       channels = devm_kzalloc(st->dev,
-                       (1 + 2 * num_channels) * sizeof(*channels), GFP_KERNEL);
+       channels = devm_kcalloc(st->dev,
+                       1 + 2 * num_channels, sizeof(*channels),
+                       GFP_KERNEL);
        if (!channels)
                return -ENOMEM;
 
index 60621cc..e1f44ce 100644 (file)
@@ -281,9 +281,10 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
                if (!page)
                        return -ENOMEM;
        }
-       child->ext_info_cache = devm_kzalloc(dev,
-                                            sizeof(*child->ext_info_cache) *
-                                            num_ext_info, GFP_KERNEL);
+       child->ext_info_cache = devm_kcalloc(dev,
+                                            num_ext_info,
+                                            sizeof(*child->ext_info_cache),
+                                            GFP_KERNEL);
        if (!child->ext_info_cache)
                return -ENOMEM;
 
index 997e3e9..e319f74 100644 (file)
@@ -109,8 +109,8 @@ static int clps711x_keypad_probe(struct platform_device *pdev)
        if (priv->row_count < 1)
                return -EINVAL;
 
-       priv->gpio_data = devm_kzalloc(dev,
-                               sizeof(*priv->gpio_data) * priv->row_count,
+       priv->gpio_data = devm_kcalloc(dev,
+                               priv->row_count, sizeof(*priv->gpio_data),
                                GFP_KERNEL);
        if (!priv->gpio_data)
                return -ENOMEM;
index 41614c1..f51ae09 100644 (file)
@@ -443,9 +443,9 @@ matrix_keypad_parse_dt(struct device *dev)
        of_property_read_u32(np, "col-scan-delay-us",
                                                &pdata->col_scan_delay_us);
 
-       gpios = devm_kzalloc(dev,
-                            sizeof(unsigned int) *
-                               (pdata->num_row_gpios + pdata->num_col_gpios),
+       gpios = devm_kcalloc(dev,
+                            pdata->num_row_gpios + pdata->num_col_gpios,
+                            sizeof(unsigned int),
                             GFP_KERNEL);
        if (!gpios) {
                dev_err(dev, "could not allocate memory for gpios\n");
index 3164144..1fe1aa2 100644 (file)
@@ -281,7 +281,7 @@ samsung_keypad_parse_dt(struct device *dev)
 
        key_count = of_get_child_count(np);
        keymap_data->keymap_size = key_count;
-       keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL);
+       keymap = devm_kcalloc(dev, key_count, sizeof(uint32_t), GFP_KERNEL);
        if (!keymap) {
                dev_err(dev, "could not allocate memory for keymap\n");
                return ERR_PTR(-ENOMEM);
index 8ccefc1..8b3a575 100644 (file)
@@ -170,8 +170,8 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
                return -EINVAL;
 
        if (!keymap) {
-               keymap = devm_kzalloc(input_dev->dev.parent,
-                                     max_keys * sizeof(*keymap),
+               keymap = devm_kcalloc(input_dev->dev.parent,
+                                     max_keys, sizeof(*keymap),
                                      GFP_KERNEL);
                if (!keymap) {
                        dev_err(input_dev->dev.parent,
index 1588aec..6d30438 100644 (file)
@@ -283,8 +283,8 @@ static int rotary_encoder_probe(struct platform_device *pdev)
        }
 
        encoder->irq =
-               devm_kzalloc(dev,
-                            sizeof(*encoder->irq) * encoder->gpios->ndescs,
+               devm_kcalloc(dev,
+                            encoder->gpios->ndescs, sizeof(*encoder->irq),
                             GFP_KERNEL);
        if (!encoder->irq)
                return -ENOMEM;
index f595498..7d29053 100644 (file)
@@ -636,9 +636,10 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr,
        rdesc->num_registers = bitmap_weight(rdesc->presense_map,
                                                RMI_REG_DESC_PRESENSE_BITS);
 
-       rdesc->registers = devm_kzalloc(&d->dev, rdesc->num_registers *
-                               sizeof(struct rmi_register_desc_item),
-                               GFP_KERNEL);
+       rdesc->registers = devm_kcalloc(&d->dev,
+                                       rdesc->num_registers,
+                                       sizeof(struct rmi_register_desc_item),
+                                       GFP_KERNEL);
        if (!rdesc->registers)
                return -ENOMEM;
 
@@ -1061,7 +1062,7 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
        data->num_of_irq_regs = (data->irq_count + 7) / 8;
 
        size = BITS_TO_LONGS(data->irq_count) * sizeof(unsigned long);
-       data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL);
+       data->irq_memory = devm_kcalloc(dev, size, 4, GFP_KERNEL);
        if (!data->irq_memory) {
                dev_err(dev, "Failed to allocate memory for irq masks.\n");
                return -ENOMEM;
index bc5e37f..12a2332 100644 (file)
@@ -1190,14 +1190,15 @@ static int rmi_f11_initialize(struct rmi_function *fn)
                f11->sensor.attn_size += f11->sensor.nbr_fingers * 2;
 
        /* allocate the in-kernel tracking buffers */
-       sensor->tracking_pos = devm_kzalloc(&fn->dev,
-                       sizeof(struct input_mt_pos) * sensor->nbr_fingers,
+       sensor->tracking_pos = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers, sizeof(struct input_mt_pos),
+                       GFP_KERNEL);
+       sensor->tracking_slots = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
+       sensor->objs = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers,
+                       sizeof(struct rmi_2d_sensor_abs_object),
                        GFP_KERNEL);
-       sensor->tracking_slots = devm_kzalloc(&fn->dev,
-                       sizeof(int) * sensor->nbr_fingers, GFP_KERNEL);
-       sensor->objs = devm_kzalloc(&fn->dev,
-                       sizeof(struct rmi_2d_sensor_abs_object)
-                       * sensor->nbr_fingers, GFP_KERNEL);
        if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
                return -ENOMEM;
 
index 8b0db08..a3d1aa8 100644 (file)
@@ -502,14 +502,15 @@ static int rmi_f12_probe(struct rmi_function *fn)
        }
 
        /* allocate the in-kernel tracking buffers */
-       sensor->tracking_pos = devm_kzalloc(&fn->dev,
-                       sizeof(struct input_mt_pos) * sensor->nbr_fingers,
+       sensor->tracking_pos = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers, sizeof(struct input_mt_pos),
+                       GFP_KERNEL);
+       sensor->tracking_slots = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
+       sensor->objs = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers,
+                       sizeof(struct rmi_2d_sensor_abs_object),
                        GFP_KERNEL);
-       sensor->tracking_slots = devm_kzalloc(&fn->dev,
-                       sizeof(int) * sensor->nbr_fingers, GFP_KERNEL);
-       sensor->objs = devm_kzalloc(&fn->dev,
-                       sizeof(struct rmi_2d_sensor_abs_object)
-                       * sensor->nbr_fingers, GFP_KERNEL);
        if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
                return -ENOMEM;
 
index 5343f2c..e8a59d1 100644 (file)
@@ -685,7 +685,7 @@ static int rmi_f54_probe(struct rmi_function *fn)
        rx = f54->num_rx_electrodes;
        tx = f54->num_tx_electrodes;
        f54->report_data = devm_kzalloc(&fn->dev,
-                                       sizeof(u16) * tx * rx,
+                                       array3_size(tx, rx, sizeof(u16)),
                                        GFP_KERNEL);
        if (f54->report_data == NULL)
                return -ENOMEM;
index 082defc..33b8c6e 100644 (file)
@@ -69,7 +69,7 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len)
                buf_size = RMI_SPI_XFER_SIZE_LIMIT;
 
        tmp = rmi_spi->rx_buf;
-       buf = devm_kzalloc(&spi->dev, buf_size * 2,
+       buf = devm_kcalloc(&spi->dev, buf_size, 2,
                                GFP_KERNEL | GFP_DMA);
        if (!buf)
                return -ENOMEM;
@@ -96,9 +96,10 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len)
         * per byte delays.
         */
        tmp = rmi_spi->rx_xfers;
-       xfer_buf = devm_kzalloc(&spi->dev,
-               (rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count)
-               * sizeof(struct spi_transfer), GFP_KERNEL);
+       xfer_buf = devm_kcalloc(&spi->dev,
+               rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count,
+               sizeof(struct spi_transfer),
+               GFP_KERNEL);
        if (!xfer_buf)
                return -ENOMEM;
 
index 69e7c60..f7a96bc 100644 (file)
@@ -2082,7 +2082,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       smmu->irqs = devm_kzalloc(dev, sizeof(*smmu->irqs) * num_irqs,
+       smmu->irqs = devm_kcalloc(dev, num_irqs, sizeof(*smmu->irqs),
                                  GFP_KERNEL);
        if (!smmu->irqs) {
                dev_err(dev, "failed to allocate %d irqs\n", num_irqs);
index 0468acf..054cd2c 100644 (file)
@@ -1135,7 +1135,7 @@ static int rk_iommu_probe(struct platform_device *pdev)
        iommu->dev = dev;
        iommu->num_mmu = 0;
 
-       iommu->bases = devm_kzalloc(dev, sizeof(*iommu->bases) * num_res,
+       iommu->bases = devm_kcalloc(dev, num_res, sizeof(*iommu->bases),
                                    GFP_KERNEL);
        if (!iommu->bases)
                return -ENOMEM;
index e80263e..d00489a 100644 (file)
@@ -354,7 +354,7 @@ static int pdc_intc_probe(struct platform_device *pdev)
        priv->nr_syswakes = val;
 
        /* Get peripheral IRQ numbers */
-       priv->perip_irqs = devm_kzalloc(&pdev->dev, 4 * priv->nr_perips,
+       priv->perip_irqs = devm_kcalloc(&pdev->dev, 4, priv->nr_perips,
                                        GFP_KERNEL);
        if (!priv->perip_irqs) {
                dev_err(&pdev->dev, "cannot allocate perip IRQ list\n");
index 4e17f70..3be5c5d 100644 (file)
@@ -191,8 +191,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev)
        gicp->spi_ranges_cnt = ret / 2;
 
        gicp->spi_ranges =
-               devm_kzalloc(&pdev->dev,
-                            gicp->spi_ranges_cnt *
+               devm_kcalloc(&pdev->dev,
+                            gicp->spi_ranges_cnt,
                             sizeof(struct mvebu_gicp_spi_range),
                             GFP_KERNEL);
        if (!gicp->spi_ranges)
@@ -210,8 +210,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev)
                gicp->spi_cnt += gicp->spi_ranges[i].count;
        }
 
-       gicp->spi_bitmap = devm_kzalloc(&pdev->dev,
-                               BITS_TO_LONGS(gicp->spi_cnt) * sizeof(long),
+       gicp->spi_bitmap = devm_kcalloc(&pdev->dev,
+                               BITS_TO_LONGS(gicp->spi_cnt), sizeof(long),
                                GFP_KERNEL);
        if (!gicp->spi_bitmap)
                return -ENOMEM;
index 853b2d3..7ecf080 100644 (file)
@@ -108,7 +108,7 @@ static int adp5520_led_probe(struct platform_device *pdev)
                return -EFAULT;
        }
 
-       led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds,
+       led = devm_kcalloc(&pdev->dev, pdata->num_leds, sizeof(*led),
                                GFP_KERNEL);
        if (!led)
                return -ENOMEM;
index 90eeedc..8c93d68 100644 (file)
@@ -171,8 +171,8 @@ static int apu_led_config(struct device *dev, struct apu_led_pdata *apuld)
        int i;
        int err;
 
-       apu_led->pled = devm_kzalloc(dev,
-               sizeof(struct apu_led_priv) * apu_led->num_led_instances,
+       apu_led->pled = devm_kcalloc(dev,
+               apu_led->num_led_instances, sizeof(struct apu_led_priv),
                GFP_KERNEL);
 
        if (!apu_led->pled)
index f8c7d82..31d4c94 100644 (file)
@@ -113,8 +113,8 @@ static int da9052_led_probe(struct platform_device *pdev)
                goto err;
        }
 
-       led = devm_kzalloc(&pdev->dev,
-                          sizeof(struct da9052_led) * pled->num_leds,
+       led = devm_kcalloc(&pdev->dev,
+                          pled->num_leds, sizeof(struct da9052_led),
                           GFP_KERNEL);
        if (!led) {
                error = -ENOMEM;
index 55c0517..99689b5 100644 (file)
@@ -533,8 +533,8 @@ static int lp5521_probe(struct i2c_client *client,
        if (!chip)
                return -ENOMEM;
 
-       led = devm_kzalloc(&client->dev,
-                       sizeof(*led) * pdata->num_channels, GFP_KERNEL);
+       led = devm_kcalloc(&client->dev,
+                       pdata->num_channels, sizeof(*led), GFP_KERNEL);
        if (!led)
                return -ENOMEM;
 
index 52b6f52..a2e74fe 100644 (file)
@@ -898,8 +898,8 @@ static int lp5523_probe(struct i2c_client *client,
        if (!chip)
                return -ENOMEM;
 
-       led = devm_kzalloc(&client->dev,
-                       sizeof(*led) * pdata->num_channels, GFP_KERNEL);
+       led = devm_kcalloc(&client->dev,
+                       pdata->num_channels, sizeof(*led), GFP_KERNEL);
        if (!led)
                return -ENOMEM;
 
index 05ffa34..2a9009f 100644 (file)
@@ -534,8 +534,8 @@ static int lp5562_probe(struct i2c_client *client,
        if (!chip)
                return -ENOMEM;
 
-       led = devm_kzalloc(&client->dev,
-                       sizeof(*led) * pdata->num_channels, GFP_KERNEL);
+       led = devm_kcalloc(&client->dev,
+                       pdata->num_channels, sizeof(*led), GFP_KERNEL);
        if (!led)
                return -ENOMEM;
 
index 5377f22..3d79a63 100644 (file)
@@ -560,7 +560,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
                return ERR_PTR(-EINVAL);
        }
 
-       cfg = devm_kzalloc(dev, sizeof(*cfg) * num_channels, GFP_KERNEL);
+       cfg = devm_kcalloc(dev, num_channels, sizeof(*cfg), GFP_KERNEL);
        if (!cfg)
                return ERR_PTR(-ENOMEM);
 
index 3adb113..4c800b5 100644 (file)
@@ -327,8 +327,8 @@ static int lp8501_probe(struct i2c_client *client,
        if (!chip)
                return -ENOMEM;
 
-       led = devm_kzalloc(&client->dev,
-                       sizeof(*led) * pdata->num_channels, GFP_KERNEL);
+       led = devm_kcalloc(&client->dev,
+                       pdata->num_channels, sizeof(*led), GFP_KERNEL);
        if (!led)
                return -ENOMEM;
 
index a7ff510..5ec730a 100644 (file)
@@ -128,8 +128,8 @@ static int lt3593_led_probe(struct platform_device *pdev)
        if (!pdata)
                return -EBUSY;
 
-       leds_data = devm_kzalloc(&pdev->dev,
-                       sizeof(struct lt3593_led_data) * pdata->num_leds,
+       leds_data = devm_kcalloc(&pdev->dev,
+                       pdata->num_leds, sizeof(struct lt3593_led_data),
                        GFP_KERNEL);
        if (!leds_data)
                return -ENOMEM;
index 2421cf1..47ad7de 100644 (file)
@@ -136,7 +136,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt(
 
        pdata->num_leds = of_get_child_count(parent);
 
-       pdata->led = devm_kzalloc(dev, pdata->num_leds * sizeof(*pdata->led),
+       pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led),
                                  GFP_KERNEL);
        if (!pdata->led) {
                ret = -ENOMEM;
@@ -210,7 +210,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       leds->led = devm_kzalloc(dev, leds->num_leds * sizeof(*leds->led),
+       leds->led = devm_kcalloc(dev, leds->num_leds, sizeof(*leds->led),
                                 GFP_KERNEL);
        if (!leds->led)
                return -ENOMEM;
index 281482e..f4721f8 100644 (file)
@@ -329,8 +329,10 @@ static int mlxcpld_led_config(struct device *dev,
        int i;
        int err;
 
-       cpld->pled = devm_kzalloc(dev, sizeof(struct mlxcpld_led_priv) *
-                                 cpld->num_led_instances, GFP_KERNEL);
+       cpld->pled = devm_kcalloc(dev,
+                                 cpld->num_led_instances,
+                                 sizeof(struct mlxcpld_led_priv),
+                                 GFP_KERNEL);
        if (!cpld->pled)
                return -ENOMEM;
 
index f48b1ae..62fa0de 100644 (file)
@@ -335,7 +335,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np,
                return ret;
        }
        num_addr = ret;
-       addr = devm_kzalloc(dev, num_addr * sizeof(*addr), GFP_KERNEL);
+       addr = devm_kcalloc(dev, num_addr, sizeof(*addr), GFP_KERNEL);
        if (!addr)
                return -ENOMEM;
 
@@ -355,7 +355,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np,
                return ret;
        }
        num_data = ret;
-       data = devm_kzalloc(dev, num_data * sizeof(*data), GFP_KERNEL);
+       data = devm_kcalloc(dev, num_data, sizeof(*data), GFP_KERNEL);
        if (!data)
                return -ENOMEM;
 
@@ -415,7 +415,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
                if (ret % 3)
                        return -EINVAL;
                num_timers = ret / 3;
-               timers = devm_kzalloc(dev, num_timers * sizeof(*timers),
+               timers = devm_kcalloc(dev, num_timers, sizeof(*timers),
                                      GFP_KERNEL);
                if (!timers)
                        return -ENOMEM;
@@ -444,7 +444,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
                return -ENODEV;
        }
 
-       leds = devm_kzalloc(dev, num_leds * sizeof(*leds), GFP_KERNEL);
+       leds = devm_kcalloc(dev, num_leds, sizeof(*leds), GFP_KERNEL);
        if (!leds)
                return -ENOMEM;
 
@@ -470,8 +470,8 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
                        goto err_node_put;
 
                mode_val =
-                       devm_kzalloc(dev,
-                                    NETXBIG_LED_MODE_NUM * sizeof(*mode_val),
+                       devm_kcalloc(dev,
+                                    NETXBIG_LED_MODE_NUM, sizeof(*mode_val),
                                     GFP_KERNEL);
                if (!mode_val) {
                        ret = -ENOMEM;
@@ -560,8 +560,8 @@ static int netxbig_led_probe(struct platform_device *pdev)
                        return ret;
        }
 
-       leds_data = devm_kzalloc(&pdev->dev,
-                                pdata->num_leds * sizeof(*leds_data),
+       leds_data = devm_kcalloc(&pdev->dev,
+                                pdata->num_leds, sizeof(*leds_data),
                                 GFP_KERNEL);
        if (!leds_data)
                return -ENOMEM;
index 506b75b..14fe5cd 100644 (file)
@@ -264,7 +264,7 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata)
        if (!num_leds)
                return -ENODEV;
 
-       leds = devm_kzalloc(dev, num_leds * sizeof(struct ns2_led),
+       leds = devm_kcalloc(dev, num_leds, sizeof(struct ns2_led),
                            GFP_KERNEL);
        if (!leds)
                return -ENOMEM;
@@ -298,8 +298,9 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata)
                }
 
                num_modes = ret / 3;
-               modval = devm_kzalloc(dev,
-                                     num_modes * sizeof(struct ns2_led_modval),
+               modval = devm_kcalloc(dev,
+                                     num_modes,
+                                     sizeof(struct ns2_led_modval),
                                      GFP_KERNEL);
                if (!modval)
                        return -ENOMEM;
index 78183f9..f51b356 100644 (file)
@@ -390,8 +390,8 @@ pca955x_pdata_of_init(struct i2c_client *client, struct pca955x_chipdef *chip)
        if (!pdata)
                return ERR_PTR(-ENOMEM);
 
-       pdata->leds = devm_kzalloc(&client->dev,
-                                  sizeof(struct pca955x_led) * chip->bits,
+       pdata->leds = devm_kcalloc(&client->dev,
+                                  chip->bits, sizeof(struct pca955x_led),
                                   GFP_KERNEL);
        if (!pdata->leds)
                return ERR_PTR(-ENOMEM);
@@ -494,8 +494,8 @@ static int pca955x_probe(struct i2c_client *client,
        if (!pca955x)
                return -ENOMEM;
 
-       pca955x->leds = devm_kzalloc(&client->dev,
-                       sizeof(*pca955x_led) * chip->bits, GFP_KERNEL);
+       pca955x->leds = devm_kcalloc(&client->dev,
+                       chip->bits, sizeof(*pca955x_led), GFP_KERNEL);
        if (!pca955x->leds)
                return -ENOMEM;
 
index 3bf9a12..5c09081 100644 (file)
@@ -300,8 +300,8 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
        if (!count || count > chip->n_leds)
                return ERR_PTR(-ENODEV);
 
-       pca963x_leds = devm_kzalloc(&client->dev,
-                       sizeof(struct led_info) * chip->n_leds, GFP_KERNEL);
+       pca963x_leds = devm_kcalloc(&client->dev,
+                       chip->n_leds, sizeof(struct led_info), GFP_KERNEL);
        if (!pca963x_leds)
                return ERR_PTR(-ENOMEM);
 
@@ -407,7 +407,7 @@ static int pca963x_probe(struct i2c_client *client,
                                                                GFP_KERNEL);
        if (!pca963x_chip)
                return -ENOMEM;
-       pca963x = devm_kzalloc(&client->dev, chip->n_leds * sizeof(*pca963x),
+       pca963x = devm_kcalloc(&client->dev, chip->n_leds, sizeof(*pca963x),
                                                                GFP_KERNEL);
        if (!pca963x)
                return -ENOMEM;
index c12c16f..8f343af 100644 (file)
@@ -697,8 +697,8 @@ tca6507_led_dt_init(struct i2c_client *client)
        if (!count || count > NUM_LEDS)
                return ERR_PTR(-ENODEV);
 
-       tca_leds = devm_kzalloc(&client->dev,
-                       sizeof(struct led_info) * NUM_LEDS, GFP_KERNEL);
+       tca_leds = devm_kcalloc(&client->dev,
+                       NUM_LEDS, sizeof(struct led_info), GFP_KERNEL);
        if (!tca_leds)
                return ERR_PTR(-ENOMEM);
 
index 519376d..4fa9803 100644 (file)
@@ -282,13 +282,13 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
 
        mbox->dev = dev;
        mbox->chan_num = MBOX_CHAN_MAX;
-       mbox->mchan = devm_kzalloc(dev,
-               mbox->chan_num * sizeof(*mbox->mchan), GFP_KERNEL);
+       mbox->mchan = devm_kcalloc(dev,
+               mbox->chan_num, sizeof(*mbox->mchan), GFP_KERNEL);
        if (!mbox->mchan)
                return -ENOMEM;
 
-       mbox->chan = devm_kzalloc(dev,
-               mbox->chan_num * sizeof(*mbox->chan), GFP_KERNEL);
+       mbox->chan = devm_kcalloc(dev,
+               mbox->chan_num, sizeof(*mbox->chan), GFP_KERNEL);
        if (!mbox->chan)
                return -ENOMEM;
 
index 41bcd33..779d412 100644 (file)
@@ -442,8 +442,8 @@ static int sti_mbox_probe(struct platform_device *pdev)
        if (!mbox)
                return -ENOMEM;
 
-       chans = devm_kzalloc(&pdev->dev,
-                            sizeof(*chans) * STI_MBOX_CHAN_MAX, GFP_KERNEL);
+       chans = devm_kcalloc(&pdev->dev,
+                            STI_MBOX_CHAN_MAX, sizeof(*chans), GFP_KERNEL);
        if (!chans)
                return -ENOMEM;
 
index 2517038..e1e2c08 100644 (file)
@@ -729,7 +729,7 @@ static int omap_mbox_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       finfoblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*finfoblk),
+       finfoblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*finfoblk),
                                GFP_KERNEL);
        if (!finfoblk)
                return -ENOMEM;
@@ -773,23 +773,23 @@ static int omap_mbox_probe(struct platform_device *pdev)
        if (IS_ERR(mdev->mbox_base))
                return PTR_ERR(mdev->mbox_base);
 
-       mdev->irq_ctx = devm_kzalloc(&pdev->dev, num_users * sizeof(u32),
+       mdev->irq_ctx = devm_kcalloc(&pdev->dev, num_users, sizeof(u32),
                                     GFP_KERNEL);
        if (!mdev->irq_ctx)
                return -ENOMEM;
 
        /* allocate one extra for marking end of list */
-       list = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*list),
+       list = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*list),
                            GFP_KERNEL);
        if (!list)
                return -ENOMEM;
 
-       chnls = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*chnls),
+       chnls = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*chnls),
                             GFP_KERNEL);
        if (!chnls)
                return -ENOMEM;
 
-       mboxblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*mbox),
+       mboxblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*mbox),
                               GFP_KERNEL);
        if (!mboxblk)
                return -ENOMEM;
index 78753a8..5d04738 100644 (file)
@@ -568,12 +568,12 @@ static int ti_msgmgr_probe(struct platform_device *pdev)
        }
        inst->num_valid_queues = queue_count;
 
-       qinst = devm_kzalloc(dev, sizeof(*qinst) * queue_count, GFP_KERNEL);
+       qinst = devm_kcalloc(dev, queue_count, sizeof(*qinst), GFP_KERNEL);
        if (!qinst)
                return -ENOMEM;
        inst->qinsts = qinst;
 
-       chans = devm_kzalloc(dev, sizeof(*chans) * queue_count, GFP_KERNEL);
+       chans = devm_kcalloc(dev, queue_count, sizeof(*chans), GFP_KERNEL);
        if (!chans)
                return -ENOMEM;
        inst->chans = chans;
index ff46d2c..5007c96 100644 (file)
@@ -373,7 +373,7 @@ static int s5k5baf_fw_parse(struct device *dev, struct s5k5baf_fw **fw,
        data += S5K5BAG_FW_TAG_LEN;
        count -= S5K5BAG_FW_TAG_LEN;
 
-       d = devm_kzalloc(dev, count * sizeof(u16), GFP_KERNEL);
+       d = devm_kcalloc(dev, count, sizeof(u16), GFP_KERNEL);
        if (!d)
                return -ENOMEM;
 
index 58ebc22..b05738a 100644 (file)
@@ -2586,8 +2586,10 @@ static int vpfe_probe(struct platform_device *pdev)
 
        pm_runtime_put_sync(&pdev->dev);
 
-       vpfe->sd = devm_kzalloc(&pdev->dev, sizeof(struct v4l2_subdev *) *
-                               ARRAY_SIZE(vpfe->cfg->asd), GFP_KERNEL);
+       vpfe->sd = devm_kcalloc(&pdev->dev,
+                               ARRAY_SIZE(vpfe->cfg->asd),
+                               sizeof(struct v4l2_subdev *),
+                               GFP_KERNEL);
        if (!vpfe->sd) {
                ret = -ENOMEM;
                goto probe_out_v4l2_unregister;
index 9364cdf..a96f53c 100644 (file)
@@ -1528,8 +1528,10 @@ vpif_capture_get_pdata(struct platform_device *pdev)
        if (!pdata)
                return NULL;
        pdata->subdev_info =
-               devm_kzalloc(&pdev->dev, sizeof(*pdata->subdev_info) *
-                            VPIF_CAPTURE_NUM_CHANNELS, GFP_KERNEL);
+               devm_kcalloc(&pdev->dev,
+                            VPIF_CAPTURE_NUM_CHANNELS,
+                            sizeof(*pdata->subdev_info),
+                            GFP_KERNEL);
 
        if (!pdata->subdev_info)
                return NULL;
@@ -1546,9 +1548,9 @@ vpif_capture_get_pdata(struct platform_device *pdev)
 
                sdinfo = &pdata->subdev_info[i];
                chan = &pdata->chan_config[i];
-               chan->inputs = devm_kzalloc(&pdev->dev,
-                                           sizeof(*chan->inputs) *
+               chan->inputs = devm_kcalloc(&pdev->dev,
                                            VPIF_CAPTURE_NUM_CHANNELS,
+                                           sizeof(*chan->inputs),
                                            GFP_KERNEL);
                if (!chan->inputs)
                        return NULL;
index 64df828..226f36e 100644 (file)
@@ -845,7 +845,7 @@ int msm_csid_subdev_init(struct csid_device *csid,
        while (res->clock[csid->nclocks])
                csid->nclocks++;
 
-       csid->clock = devm_kzalloc(dev, csid->nclocks * sizeof(*csid->clock),
+       csid->clock = devm_kcalloc(dev, csid->nclocks, sizeof(*csid->clock),
                                    GFP_KERNEL);
        if (!csid->clock)
                return -ENOMEM;
@@ -868,8 +868,10 @@ int msm_csid_subdev_init(struct csid_device *csid,
                        continue;
                }
 
-               clock->freq = devm_kzalloc(dev, clock->nfreqs *
-                                          sizeof(*clock->freq), GFP_KERNEL);
+               clock->freq = devm_kcalloc(dev,
+                                          clock->nfreqs,
+                                          sizeof(*clock->freq),
+                                          GFP_KERNEL);
                if (!clock->freq)
                        return -ENOMEM;
 
index 072c6cf..7e61cab 100644 (file)
@@ -732,8 +732,9 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
        while (res->clock[csiphy->nclocks])
                csiphy->nclocks++;
 
-       csiphy->clock = devm_kzalloc(dev, csiphy->nclocks *
-                                    sizeof(*csiphy->clock), GFP_KERNEL);
+       csiphy->clock = devm_kcalloc(dev,
+                                    csiphy->nclocks, sizeof(*csiphy->clock),
+                                    GFP_KERNEL);
        if (!csiphy->clock)
                return -ENOMEM;
 
@@ -755,8 +756,10 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
                        continue;
                }
 
-               clock->freq = devm_kzalloc(dev, clock->nfreqs *
-                                          sizeof(*clock->freq), GFP_KERNEL);
+               clock->freq = devm_kcalloc(dev,
+                                          clock->nfreqs,
+                                          sizeof(*clock->freq),
+                                          GFP_KERNEL);
                if (!clock->freq)
                        return -ENOMEM;
 
index 24da529..9d1af93 100644 (file)
@@ -948,7 +948,8 @@ int msm_ispif_subdev_init(struct ispif_device *ispif,
        while (res->clock[ispif->nclocks])
                ispif->nclocks++;
 
-       ispif->clock = devm_kzalloc(dev, ispif->nclocks * sizeof(*ispif->clock),
+       ispif->clock = devm_kcalloc(dev,
+                                   ispif->nclocks, sizeof(*ispif->clock),
                                    GFP_KERNEL);
        if (!ispif->clock)
                return -ENOMEM;
@@ -968,8 +969,10 @@ int msm_ispif_subdev_init(struct ispif_device *ispif,
        while (res->clock_for_reset[ispif->nclocks_for_reset])
                ispif->nclocks_for_reset++;
 
-       ispif->clock_for_reset = devm_kzalloc(dev, ispif->nclocks_for_reset *
-                       sizeof(*ispif->clock_for_reset), GFP_KERNEL);
+       ispif->clock_for_reset = devm_kcalloc(dev,
+                                             ispif->nclocks_for_reset,
+                                             sizeof(*ispif->clock_for_reset),
+                                             GFP_KERNEL);
        if (!ispif->clock_for_reset)
                return -ENOMEM;
 
index 55232a9..a6329a8 100644 (file)
@@ -2794,7 +2794,7 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res)
        while (res->clock[vfe->nclocks])
                vfe->nclocks++;
 
-       vfe->clock = devm_kzalloc(dev, vfe->nclocks * sizeof(*vfe->clock),
+       vfe->clock = devm_kcalloc(dev, vfe->nclocks, sizeof(*vfe->clock),
                                  GFP_KERNEL);
        if (!vfe->clock)
                return -ENOMEM;
@@ -2817,8 +2817,10 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res)
                        continue;
                }
 
-               clock->freq = devm_kzalloc(dev, clock->nfreqs *
-                                          sizeof(*clock->freq), GFP_KERNEL);
+               clock->freq = devm_kcalloc(dev,
+                                          clock->nfreqs,
+                                          sizeof(*clock->freq),
+                                          GFP_KERNEL);
                if (!clock->freq)
                        return -ENOMEM;
 
index 05f06c9..23fda62 100644 (file)
@@ -271,7 +271,8 @@ static int camss_of_parse_endpoint_node(struct device *dev,
        lncfg->clk.pol = mipi_csi2->lane_polarities[0];
        lncfg->num_data = mipi_csi2->num_data_lanes;
 
-       lncfg->data = devm_kzalloc(dev, lncfg->num_data * sizeof(*lncfg->data),
+       lncfg->data = devm_kcalloc(dev,
+                                  lncfg->num_data, sizeof(*lncfg->data),
                                   GFP_KERNEL);
        if (!lncfg->data)
                return -ENOMEM;
index da276a8..36a29e1 100644 (file)
@@ -630,7 +630,8 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
        entity->source_pad = num_pads - 1;
 
        /* Allocate and initialize pads. */
-       entity->pads = devm_kzalloc(vsp1->dev, num_pads * sizeof(*entity->pads),
+       entity->pads = devm_kcalloc(vsp1->dev,
+                                   num_pads, sizeof(*entity->pads),
                                    GFP_KERNEL);
        if (entity->pads == NULL)
                return -ENOMEM;
index 6bb28cd..6d95ec1 100644 (file)
@@ -532,7 +532,7 @@ static int xvip_graph_init(struct xvip_composite_device *xdev)
 
        /* Register the subdevices notifier. */
        num_subdevs = xdev->num_subdevs;
-       subdevs = devm_kzalloc(xdev->dev, sizeof(*subdevs) * num_subdevs,
+       subdevs = devm_kcalloc(xdev->dev, num_subdevs, sizeof(*subdevs),
                               GFP_KERNEL);
        if (subdevs == NULL) {
                ret = -ENOMEM;
index 4ceef21..215b480 100644 (file)
@@ -412,9 +412,10 @@ static int v4l2_flash_init_controls(struct v4l2_flash *v4l2_flash,
        struct v4l2_ctrl_config *ctrl_cfg;
        int i, ret, num_ctrls = 0;
 
-       v4l2_flash->ctrls = devm_kzalloc(v4l2_flash->sd.dev,
-                                       sizeof(*v4l2_flash->ctrls) *
-                                       (STROBE_SOURCE + 1), GFP_KERNEL);
+       v4l2_flash->ctrls = devm_kcalloc(v4l2_flash->sd.dev,
+                                       STROBE_SOURCE + 1,
+                                       sizeof(*v4l2_flash->ctrls),
+                                       GFP_KERNEL);
        if (!v4l2_flash->ctrls)
                return -ENOMEM;
 
index 568f05e..2f5ed73 100644 (file)
@@ -126,8 +126,8 @@ const struct lpddr2_timings *of_get_ddr_timings(struct device_node *np_ddr,
                        arr_sz++;
 
        if (arr_sz)
-               timings = devm_kzalloc(dev, sizeof(*timings) * arr_sz,
-                       GFP_KERNEL);
+               timings = devm_kcalloc(dev, arr_sz, sizeof(*timings),
+                                      GFP_KERNEL);
 
        if (!timings)
                goto default_timings;
index 831a1ce..8d652b2 100644 (file)
@@ -2659,18 +2659,18 @@ static int ab8500_debug_probe(struct platform_device *plf)
        ab8500 = dev_get_drvdata(plf->dev.parent);
        num_irqs = ab8500->mask_size;
 
-       irq_count = devm_kzalloc(&plf->dev,
-                                sizeof(*irq_count)*num_irqs, GFP_KERNEL);
+       irq_count = devm_kcalloc(&plf->dev,
+                                num_irqs, sizeof(*irq_count), GFP_KERNEL);
        if (!irq_count)
                return -ENOMEM;
 
-       dev_attr = devm_kzalloc(&plf->dev,
-                               sizeof(*dev_attr)*num_irqs, GFP_KERNEL);
+       dev_attr = devm_kcalloc(&plf->dev,
+                               num_irqs, sizeof(*dev_attr), GFP_KERNEL);
        if (!dev_attr)
                return -ENOMEM;
 
-       event_name = devm_kzalloc(&plf->dev,
-                                 sizeof(*event_name)*num_irqs, GFP_KERNEL);
+       event_name = devm_kcalloc(&plf->dev,
+                                 num_irqs, sizeof(*event_name), GFP_KERNEL);
        if (!event_name)
                return -ENOMEM;
 
index 4bf8b77..01572b5 100644 (file)
@@ -477,7 +477,9 @@ static int htcpld_setup_chips(struct platform_device *pdev)
 
        /* Setup each chip's output GPIOs */
        htcpld->nchips = pdata->num_chip;
-       htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips,
+       htcpld->chip = devm_kcalloc(dev,
+                                   htcpld->nchips,
+                                   sizeof(struct htcpld_chip),
                                    GFP_KERNEL);
        if (!htcpld->chip)
                return -ENOMEM;
index d2cc1ea..5276911 100644 (file)
@@ -173,9 +173,9 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap)
        int ret;
 
        cpcap->irqs = devm_kzalloc(&cpcap->spi->dev,
-                                  sizeof(*cpcap->irqs) *
-                                  CPCAP_NR_IRQ_REG_BANKS *
-                                  cpcap->regmap_conf->val_bits,
+                                  array3_size(sizeof(*cpcap->irqs),
+                                              CPCAP_NR_IRQ_REG_BANKS,
+                                              cpcap->regmap_conf->val_bits),
                                   GFP_KERNEL);
        if (!cpcap->irqs)
                return -ENOMEM;
index 3460ef0..69df277 100644 (file)
@@ -199,8 +199,9 @@ static int sprd_pmic_probe(struct spi_device *spi)
        ddata->irq_chip.num_irqs = pdata->num_irqs;
        ddata->irq_chip.mask_invert = true;
 
-       ddata->irqs = devm_kzalloc(&spi->dev, sizeof(struct regmap_irq) *
-                                  pdata->num_irqs, GFP_KERNEL);
+       ddata->irqs = devm_kcalloc(&spi->dev,
+                                  pdata->num_irqs, sizeof(struct regmap_irq),
+                                  GFP_KERNEL);
        if (!ddata->irqs)
                return -ENOMEM;
 
index c649344..4be3d23 100644 (file)
@@ -1139,8 +1139,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
        }
 
        num_slaves = twl_get_num_slaves();
-       twl_priv->twl_modules = devm_kzalloc(&client->dev,
-                                        sizeof(struct twl_client) * num_slaves,
+       twl_priv->twl_modules = devm_kcalloc(&client->dev,
+                                        num_slaves,
+                                        sizeof(struct twl_client),
                                         GFP_KERNEL);
        if (!twl_priv->twl_modules) {
                status = -ENOMEM;
index 953d079..5d5888e 100644 (file)
@@ -368,9 +368,10 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
                goto err;
        }
 
-       wm8994->supplies = devm_kzalloc(wm8994->dev,
-                                       sizeof(struct regulator_bulk_data) *
-                                       wm8994->num_supplies, GFP_KERNEL);
+       wm8994->supplies = devm_kcalloc(wm8994->dev,
+                                       wm8994->num_supplies,
+                                       sizeof(struct regulator_bulk_data),
+                                       GFP_KERNEL);
        if (!wm8994->supplies) {
                ret = -ENOMEM;
                goto err;
index e2e31b6..c5dc609 100644 (file)
@@ -264,8 +264,8 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
        list_sort(NULL, &reserve_list, sram_reserve_cmp);
 
        if (exports) {
-               sram->partition = devm_kzalloc(sram->dev,
-                                      exports * sizeof(*sram->partition),
+               sram->partition = devm_kcalloc(sram->dev,
+                                      exports, sizeof(*sram->partition),
                                       GFP_KERNEL);
                if (!sram->partition) {
                        ret = -ENOMEM;
index f3a7c8e..88347ce 100644 (file)
@@ -797,8 +797,10 @@ static int sdhci_omap_config_iodelay_pinctrl_state(struct sdhci_omap_host
        if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY))
                return 0;
 
-       pinctrl_state = devm_kzalloc(dev, sizeof(*pinctrl_state) *
-                                    (MMC_TIMING_MMC_HS200 + 1), GFP_KERNEL);
+       pinctrl_state = devm_kcalloc(dev,
+                                    MMC_TIMING_MMC_HS200 + 1,
+                                    sizeof(*pinctrl_state),
+                                    GFP_KERNEL);
        if (!pinctrl_state)
                return -ENOMEM;
 
index a0d485f..512bd4c 100644 (file)
@@ -1993,7 +1993,7 @@ static int __init docg3_probe(struct platform_device *pdev)
        base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
 
        ret = -ENOMEM;
-       cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS,
+       cascade = devm_kcalloc(dev, DOC_MAX_NBFLOORS, sizeof(*cascade),
                               GFP_KERNEL);
        if (!cascade)
                return ret;
index b554fb6..6a5519f 100644 (file)
@@ -2510,8 +2510,8 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
        if (!nandc->regs)
                return -ENOMEM;
 
-       nandc->reg_read_buf = devm_kzalloc(nandc->dev,
-                               MAX_REG_RD * sizeof(*nandc->reg_read_buf),
+       nandc->reg_read_buf = devm_kcalloc(nandc->dev,
+                               MAX_REG_RD, sizeof(*nandc->reg_read_buf),
                                GFP_KERNEL);
        if (!nandc->reg_read_buf)
                return -ENOMEM;
index 1bc0458..19661c5 100644 (file)
@@ -1038,7 +1038,7 @@ static int s3c24xx_nand_probe_dt(struct platform_device *pdev)
        if (!pdata->nr_sets)
                return 0;
 
-       sets = devm_kzalloc(&pdev->dev, sizeof(*sets) * pdata->nr_sets,
+       sets = devm_kcalloc(&pdev->dev, pdata->nr_sets, sizeof(*sets),
                            GFP_KERNEL);
        if (!sets)
                return -ENOMEM;
index 5e010b1..d93c790 100644 (file)
@@ -2044,14 +2044,14 @@ static int b53_switch_init(struct b53_device *dev)
                }
        }
 
-       dev->ports = devm_kzalloc(dev->dev,
-                                 sizeof(struct b53_port) * dev->num_ports,
+       dev->ports = devm_kcalloc(dev->dev,
+                                 dev->num_ports, sizeof(struct b53_port),
                                  GFP_KERNEL);
        if (!dev->ports)
                return -ENOMEM;
 
-       dev->vlans = devm_kzalloc(dev->dev,
-                                 sizeof(struct b53_vlan) * dev->num_vlans,
+       dev->vlans = devm_kcalloc(dev->dev,
+                                 dev->num_vlans, sizeof(struct b53_vlan),
                                  GFP_KERNEL);
        if (!dev->vlans)
                return -ENOMEM;
index 060cb18..521607b 100644 (file)
@@ -838,8 +838,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf)
                return;
        }
 
-       strings_buf = devm_kzalloc(&adapter->pdev->dev,
-                                  strings_num * ETH_GSTRING_LEN,
+       strings_buf = devm_kcalloc(&adapter->pdev->dev,
+                                  ETH_GSTRING_LEN, strings_num,
                                   GFP_ATOMIC);
        if (!strings_buf) {
                netif_err(adapter, drv, netdev,
@@ -847,8 +847,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf)
                return;
        }
 
-       data_buf = devm_kzalloc(&adapter->pdev->dev,
-                               strings_num * sizeof(u64),
+       data_buf = devm_kcalloc(&adapter->pdev->dev,
+                               strings_num, sizeof(u64),
                                GFP_ATOMIC);
        if (!data_buf) {
                netif_err(adapter, drv, netdev,
index 00a5727..60da049 100644 (file)
@@ -1141,7 +1141,8 @@ static int ethoc_probe(struct platform_device *pdev)
        dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n",
                priv->num_tx, priv->num_rx);
 
-       priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL);
+       priv->vma = devm_kcalloc(&pdev->dev, num_bd, sizeof(void *),
+                                GFP_KERNEL);
        if (!priv->vma) {
                ret = -ENOMEM;
                goto free;
index fd43f98..5f4e1ff 100644 (file)
@@ -664,7 +664,7 @@ static struct dpaa_fq *dpaa_fq_alloc(struct device *dev,
        struct dpaa_fq *dpaa_fq;
        int i;
 
-       dpaa_fq = devm_kzalloc(dev, sizeof(*dpaa_fq) * count,
+       dpaa_fq = devm_kcalloc(dev, count, sizeof(*dpaa_fq),
                               GFP_KERNEL);
        if (!dpaa_fq)
                return NULL;
index f2b31d2..25a73bb 100644 (file)
@@ -2846,8 +2846,10 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv)
        struct pci_dev *pdev = h->pdev;
        int i, ret;
 
-       priv->ring_data =  devm_kzalloc(&pdev->dev, h->kinfo.num_tqps *
-                                       sizeof(*priv->ring_data) * 2,
+       priv->ring_data =  devm_kzalloc(&pdev->dev,
+                                       array3_size(h->kinfo.num_tqps,
+                                                   sizeof(*priv->ring_data),
+                                                   2),
                                        GFP_KERNEL);
        if (!priv->ring_data)
                return -ENOMEM;
index b092894..09f674e 100644 (file)
@@ -247,9 +247,8 @@ static int nixge_hw_dma_bd_init(struct net_device *ndev)
        if (!priv->tx_bd_v)
                goto out;
 
-       priv->tx_skb = devm_kzalloc(ndev->dev.parent,
-                                   sizeof(*priv->tx_skb) *
-                                   TX_BD_NUM,
+       priv->tx_skb = devm_kcalloc(ndev->dev.parent,
+                                   TX_BD_NUM, sizeof(*priv->tx_skb),
                                    GFP_KERNEL);
        if (!priv->tx_skb)
                goto out;
index 881c94b..2258cd8 100644 (file)
@@ -277,8 +277,8 @@ static int tc_init(struct stmmac_priv *priv)
 
        /* Reserve one last filter which lets all pass */
        priv->tc_entries_max = count;
-       priv->tc_entries = devm_kzalloc(priv->device,
-                       sizeof(*priv->tc_entries) * count, GFP_KERNEL);
+       priv->tc_entries = devm_kcalloc(priv->device,
+                       count, sizeof(*priv->tc_entries), GFP_KERNEL);
        if (!priv->tc_entries)
                return -ENOMEM;
 
index 534596c..358edab 100644 (file)
@@ -2740,8 +2740,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
        }
        data->active_slave = prop;
 
-       data->slave_data = devm_kzalloc(&pdev->dev, data->slaves
-                                       * sizeof(struct cpsw_slave_data),
+       data->slave_data = devm_kcalloc(&pdev->dev,
+                                       data->slaves,
+                                       sizeof(struct cpsw_slave_data),
                                        GFP_KERNEL);
        if (!data->slave_data)
                return -ENOMEM;
@@ -3045,8 +3046,8 @@ static int cpsw_probe(struct platform_device *pdev)
 
        memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
 
-       cpsw->slaves = devm_kzalloc(&pdev->dev,
-                                   sizeof(struct cpsw_slave) * data->slaves,
+       cpsw->slaves = devm_kcalloc(&pdev->dev,
+                                   data->slaves, sizeof(struct cpsw_slave),
                                    GFP_KERNEL);
        if (!cpsw->slaves) {
                ret = -ENOMEM;
index 6e455a2..72b98e2 100644 (file)
@@ -3285,8 +3285,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
        gbe_dev->et_stats = xgbe10_et_stats;
        gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats);
 
-       gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
-                                        gbe_dev->num_et_stats * sizeof(u64),
+       gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
+                                        gbe_dev->num_et_stats, sizeof(u64),
                                         GFP_KERNEL);
        if (!gbe_dev->hw_stats) {
                dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3294,8 +3294,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
        }
 
        gbe_dev->hw_stats_prev =
-               devm_kzalloc(gbe_dev->dev,
-                            gbe_dev->num_et_stats * sizeof(u32),
+               devm_kcalloc(gbe_dev->dev,
+                            gbe_dev->num_et_stats, sizeof(u32),
                             GFP_KERNEL);
        if (!gbe_dev->hw_stats_prev) {
                dev_err(gbe_dev->dev,
@@ -3405,8 +3405,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
        gbe_dev->et_stats = gbe13_et_stats;
        gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats);
 
-       gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
-                                        gbe_dev->num_et_stats * sizeof(u64),
+       gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
+                                        gbe_dev->num_et_stats, sizeof(u64),
                                         GFP_KERNEL);
        if (!gbe_dev->hw_stats) {
                dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3414,8 +3414,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
        }
 
        gbe_dev->hw_stats_prev =
-               devm_kzalloc(gbe_dev->dev,
-                            gbe_dev->num_et_stats * sizeof(u32),
+               devm_kcalloc(gbe_dev->dev,
+                            gbe_dev->num_et_stats, sizeof(u32),
                             GFP_KERNEL);
        if (!gbe_dev->hw_stats_prev) {
                dev_err(gbe_dev->dev,
@@ -3477,8 +3477,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
                gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
                                        GBENU_ET_STATS_PORT_SIZE;
 
-       gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
-                                        gbe_dev->num_et_stats * sizeof(u64),
+       gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
+                                        gbe_dev->num_et_stats, sizeof(u64),
                                         GFP_KERNEL);
        if (!gbe_dev->hw_stats) {
                dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3486,8 +3486,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
        }
 
        gbe_dev->hw_stats_prev =
-               devm_kzalloc(gbe_dev->dev,
-                            gbe_dev->num_et_stats * sizeof(u32),
+               devm_kcalloc(gbe_dev->dev,
+                            gbe_dev->num_et_stats, sizeof(u32),
                             GFP_KERNEL);
        if (!gbe_dev->hw_stats_prev) {
                dev_err(gbe_dev->dev,
index 39ecad2..491efc1 100644 (file)
@@ -128,9 +128,9 @@ int phy_led_triggers_register(struct phy_device *phy)
        if (err)
                goto out_free_link;
 
-       phy->phy_led_triggers = devm_kzalloc(&phy->mdio.dev,
-                                           sizeof(struct phy_led_trigger) *
-                                                  phy->phy_num_led_triggers,
+       phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev,
+                                           phy->phy_num_led_triggers,
+                                           sizeof(struct phy_led_trigger),
                                            GFP_KERNEL);
        if (!phy->phy_led_triggers) {
                err = -ENOMEM;
index fcd079a..d62e34e 100644 (file)
@@ -181,7 +181,7 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband,
        if (!chanlist)
                return -ENOMEM;
 
-       msband->chan = devm_kzalloc(dev->dev, n_chan * sizeof(*msband->chan),
+       msband->chan = devm_kcalloc(dev->dev, n_chan, sizeof(*msband->chan),
                                    GFP_KERNEL);
        if (!msband->chan)
                return -ENOMEM;
index 3d8283e..e3fe412 100644 (file)
@@ -467,7 +467,8 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev)
                dev_err(dev, "missing \"cdns,max-outbound-regions\"\n");
                return ret;
        }
-       ep->ob_addr = devm_kzalloc(dev, ep->max_regions * sizeof(*ep->ob_addr),
+       ep->ob_addr = devm_kcalloc(dev,
+                                  ep->max_regions, sizeof(*ep->ob_addr),
                                   GFP_KERNEL);
        if (!ep->ob_addr)
                return -ENOMEM;
index f688204..2810c6a 100644 (file)
@@ -639,11 +639,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
                return phy_count;
        }
 
-       phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL);
+       phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL);
        if (!phy)
                return -ENOMEM;
 
-       link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL);
+       link = devm_kcalloc(dev, phy_count, sizeof(*link), GFP_KERNEL);
        if (!link)
                return -ENOMEM;
 
index 1eec441..8650416 100644 (file)
@@ -366,19 +366,21 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
                return -EINVAL;
        }
 
-       ep->ib_window_map = devm_kzalloc(dev, sizeof(long) *
+       ep->ib_window_map = devm_kcalloc(dev,
                                         BITS_TO_LONGS(ep->num_ib_windows),
+                                        sizeof(long),
                                         GFP_KERNEL);
        if (!ep->ib_window_map)
                return -ENOMEM;
 
-       ep->ob_window_map = devm_kzalloc(dev, sizeof(long) *
+       ep->ob_window_map = devm_kcalloc(dev,
                                         BITS_TO_LONGS(ep->num_ob_windows),
+                                        sizeof(long),
                                         GFP_KERNEL);
        if (!ep->ob_window_map)
                return -ENOMEM;
 
-       addr = devm_kzalloc(dev, sizeof(phys_addr_t) * ep->num_ob_windows,
+       addr = devm_kcalloc(dev, ep->num_ob_windows, sizeof(phys_addr_t),
                            GFP_KERNEL);
        if (!addr)
                return -ENOMEM;
index fc267a4..6beba8e 100644 (file)
@@ -593,7 +593,7 @@ static int rockchip_pcie_ep_probe(struct platform_device *pdev)
                            PCIE_CLIENT_CONFIG);
 
        max_regions = ep->max_regions;
-       ep->ob_addr = devm_kzalloc(dev, max_regions * sizeof(*ep->ob_addr),
+       ep->ob_addr = devm_kcalloc(dev, max_regions, sizeof(*ep->ob_addr),
                                   GFP_KERNEL);
 
        if (!ep->ob_addr) {
index a620a8e..d6d183e 100644 (file)
@@ -216,8 +216,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)
        }
 
        /* we will reallocate later */
-       pctrl->functions = devm_kzalloc(&pdev->dev,
-                                       max_functions * sizeof(*pctrl->functions),
+       pctrl->functions = devm_kcalloc(&pdev->dev,
+                                       max_functions,
+                                       sizeof(*pctrl->functions),
                                        GFP_KERNEL);
        if (!pctrl->functions)
                return -ENOMEM;
@@ -261,8 +262,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)
 
                        if (!function->groups) {
                                function->groups =
-                                       devm_kzalloc(&pdev->dev,
-                                                    function->ngroups * sizeof(char *),
+                                       devm_kcalloc(&pdev->dev,
+                                                    function->ngroups,
+                                                    sizeof(char *),
                                                     GFP_KERNEL);
 
                                if (!function->groups)
index 28e5b7f..1c6bb15 100644 (file)
@@ -477,10 +477,12 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
        config = imx_pinconf_parse_generic_config(np, ipctl);
 
        grp->num_pins = size / pin_size;
-       grp->data = devm_kzalloc(ipctl->dev, grp->num_pins *
-                                sizeof(struct imx_pin), GFP_KERNEL);
-       grp->pins = devm_kzalloc(ipctl->dev, grp->num_pins *
-                                sizeof(unsigned int), GFP_KERNEL);
+       grp->data = devm_kcalloc(ipctl->dev,
+                                grp->num_pins, sizeof(struct imx_pin),
+                                GFP_KERNEL);
+       grp->pins = devm_kcalloc(ipctl->dev,
+                                grp->num_pins, sizeof(unsigned int),
+                                GFP_KERNEL);
        if (!grp->pins || !grp->data)
                return -ENOMEM;
 
index e7169ac..c3bdd90 100644 (file)
@@ -483,10 +483,10 @@ static int imx1_pinctrl_parse_groups(struct device_node *np,
        }
 
        grp->npins = size / 12;
-       grp->pins = devm_kzalloc(info->dev,
-                       grp->npins * sizeof(struct imx1_pin), GFP_KERNEL);
-       grp->pin_ids = devm_kzalloc(info->dev,
-                       grp->npins * sizeof(unsigned int), GFP_KERNEL);
+       grp->pins = devm_kcalloc(info->dev,
+                       grp->npins, sizeof(struct imx1_pin), GFP_KERNEL);
+       grp->pin_ids = devm_kcalloc(info->dev,
+                       grp->npins, sizeof(unsigned int), GFP_KERNEL);
 
        if (!grp->pins || !grp->pin_ids)
                return -ENOMEM;
@@ -523,8 +523,8 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
        if (func->num_groups == 0)
                return -EINVAL;
 
-       func->groups = devm_kzalloc(info->dev,
-                       func->num_groups * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(info->dev,
+                       func->num_groups, sizeof(char *), GFP_KERNEL);
 
        if (!func->groups)
                return -ENOMEM;
@@ -566,12 +566,12 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
        }
 
        info->nfunctions = nfuncs;
-       info->functions = devm_kzalloc(&pdev->dev,
-                       nfuncs * sizeof(struct imx1_pmx_func), GFP_KERNEL);
+       info->functions = devm_kcalloc(&pdev->dev,
+                       nfuncs, sizeof(struct imx1_pmx_func), GFP_KERNEL);
 
        info->ngroups = ngroups;
-       info->groups = devm_kzalloc(&pdev->dev,
-                       ngroups * sizeof(struct imx1_pin_group), GFP_KERNEL);
+       info->groups = devm_kcalloc(&pdev->dev,
+                       ngroups, sizeof(struct imx1_pin_group), GFP_KERNEL);
 
 
        if (!info->functions || !info->groups)
index 3a17846..a612e46 100644 (file)
@@ -370,12 +370,12 @@ static int mxs_pinctrl_parse_group(struct platform_device *pdev,
                return -EINVAL;
        g->npins = length / sizeof(u32);
 
-       g->pins = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->pins),
+       g->pins = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->pins),
                               GFP_KERNEL);
        if (!g->pins)
                return -ENOMEM;
 
-       g->muxsel = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->muxsel),
+       g->muxsel = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->muxsel),
                                 GFP_KERNEL);
        if (!g->muxsel)
                return -ENOMEM;
@@ -426,13 +426,16 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
                }
        }
 
-       soc->functions = devm_kzalloc(&pdev->dev, soc->nfunctions *
-                                     sizeof(*soc->functions), GFP_KERNEL);
+       soc->functions = devm_kcalloc(&pdev->dev,
+                                     soc->nfunctions,
+                                     sizeof(*soc->functions),
+                                     GFP_KERNEL);
        if (!soc->functions)
                return -ENOMEM;
 
-       soc->groups = devm_kzalloc(&pdev->dev, soc->ngroups *
-                                  sizeof(*soc->groups), GFP_KERNEL);
+       soc->groups = devm_kcalloc(&pdev->dev,
+                                  soc->ngroups, sizeof(*soc->groups),
+                                  GFP_KERNEL);
        if (!soc->groups)
                return -ENOMEM;
 
@@ -492,7 +495,8 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 
                if (strcmp(fn, child->name)) {
                        f = &soc->functions[idxf++];
-                       f->groups = devm_kzalloc(&pdev->dev, f->ngroups *
+                       f->groups = devm_kcalloc(&pdev->dev,
+                                                f->ngroups,
                                                 sizeof(*f->groups),
                                                 GFP_KERNEL);
                        if (!f->groups)
index 674ffdf..53cf800 100644 (file)
@@ -856,9 +856,10 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
                struct armada_37xx_pin_group *grp = &info->groups[n];
                int i, j, f;
 
-               grp->pins = devm_kzalloc(info->dev,
-                                        (grp->npins + grp->extra_npins) *
-                                        sizeof(*grp->pins), GFP_KERNEL);
+               grp->pins = devm_kcalloc(info->dev,
+                                        grp->npins + grp->extra_npins,
+                                        sizeof(*grp->pins),
+                                        GFP_KERNEL);
                if (!grp->pins)
                        return -ENOMEM;
 
@@ -908,7 +909,8 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info)
                const char **groups;
                int g;
 
-               funcs[n].groups = devm_kzalloc(info->dev, funcs[n].ngroups *
+               funcs[n].groups = devm_kcalloc(info->dev,
+                                              funcs[n].ngroups,
                                               sizeof(*(funcs[n].groups)),
                                               GFP_KERNEL);
                if (!funcs[n].groups)
@@ -948,8 +950,9 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
        ctrldesc->pmxops = &armada_37xx_pmx_ops;
        ctrldesc->confops = &armada_37xx_pinconf_ops;
 
-       pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
-                              pin_data->nr_pins, GFP_KERNEL);
+       pindesc = devm_kcalloc(&pdev->dev,
+                              pin_data->nr_pins, sizeof(*pindesc),
+                              GFP_KERNEL);
        if (!pindesc)
                return -ENOMEM;
 
@@ -968,8 +971,10 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
         * we allocate functions for number of pins and hope there are
         * fewer unique functions than pins available
         */
-       info->funcs = devm_kzalloc(&pdev->dev, pin_data->nr_pins *
-                          sizeof(struct armada_37xx_pmx_func), GFP_KERNEL);
+       info->funcs = devm_kcalloc(&pdev->dev,
+                                  pin_data->nr_pins,
+                                  sizeof(struct armada_37xx_pmx_func),
+                                  GFP_KERNEL);
        if (!info->funcs)
                return -ENOMEM;
 
index 9e05cfa..d7ec711 100644 (file)
@@ -501,8 +501,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev,
 
        /* we allocate functions for number of pins and hope
         * there are fewer unique functions than pins available */
-       funcs = devm_kzalloc(&pdev->dev, funcsize *
-                            sizeof(struct mvebu_pinctrl_function), GFP_KERNEL);
+       funcs = devm_kcalloc(&pdev->dev,
+                            funcsize, sizeof(struct mvebu_pinctrl_function),
+                            GFP_KERNEL);
        if (!funcs)
                return -ENOMEM;
 
@@ -549,8 +550,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev,
 
                        /* allocate group name array if not done already */
                        if (!f->groups) {
-                               f->groups = devm_kzalloc(&pdev->dev,
-                                                f->num_groups * sizeof(char *),
+                               f->groups = devm_kcalloc(&pdev->dev,
+                                                f->num_groups,
+                                                sizeof(char *),
                                                 GFP_KERNEL);
                                if (!f->groups)
                                        return -ENOMEM;
@@ -622,8 +624,10 @@ int mvebu_pinctrl_probe(struct platform_device *pdev)
                }
        }
 
-       pdesc = devm_kzalloc(&pdev->dev, pctl->desc.npins *
-                            sizeof(struct pinctrl_pin_desc), GFP_KERNEL);
+       pdesc = devm_kcalloc(&pdev->dev,
+                            pctl->desc.npins,
+                            sizeof(struct pinctrl_pin_desc),
+                            GFP_KERNEL);
        if (!pdesc)
                return -ENOMEM;
 
index bafb3d4..67e4d9f 100644 (file)
@@ -945,27 +945,30 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
                return PTR_ERR(atmel_pioctrl->clk);
        }
 
-       atmel_pioctrl->pins = devm_kzalloc(dev, sizeof(*atmel_pioctrl->pins)
-                       * atmel_pioctrl->npins, GFP_KERNEL);
+       atmel_pioctrl->pins = devm_kcalloc(dev,
+                                          atmel_pioctrl->npins,
+                                          sizeof(*atmel_pioctrl->pins),
+                                          GFP_KERNEL);
        if (!atmel_pioctrl->pins)
                return -ENOMEM;
 
-       pin_desc = devm_kzalloc(dev, sizeof(*pin_desc)
-                       * atmel_pioctrl->npins, GFP_KERNEL);
+       pin_desc = devm_kcalloc(dev, atmel_pioctrl->npins, sizeof(*pin_desc),
+                               GFP_KERNEL);
        if (!pin_desc)
                return -ENOMEM;
        atmel_pinctrl_desc.pins = pin_desc;
        atmel_pinctrl_desc.npins = atmel_pioctrl->npins;
 
        /* One pin is one group since a pin can achieve all functions. */
-       group_names = devm_kzalloc(dev, sizeof(*group_names)
-                       * atmel_pioctrl->npins, GFP_KERNEL);
+       group_names = devm_kcalloc(dev,
+                                  atmel_pioctrl->npins, sizeof(*group_names),
+                                  GFP_KERNEL);
        if (!group_names)
                return -ENOMEM;
        atmel_pioctrl->group_names = group_names;
 
-       atmel_pioctrl->groups = devm_kzalloc(&pdev->dev,
-                       sizeof(*atmel_pioctrl->groups) * atmel_pioctrl->npins,
+       atmel_pioctrl->groups = devm_kcalloc(&pdev->dev,
+                       atmel_pioctrl->npins, sizeof(*atmel_pioctrl->groups),
                        GFP_KERNEL);
        if (!atmel_pioctrl->groups)
                return -ENOMEM;
@@ -1001,20 +1004,24 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
        atmel_pioctrl->gpio_chip->parent = dev;
        atmel_pioctrl->gpio_chip->names = atmel_pioctrl->group_names;
 
-       atmel_pioctrl->pm_wakeup_sources = devm_kzalloc(dev,
-                       sizeof(*atmel_pioctrl->pm_wakeup_sources)
-                       * atmel_pioctrl->nbanks, GFP_KERNEL);
+       atmel_pioctrl->pm_wakeup_sources = devm_kcalloc(dev,
+                       atmel_pioctrl->nbanks,
+                       sizeof(*atmel_pioctrl->pm_wakeup_sources),
+                       GFP_KERNEL);
        if (!atmel_pioctrl->pm_wakeup_sources)
                return -ENOMEM;
 
-       atmel_pioctrl->pm_suspend_backup = devm_kzalloc(dev,
-                       sizeof(*atmel_pioctrl->pm_suspend_backup)
-                       * atmel_pioctrl->nbanks, GFP_KERNEL);
+       atmel_pioctrl->pm_suspend_backup = devm_kcalloc(dev,
+                       atmel_pioctrl->nbanks,
+                       sizeof(*atmel_pioctrl->pm_suspend_backup),
+                       GFP_KERNEL);
        if (!atmel_pioctrl->pm_suspend_backup)
                return -ENOMEM;
 
-       atmel_pioctrl->irqs = devm_kzalloc(dev, sizeof(*atmel_pioctrl->irqs)
-                       * atmel_pioctrl->nbanks, GFP_KERNEL);
+       atmel_pioctrl->irqs = devm_kcalloc(dev,
+                                          atmel_pioctrl->nbanks,
+                                          sizeof(*atmel_pioctrl->irqs),
+                                          GFP_KERNEL);
        if (!atmel_pioctrl->irqs)
                return -ENOMEM;
 
index 297f1d1..50f0ec4 100644 (file)
@@ -269,7 +269,8 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev,
        }
 
        map_num += grp->npins;
-       new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, GFP_KERNEL);
+       new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map),
+                              GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
 
@@ -1049,7 +1050,8 @@ static int at91_pinctrl_mux_mask(struct at91_pinctrl *info,
        }
        info->nmux = size / gpio_banks;
 
-       info->mux_mask = devm_kzalloc(info->dev, sizeof(u32) * size, GFP_KERNEL);
+       info->mux_mask = devm_kcalloc(info->dev, size, sizeof(u32),
+                                     GFP_KERNEL);
        if (!info->mux_mask)
                return -ENOMEM;
 
@@ -1087,10 +1089,12 @@ static int at91_pinctrl_parse_groups(struct device_node *np,
        }
 
        grp->npins = size / 4;
-       pin = grp->pins_conf = devm_kzalloc(info->dev, grp->npins * sizeof(struct at91_pmx_pin),
-                               GFP_KERNEL);
-       grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int),
-                               GFP_KERNEL);
+       pin = grp->pins_conf = devm_kcalloc(info->dev,
+                                           grp->npins,
+                                           sizeof(struct at91_pmx_pin),
+                                           GFP_KERNEL);
+       grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int),
+                                GFP_KERNEL);
        if (!grp->pins_conf || !grp->pins)
                return -ENOMEM;
 
@@ -1129,8 +1133,8 @@ static int at91_pinctrl_parse_functions(struct device_node *np,
                dev_err(info->dev, "no groups defined\n");
                return -EINVAL;
        }
-       func->groups = devm_kzalloc(info->dev,
-                       func->ngroups * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(info->dev,
+                       func->ngroups, sizeof(char *), GFP_KERNEL);
        if (!func->groups)
                return -ENOMEM;
 
@@ -1192,12 +1196,16 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
 
        dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
        dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups);
-       info->functions = devm_kzalloc(&pdev->dev, info->nfunctions * sizeof(struct at91_pmx_func),
+       info->functions = devm_kcalloc(&pdev->dev,
+                                       info->nfunctions,
+                                       sizeof(struct at91_pmx_func),
                                        GFP_KERNEL);
        if (!info->functions)
                return -ENOMEM;
 
-       info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct at91_pin_group),
+       info->groups = devm_kcalloc(&pdev->dev,
+                                       info->ngroups,
+                                       sizeof(struct at91_pin_group),
                                        GFP_KERNEL);
        if (!info->groups)
                return -ENOMEM;
@@ -1256,7 +1264,9 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
        at91_pinctrl_desc.name = dev_name(&pdev->dev);
        at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK;
        at91_pinctrl_desc.pins = pdesc =
-               devm_kzalloc(&pdev->dev, sizeof(*pdesc) * at91_pinctrl_desc.npins, GFP_KERNEL);
+               devm_kcalloc(&pdev->dev,
+                            at91_pinctrl_desc.npins, sizeof(*pdesc),
+                            GFP_KERNEL);
 
        if (!at91_pinctrl_desc.pins)
                return -ENOMEM;
@@ -1763,7 +1773,7 @@ static int at91_gpio_probe(struct platform_device *pdev)
                        chip->ngpio = ngpio;
        }
 
-       names = devm_kzalloc(&pdev->dev, sizeof(char *) * chip->ngpio,
+       names = devm_kcalloc(&pdev->dev, chip->ngpio, sizeof(char *),
                             GFP_KERNEL);
 
        if (!names) {
index 1231bbb..a52779f 100644 (file)
@@ -328,7 +328,8 @@ static void axp20x_funcs_groups_from_mask(struct device *dev, unsigned int mask,
 
        func->ngroups = ngroups;
        if (func->ngroups > 0) {
-               func->groups = devm_kzalloc(dev, ngroups * sizeof(const char *),
+               func->groups = devm_kcalloc(dev,
+                                           ngroups, sizeof(const char *),
                                            GFP_KERNEL);
                group = func->groups;
                for_each_set_bit(bit, &mask_cpy, mask_len) {
@@ -358,8 +359,8 @@ static void axp20x_build_funcs_groups(struct platform_device *pdev)
        /* Every pin supports GPIO_OUT and GPIO_IN functions */
        for (i = 0; i <= AXP20X_FUNC_GPIO_IN; i++) {
                pctl->funcs[i].ngroups = npins;
-               pctl->funcs[i].groups = devm_kzalloc(&pdev->dev,
-                                                    npins * sizeof(char *),
+               pctl->funcs[i].groups = devm_kcalloc(&pdev->dev,
+                                                    npins, sizeof(char *),
                                                     GFP_KERNEL);
                for (pin = 0; pin < npins; pin++)
                        pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name;
index ce269ce..5353b23 100644 (file)
@@ -291,10 +291,11 @@ static int dc_pinctrl_probe(struct platform_device *pdev)
        if (IS_ERR(pmap->regs))
                return PTR_ERR(pmap->regs);
 
-       pins = devm_kzalloc(&pdev->dev, sizeof(*pins)*PINS_COUNT, GFP_KERNEL);
+       pins = devm_kcalloc(&pdev->dev, PINS_COUNT, sizeof(*pins),
+                           GFP_KERNEL);
        if (!pins)
                return -ENOMEM;
-       pin_names = devm_kzalloc(&pdev->dev, name_len * PINS_COUNT,
+       pin_names = devm_kcalloc(&pdev->dev, PINS_COUNT, name_len,
                                 GFP_KERNEL);
        if (!pin_names)
                return -ENOMEM;
index ac38a3f..a1d7156 100644 (file)
@@ -770,8 +770,8 @@ static int ingenic_pinctrl_probe(struct platform_device *pdev)
        pctl_desc->pmxops = &ingenic_pmxops;
        pctl_desc->confops = &ingenic_confops;
        pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
-       pctl_desc->pins = jzpc->pdesc = devm_kzalloc(&pdev->dev,
-                       sizeof(*jzpc->pdesc) * pctl_desc->npins, GFP_KERNEL);
+       pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
+                       pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
        if (!jzpc->pdesc)
                return -ENOMEM;
 
index d090f37..190f17e 100644 (file)
@@ -1308,8 +1308,9 @@ static int lpc18xx_create_group_func_map(struct device *dev,
                }
 
                scu->func[func].ngroups = ngroups;
-               scu->func[func].groups = devm_kzalloc(dev, ngroups *
-                                                     sizeof(char *), GFP_KERNEL);
+               scu->func[func].groups = devm_kcalloc(dev,
+                                                     ngroups, sizeof(char *),
+                                                     GFP_KERNEL);
                if (!scu->func[func].groups)
                        return -ENOMEM;
 
index b5b3547..15bb1cb 100644 (file)
@@ -330,7 +330,8 @@ static int ocelot_create_group_func_map(struct device *dev,
                }
 
                info->func[f].ngroups = npins;
-               info->func[f].groups = devm_kzalloc(dev, npins *
+               info->func[f].groups = devm_kcalloc(dev,
+                                                        npins,
                                                         sizeof(char *),
                                                         GFP_KERNEL);
                if (!info->func[f].groups)
index 1882713..f4a6142 100644 (file)
@@ -507,7 +507,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
        }
 
        map_num += grp->npins;
-       new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num,
+       new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map),
                                                                GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
@@ -2473,10 +2473,11 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
 
        grp->npins = size / 4;
 
-       grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int),
+       grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int),
                                                GFP_KERNEL);
-       grp->data = devm_kzalloc(info->dev, grp->npins *
-                                         sizeof(struct rockchip_pin_config),
+       grp->data = devm_kcalloc(info->dev,
+                                       grp->npins,
+                                       sizeof(struct rockchip_pin_config),
                                        GFP_KERNEL);
        if (!grp->pins || !grp->data)
                return -ENOMEM;
@@ -2528,8 +2529,8 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
        if (func->ngroups <= 0)
                return 0;
 
-       func->groups = devm_kzalloc(info->dev,
-                       func->ngroups * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(info->dev,
+                       func->ngroups, sizeof(char *), GFP_KERNEL);
        if (!func->groups)
                return -ENOMEM;
 
@@ -2560,13 +2561,15 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
        dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
        dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups);
 
-       info->functions = devm_kzalloc(dev, info->nfunctions *
+       info->functions = devm_kcalloc(dev,
+                                             info->nfunctions,
                                              sizeof(struct rockchip_pmx_func),
                                              GFP_KERNEL);
        if (!info->functions)
                return -EINVAL;
 
-       info->groups = devm_kzalloc(dev, info->ngroups *
+       info->groups = devm_kcalloc(dev,
+                                           info->ngroups,
                                            sizeof(struct rockchip_pin_group),
                                            GFP_KERNEL);
        if (!info->groups)
@@ -2604,8 +2607,9 @@ static int rockchip_pinctrl_register(struct platform_device *pdev,
        ctrldesc->pmxops = &rockchip_pmx_ops;
        ctrldesc->confops = &rockchip_pinconf_ops;
 
-       pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
-                       info->ctrl->nr_pins, GFP_KERNEL);
+       pindesc = devm_kcalloc(&pdev->dev,
+                              info->ctrl->nr_pins, sizeof(*pindesc),
+                              GFP_KERNEL);
        if (!pindesc)
                return -ENOMEM;
 
index 9c3c005..b3153c0 100644 (file)
@@ -712,8 +712,8 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
        }
 
        dev_dbg(pcs->dev, "allocating %i pins\n", nr_pins);
-       pcs->pins.pa = devm_kzalloc(pcs->dev,
-                               sizeof(*pcs->pins.pa) * nr_pins,
+       pcs->pins.pa = devm_kcalloc(pcs->dev,
+                               nr_pins, sizeof(*pcs->pins.pa),
                                GFP_KERNEL);
        if (!pcs->pins.pa)
                return -ENOMEM;
@@ -924,15 +924,15 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
        if (!nconfs)
                return 0;
 
-       func->conf = devm_kzalloc(pcs->dev,
-                                 sizeof(struct pcs_conf_vals) * nconfs,
+       func->conf = devm_kcalloc(pcs->dev,
+                                 nconfs, sizeof(struct pcs_conf_vals),
                                  GFP_KERNEL);
        if (!func->conf)
                return -ENOMEM;
        func->nconfs = nconfs;
        conf = &(func->conf[0]);
        m++;
-       settings = devm_kzalloc(pcs->dev, sizeof(unsigned long) * nconfs,
+       settings = devm_kcalloc(pcs->dev, nconfs, sizeof(unsigned long),
                                GFP_KERNEL);
        if (!settings)
                return -ENOMEM;
@@ -988,11 +988,11 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
                return -EINVAL;
        }
 
-       vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL);
+       vals = devm_kcalloc(pcs->dev, rows, sizeof(*vals), GFP_KERNEL);
        if (!vals)
                return -ENOMEM;
 
-       pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows, GFP_KERNEL);
+       pins = devm_kcalloc(pcs->dev, rows, sizeof(*pins), GFP_KERNEL);
        if (!pins)
                goto free_vals;
 
@@ -1089,13 +1089,15 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 
        npins_in_row = pcs->width / pcs->bits_per_pin;
 
-       vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row,
-                       GFP_KERNEL);
+       vals = devm_kzalloc(pcs->dev,
+                           array3_size(rows, npins_in_row, sizeof(*vals)),
+                           GFP_KERNEL);
        if (!vals)
                return -ENOMEM;
 
-       pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows * npins_in_row,
-                       GFP_KERNEL);
+       pins = devm_kzalloc(pcs->dev,
+                           array3_size(rows, npins_in_row, sizeof(*pins)),
+                           GFP_KERNEL);
        if (!pins)
                goto free_vals;
 
@@ -1217,7 +1219,7 @@ static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev,
        pcs = pinctrl_dev_get_drvdata(pctldev);
 
        /* create 2 maps. One is for pinmux, and the other is for pinconf. */
-       *map = devm_kzalloc(pcs->dev, sizeof(**map) * 2, GFP_KERNEL);
+       *map = devm_kcalloc(pcs->dev, 2, sizeof(**map), GFP_KERNEL);
        if (!*map)
                return -ENOMEM;
 
index 2081c67..0966bb0 100644 (file)
@@ -823,8 +823,8 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
        }
 
        map_num = grp->npins + 1;
-       new_map = devm_kzalloc(pctldev->dev,
-                               sizeof(*new_map) * map_num, GFP_KERNEL);
+       new_map = devm_kcalloc(pctldev->dev,
+                               map_num, sizeof(*new_map), GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
 
@@ -1191,9 +1191,9 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 
        grp->npins = npins;
        grp->name = np->name;
-       grp->pins = devm_kzalloc(info->dev, npins * sizeof(u32), GFP_KERNEL);
-       grp->pin_conf = devm_kzalloc(info->dev,
-                                       npins * sizeof(*conf), GFP_KERNEL);
+       grp->pins = devm_kcalloc(info->dev, npins, sizeof(u32), GFP_KERNEL);
+       grp->pin_conf = devm_kcalloc(info->dev,
+                                       npins, sizeof(*conf), GFP_KERNEL);
 
        if (!grp->pins || !grp->pin_conf)
                return -ENOMEM;
@@ -1249,8 +1249,8 @@ static int st_pctl_parse_functions(struct device_node *np,
                dev_err(info->dev, "No groups defined\n");
                return -EINVAL;
        }
-       func->groups = devm_kzalloc(info->dev,
-                       func->ngroups * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(info->dev,
+                       func->ngroups, sizeof(char *), GFP_KERNEL);
        if (!func->groups)
                return -ENOMEM;
 
@@ -1573,14 +1573,15 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
        dev_info(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
        dev_info(&pdev->dev, "ngroups = %d\n", info->ngroups);
 
-       info->functions = devm_kzalloc(&pdev->dev,
-               info->nfunctions * sizeof(*info->functions), GFP_KERNEL);
+       info->functions = devm_kcalloc(&pdev->dev,
+               info->nfunctions, sizeof(*info->functions), GFP_KERNEL);
 
-       info->groups = devm_kzalloc(&pdev->dev,
-                       info->ngroups * sizeof(*info->groups) , GFP_KERNEL);
+       info->groups = devm_kcalloc(&pdev->dev,
+                       info->ngroups, sizeof(*info->groups),
+                       GFP_KERNEL);
 
-       info->banks = devm_kzalloc(&pdev->dev,
-                       info->nbanks * sizeof(*info->banks), GFP_KERNEL);
+       info->banks = devm_kcalloc(&pdev->dev,
+                       info->nbanks, sizeof(*info->banks), GFP_KERNEL);
 
        if (!info->functions || !info->groups || !info->banks)
                return -ENOMEM;
@@ -1608,8 +1609,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
        }
 
        pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK;
-       pdesc = devm_kzalloc(&pdev->dev,
-                       sizeof(*pdesc) * pctl_desc->npins, GFP_KERNEL);
+       pdesc = devm_kcalloc(&pdev->dev,
+                       pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL);
        if (!pdesc)
                return -ENOMEM;
 
index cd0f402..93f8bd0 100644 (file)
@@ -1727,8 +1727,8 @@ static int pinmux_xway_probe(struct platform_device *pdev)
        xway_chip.ngpio = xway_soc->pin_count;
 
        /* load our pad descriptors */
-       xway_info.pads = devm_kzalloc(&pdev->dev,
-                       sizeof(struct pinctrl_pin_desc) * xway_chip.ngpio,
+       xway_info.pads = devm_kcalloc(&pdev->dev,
+                       xway_chip.ngpio, sizeof(struct pinctrl_pin_desc),
                        GFP_KERNEL);
        if (!xway_info.pads)
                return -ENOMEM;
index 0a625a6..a263ddd 100644 (file)
@@ -491,8 +491,9 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
                        continue;
                }
 
-               weint_data = devm_kzalloc(dev, bank->nr_pins
-                                       * sizeof(*weint_data), GFP_KERNEL);
+               weint_data = devm_kcalloc(dev,
+                                         bank->nr_pins, sizeof(*weint_data),
+                                         GFP_KERNEL);
                if (!weint_data)
                        return -ENOMEM;
 
index 618945a..698c7d8 100644 (file)
@@ -674,7 +674,7 @@ static struct samsung_pin_group *samsung_pinctrl_create_groups(
        const struct pinctrl_pin_desc *pdesc;
        int i;
 
-       groups = devm_kzalloc(dev, ctrldesc->npins * sizeof(*groups),
+       groups = devm_kcalloc(dev, ctrldesc->npins, sizeof(*groups),
                                GFP_KERNEL);
        if (!groups)
                return ERR_PTR(-EINVAL);
@@ -711,7 +711,7 @@ static int samsung_pinctrl_create_function(struct device *dev,
 
        func->name = func_np->full_name;
 
-       func->groups = devm_kzalloc(dev, npins * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
        if (!func->groups)
                return -ENOMEM;
 
@@ -768,7 +768,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
                }
        }
 
-       functions = devm_kzalloc(dev, func_cnt * sizeof(*functions),
+       functions = devm_kcalloc(dev, func_cnt, sizeof(*functions),
                                        GFP_KERNEL);
        if (!functions)
                return ERR_PTR(-ENOMEM);
@@ -860,8 +860,9 @@ static int samsung_pinctrl_register(struct platform_device *pdev,
        ctrldesc->pmxops = &samsung_pinmux_ops;
        ctrldesc->confops = &samsung_pinconf_ops;
 
-       pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
-                       drvdata->nr_pins, GFP_KERNEL);
+       pindesc = devm_kcalloc(&pdev->dev,
+                              drvdata->nr_pins, sizeof(*pindesc),
+                              GFP_KERNEL);
        if (!pindesc)
                return -ENOMEM;
        ctrldesc->pins = pindesc;
@@ -875,8 +876,10 @@ static int samsung_pinctrl_register(struct platform_device *pdev,
         * allocate space for storing the dynamically generated names for all
         * the pins which belong to this pin-controller.
         */
-       pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH *
-                                       drvdata->nr_pins, GFP_KERNEL);
+       pin_names = devm_kzalloc(&pdev->dev,
+                                array3_size(sizeof(char), PIN_NAME_LENGTH,
+                                            drvdata->nr_pins),
+                                GFP_KERNEL);
        if (!pin_names)
                return -ENOMEM;
 
index eb06981..c671c3c 100644 (file)
@@ -57,7 +57,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc,
                return -EINVAL;
 
        /* Allocate memory windows and IRQs arrays. */
-       windows = devm_kzalloc(pfc->dev, num_windows * sizeof(*windows),
+       windows = devm_kcalloc(pfc->dev, num_windows, sizeof(*windows),
                               GFP_KERNEL);
        if (windows == NULL)
                return -ENOMEM;
@@ -66,7 +66,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc,
        pfc->windows = windows;
 
        if (num_irqs) {
-               irqs = devm_kzalloc(pfc->dev, num_irqs * sizeof(*irqs),
+               irqs = devm_kcalloc(pfc->dev, num_irqs, sizeof(*irqs),
                                    GFP_KERNEL);
                if (irqs == NULL)
                        return -ENOMEM;
@@ -444,7 +444,7 @@ static int sh_pfc_init_ranges(struct sh_pfc *pfc)
        }
 
        pfc->nr_ranges = nr_ranges;
-       pfc->ranges = devm_kzalloc(pfc->dev, sizeof(*pfc->ranges) * nr_ranges,
+       pfc->ranges = devm_kcalloc(pfc->dev, nr_ranges, sizeof(*pfc->ranges),
                                   GFP_KERNEL);
        if (pfc->ranges == NULL)
                return -ENOMEM;
index 946d9be..6ffdc6b 100644 (file)
@@ -107,7 +107,7 @@ static int gpio_setup_data_regs(struct sh_pfc_chip *chip)
        for (i = 0; pfc->info->data_regs[i].reg_width; ++i)
                ;
 
-       chip->regs = devm_kzalloc(pfc->dev, i * sizeof(*chip->regs),
+       chip->regs = devm_kcalloc(pfc->dev, i, sizeof(*chip->regs),
                                  GFP_KERNEL);
        if (chip->regs == NULL)
                return -ENOMEM;
@@ -224,8 +224,9 @@ static int gpio_pin_setup(struct sh_pfc_chip *chip)
        struct gpio_chip *gc = &chip->gpio_chip;
        int ret;
 
-       chip->pins = devm_kzalloc(pfc->dev, pfc->info->nr_pins *
-                                 sizeof(*chip->pins), GFP_KERNEL);
+       chip->pins = devm_kcalloc(pfc->dev,
+                                 pfc->info->nr_pins, sizeof(*chip->pins),
+                                 GFP_KERNEL);
        if (chip->pins == NULL)
                return -ENOMEM;
 
index 70db216..654dc20 100644 (file)
@@ -770,14 +770,14 @@ static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
        unsigned int i;
 
        /* Allocate and initialize the pins and configs arrays. */
-       pmx->pins = devm_kzalloc(pfc->dev,
-                                sizeof(*pmx->pins) * pfc->info->nr_pins,
+       pmx->pins = devm_kcalloc(pfc->dev,
+                                pfc->info->nr_pins, sizeof(*pmx->pins),
                                 GFP_KERNEL);
        if (unlikely(!pmx->pins))
                return -ENOMEM;
 
-       pmx->configs = devm_kzalloc(pfc->dev,
-                                   sizeof(*pmx->configs) * pfc->info->nr_pins,
+       pmx->configs = devm_kcalloc(pfc->dev,
+                                   pfc->info->nr_pins, sizeof(*pmx->configs),
                                    GFP_KERNEL);
        if (unlikely(!pmx->configs))
                return -ENOMEM;
index d2123e3..9d90647 100644 (file)
@@ -538,9 +538,9 @@ static int plgpio_probe(struct platform_device *pdev)
                dev_warn(&pdev->dev, "clk_get() failed, work without it\n");
 
 #ifdef CONFIG_PM_SLEEP
-       plgpio->csave_regs = devm_kzalloc(&pdev->dev,
-                       sizeof(*plgpio->csave_regs) *
+       plgpio->csave_regs = devm_kcalloc(&pdev->dev,
                        DIV_ROUND_UP(plgpio->chip.ngpio, MAX_GPIO_PER_REG),
+                       sizeof(*plgpio->csave_regs),
                        GFP_KERNEL);
        if (!plgpio->csave_regs)
                return -ENOMEM;
index ba1c2ca..78c2f54 100644 (file)
@@ -879,8 +879,9 @@ static int sprd_pinctrl_parse_groups(struct device_node *np,
 
        grp->name = np->name;
        grp->npins = ret;
-       grp->pins = devm_kzalloc(sprd_pctl->dev, grp->npins *
-                                sizeof(unsigned int), GFP_KERNEL);
+       grp->pins = devm_kcalloc(sprd_pctl->dev,
+                                grp->npins, sizeof(unsigned int),
+                                GFP_KERNEL);
        if (!grp->pins)
                return -ENOMEM;
 
@@ -931,14 +932,15 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl)
        if (!info->ngroups)
                return 0;
 
-       info->groups = devm_kzalloc(sprd_pctl->dev, info->ngroups *
+       info->groups = devm_kcalloc(sprd_pctl->dev,
+                                   info->ngroups,
                                    sizeof(struct sprd_pin_group),
                                    GFP_KERNEL);
        if (!info->groups)
                return -ENOMEM;
 
-       info->grp_names = devm_kzalloc(sprd_pctl->dev,
-                                      info->ngroups * sizeof(char *),
+       info->grp_names = devm_kcalloc(sprd_pctl->dev,
+                                      info->ngroups, sizeof(char *),
                                       GFP_KERNEL);
        if (!info->grp_names)
                return -ENOMEM;
@@ -980,8 +982,8 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl,
        int i;
 
        info->npins = pins_cnt;
-       info->pins = devm_kzalloc(sprd_pctl->dev,
-                                 info->npins * sizeof(struct sprd_pin),
+       info->pins = devm_kcalloc(sprd_pctl->dev,
+                                 info->npins, sizeof(struct sprd_pin),
                                  GFP_KERNEL);
        if (!info->pins)
                return -ENOMEM;
@@ -1057,7 +1059,8 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
                return ret;
        }
 
-       pin_desc = devm_kzalloc(&pdev->dev, pinctrl_info->npins *
+       pin_desc = devm_kcalloc(&pdev->dev,
+                               pinctrl_info->npins,
                                sizeof(struct pinctrl_pin_desc),
                                GFP_KERNEL);
        if (!pin_desc)
index eaace8e..4d9bf9b 100644 (file)
@@ -1055,8 +1055,8 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
         * this means that the number of pins is the maximum group
         * number we will ever see.
         */
-       pctl->groups = devm_kzalloc(&pdev->dev,
-                                   pctl->desc->npins * sizeof(*pctl->groups),
+       pctl->groups = devm_kcalloc(&pdev->dev,
+                                   pctl->desc->npins, sizeof(*pctl->groups),
                                    GFP_KERNEL);
        if (!pctl->groups)
                return -ENOMEM;
@@ -1079,8 +1079,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
         * We suppose that we won't have any more functions than pins,
         * we'll reallocate that later anyway
         */
-       pctl->functions = devm_kzalloc(&pdev->dev,
-                                      pctl->ngroups * sizeof(*pctl->functions),
+       pctl->functions = devm_kcalloc(&pdev->dev,
+                                      pctl->ngroups,
+                                      sizeof(*pctl->functions),
                                       GFP_KERNEL);
        if (!pctl->functions)
                return -ENOMEM;
@@ -1137,8 +1138,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
 
                        if (!func_item->groups) {
                                func_item->groups =
-                                       devm_kzalloc(&pdev->dev,
-                                                    func_item->ngroups * sizeof(*func_item->groups),
+                                       devm_kcalloc(&pdev->dev,
+                                                    func_item->ngroups,
+                                                    sizeof(*func_item->groups),
                                                     GFP_KERNEL);
                                if (!func_item->groups)
                                        return -ENOMEM;
@@ -1281,8 +1283,8 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,
                return ret;
        }
 
-       pins = devm_kzalloc(&pdev->dev,
-                           pctl->desc->npins * sizeof(*pins),
+       pins = devm_kcalloc(&pdev->dev,
+                           pctl->desc->npins, sizeof(*pins),
                            GFP_KERNEL);
        if (!pins)
                return -ENOMEM;
index 49c7c14..f974eee 100644 (file)
@@ -665,8 +665,8 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
         * Each mux group will appear in 4 functions' list of groups.
         * This over-allocates slightly, since not all groups are mux groups.
         */
-       pmx->group_pins = devm_kzalloc(&pdev->dev,
-               soc_data->ngroups * 4 * sizeof(*pmx->group_pins),
+       pmx->group_pins = devm_kcalloc(&pdev->dev,
+               soc_data->ngroups * 4, sizeof(*pmx->group_pins),
                GFP_KERNEL);
        if (!pmx->group_pins)
                return -ENOMEM;
@@ -708,7 +708,7 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
        }
        pmx->nbanks = i;
 
-       pmx->regs = devm_kzalloc(&pdev->dev, pmx->nbanks * sizeof(*pmx->regs),
+       pmx->regs = devm_kcalloc(&pdev->dev, pmx->nbanks, sizeof(*pmx->regs),
                                 GFP_KERNEL);
        if (!pmx->regs)
                return -ENOMEM;
index a8a6510..8782c34 100644 (file)
@@ -510,11 +510,11 @@ static int ti_iodelay_dt_node_to_map(struct pinctrl_dev *pctldev,
                goto free_map;
        }
 
-       pins = devm_kzalloc(iod->dev, sizeof(*pins) * rows, GFP_KERNEL);
+       pins = devm_kcalloc(iod->dev, rows, sizeof(*pins), GFP_KERNEL);
        if (!pins)
                goto free_group;
 
-       cfg = devm_kzalloc(iod->dev, sizeof(*cfg) * rows, GFP_KERNEL);
+       cfg = devm_kcalloc(iod->dev, rows, sizeof(*cfg), GFP_KERNEL);
        if (!cfg) {
                error = -ENOMEM;
                goto free_pins;
@@ -749,7 +749,7 @@ static int ti_iodelay_alloc_pins(struct device *dev,
        nr_pins = ti_iodelay_offset_to_pin(iod, r->regmap_config->max_register);
        dev_dbg(dev, "Allocating %i pins\n", nr_pins);
 
-       iod->pa = devm_kzalloc(dev, sizeof(*iod->pa) * nr_pins, GFP_KERNEL);
+       iod->pa = devm_kcalloc(dev, nr_pins, sizeof(*iod->pa), GFP_KERNEL);
        if (!iod->pa)
                return -ENOMEM;
 
index ded366b..caa44dd 100644 (file)
@@ -277,7 +277,7 @@ static int zx_pinctrl_build_state(struct platform_device *pdev)
 
        /* Every single pin composes a group */
        ngroups = info->npins;
-       groups = devm_kzalloc(&pdev->dev, ngroups * sizeof(*groups),
+       groups = devm_kcalloc(&pdev->dev, ngroups, sizeof(*groups),
                              GFP_KERNEL);
        if (!groups)
                return -ENOMEM;
@@ -362,8 +362,8 @@ static int zx_pinctrl_build_state(struct platform_device *pdev)
 
                        func = functions + j;
                        if (!func->group_names) {
-                               func->group_names = devm_kzalloc(&pdev->dev,
-                                               func->num_group_names *
+                               func->group_names = devm_kcalloc(&pdev->dev,
+                                               func->num_group_names,
                                                sizeof(*func->group_names),
                                                GFP_KERNEL);
                                if (!func->group_names) {
index ea9e7f4..36a41ff 100644 (file)
@@ -217,7 +217,8 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
                }
        }
 
-       priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs *
+       priv->group.attrs = devm_kcalloc(&priv->pdev->dev,
+                                        num_attrs,
                                         sizeof(struct attribute *),
                                         GFP_KERNEL);
        if (!priv->group.attrs)
index 2a50b46..faa1a67 100644 (file)
@@ -1380,7 +1380,7 @@ static int charger_manager_register_sysfs(struct charger_manager *cm)
 
                snprintf(buf, 10, "charger.%d", i);
                str = devm_kzalloc(cm->dev,
-                               sizeof(char) * (strlen(buf) + 1), GFP_KERNEL);
+                               strlen(buf) + 1, GFP_KERNEL);
                if (!str)
                        return -ENOMEM;
 
@@ -1522,8 +1522,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
        of_property_read_u32(np, "cm-num-chargers", &num_chgs);
        if (num_chgs) {
                /* Allocate empty bin at the tail of array */
-               desc->psy_charger_stat = devm_kzalloc(dev, sizeof(char *)
-                                               * (num_chgs + 1), GFP_KERNEL);
+               desc->psy_charger_stat = devm_kcalloc(dev,
+                                                     num_chgs + 1,
+                                                     sizeof(char *),
+                                                     GFP_KERNEL);
                if (desc->psy_charger_stat) {
                        int i;
                        for (i = 0; i < num_chgs; i++)
@@ -1555,8 +1557,9 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
                struct charger_regulator *chg_regs;
                struct device_node *child;
 
-               chg_regs = devm_kzalloc(dev, sizeof(*chg_regs)
-                                       * desc->num_charger_regulators,
+               chg_regs = devm_kcalloc(dev,
+                                       desc->num_charger_regulators,
+                                       sizeof(*chg_regs),
                                        GFP_KERNEL);
                if (!chg_regs)
                        return ERR_PTR(-ENOMEM);
@@ -1573,9 +1576,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
                        /* charger cables */
                        chg_regs->num_cables = of_get_child_count(child);
                        if (chg_regs->num_cables) {
-                               cables = devm_kzalloc(dev, sizeof(*cables)
-                                               * chg_regs->num_cables,
-                                               GFP_KERNEL);
+                               cables = devm_kcalloc(dev,
+                                                     chg_regs->num_cables,
+                                                     sizeof(*cables),
+                                                     GFP_KERNEL);
                                if (!cables) {
                                        of_node_put(child);
                                        return ERR_PTR(-ENOMEM);
@@ -1725,10 +1729,11 @@ static int charger_manager_probe(struct platform_device *pdev)
        cm->charger_psy_desc.name = cm->psy_name_buf;
 
        /* Allocate for psy properties because they may vary */
-       cm->charger_psy_desc.properties = devm_kzalloc(&pdev->dev,
-                               sizeof(enum power_supply_property)
-                               * (ARRAY_SIZE(default_charger_props) +
-                               NUM_CHARGER_PSY_OPTIONAL), GFP_KERNEL);
+       cm->charger_psy_desc.properties =
+               devm_kcalloc(&pdev->dev,
+                            ARRAY_SIZE(default_charger_props) +
+                               NUM_CHARGER_PSY_OPTIONAL,
+                            sizeof(enum power_supply_property), GFP_KERNEL);
        if (!cm->charger_psy_desc.properties)
                return -ENOMEM;
 
index f57ab0a..d21f478 100644 (file)
@@ -263,8 +263,8 @@ static int power_supply_check_supplies(struct power_supply *psy)
        if (!psy->supplied_from)
                return -ENOMEM;
 
-       *psy->supplied_from = devm_kzalloc(&psy->dev,
-                                          sizeof(char *) * (cnt - 1),
+       *psy->supplied_from = devm_kcalloc(&psy->dev,
+                                          cnt - 1, sizeof(char *),
                                           GFP_KERNEL);
        if (!*psy->supplied_from)
                return -ENOMEM;
index 52584e9..15b40a8 100644 (file)
@@ -225,7 +225,7 @@ static int lp3943_pwm_parse_dt(struct device *dev,
                if (num_outputs == 0)
                        continue;
 
-               output = devm_kzalloc(dev, sizeof(*output) * num_outputs,
+               output = devm_kcalloc(dev, num_outputs, sizeof(*output),
                                      GFP_KERNEL);
                if (!output)
                        return -ENOMEM;
index 7652477..21e2048 100644 (file)
@@ -424,9 +424,10 @@ static int act8865_pdata_from_dt(struct device *dev,
        if (matched <= 0)
                return matched;
 
-       pdata->regulators = devm_kzalloc(dev,
-                                        sizeof(struct act8865_regulator_data) *
-                                        num_matches, GFP_KERNEL);
+       pdata->regulators = devm_kcalloc(dev,
+                                        num_matches,
+                                        sizeof(struct act8865_regulator_data),
+                                        GFP_KERNEL);
        if (!pdata->regulators)
                return -ENOMEM;
 
index 874d415..565a713 100644 (file)
@@ -239,8 +239,10 @@ static int as3711_regulator_probe(struct platform_device *pdev)
                }
        }
 
-       regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM *
-                       sizeof(struct as3711_regulator), GFP_KERNEL);
+       regs = devm_kcalloc(&pdev->dev,
+                           AS3711_REGULATOR_NUM,
+                           sizeof(struct as3711_regulator),
+                           GFP_KERNEL);
        if (!regs)
                return -ENOMEM;
 
index 9dd7154..92d6d7b 100644 (file)
@@ -383,8 +383,10 @@ static int bcm590xx_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, pmu);
 
-       pmu->desc = devm_kzalloc(&pdev->dev, BCM590XX_NUM_REGS *
-                       sizeof(struct regulator_desc), GFP_KERNEL);
+       pmu->desc = devm_kcalloc(&pdev->dev,
+                                BCM590XX_NUM_REGS,
+                                sizeof(struct regulator_desc),
+                                GFP_KERNEL);
        if (!pmu->desc)
                return -ENOMEM;
 
index 6a8f9cd..2df26f3 100644 (file)
@@ -681,8 +681,8 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt(
        if (!pdata)
                return ERR_PTR(-ENOMEM);
 
-       pdata->regulator_data = devm_kzalloc(&pdev->dev,
-                                       num * sizeof(*pdata->regulator_data),
+       pdata->regulator_data = devm_kcalloc(&pdev->dev,
+                                       num, sizeof(*pdata->regulator_data),
                                        GFP_KERNEL);
        if (!pdata->regulator_data)
                return ERR_PTR(-ENOMEM);
index a86b899..b2f5ec4 100644 (file)
@@ -172,8 +172,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
 
        if (ret > 0) {
                config->nr_gpios = ret;
-               config->gpios = devm_kzalloc(dev,
-                                       sizeof(struct gpio) * config->nr_gpios,
+               config->gpios = devm_kcalloc(dev,
+                                       config->nr_gpios, sizeof(struct gpio),
                                        GFP_KERNEL);
                if (!config->gpios)
                        return ERR_PTR(-ENOMEM);
@@ -214,9 +214,9 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
                return ERR_PTR(-EINVAL);
        }
 
-       config->states = devm_kzalloc(dev,
-                               sizeof(struct gpio_regulator_state)
-                               * (proplen / 2),
+       config->states = devm_kcalloc(dev,
+                               proplen / 2,
+                               sizeof(struct gpio_regulator_state),
                                GFP_KERNEL);
        if (!config->states)
                return ERR_PTR(-ENOMEM);
index 66bbaa9..cc52779 100644 (file)
@@ -194,8 +194,10 @@ static int of_get_max1586_platform_data(struct device *dev,
        if (matched <= 0)
                return matched;
 
-       pdata->subdevs = devm_kzalloc(dev, sizeof(struct max1586_subdev_data) *
-                                               matched, GFP_KERNEL);
+       pdata->subdevs = devm_kcalloc(dev,
+                                     matched,
+                                     sizeof(struct max1586_subdev_data),
+                                     GFP_KERNEL);
        if (!pdata->subdevs)
                return -ENOMEM;
 
index a618342..4cf6897 100644 (file)
@@ -351,8 +351,10 @@ static int max8660_pdata_from_dt(struct device *dev,
        if (matched <= 0)
                return matched;
 
-       pdata->subdevs = devm_kzalloc(dev, sizeof(struct max8660_subdev_data) *
-                                               matched, GFP_KERNEL);
+       pdata->subdevs = devm_kcalloc(dev,
+                                     matched,
+                                     sizeof(struct max8660_subdev_data),
+                                     GFP_KERNEL);
        if (!pdata->subdevs)
                return -ENOMEM;
 
index 559b9ac..a8ea30e 100644 (file)
@@ -929,8 +929,9 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
        /* count the number of regulators to be supported in pmic */
        pdata->num_regulators = of_get_child_count(regulators_np);
 
-       rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
-                               pdata->num_regulators, GFP_KERNEL);
+       rdata = devm_kcalloc(&pdev->dev,
+                            pdata->num_regulators, sizeof(*rdata),
+                            GFP_KERNEL);
        if (!rdata) {
                of_node_put(regulators_np);
                return -ENOMEM;
index 6a2b61c..6b9f262 100644 (file)
@@ -670,8 +670,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev,
        /* count the number of regulators to be supported in pmic */
        pdata->num_regulators = of_get_child_count(regulators_np);
 
-       rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) *
-                               pdata->num_regulators, GFP_KERNEL);
+       rdata = devm_kcalloc(iodev->dev,
+                            pdata->num_regulators, sizeof(*rdata),
+                            GFP_KERNEL);
        if (!rdata) {
                of_node_put(regulators_np);
                return -ENOMEM;
index 41271ae..da4fb98 100644 (file)
@@ -171,7 +171,7 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
        if (!parent)
                return NULL;
 
-       data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators,
+       data = devm_kcalloc(&pdev->dev, priv->num_regulators, sizeof(*data),
                            GFP_KERNEL);
        if (!data) {
                of_node_put(parent);
index 8f782d2..92b41a6 100644 (file)
@@ -173,8 +173,9 @@ static int pbias_regulator_probe(struct platform_device *pdev)
        if (count < 0)
                return count;
 
-       drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data)
-                              * count, GFP_KERNEL);
+       drvdata = devm_kcalloc(&pdev->dev,
+                              count, sizeof(struct pbias_regulator_data),
+                              GFP_KERNEL);
        if (!drvdata)
                return -ENOMEM;
 
index d0f1340..2ec51af 100644 (file)
@@ -132,8 +132,10 @@ static int rc5t583_regulator_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       regs = devm_kzalloc(&pdev->dev, RC5T583_REGULATOR_MAX *
-                       sizeof(struct rc5t583_regulator), GFP_KERNEL);
+       regs = devm_kcalloc(&pdev->dev,
+                           RC5T583_REGULATOR_MAX,
+                           sizeof(struct rc5t583_regulator),
+                           GFP_KERNEL);
        if (!regs)
                return -ENOMEM;
 
index b8443a3..0cbc980 100644 (file)
@@ -553,13 +553,15 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
        /* count the number of regulators to be supported in pmic */
        pdata->num_regulators = of_get_child_count(regulators_np);
 
-       rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
-                               pdata->num_regulators, GFP_KERNEL);
+       rdata = devm_kcalloc(&pdev->dev,
+                            pdata->num_regulators, sizeof(*rdata),
+                            GFP_KERNEL);
        if (!rdata)
                return -ENOMEM;
 
-       rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) *
-                               pdata->num_regulators, GFP_KERNEL);
+       rmode = devm_kcalloc(&pdev->dev,
+                            pdata->num_regulators, sizeof(*rmode),
+                            GFP_KERNEL);
        if (!rmode)
                return -ENOMEM;
 
index d2f9942..cced1ff 100644 (file)
@@ -532,13 +532,13 @@ static int ti_abb_init_table(struct device *dev, struct ti_abb *abb,
        }
        num_entries /= num_values;
 
-       info = devm_kzalloc(dev, sizeof(*info) * num_entries, GFP_KERNEL);
+       info = devm_kcalloc(dev, num_entries, sizeof(*info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
        abb->info = info;
 
-       volt_table = devm_kzalloc(dev, sizeof(unsigned int) * num_entries,
+       volt_table = devm_kcalloc(dev, num_entries, sizeof(unsigned int),
                                  GFP_KERNEL);
        if (!volt_table)
                return -ENOMEM;
index 2d398fa..edaef9e 100644 (file)
@@ -331,8 +331,9 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data(
        if (!tps65090_pdata)
                return ERR_PTR(-ENOMEM);
 
-       reg_pdata = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX *
-                               sizeof(*reg_pdata), GFP_KERNEL);
+       reg_pdata = devm_kcalloc(&pdev->dev,
+                                TPS65090_REGULATOR_MAX, sizeof(*reg_pdata),
+                                GFP_KERNEL);
        if (!reg_pdata)
                return ERR_PTR(-ENOMEM);
 
@@ -429,8 +430,9 @@ static int tps65090_regulator_probe(struct platform_device *pdev)
                return tps65090_pdata ? PTR_ERR(tps65090_pdata) : -EINVAL;
        }
 
-       pmic = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * sizeof(*pmic),
-                       GFP_KERNEL);
+       pmic = devm_kcalloc(&pdev->dev,
+                           TPS65090_REGULATOR_MAX, sizeof(*pmic),
+                           GFP_KERNEL);
        if (!pmic)
                return -ENOMEM;
 
index 7b12e88..fc12bad 100644 (file)
@@ -229,8 +229,9 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
        unsigned int val;
 
        /* Allocate memory for strobes */
-       tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) *
-                                   TPS65217_NUM_REGULATOR, GFP_KERNEL);
+       tps->strobes = devm_kcalloc(&pdev->dev,
+                                   TPS65217_NUM_REGULATOR, sizeof(u8),
+                                   GFP_KERNEL);
 
        platform_set_drvdata(pdev, tps);
 
index 1827185..6209bee 100644 (file)
@@ -324,8 +324,9 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
        config.regmap = tps->regmap;
 
        /* Allocate memory for strobes */
-       tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) *
-                                   TPS65218_NUM_REGULATOR, GFP_KERNEL);
+       tps->strobes = devm_kcalloc(&pdev->dev,
+                                   TPS65218_NUM_REGULATOR, sizeof(u8),
+                                   GFP_KERNEL);
        if (!tps->strobes)
                return -ENOMEM;
 
index 81672a5..02ccdaa 100644 (file)
@@ -1131,18 +1131,24 @@ static int tps65910_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       pmic->desc = devm_kzalloc(&pdev->dev, pmic->num_regulators *
-                       sizeof(struct regulator_desc), GFP_KERNEL);
+       pmic->desc = devm_kcalloc(&pdev->dev,
+                                 pmic->num_regulators,
+                                 sizeof(struct regulator_desc),
+                                 GFP_KERNEL);
        if (!pmic->desc)
                return -ENOMEM;
 
-       pmic->info = devm_kzalloc(&pdev->dev, pmic->num_regulators *
-                       sizeof(struct tps_info *), GFP_KERNEL);
+       pmic->info = devm_kcalloc(&pdev->dev,
+                                 pmic->num_regulators,
+                                 sizeof(struct tps_info *),
+                                 GFP_KERNEL);
        if (!pmic->info)
                return -ENOMEM;
 
-       pmic->rdev = devm_kzalloc(&pdev->dev, pmic->num_regulators *
-                       sizeof(struct regulator_dev *), GFP_KERNEL);
+       pmic->rdev = devm_kcalloc(&pdev->dev,
+                                 pmic->num_regulators,
+                                 sizeof(struct regulator_dev *),
+                                 GFP_KERNEL);
        if (!pmic->rdev)
                return -ENOMEM;