Skip to content

Commit

Permalink
hwmon: (i5k_amb) Drop i5k_channel_pci_id
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jean Delvare authored and Guenter Roeck committed Aug 24, 2011
1 parent 858a914 commit b4cb0d4
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions drivers/hwmon/i5k_amb.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ struct i5k_amb_data {
void __iomem *amb_mmio;
struct i5k_device_attribute *attrs;
unsigned int num_attrs;
unsigned long chipset_id;
};

static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
Expand Down Expand Up @@ -444,8 +443,6 @@ static int __devinit i5k_find_amb_registers(struct i5k_amb_data *data,
goto out;
}

data->chipset_id = devid;

res = 0;
out:
pci_dev_put(pcidev);
Expand Down Expand Up @@ -478,23 +475,13 @@ static int __devinit i5k_channel_probe(u16 *amb_present, unsigned long dev_id)
return res;
}

static unsigned long i5k_channel_pci_id(struct i5k_amb_data *data,
unsigned long channel)
{
switch (data->chipset_id) {
case PCI_DEVICE_ID_INTEL_5000_ERR:
return PCI_DEVICE_ID_INTEL_5000_FBD0 + channel;
case PCI_DEVICE_ID_INTEL_5400_ERR:
return PCI_DEVICE_ID_INTEL_5400_FBD0 + channel;
default:
BUG();
}
}

static unsigned long chipset_ids[] = {
PCI_DEVICE_ID_INTEL_5000_ERR,
PCI_DEVICE_ID_INTEL_5400_ERR,
0
static struct {
unsigned long err;
unsigned long fbd0;
} chipset_ids[] __devinitdata = {
{ PCI_DEVICE_ID_INTEL_5000_ERR, PCI_DEVICE_ID_INTEL_5000_FBD0 },
{ PCI_DEVICE_ID_INTEL_5400_ERR, PCI_DEVICE_ID_INTEL_5400_FBD0 },
{ 0, 0 }
};

#ifdef MODULE
Expand All @@ -510,8 +497,7 @@ static int __devinit i5k_amb_probe(struct platform_device *pdev)
{
struct i5k_amb_data *data;
struct resource *reso;
int i;
int res = -ENODEV;
int i, res;

data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
Expand All @@ -520,22 +506,22 @@ static int __devinit i5k_amb_probe(struct platform_device *pdev)
/* Figure out where the AMB registers live */
i = 0;
do {
res = i5k_find_amb_registers(data, chipset_ids[i]);
res = i5k_find_amb_registers(data, chipset_ids[i].err);
if (res == 0)
break;
i++;
} while (res && chipset_ids[i]);
} while (chipset_ids[i].err);

if (res)
goto err;

/* Copy the DIMM presence map for the first two channels */
res = i5k_channel_probe(&data->amb_present[0],
i5k_channel_pci_id(data, 0));
res = i5k_channel_probe(&data->amb_present[0], chipset_ids[i].fbd0);
if (res)
goto err;

/* Copy the DIMM presence map for the optional second two channels */
i5k_channel_probe(&data->amb_present[2],
i5k_channel_pci_id(data, 1));
i5k_channel_probe(&data->amb_present[2], chipset_ids[i].fbd0 + 1);

/* Set up resource regions */
reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME);
Expand Down

0 comments on commit b4cb0d4

Please sign in to comment.