Skip to contentSkip to conversation

bcma: clean bus initialiation code

PATCH Superseded Rafał Miłecki 3 participants 8 messages Jan 16, 2015 – Jan 23, 2015 Broadcom specific amba driver (bcma)

lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH 1/1 bcma: clean bus initialiation code

This moves main bus init code to the main.c and renames old function to make its purpose clear.
Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future.

---
 drivers/bcma/bcma_private.h |  3 ++-
 drivers/bcma/main.c         | 16 ++++++++++++----
 drivers/bcma/scan.c         |  5 +----
 3 files changed, 15 insertions(+), 9 deletions(-)
drivers/bcma/bcma_private.h +2 -1
index 314ae40..08fa58a 100644
@@ -25,6 +25,7 @@ struct bcma_bus;
 bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
 		     int timeout);
 void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
+void bcma_init_bus(struct bcma_bus *bus);
 int bcma_bus_register(struct bcma_bus *bus);
 void bcma_bus_unregister(struct bcma_bus *bus);
 int __init bcma_bus_early_register(struct bcma_bus *bus,
@@ -40,7 +41,7 @@ int bcma_bus_scan(struct bcma_bus *bus);
 int __init bcma_bus_scan_early(struct bcma_bus *bus,
 			       struct bcma_device_id *match,
 			       struct bcma_device *core);
-void bcma_init_bus(struct bcma_bus *bus);
+void bcma_detect_chip(struct bcma_bus *bus);
 
 /* sprom.c */
 int bcma_sprom_get(struct bcma_bus *bus);
drivers/bcma/main.c +12 -4
index 534e133..c166d44 100644
@@ -268,6 +268,18 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
 	}
 }
 
+void bcma_init_bus(struct bcma_bus *bus)
+{
+	mutex_lock(&bcma_buses_mutex);
+	bus->num = bcma_bus_next_num++;
+	mutex_unlock(&bcma_buses_mutex);
+
+	INIT_LIST_HEAD(&bus->cores);
+	bus->nr_cores = 0;
+
+	bcma_detect_chip(bus);
+}
+
 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
 {
 	int err;
@@ -369,10 +381,6 @@ int bcma_bus_register(struct bcma_bus *bus)
 	int err;
 	struct bcma_device *core;
 
-	mutex_lock(&bcma_buses_mutex);
-	bus->num = bcma_bus_next_num++;
-	mutex_unlock(&bcma_buses_mutex);
-
 	/* Scan for devices (cores) */
 	err = bcma_bus_scan(bus);
 	if (err) {
drivers/bcma/scan.c +1 -4
index 9175207..5328ee5 100644
@@ -435,15 +435,12 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
 	return 0;
 }
 
-void bcma_init_bus(struct bcma_bus *bus)
+void bcma_detect_chip(struct bcma_bus *bus)
 {
 	s32 tmp;
 	struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
 	char chip_id[8];
 
-	INIT_LIST_HEAD(&bus->cores);
-	bus->nr_cores = 0;
-
 	bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
 
 	tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);
Signature · 1 line
1.8.4.5
author maintainer
#1 lore raw

PATCH v2 1/1 bcma: clean bus initialization code

This moves main bus init code to the main.c and renames old function to make its purpose clear.
Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future.

---
V2: Fix typo (s/initialiation/initialization/)
Put bcma_detect_chip earlier in .h to match order in .c

---
 drivers/bcma/bcma_private.h |  3 ++-
 drivers/bcma/main.c         | 16 ++++++++++++----
 drivers/bcma/scan.c         |  5 +----
 3 files changed, 15 insertions(+), 9 deletions(-)
drivers/bcma/bcma_private.h +2 -1
index 314ae40..59422b5 100644
@@ -25,6 +25,7 @@ struct bcma_bus;
 bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
 		     int timeout);
 void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
+void bcma_init_bus(struct bcma_bus *bus);
 int bcma_bus_register(struct bcma_bus *bus);
 void bcma_bus_unregister(struct bcma_bus *bus);
 int __init bcma_bus_early_register(struct bcma_bus *bus,
@@ -36,11 +37,11 @@ int bcma_bus_resume(struct bcma_bus *bus);
 #endif
 
 /* scan.c */
+void bcma_detect_chip(struct bcma_bus *bus);
 int bcma_bus_scan(struct bcma_bus *bus);
 int __init bcma_bus_scan_early(struct bcma_bus *bus,
 			       struct bcma_device_id *match,
 			       struct bcma_device *core);
-void bcma_init_bus(struct bcma_bus *bus);
 
 /* sprom.c */
 int bcma_sprom_get(struct bcma_bus *bus);
drivers/bcma/main.c +12 -4
index 534e133..c166d44 100644
@@ -268,6 +268,18 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
 	}
 }
 
