aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-06-22 21:48:30 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-10 10:44:47 -0400
commitb7c761512c5412eb30be567a0640060cccfc372f (patch)
treea25f9a962d87cd4eb42dbf58fa142cac4540071e
parent1c6fed808f1ccd0804786e87f6b2c907dcd730fa (diff)
i7core_edac: Improve error handling
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/edac/i7core_edac.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 556a150e645..62ae472c4e2 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -328,8 +328,10 @@ static int i7core_get_active_channels(int *channels)
328 } 328 }
329 } 329 }
330 330
331 if (!pdev) 331 if (!pdev) {
332 i7core_printk(KERN_ERR, "Couldn't find fn 3.0!!!\n");
332 return -ENODEV; 333 return -ENODEV;
334 }
333 335
334 /* Device 3 function 0 reads */ 336 /* Device 3 function 0 reads */
335 pci_read_config_dword(pdev, MC_STATUS, &status); 337 pci_read_config_dword(pdev, MC_STATUS, &status);
@@ -1109,16 +1111,19 @@ static int __devinit i7core_probe(struct pci_dev *pdev,
1109 int num_channels = 0; 1111 int num_channels = 0;
1110 int num_csrows; 1112 int num_csrows;
1111 int dev_idx = id->driver_data; 1113 int dev_idx = id->driver_data;
1114 int rc;
1112 1115
1113 if (unlikely(dev_idx >= ARRAY_SIZE(i7core_devs))) 1116 if (unlikely(dev_idx >= ARRAY_SIZE(i7core_devs)))
1114 return -EINVAL; 1117 return -EINVAL;
1115 1118
1116 /* get the pci devices we want to reserve for our use */ 1119 /* get the pci devices we want to reserve for our use */
1117 if (unlikely(i7core_get_devices() < 0)) 1120 rc = i7core_get_devices();
1118 return -ENODEV; 1121 if (unlikely(rc < 0))
1122 return rc;
1119 1123
1120 /* Check the number of active and not disabled channels */ 1124 /* Check the number of active and not disabled channels */
1121 if (unlikely (i7core_get_active_channels(&num_channels)) < 0) 1125 rc = i7core_get_active_channels(&num_channels);
1126 if (unlikely (rc < 0))
1122 goto fail0; 1127 goto fail0;
1123 1128
1124 /* FIXME: we currently don't know the number of csrows */ 1129 /* FIXME: we currently don't know the number of csrows */
@@ -1126,8 +1131,10 @@ static int __devinit i7core_probe(struct pci_dev *pdev,
1126 1131
1127 /* allocate a new MC control structure */ 1132 /* allocate a new MC control structure */
1128 mci = edac_mc_alloc(sizeof(*pvt), num_csrows, num_channels, 0); 1133 mci = edac_mc_alloc(sizeof(*pvt), num_csrows, num_channels, 0);
1129 if (unlikely (!mci)) 1134 if (unlikely (!mci)) {
1130 return -ENOMEM; 1135 rc = -ENOMEM;
1136 goto fail0;
1137 }
1131 1138
1132 debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci); 1139 debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci);
1133 1140
@@ -1150,19 +1157,22 @@ static int __devinit i7core_probe(struct pci_dev *pdev,
1150 mci->edac_check = i7core_check_error; 1157 mci->edac_check = i7core_check_error;
1151 1158
1152 /* Store pci devices at mci for faster access */ 1159 /* Store pci devices at mci for faster access */
1153 if (unlikely (mci_bind_devs(mci)) < 0) 1160 rc = mci_bind_devs(mci);
1161 if (unlikely (rc < 0))
1154 goto fail1; 1162 goto fail1;
1155 1163
1156 /* Get dimm basic config */ 1164 /* Get dimm basic config */
1157 get_dimm_config(mci); 1165 get_dimm_config(mci);
1158 1166
1159 /* add this new MC control structure to EDAC's list of MCs */ 1167 /* add this new MC control structure to EDAC's list of MCs */
1160 if (unlikely(edac_mc_add_mc(mci)) < 0) { 1168 if (unlikely(edac_mc_add_mc(mci))) {
1161 debugf0("MC: " __FILE__ 1169 debugf0("MC: " __FILE__
1162 ": %s(): failed edac_mc_add_mc()\n", __func__); 1170 ": %s(): failed edac_mc_add_mc()\n", __func__);
1163 /* FIXME: perhaps some code should go here that disables error 1171 /* FIXME: perhaps some code should go here that disables error
1164 * reporting if we just enabled it 1172 * reporting if we just enabled it
1165 */ 1173 */
1174
1175 rc = -EINVAL;
1166 goto fail1; 1176 goto fail1;
1167 } 1177 }
1168 1178
@@ -1190,11 +1200,11 @@ static int __devinit i7core_probe(struct pci_dev *pdev,
1190 return 0; 1200 return 0;
1191 1201
1192fail1: 1202fail1:
1193 i7core_put_devices(); 1203 edac_mc_free(mci);
1194 1204
1195fail0: 1205fail0:
1196 edac_mc_free(mci); 1206 i7core_put_devices();
1197 return -ENODEV; 1207 return rc;
1198} 1208}
1199 1209
1200/* 1210/*