diff mbox series

[v3,net-next,03/11] net: dsa: microchip: Initialize mutex before use

Message ID 1540261575-1889-4-git-send-email-Tristram.Ha@microchip.com
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers | expand

Commit Message

Tristram.Ha@microchip.com Oct. 23, 2018, 2:26 a.m. UTC
From: Tristram Ha <Tristram.Ha@microchip.com>

Initialize mutex before use.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
---
 drivers/net/dsa/microchip/ksz_common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Oct. 23, 2018, 1:15 p.m. UTC | #1
On Mon, Oct 22, 2018 at 07:26:07PM -0700, Tristram.Ha@microchip.com wrote:
> From: Tristram Ha <Tristram.Ha@microchip.com>
> 
> Initialize mutex before use.

Hi Tristram

This seems like a fix for the driver, not simple refactoring.

Please could you rebase this on net, add a fixes: tag, and send it to
netdev for merging. Dave will take fixes anytime.

Thanks
	Andrew
Pavel Machek Oct. 24, 2018, 11:07 a.m. UTC | #2
On Mon 2018-10-22 19:26:07, Tristram.Ha@microchip.com wrote:
> From: Tristram Ha <Tristram.Ha@microchip.com>
> 
> Initialize mutex before use.
> 
> Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>

> ---
>  drivers/net/dsa/microchip/ksz_common.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 8c5853e..88e8d2a 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -1118,7 +1118,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);
> @@ -1207,6 +1206,9 @@ 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);
> +
>  	if (ksz_switch_detect(dev))
>  		return -EINVAL;

Actually, would it make sense to move all mutex_init's there? No harm
in doing them sooner...
									Pavel
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 8c5853e..88e8d2a 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -1118,7 +1118,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);
@@ -1207,6 +1206,9 @@  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);
+
 	if (ksz_switch_detect(dev))
 		return -EINVAL;