+void bcma_init_bus(struct bcma_bus *bus)
+{
+	mutex_lock(&bcma_buses_mutex);
+	bus->num = bcma_bus_next_num++;
+	mutex_unlock(&bcma_buses_mutex);
+
+	INIT_LIST_HEAD(&bus->cores);
+	bus->nr_cores = 0;
+
+	bcma_detect_chip(bus);
+}
+
 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
 {
 	int err;
@@ -369,10 +381,6 @@ int bcma_bus_register(struct bcma_bus *bus)
 	int err;
 	struct bcma_device *core;
 
-	mutex_lock(&bcma_buses_mutex);
-	bus->num = bcma_bus_next_num++;
-	mutex_unlock(&bcma_buses_mutex);
-
 	/* Scan for devices (cores) */
 	err = bcma_bus_scan(bus);
 	if (err) {
drivers/bcma/scan.c +1 -4
index 9175207..5328ee5 100644
@@ -435,15 +435,12 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
 	return 0;
 }
 
-void bcma_init_bus(struct bcma_bus *bus)
+void bcma_detect_chip(struct bcma_bus *bus)
 {
 	s32 tmp;
 	struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
 	char chip_id[8];
 
-	INIT_LIST_HEAD(&bus->cores);
-	bus->nr_cores = 0;
-
 	bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
 
 	tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);
Signature · 1 line
1.8.4.5
#2 lore raw

Re: [PATCH V2] bcma: clean bus initialization code

Quoted 6 lines · Rafał Miłecki

This moves main bus init code to the main.c and renames old function to make its purpose clear.
Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future.

This should also fix the problem that the bus number in the early init part was wrongly set to 0. I saw this on a SoC with BCMA as main bus and some PCIe cards with bcma on it.

Quoted 90 lines

---
V2: Fix typo (s/initialiation/initialization/)
Put bcma_detect_chip earlier in .h to match order in .c

---
 drivers/bcma/bcma_private.h |  3 ++-
 drivers/bcma/main.c         | 16 ++++++++++++----
 drivers/bcma/scan.c         |  5 +----
 3 files changed, 15 insertions(+), 9 deletions(-)
drivers/bcma/bcma_private.h +2 -1
index 314ae40..59422b5 100644
@@ -25,6 +25,7 @@ struct bcma_bus;
 bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
 		     int timeout);
 void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
+void bcma_init_bus(struct bcma_bus *bus);
 int bcma_bus_register(struct bcma_bus *bus);
 void bcma_bus_unregister(struct bcma_bus *bus);
 int __init bcma_bus_early_register(struct bcma_bus *bus,
@@ -36,11 +37,11 @@ int bcma_bus_resume(struct bcma_bus *bus);
 #endif
 
 /* scan.c */
+void bcma_detect_chip(struct bcma_bus *bus);
 int bcma_bus_scan(struct bcma_bus *bus);
 int __init bcma_bus_scan_early(struct bcma_bus *bus,
 			       struct bcma_device_id *match,
 			       struct bcma_device *core);
-void bcma_init_bus(struct bcma_bus *bus);
 
 /* sprom.c */
 int bcma_sprom_get(struct bcma_bus *bus);
drivers/bcma/main.c +12 -4
index 534e133..c166d44 100644
@@ -268,6 +268,18 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
 	}
 }
 
