coresight: Use devm_bitmap_zalloc when applicable
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 3 Nov 2021 18:39:18 +0000 (19:39 +0100)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 16 Nov 2021 17:13:21 +0000 (10:13 -0700)
'drvdata->chs.guaranteed' is a bitmap. So use 'devm_bitmap_kzalloc()' to
simplify code, improve the semantic and avoid some open-coded arithmetic
in allocator arguments.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/a4b8454f560b70cedf0e4d06275787f08d576ee5.1635964610.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/hwtracing/coresight/coresight-stm.c

index 58062a5a8238d20d1afc496ea522490055a3ece4..bb14a3a8a921013e5aee9b85a94f19b05127304e 100644 (file)
@@ -856,13 +856,11 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
 {
        int ret;
        void __iomem *base;
-       unsigned long *guaranteed;
        struct device *dev = &adev->dev;
        struct coresight_platform_data *pdata = NULL;
        struct stm_drvdata *drvdata;
        struct resource *res = &adev->res;
        struct resource ch_res;
-       size_t bitmap_size;
        struct coresight_desc desc = { 0 };
 
        desc.name = coresight_alloc_device_name(&stm_devs, dev);
@@ -904,12 +902,10 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
        else
                drvdata->numsp = stm_num_stimulus_port(drvdata);
 
-       bitmap_size = BITS_TO_LONGS(drvdata->numsp) * sizeof(long);
-
-       guaranteed = devm_kzalloc(dev, bitmap_size, GFP_KERNEL);
-       if (!guaranteed)
+       drvdata->chs.guaranteed = devm_bitmap_zalloc(dev, drvdata->numsp,
+                                                    GFP_KERNEL);
+       if (!drvdata->chs.guaranteed)
                return -ENOMEM;
-       drvdata->chs.guaranteed = guaranteed;
 
        spin_lock_init(&drvdata->spinlock);