/* * Example stub i2c driver * * Copyright (c) 2015 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Red Hat authors: * Hans de Goede */ #include #include #include #include #include struct stub_data { struct i2c_client *client; /* Add driver data here */ }; static int stub_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct device *dev = &client->dev; struct stub_data *data; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->client = client; i2c_set_clientdata(client, data); dev_info(dev, "Stub i2c device Stub Model successfully initialized\n"); return 0; } static const struct of_device_id stub_of_match[] = { { .compatible = "stub,stub-model" }, { } }; MODULE_DEVICE_TABLE(of, stub_of_match); /* This is useless for OF-enabled devices, but it is needed by I2C subsystem */ static const struct i2c_device_id stub_i2c_id[] = { { }, }; MODULE_DEVICE_TABLE(i2c, stub_i2c_id); static struct i2c_driver stub_driver = { .driver = { .owner = THIS_MODULE, .name = "stub_stub_model", .of_match_table = stub_of_match, }, .probe = stub_probe, .id_table = stub_i2c_id, }; module_i2c_driver(stub_driver); MODULE_DESCRIPTION("Basic stub I2C driver"); MODULE_AUTHOR("Hans de Goede "); MODULE_LICENSE("GPL");