Commit b4cb0d4da745bc1d806b9b4a27cc4ce1f7adbf99

Authored by Jean Delvare
Committed by Guenter Roeck
1 parent 858a914324

hwmon: (i5k_amb) Drop i5k_channel_pci_id

Function i5k_channel_pci_id looks like it can fail, while a better
code design would make it more obvious that it can't. We can even get
rid of the function.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>

Showing 1 changed file with 14 additions and 28 deletions Side-by-side Diff

drivers/hwmon/i5k_amb.c
... ... @@ -114,7 +114,6 @@
114 114 void __iomem *amb_mmio;
115 115 struct i5k_device_attribute *attrs;
116 116 unsigned int num_attrs;
117   - unsigned long chipset_id;
118 117 };
119 118  
120 119 static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
... ... @@ -444,8 +443,6 @@
444 443 goto out;
445 444 }
446 445  
447   - data->chipset_id = devid;
448   -
449 446 res = 0;
450 447 out:
451 448 pci_dev_put(pcidev);
... ... @@ -478,23 +475,13 @@
478 475 return res;
479 476 }
480 477  
481   -static unsigned long i5k_channel_pci_id(struct i5k_amb_data *data,
482   - unsigned long channel)
483   -{
484   - switch (data->chipset_id) {
485   - case PCI_DEVICE_ID_INTEL_5000_ERR:
486   - return PCI_DEVICE_ID_INTEL_5000_FBD0 + channel;
487   - case PCI_DEVICE_ID_INTEL_5400_ERR:
488   - return PCI_DEVICE_ID_INTEL_5400_FBD0 + channel;
489   - default:
490   - BUG();
491   - }
492   -}
493   -
494   -static unsigned long chipset_ids[] = {
495   - PCI_DEVICE_ID_INTEL_5000_ERR,
496   - PCI_DEVICE_ID_INTEL_5400_ERR,
497   - 0
  478 +static struct {
  479 + unsigned long err;
  480 + unsigned long fbd0;
  481 +} chipset_ids[] __devinitdata = {
  482 + { PCI_DEVICE_ID_INTEL_5000_ERR, PCI_DEVICE_ID_INTEL_5000_FBD0 },
  483 + { PCI_DEVICE_ID_INTEL_5400_ERR, PCI_DEVICE_ID_INTEL_5400_FBD0 },
  484 + { 0, 0 }
498 485 };
499 486  
500 487 #ifdef MODULE
... ... @@ -510,8 +497,7 @@
510 497 {
511 498 struct i5k_amb_data *data;
512 499 struct resource *reso;
513   - int i;
514   - int res = -ENODEV;
  500 + int i, res;
515 501  
516 502 data = kzalloc(sizeof(*data), GFP_KERNEL);
517 503 if (!data)
518 504  
519 505  
520 506  
... ... @@ -520,22 +506,22 @@
520 506 /* Figure out where the AMB registers live */
521 507 i = 0;
522 508 do {
523   - res = i5k_find_amb_registers(data, chipset_ids[i]);
  509 + res = i5k_find_amb_registers(data, chipset_ids[i].err);
  510 + if (res == 0)
  511 + break;
524 512 i++;
525   - } while (res && chipset_ids[i]);
  513 + } while (chipset_ids[i].err);
526 514  
527 515 if (res)
528 516 goto err;
529 517  
530 518 /* Copy the DIMM presence map for the first two channels */
531   - res = i5k_channel_probe(&data->amb_present[0],
532   - i5k_channel_pci_id(data, 0));
  519 + res = i5k_channel_probe(&data->amb_present[0], chipset_ids[i].fbd0);
533 520 if (res)
534 521 goto err;
535 522  
536 523 /* Copy the DIMM presence map for the optional second two channels */
537   - i5k_channel_probe(&data->amb_present[2],
538   - i5k_channel_pci_id(data, 1));
  524 + i5k_channel_probe(&data->amb_present[2], chipset_ids[i].fbd0 + 1);
539 525  
540 526 /* Set up resource regions */
541 527 reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME);