--- zzzz-none-000/linux-3.10.107/drivers/input/misc/mma8450.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/input/misc/mma8450.c 2021-02-04 17:41:59.000000000 +0000 @@ -168,18 +168,19 @@ * I2C init/probing/exit functions */ static int mma8450_probe(struct i2c_client *c, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct input_polled_dev *idev; struct mma8450 *m; int err; - m = kzalloc(sizeof(struct mma8450), GFP_KERNEL); - idev = input_allocate_polled_device(); - if (!m || !idev) { - err = -ENOMEM; - goto err_free_mem; - } + m = devm_kzalloc(&c->dev, sizeof(*m), GFP_KERNEL); + if (!m) + return -ENOMEM; + + idev = devm_input_allocate_polled_device(&c->dev); + if (!idev) + return -ENOMEM; m->client = c; m->idev = idev; @@ -201,25 +202,10 @@ err = input_register_polled_device(idev); if (err) { dev_err(&c->dev, "failed to register polled input device\n"); - goto err_free_mem; + return err; } - return 0; - -err_free_mem: - input_free_polled_device(idev); - kfree(m); - return err; -} - -static int mma8450_remove(struct i2c_client *c) -{ - struct mma8450 *m = i2c_get_clientdata(c); - struct input_polled_dev *idev = m->idev; - - input_unregister_polled_device(idev); - input_free_polled_device(idev); - kfree(m); + i2c_set_clientdata(c, m); return 0; } @@ -239,11 +225,9 @@ static struct i2c_driver mma8450_driver = { .driver = { .name = MMA8450_DRV_NAME, - .owner = THIS_MODULE, .of_match_table = mma8450_dt_ids, }, .probe = mma8450_probe, - .remove = mma8450_remove, .id_table = mma8450_id, };