diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-10-11 04:22:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-11 14:14:25 -0400 |
commit | 49a6cbe1cd8a72451d9d6ab5b1e163f17c1bbee3 (patch) | |
tree | 519d69f7daef24f8258c0ca125e1da7344d3a81d /drivers/mca/mca-bus.c | |
parent | 69b2186c5fcb335e29c558e3b4e410e1939b5cc8 (diff) |
[PATCH] drivers/mca: handle sysfs errors
Also includes a kmalloc->kzalloc cleanup.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/mca/mca-bus.c')
-rw-r--r-- | drivers/mca/mca-bus.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c index 09baa43b2599..da862e4632dd 100644 --- a/drivers/mca/mca-bus.c +++ b/drivers/mca/mca-bus.c | |||
@@ -100,6 +100,7 @@ static DEVICE_ATTR(pos, S_IRUGO, mca_show_pos, NULL); | |||
100 | int __init mca_register_device(int bus, struct mca_device *mca_dev) | 100 | int __init mca_register_device(int bus, struct mca_device *mca_dev) |
101 | { | 101 | { |
102 | struct mca_bus *mca_bus = mca_root_busses[bus]; | 102 | struct mca_bus *mca_bus = mca_root_busses[bus]; |
103 | int rc; | ||
103 | 104 | ||
104 | mca_dev->dev.parent = &mca_bus->dev; | 105 | mca_dev->dev.parent = &mca_bus->dev; |
105 | mca_dev->dev.bus = &mca_bus_type; | 106 | mca_dev->dev.bus = &mca_bus_type; |
@@ -108,13 +109,23 @@ int __init mca_register_device(int bus, struct mca_device *mca_dev) | |||
108 | mca_dev->dev.dma_mask = &mca_dev->dma_mask; | 109 | mca_dev->dev.dma_mask = &mca_dev->dma_mask; |
109 | mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask; | 110 | mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask; |
110 | 111 | ||
111 | if (device_register(&mca_dev->dev)) | 112 | rc = device_register(&mca_dev->dev); |
112 | return 0; | 113 | if (rc) |
114 | goto err_out; | ||
113 | 115 | ||
114 | device_create_file(&mca_dev->dev, &dev_attr_id); | 116 | rc = device_create_file(&mca_dev->dev, &dev_attr_id); |
115 | device_create_file(&mca_dev->dev, &dev_attr_pos); | 117 | if (rc) goto err_out_devreg; |
118 | rc = device_create_file(&mca_dev->dev, &dev_attr_pos); | ||
119 | if (rc) goto err_out_id; | ||
116 | 120 | ||
117 | return 1; | 121 | return 1; |
122 | |||
123 | err_out_id: | ||
124 | device_remove_file(&mca_dev->dev, &dev_attr_id); | ||
125 | err_out_devreg: | ||
126 | device_unregister(&mca_dev->dev); | ||
127 | err_out: | ||
128 | return 0; | ||
118 | } | 129 | } |
119 | 130 | ||
120 | /* */ | 131 | /* */ |
@@ -130,13 +141,16 @@ struct mca_bus * __devinit mca_attach_bus(int bus) | |||
130 | return NULL; | 141 | return NULL; |
131 | } | 142 | } |
132 | 143 | ||
133 | mca_bus = kmalloc(sizeof(struct mca_bus), GFP_KERNEL); | 144 | mca_bus = kzalloc(sizeof(struct mca_bus), GFP_KERNEL); |
134 | if (!mca_bus) | 145 | if (!mca_bus) |
135 | return NULL; | 146 | return NULL; |
136 | memset(mca_bus, 0, sizeof(struct mca_bus)); | 147 | |
137 | sprintf(mca_bus->dev.bus_id,"mca%d",bus); | 148 | sprintf(mca_bus->dev.bus_id,"mca%d",bus); |
138 | sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary"); | 149 | sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary"); |
139 | device_register(&mca_bus->dev); | 150 | if (device_register(&mca_bus->dev)) { |
151 | kfree(mca_bus); | ||
152 | return NULL; | ||
153 | } | ||
140 | 154 | ||
141 | mca_root_busses[bus] = mca_bus; | 155 | mca_root_busses[bus] = mca_bus; |
142 | 156 | ||