All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH 3/4] pwm: Mark free pwm IDs as used in alloc_pwms()
Date: Wed, 16 Nov 2022 16:04:12 +0200	[thread overview]
Message-ID: <Y3Tt3IvCchpZotk9@smile.fi.intel.com> (raw)
In-Reply-To: <20221115211515.3750209-4-u.kleine-koenig@pengutronix.de>

On Tue, Nov 15, 2022 at 10:15:14PM +0100, Uwe Kleine-König wrote:
> alloc_pwms() only identified a free range of IDs and this range was marked
> as used only later by pwmchip_add(). Instead let alloc_pwms() already do
> the marking (which makes the function actually allocating the range and so
> justifies the function name). This way access to the allocated_pwms
> bitfield is limited to two functions only.

Let's assume that developers will be cautious about properly freeing allocated
resources.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/pwm/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 2338119a09d8..b43b24bd3c9f 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -51,6 +51,8 @@ static int alloc_pwms(unsigned int count)
>  	if (start + count > MAX_PWMS)
>  		return -ENOSPC;
>  
> +	bitmap_set(allocated_pwms, start, count);
> +
>  	return start;
>  }
>  
> @@ -297,8 +299,6 @@ int pwmchip_add(struct pwm_chip *chip)
>  		radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
>  	}
>  
> -	bitmap_set(allocated_pwms, chip->base, chip->npwm);
> -
>  	INIT_LIST_HEAD(&chip->list);
>  	list_add(&chip->list, &pwm_chips);
>  
> -- 
> 2.38.1
> 

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2022-11-16 14:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 21:15 [PATCH 0/4] pwm: Some refactoring of pwmchip_add() Uwe Kleine-König
2022-11-15 21:15 ` [PATCH 1/4] pwm: Document variables protected by pwm_lock Uwe Kleine-König
2022-11-16  8:22   ` Andy Shevchenko
2022-11-15 21:15 ` [PATCH 2/4] pwm: Reduce time the pwm_lock mutex is held in pwmchip_add() Uwe Kleine-König
2022-11-16  8:11   ` Andy Shevchenko
2022-11-17 14:00     ` Uwe Kleine-König
2022-11-17 15:33       ` Andy Shevchenko
2022-11-15 21:15 ` [PATCH 3/4] pwm: Mark free pwm IDs as used in alloc_pwms() Uwe Kleine-König
2022-11-16  8:17   ` Andy Shevchenko
2022-11-16 13:59     ` Uwe Kleine-König
2022-11-16 14:04   ` Andy Shevchenko [this message]
2022-11-15 21:15 ` [PATCH 4/4] pwm: Don't initialize list head before calling list_add() Uwe Kleine-König
2022-11-16  8:21   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3Tt3IvCchpZotk9@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.