Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C kernel module removal fix #102

Merged
merged 1 commit into from
Apr 20, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions drivers/amlogic/i2c/aml_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,8 @@ static int aml_i2c_probe(struct platform_device *pdev)
if(ret)
printk(" class register i2c_class fail!\n");

platform_set_drvdata(pdev, i2c);

return 0;
}

Expand All @@ -1180,14 +1182,24 @@ static int aml_i2c_probe(struct platform_device *pdev)
static int aml_i2c_remove(struct platform_device *pdev)
{
struct aml_i2c *i2c = platform_get_drvdata(pdev);
if (i2c->mode == I2C_INTERRUPT_MODE)
free_irq(i2c->irq, i2c);
if (i2c->mode == I2C_TIMER_POLLING_MODE)
hrtimer_cancel(&i2c->aml_i2c_hrtimer);
mutex_destroy(i2c->lock);
i2c_del_adapter(&i2c->adap);
kzfree(i2c);
i2c= NULL;

if (i2c != NULL) {
if (i2c->mode == I2C_INTERRUPT_MODE) {
free_irq(i2c->irq, i2c);
}

if (i2c->mode == I2C_TIMER_POLLING_MODE) {
hrtimer_cancel(&i2c->aml_i2c_hrtimer);
}

mutex_destroy(i2c->lock);
i2c_del_adapter(&i2c->adap);
class_unregister(&i2c->cls);
kzfree(i2c);
} else {
printk(KERN_ALERT "[%s]: i2c is NULL\n", __func__);
}

return 0;
}

Expand Down