aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-03-30 15:10:51 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-06-11 12:23:46 -0400
commit356f0a30860d44de7ac021708caa0c8bd5688dbe (patch)
treec92b669ad95f4001ea96d79cd2452b68dce45e5f
parentde3910eb79ac8c0f29a11224661c0ebaaf813039 (diff)
i7core_edac: change the mem allocation scheme to make Documentation/kobject.txt happy
Kernel kobjects have rigid rules: each container object should be dynamically allocated, and can't be allocated into a single kmalloc. EDAC never obeyed this rule: it has a single malloc function that allocates all needed data into a single kzalloc. As this is not accepted anymore, change the allocation schema of the EDAC *_info structs to enforce this Kernel standard. Cc: Aristeu Rozanski <arozansk@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/edac/i7core_edac.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index ab3b84b906b..c29944fbb7d 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -248,7 +248,7 @@ struct i7core_dev {
248}; 248};
249 249
250struct i7core_pvt { 250struct i7core_pvt {
251 struct device addrmatch_dev, chancounts_dev; 251 struct device *addrmatch_dev, *chancounts_dev;
252 252
253 struct pci_dev *pci_noncore; 253 struct pci_dev *pci_noncore;
254 struct pci_dev *pci_mcr[MAX_MCR_FUNC + 1]; 254 struct pci_dev *pci_mcr[MAX_MCR_FUNC + 1];
@@ -1105,6 +1105,7 @@ static const struct attribute_group *addrmatch_groups[] = {
1105static void addrmatch_release(struct device *device) 1105static void addrmatch_release(struct device *device)
1106{ 1106{
1107 debugf1("Releasing device %s\n", dev_name(device)); 1107 debugf1("Releasing device %s\n", dev_name(device));
1108 kfree(device);
1108} 1109}
1109 1110
1110static struct device_type addrmatch_type = { 1111static struct device_type addrmatch_type = {
@@ -1135,6 +1136,7 @@ static const struct attribute_group *all_channel_counts_groups[] = {
1135static void all_channel_counts_release(struct device *device) 1136static void all_channel_counts_release(struct device *device)
1136{ 1137{
1137 debugf1("Releasing device %s\n", dev_name(device)); 1138 debugf1("Releasing device %s\n", dev_name(device));
1139 kfree(device);
1138} 1140}
1139 1141
1140static struct device_type all_channel_counts_type = { 1142static struct device_type all_channel_counts_type = {
@@ -1177,32 +1179,44 @@ static int i7core_create_sysfs_devices(struct mem_ctl_info *mci)
1177 if (rc < 0) 1179 if (rc < 0)
1178 return rc; 1180 return rc;
1179 1181
1180 pvt->addrmatch_dev.type = &addrmatch_type; 1182 pvt->addrmatch_dev = kzalloc(sizeof(*pvt->addrmatch_dev), GFP_KERNEL);
1181 pvt->addrmatch_dev.bus = mci->dev.bus; 1183 if (!pvt->addrmatch_dev)
1182 device_initialize(&pvt->addrmatch_dev); 1184 return rc;
1183 pvt->addrmatch_dev.parent = &mci->dev; 1185
1184 dev_set_name(&pvt->addrmatch_dev, "inject_addrmatch"); 1186 pvt->addrmatch_dev->type = &addrmatch_type;
1185 dev_set_drvdata(&pvt->addrmatch_dev, mci); 1187 pvt->addrmatch_dev->bus = mci->dev.bus;
1188 device_initialize(pvt->addrmatch_dev);
1189 pvt->addrmatch_dev->parent = &mci->dev;
1190 dev_set_name(pvt->addrmatch_dev, "inject_addrmatch");
1191 dev_set_drvdata(pvt->addrmatch_dev, mci);
1186 1192
1187 debugf1("%s(): creating %s\n", __func__, 1193 debugf1("%s(): creating %s\n", __func__,
1188 dev_name(&pvt->addrmatch_dev)); 1194 dev_name(pvt->addrmatch_dev));
1189 1195
1190 rc = device_add(&pvt->addrmatch_dev); 1196 rc = device_add(pvt->addrmatch_dev);
1191 if (rc < 0) 1197 if (rc < 0)
1192 return rc; 1198 return rc;
1193 1199
1194 if (!pvt->is_registered) { 1200 if (!pvt->is_registered) {
1195 pvt->chancounts_dev.type = &all_channel_counts_type; 1201 pvt->chancounts_dev = kzalloc(sizeof(*pvt->chancounts_dev),
1196 pvt->chancounts_dev.bus = mci->dev.bus; 1202 GFP_KERNEL);
1197 device_initialize(&pvt->chancounts_dev); 1203 if (!pvt->chancounts_dev) {
1198 pvt->chancounts_dev.parent = &mci->dev; 1204 put_device(pvt->addrmatch_dev);
1199 dev_set_name(&pvt->chancounts_dev, "all_channel_counts"); 1205 device_del(pvt->addrmatch_dev);
1200 dev_set_drvdata(&pvt->chancounts_dev, mci); 1206 return rc;
1207 }
1208
1209 pvt->chancounts_dev->type = &all_channel_counts_type;
1210 pvt->chancounts_dev->bus = mci->dev.bus;
1211 device_initialize(pvt->chancounts_dev);
1212 pvt->chancounts_dev->parent = &mci->dev;
1213 dev_set_name(pvt->chancounts_dev, "all_channel_counts");
1214 dev_set_drvdata(pvt->chancounts_dev, mci);
1201 1215
1202 debugf1("%s(): creating %s\n", __func__, 1216 debugf1("%s(): creating %s\n", __func__,
1203 dev_name(&pvt->chancounts_dev)); 1217 dev_name(pvt->chancounts_dev));
1204 1218
1205 rc = device_add(&pvt->chancounts_dev); 1219 rc = device_add(pvt->chancounts_dev);
1206 if (rc < 0) 1220 if (rc < 0)
1207 return rc; 1221 return rc;
1208 } 1222 }
@@ -1221,11 +1235,11 @@ static void i7core_delete_sysfs_devices(struct mem_ctl_info *mci)
1221 device_remove_file(&mci->dev, &dev_attr_inject_enable); 1235 device_remove_file(&mci->dev, &dev_attr_inject_enable);
1222 1236
1223 if (!pvt->is_registered) { 1237 if (!pvt->is_registered) {
1224 put_device(&pvt->chancounts_dev); 1238 put_device(pvt->chancounts_dev);
1225 device_del(&pvt->chancounts_dev); 1239 device_del(pvt->chancounts_dev);
1226 } 1240 }
1227 put_device(&pvt->addrmatch_dev); 1241 put_device(pvt->addrmatch_dev);
1228 device_del(&pvt->addrmatch_dev); 1242 device_del(pvt->addrmatch_dev);
1229} 1243}
1230 1244
1231/**************************************************************************** 1245/****************************************************************************