diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-08-15 12:26:30 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-26 18:38:50 -0400 |
commit | b119c6c952a086f74202ccda4b7ed72161bb6522 (patch) | |
tree | d402c6b9ea26897077b2042a31045ecc0d689883 /drivers/i2c/busses | |
parent | 22f76e744dc41096987c6df8270b5c249511cde5 (diff) |
i2c: __must_check fixes (core drivers)
i2c: __must_check fixes (core drivers)
Check for error on sysfs file creation.
Check for error on device registration.
Check for error on class device registration.
Greg, I am not familiar with completion, can you please tell me if I
need to take care of it in the error paths (as I did in this patch,
see /* Needed? */ comments), or if it isn't needed?
These patches were tested, including forced errors, so they should work
fine. But of course more testing can't hurt.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r-- | drivers/i2c/busses/i2c-isa.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index c3e1d3e888d7..d7486e586068 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -125,6 +125,8 @@ int i2c_isa_del_driver(struct i2c_driver *driver) | |||
125 | 125 | ||
126 | static int __init i2c_isa_init(void) | 126 | static int __init i2c_isa_init(void) |
127 | { | 127 | { |
128 | int err; | ||
129 | |||
128 | mutex_init(&isa_adapter.clist_lock); | 130 | mutex_init(&isa_adapter.clist_lock); |
129 | INIT_LIST_HEAD(&isa_adapter.clients); | 131 | INIT_LIST_HEAD(&isa_adapter.clients); |
130 | 132 | ||
@@ -133,8 +135,16 @@ static int __init i2c_isa_init(void) | |||
133 | sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr); | 135 | sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr); |
134 | isa_adapter.dev.driver = &i2c_adapter_driver; | 136 | isa_adapter.dev.driver = &i2c_adapter_driver; |
135 | isa_adapter.dev.release = &i2c_adapter_dev_release; | 137 | isa_adapter.dev.release = &i2c_adapter_dev_release; |
136 | device_register(&isa_adapter.dev); | 138 | err = device_register(&isa_adapter.dev); |
137 | device_create_file(&isa_adapter.dev, &dev_attr_name); | 139 | if (err) { |
140 | printk(KERN_ERR "i2c-isa: Failed to register device\n"); | ||
141 | goto exit; | ||
142 | } | ||
143 | err = device_create_file(&isa_adapter.dev, &dev_attr_name); | ||
144 | if (err) { | ||
145 | printk(KERN_ERR "i2c-isa: Failed to create name file\n"); | ||
146 | goto exit_unregister; | ||
147 | } | ||
138 | 148 | ||
139 | /* Add this adapter to the i2c_adapter class */ | 149 | /* Add this adapter to the i2c_adapter class */ |
140 | memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device)); | 150 | memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device)); |
@@ -142,11 +152,24 @@ static int __init i2c_isa_init(void) | |||
142 | isa_adapter.class_dev.class = &i2c_adapter_class; | 152 | isa_adapter.class_dev.class = &i2c_adapter_class; |
143 | strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id, | 153 | strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id, |
144 | BUS_ID_SIZE); | 154 | BUS_ID_SIZE); |
145 | class_device_register(&isa_adapter.class_dev); | 155 | err = class_device_register(&isa_adapter.class_dev); |
156 | if (err) { | ||
157 | printk(KERN_ERR "i2c-isa: Failed to register class device\n"); | ||
158 | goto exit_remove_name; | ||
159 | } | ||
146 | 160 | ||
147 | dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name); | 161 | dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name); |
148 | 162 | ||
149 | return 0; | 163 | return 0; |
164 | |||
165 | exit_remove_name: | ||
166 | device_remove_file(&isa_adapter.dev, &dev_attr_name); | ||
167 | exit_unregister: | ||
168 | init_completion(&isa_adapter.dev_released); /* Needed? */ | ||
169 | device_unregister(&isa_adapter.dev); | ||
170 | wait_for_completion(&isa_adapter.dev_released); | ||
171 | exit: | ||
172 | return err; | ||
150 | } | 173 | } |
151 | 174 | ||
152 | static void __exit i2c_isa_exit(void) | 175 | static void __exit i2c_isa_exit(void) |