+void bcma_init_bus(struct bcma_bus *bus)
+{
+	mutex_lock(&bcma_buses_mutex);
+	bus->num = bcma_bus_next_num++;
+	mutex_unlock(&bcma_buses_mutex);
+
+	INIT_LIST_HEAD(&bus->cores);
+	bus->nr_cores = 0;
+
+	bcma_detect_chip(bus);
+}
+
 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
 {
 	int err;
@@ -369,10 +381,6 @@ int bcma_bus_register(struct bcma_bus *bus)
 	int err;
 	struct bcma_device *core;
 
-	mutex_lock(&bcma_buses_mutex);
-	bus->num = bcma_bus_next_num++;
-	mutex_unlock(&bcma_buses_mutex);
-
 	/* Scan for devices (cores) */
 	err = bcma_bus_scan(bus);
 	if (err) {
drivers/bcma/scan.c +1 -4
index 9175207..5328ee5 100644
@@ -435,15 +435,12 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
 	return 0;
 }
 
-void bcma_init_bus(struct bcma_bus *bus)
+void bcma_detect_chip(struct bcma_bus *bus)
 {
 	s32 tmp;
 	struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
 	char chip_id[8];
 
-	INIT_LIST_HEAD(&bus->cores);
-	bus->nr_cores = 0;
-
 	bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
 
 	tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);
#3 lore raw

Re: [PATCH V2] bcma: clean bus initialization code

Quoted 9 lines · Hauke Mehrtens
Quoted 6 lines · Rafał Miłecki

This moves main bus init code to the main.c and renames old function to make its purpose clear.
Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future.

No need to change anything now, but I think that in cases like this you should use Acked-by:

"13) When to use Acked-by: and Cc:

The Signed-off-by: tag indicates that the signer was involved in the development of the patch, or that he/she was in the patch's delivery path.

If a person was not directly involved in the preparation or handling of a patch but wishes to signify and record their approval of it then they can arrange to have an Acked-by: line added to the patch's changelog.

Acked-by: is often used by the maintainer of the affected code when that maintainer neither contributed to nor forwarded the patch."

Signature · 1 line
Kalle Valo
#4 lore raw

Re: [PATCH V2] bcma: clean bus initialization code

Quoted 21 lines · Kalle Valo
Quoted 9 lines · Hauke Mehrtens
Quoted 6 lines · Rafał Miłecki

This moves main bus init code to the main.c and renames old function to make its purpose clear.
Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future.

No need to change anything now, but I think that in cases like this you should use Acked-by:

"13) When to use Acked-by: and Cc:

The Signed-off-by: tag indicates that the signer was involved in the development of the patch, or that he/she was in the patch's delivery path.

Quoted 9 lines

If a person was not directly involved in the preparation or handling of a patch but wishes to signify and record their approval of it then they can arrange to have an Acked-by: line added to the patch's changelog.

Acked-by: is often used by the maintainer of the affected code when that maintainer neither contributed to nor forwarded the patch."

Yes you are right I thought about that right after I send clicked on send. Sorry.

Hauke

Applied
#5 lore raw

Re: [PATCH V2] bcma: clean bus initialization code

In reply to Rafał Miłecki
Quoted 9 lines · Rafał Miłecki

This moves main bus init code to the main.c and renames old function to make its purpose clear.
Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future.

---
V2: Fix typo (s/initialiation/initialization/)
Put bcma_detect_chip earlier in .h to match order in .c

Thanks, applied to wireless-drivers-next.git. But to avoid any UTF-8 problems I applied this one manually from email. 'git log' and gitk look good to me, but please do check still that the log is valid.

Signature · 1 line
Kalle Valo
author maintainer
#6 lore raw

Re: [PATCH V2] bcma: clean bus initialization code

Quoted 7 lines · Kalle Valo
Quoted 5 lines · Rafał Miłecki

This moves main bus init code to the main.c and renames old function to make its purpose clear.
Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future.

Quoted 8 lines
Quoted 4 lines

---
V2: Fix typo (s/initialiation/initialization/)
Put bcma_detect_chip earlier in .h to match order in .c

Thanks, applied to wireless-drivers-next.git. But to avoid any UTF-8 problems I applied this one manually from email. 'git log' and gitk look good to me, but please do check still that the log is valid.

Looks great, thanks.

I hope kernel.org team will upgrade patchwork soon so I can send more patches :|

Signature · 1 line
Rafał
#7 lore raw

Re: [PATCH V2] bcma: clean bus initialization code

Quoted 13 lines · Rafał Miłecki
Quoted 12 lines · Kalle Valo
Quoted 9 lines · Rafał Miłecki

This moves main bus init code to the main.c and renames old function to make its purpose clear.
Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future.

---
V2: Fix typo (s/initialiation/initialization/)
Put bcma_detect_chip earlier in .h to match order in .c

Quoted 5 lines
Quoted 3 lines

Thanks, applied to wireless-drivers-next.git. But to avoid any UTF-8 problems I applied this one manually from email. 'git log' and gitk look good to me, but please do check still that the log is valid.

Looks great, thanks.

Thanks for checking.

Quoted 2 lines

I hope kernel.org team will upgrade patchwork soon so I can send more patches :|

It might take some time, they (or is it just one person?) seem to be quite busy. Just continue sending patches and I'll apply them manually. Luckily you seem to be the only one using non-ascii characters.

Signature · 1 line
Kalle Valo