Skip to contentSkip to conversation

perf/x86/uncore: Remove unnecessary assignment to "box" in uncore_pci_remove(...)

PATCH In review Giedrius Rekasius 3 participants 5 messages May 28, 2014 – May 29, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/x86/uncore: Remove unnecessary assignment to "box" in uncore_pci_remove(...)

Local variable "box" gets assigned correct value when it is initialized. There is no need to assign the same value again.

---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel_uncore.c +0 -1
index 65bbbea..8cbbb1b 100644
@@ -3817,7 +3817,6 @@ static void uncore_pci_remove(struct pci_dev *pdev)
 	struct intel_uncore_pmu *pmu;
 	int i, cpu, phys_id = pcibus_to_physid[pdev->bus->number];
 
-	box = pci_get_drvdata(pdev);
 	if (!box) {
 		for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
 			if (extra_pci_dev[phys_id][i] = pdev) {
Signature · 1 line
1.9.3
#1 lore raw

Am 28.05.2014 11:11, schrieb Giedrius Rekasius:

Quoted 13 lines

Local variable "box" gets assigned correct value when it is initialized. There is no need to assign the same value again.

---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel_uncore.c +0 -0
index 65bbbea..8cbbb1b 100644

arch/x86/kernel/cpu/perf_event_intel_uncore.c static void uncore_pci_remove(struct pci_dev *pdev) · line 3822

Quoted 7 lines
arch/x86/kernel/cpu/perf_event_intel_uncore.c +0 -1
@@ -3817,7 +3817,6 @@ static void uncore_pci_remove(struct pci_dev *pdev)
 	struct intel_uncore_pmu *pmu;
 	int i, cpu, phys_id = pcibus_to_physid[pdev->bus->number];
 
-	box = pci_get_drvdata(pdev);
 	if (!box) {
 		for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
 			if (extra_pci_dev[phys_id][i] = pdev) {

Just a remark,
for readability it is better to remove the other one.

re,
wh

#2 lore raw
Quoted 19 lines · walter harms

Am 28.05.2014 11:11, schrieb Giedrius Rekasius:

Quoted 16 lines

Local variable "box" gets assigned correct value when it is initialized. There is no need to assign the same value again.

---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel_uncore.c +0 -0
index 65bbbea..8cbbb1b 100644
@@ -3817,7 +3817,6 @@ static void uncore_pci_remove(struct pci_dev *pdev)
 	struct intel_uncore_pmu *pmu;
 	int i, cpu, phys_id = pcibus_to_physid[pdev->bus->number];
 
Quoted 7 lines

arch/x86/kernel/cpu/perf_event_intel_uncore.c static void uncore_pci_remove(struct pci_dev *pdev) · line 3822

Quoted 4 lines
arch/x86/kernel/cpu/perf_event_intel_uncore.c +0 -1
-	box = pci_get_drvdata(pdev);
 	if (!box) {
 		for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
 			if (extra_pci_dev[phys_id][i] = pdev) {

Just a remark,
for readability it is better to remove the other one.

I could move the declaration itself closer to the if statement while still keeping whole statement in one line.

On the other hand I'm not so sure if it makes any real difference to have assignment right next to the if statement compared to a few lines above it.

Regards,
Giedrius

#3 lore raw
In reply to walter harms
Quoted 17 lines · walter harms

Am 28.05.2014 11:11, schrieb Giedrius Rekasius:

Quoted 16 lines

Local variable "box" gets assigned correct value when it is initialized. There is no need to assign the same value again.

---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel_uncore.c +0 -0
index 65bbbea..8cbbb1b 100644
@@ -3817,7 +3817,6 @@ static void uncore_pci_remove(struct pci_dev *pdev)
 	struct intel_uncore_pmu *pmu;
 	int i, cpu, phys_id = pcibus_to_physid[pdev->bus->number];
 
Quoted 7 lines

arch/x86/kernel/cpu/perf_event_intel_uncore.c static void uncore_pci_remove(struct pci_dev *pdev) · line 3822

Quoted 4 lines
arch/x86/kernel/cpu/perf_event_intel_uncore.c +0 -1
-	box = pci_get_drvdata(pdev);
 	if (!box) {
 		for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
 			if (extra_pci_dev[phys_id][i] = pdev) {

Just a remark,
for readability it is better to remove the other one.

I rather have stuff reshuffled a bit more:

static void uncore_pci_remove(struct pci_dev *pdev)

{
	int i, cpu, phys_id = pcibus_to_physid[pdev->bus->number];
	struct intel_uncore_box *box = pci_get_drvdata(pdev);
	struct intel_uncore_pmu *pmu;

	if (!box) {

That's less lines and entirely readable.

Thanks,

tglx

#4 lore raw

PATCH 1/1 perf/x86/uncore: Remove unnecessary assignment to "box" in uncore_pci_remove(...)

Local variable "box" gets assigned correct value when it is initialized. There is no need to assign the same value again. Variable declarations were reshuffled for better readability.

---
Original patch was amended for better readability based on feedback from Walter Harms and Thomas Gleixner.

 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event_intel_uncore.c +1 -2
index 65bbbea..6fe20db 100644
@@ -3813,11 +3813,10 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
 
 static void uncore_pci_remove(struct pci_dev *pdev)
 {
+	int i, cpu, phys_id = pcibus_to_physid[pdev->bus->number];
 	struct intel_uncore_box *box = pci_get_drvdata(pdev);
 	struct intel_uncore_pmu *pmu;
-	int i, cpu, phys_id = pcibus_to_physid[pdev->bus->number];
 
-	box = pci_get_drvdata(pdev);
 	if (!box) {
 		for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
 			if (extra_pci_dev[phys_id][i] = pdev) {
Signature · 1 line
1.9.3