All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] coresight: Use devm_bitmap_zalloc when applicable
@ 2021-11-03 18:39 ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2021-11-03 18:39 UTC (permalink / raw)
  To: mathieu.poirier, suzuki.poulose, mike.leach, leo.yan,
	alexander.shishkin, mcoquelin.stm32, alexandre.torgue
  Cc: coresight, linux-arm-kernel, linux-stm32, linux-kernel,
	kernel-janitors, Christophe JAILLET

'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>
---
v1 --> v2: remove the 'guaranteed' variable to be even less verbose
---
 drivers/hwtracing/coresight/coresight-stm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 58062a5a8238..bb14a3a8a921 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -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);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2] coresight: Use devm_bitmap_zalloc when applicable
@ 2021-11-03 18:39 ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2021-11-03 18:39 UTC (permalink / raw)
  To: mathieu.poirier, suzuki.poulose, mike.leach, leo.yan,
	alexander.shishkin, mcoquelin.stm32, alexandre.torgue
  Cc: coresight, linux-arm-kernel, linux-stm32, linux-kernel,
	kernel-janitors, Christophe JAILLET

'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>
---
v1 --> v2: remove the 'guaranteed' variable to be even less verbose
---
 drivers/hwtracing/coresight/coresight-stm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 58062a5a8238..bb14a3a8a921 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -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);
 
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] coresight: Use devm_bitmap_zalloc when applicable
  2021-11-03 18:39 ` Christophe JAILLET
@ 2021-11-11 18:25   ` Mathieu Poirier
  -1 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2021-11-11 18:25 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Suzuki.Poulose, mike.leach, leo.yan, alexander.shishkin,
	mcoquelin.stm32, alexandre.torgue, coresight, linux-arm-kernel,
	linux-stm32, linux-kernel, kernel-janitors

Hi Christophe,

On Wed, 3 Nov 2021 at 12:39, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> '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>
> ---
> v1 --> v2: remove the 'guaranteed' variable to be even less verbose
> ---
>  drivers/hwtracing/coresight/coresight-stm.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
> index 58062a5a8238..bb14a3a8a921 100644
> --- a/drivers/hwtracing/coresight/coresight-stm.c
> +++ b/drivers/hwtracing/coresight/coresight-stm.c
> @@ -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;

I will pick up this patch when -rc1 gets released.

Thanks,
Mathieu

>
>         spin_lock_init(&drvdata->spinlock);
>
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] coresight: Use devm_bitmap_zalloc when applicable
@ 2021-11-11 18:25   ` Mathieu Poirier
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2021-11-11 18:25 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Suzuki.Poulose, mike.leach, leo.yan, alexander.shishkin,
	mcoquelin.stm32, alexandre.torgue, coresight, linux-arm-kernel,
	linux-stm32, linux-kernel, kernel-janitors

Hi Christophe,

On Wed, 3 Nov 2021 at 12:39, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> '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>
> ---
> v1 --> v2: remove the 'guaranteed' variable to be even less verbose
> ---
>  drivers/hwtracing/coresight/coresight-stm.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
> index 58062a5a8238..bb14a3a8a921 100644
> --- a/drivers/hwtracing/coresight/coresight-stm.c
> +++ b/drivers/hwtracing/coresight/coresight-stm.c
> @@ -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;

I will pick up this patch when -rc1 gets released.

Thanks,
Mathieu

>
>         spin_lock_init(&drvdata->spinlock);
>
> --
> 2.30.2
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-11 18:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 18:39 [PATCH v2] coresight: Use devm_bitmap_zalloc when applicable Christophe JAILLET
2021-11-03 18:39 ` Christophe JAILLET
2021-11-11 18:25 ` Mathieu Poirier
2021-11-11 18:25   ` Mathieu Poirier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.