net: dsa: microchip: initialize mutex before use
PATCH 1/1 net: dsa: microchip: initialize mutex before use
From: Tristram Ha <[email protected]>
Initialize mutex before use. Avoid kernel complaint when CONFIG_DEBUG_LOCK_ALLOC is enabled.
--- drivers/net/dsa/microchip/ksz_common.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/dsa/microchip/ksz_common.c +6 -5
@@ -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 ;
Signature · 1 line
1.9.1
Andrew Lunn
maintainerQuoted 28 lines · On Tue, Oct 30, 2018 at 04:45:49PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
Initialize mutex before use. Avoid kernel complaint when
CONFIG_DEBUG_LOCK_ALLOCis enabled.Fixes b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477")Signed-off-by Tristram Ha <[email protected]>--- drivers/net/dsa/microchip/ksz_common.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/net/dsa/microchip/ksz_common.c +0
-5@@ -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++) {
drivers/net/dsa/microchip/ksz_common.c int ksz_switch_register(struct ksz_device *dev) · line 1208
Quoted 8 lines
drivers/net/dsa/microchip/ksz_common.c +5
-0@@ -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
Quoted 7 lines · On Tue 2018-10-30 16:45:49, [email protected] wrote:
From: Tristram Ha <[email protected]>
Initialize mutex before use. Avoid kernel complaint when
CONFIG_DEBUG_LOCK_ALLOCis enabled.Fixes b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477")Signed-off-by Tristram Ha <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
David Miller
maintainerFrom: <[email protected]>
Date: Tue, 30 Oct 2018 16:45:49 -0700
drivers/net/dsa/microchip/ksz_common.c int ksz_switch_register(struct ksz_device *dev) · line 1209
Quoted 10 lines
drivers/net/dsa/microchip/ksz_common.c +6
-0@@ -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.