netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: microchip: initialize mutex before use
@ 2018-10-30 23:45 Tristram.Ha
  2018-10-31  1:21 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tristram.Ha @ 2018-10-30 23:45 UTC (permalink / raw)
  To: David S. Miller
  Cc: Tristram Ha, Andrew Lunn, Florian Fainelli, Pavel Machek,
	UNGLinuxDriver, netdev

From: Tristram Ha <Tristram.Ha@microchip.com>

Initialize mutex before use.  Avoid kernel complaint when
CONFIG_DEBUG_LOCK_ALLOC is enabled.

Fixes: b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477")
Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
---
 drivers/net/dsa/microchip/ksz_common.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 54e0ca6..f6f0662 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -1117,11 +1117,6 @@ static int ksz_switch_init(struct ksz_device *dev)
 {
 	int i;
 
-	mutex_init(&dev->reg_mutex);
-	mutex_init(&dev->stats_mutex);
-	mutex_init(&dev->alu_mutex);
-	mutex_init(&dev->vlan_mutex);
-
 	dev->ds->ops = &ksz_switch_ops;
 
 	for (i = 0; i < ARRAY_SIZE(ksz_switch_chips); i++) {
@@ -1206,6 +1201,12 @@ int ksz_switch_register(struct ksz_device *dev)
 	if (dev->pdata)
 		dev->chip_id = dev->pdata->chip_id;
 
+	/* mutex is used in next function call. */
+	mutex_init(&dev->reg_mutex);
+	mutex_init(&dev->stats_mutex);
+	mutex_init(&dev->alu_mutex);
+	mutex_init(&dev->vlan_mutex);
+
 	if (ksz_switch_detect(dev))
 		return -EINVAL;
 
-- 
1.9.1

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

* Re: [PATCH net] net: dsa: microchip: initialize mutex before use
  2018-10-30 23:45 [PATCH net] net: dsa: microchip: initialize mutex before use Tristram.Ha
@ 2018-10-31  1:21 ` Andrew Lunn
  2018-10-31  7:42 ` Pavel Machek
  2018-10-31 19:52 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2018-10-31  1:21 UTC (permalink / raw)
  To: Tristram.Ha
  Cc: David S. Miller, Florian Fainelli, Pavel Machek, UNGLinuxDriver,
	netdev

On Tue, Oct 30, 2018 at 04:45:49PM -0700, Tristram.Ha@microchip.com wrote:
> From: Tristram Ha <Tristram.Ha@microchip.com>
> 
> Initialize mutex before use.  Avoid kernel complaint when
> CONFIG_DEBUG_LOCK_ALLOC is enabled.
> 
> Fixes: b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477")
> Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
> ---
>  drivers/net/dsa/microchip/ksz_common.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 54e0ca6..f6f0662 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -1117,11 +1117,6 @@ static int ksz_switch_init(struct ksz_device *dev)
>  {
>  	int i;
>  
> -	mutex_init(&dev->reg_mutex);
> -	mutex_init(&dev->stats_mutex);
> -	mutex_init(&dev->alu_mutex);
> -	mutex_init(&dev->vlan_mutex);
> -
>  	dev->ds->ops = &ksz_switch_ops;
>  
>  	for (i = 0; i < ARRAY_SIZE(ksz_switch_chips); i++) {
> @@ -1206,6 +1201,12 @@ int ksz_switch_register(struct ksz_device *dev)
>  	if (dev->pdata)
>  		dev->chip_id = dev->pdata->chip_id;
>  
> +	/* mutex is used in next function call. */
> +	mutex_init(&dev->reg_mutex);
> +	mutex_init(&dev->stats_mutex);
> +	mutex_init(&dev->alu_mutex);
> +	mutex_init(&dev->vlan_mutex);

Hi Tristram

The comment is no longer relevant now that all mutexes are
initialised.

	Andrew

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

* Re: [PATCH net] net: dsa: microchip: initialize mutex before use
  2018-10-30 23:45 [PATCH net] net: dsa: microchip: initialize mutex before use Tristram.Ha
  2018-10-31  1:21 ` Andrew Lunn
@ 2018-10-31  7:42 ` Pavel Machek
  2018-10-31 19:52 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2018-10-31  7:42 UTC (permalink / raw)
  To: Tristram.Ha
  Cc: David S. Miller, Andrew Lunn, Florian Fainelli, UNGLinuxDriver,
	netdev

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

On Tue 2018-10-30 16:45:49, Tristram.Ha@microchip.com wrote:
> From: Tristram Ha <Tristram.Ha@microchip.com>
> 
> Initialize mutex before use.  Avoid kernel complaint when
> CONFIG_DEBUG_LOCK_ALLOC is enabled.
> 
> Fixes: b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477")
> Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>

Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: [PATCH net] net: dsa: microchip: initialize mutex before use
  2018-10-30 23:45 [PATCH net] net: dsa: microchip: initialize mutex before use Tristram.Ha
  2018-10-31  1:21 ` Andrew Lunn
  2018-10-31  7:42 ` Pavel Machek
@ 2018-10-31 19:52 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-10-31 19:52 UTC (permalink / raw)
  To: Tristram.Ha; +Cc: andrew, f.fainelli, pavel, UNGLinuxDriver, netdev

From: <Tristram.Ha@microchip.com>
Date: Tue, 30 Oct 2018 16:45:49 -0700

> @@ -1206,6 +1201,12 @@ int ksz_switch_register(struct ksz_device *dev)
>  	if (dev->pdata)
>  		dev->chip_id = dev->pdata->chip_id;
>  
> +	/* mutex is used in next function call. */
> +	mutex_init(&dev->reg_mutex);
> +	mutex_init(&dev->stats_mutex);
> +	mutex_init(&dev->alu_mutex);
> +	mutex_init(&dev->vlan_mutex);
> +

Please remove this comment, as per Andrew Lunn's feedback.

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

end of thread, other threads:[~2018-11-01  4:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-30 23:45 [PATCH net] net: dsa: microchip: initialize mutex before use Tristram.Ha
2018-10-31  1:21 ` Andrew Lunn
2018-10-31  7:42 ` Pavel Machek
2018-10-31 19:52 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).