0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/err.h>
0012 #include <linux/init.h>
0013 #include <linux/i2c.h>
0014 #include <linux/platform_device.h>
0015 #include <linux/mfd/wm8350/core.h>
0016 #include <linux/regmap.h>
0017 #include <linux/slab.h>
0018
0019 static int wm8350_i2c_probe(struct i2c_client *i2c,
0020 const struct i2c_device_id *id)
0021 {
0022 struct wm8350 *wm8350;
0023 struct wm8350_platform_data *pdata = dev_get_platdata(&i2c->dev);
0024 int ret = 0;
0025
0026 wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL);
0027 if (wm8350 == NULL)
0028 return -ENOMEM;
0029
0030 wm8350->regmap = devm_regmap_init_i2c(i2c, &wm8350_regmap);
0031 if (IS_ERR(wm8350->regmap)) {
0032 ret = PTR_ERR(wm8350->regmap);
0033 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
0034 ret);
0035 return ret;
0036 }
0037
0038 i2c_set_clientdata(i2c, wm8350);
0039 wm8350->dev = &i2c->dev;
0040
0041 return wm8350_device_init(wm8350, i2c->irq, pdata);
0042 }
0043
0044 static const struct i2c_device_id wm8350_i2c_id[] = {
0045 { "wm8350", 0 },
0046 { "wm8351", 0 },
0047 { "wm8352", 0 },
0048 { }
0049 };
0050
0051 static struct i2c_driver wm8350_i2c_driver = {
0052 .driver = {
0053 .name = "wm8350",
0054 .suppress_bind_attrs = true,
0055 },
0056 .probe = wm8350_i2c_probe,
0057 .id_table = wm8350_i2c_id,
0058 };
0059
0060 static int __init wm8350_i2c_init(void)
0061 {
0062 return i2c_add_driver(&wm8350_i2c_driver);
0063 }
0064
0065 subsys_initcall(wm8350_i2c_init);