File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -1172,6 +1172,8 @@ static int aml_i2c_probe(struct platform_device *pdev)
1172
1172
if (ret )
1173
1173
printk (" class register i2c_class fail!\n" );
1174
1174
1175
+ platform_set_drvdata (pdev , i2c );
1176
+
1175
1177
return 0 ;
1176
1178
}
1177
1179
@@ -1180,14 +1182,24 @@ static int aml_i2c_probe(struct platform_device *pdev)
1180
1182
static int aml_i2c_remove (struct platform_device * pdev )
1181
1183
{
1182
1184
struct aml_i2c * i2c = platform_get_drvdata (pdev );
1183
- if (i2c -> mode == I2C_INTERRUPT_MODE )
1184
- free_irq (i2c -> irq , i2c );
1185
- if (i2c -> mode == I2C_TIMER_POLLING_MODE )
1186
- hrtimer_cancel (& i2c -> aml_i2c_hrtimer );
1187
- mutex_destroy (i2c -> lock );
1188
- i2c_del_adapter (& i2c -> adap );
1189
- kzfree (i2c );
1190
- i2c = NULL ;
1185
+
1186
+ if (i2c != NULL ) {
1187
+ if (i2c -> mode == I2C_INTERRUPT_MODE ) {
1188
+ free_irq (i2c -> irq , i2c );
1189
+ }
1190
+
1191
+ if (i2c -> mode == I2C_TIMER_POLLING_MODE ) {
1192
+ hrtimer_cancel (& i2c -> aml_i2c_hrtimer );
1193
+ }
1194
+
1195
+ mutex_destroy (i2c -> lock );
1196
+ i2c_del_adapter (& i2c -> adap );
1197
+ class_unregister (& i2c -> cls );
1198
+ kzfree (i2c );
1199
+ } else {
1200
+ printk (KERN_ALERT "[%s]: i2c is NULL\n" , __func__ );
1201
+ }
1202
+
1191
1203
return 0 ;
1192
1204
}
1193
1205
You can’t perform that action at this time.
0 commit comments