mma7455_i2c.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * IIO accel I2C driver for Freescale MMA7455L 3-axis 10-bit accelerometer
  3. * Copyright 2015 Joachim Eastwood <manabian@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/i2c.h>
  10. #include <linux/module.h>
  11. #include <linux/regmap.h>
  12. #include "mma7455.h"
  13. static int mma7455_i2c_probe(struct i2c_client *i2c,
  14. const struct i2c_device_id *id)
  15. {
  16. struct regmap *regmap;
  17. const char *name = NULL;
  18. regmap = devm_regmap_init_i2c(i2c, &mma7455_core_regmap);
  19. if (IS_ERR(regmap))
  20. return PTR_ERR(regmap);
  21. if (id)
  22. name = id->name;
  23. return mma7455_core_probe(&i2c->dev, regmap, name);
  24. }
  25. static int mma7455_i2c_remove(struct i2c_client *i2c)
  26. {
  27. return mma7455_core_remove(&i2c->dev);
  28. }
  29. static const struct i2c_device_id mma7455_i2c_ids[] = {
  30. { "mma7455", 0 },
  31. { "mma7456", 0 },
  32. { }
  33. };
  34. MODULE_DEVICE_TABLE(i2c, mma7455_i2c_ids);
  35. static struct i2c_driver mma7455_i2c_driver = {
  36. .probe = mma7455_i2c_probe,
  37. .remove = mma7455_i2c_remove,
  38. .id_table = mma7455_i2c_ids,
  39. .driver = {
  40. .name = "mma7455-i2c",
  41. },
  42. };
  43. module_i2c_driver(mma7455_i2c_driver);
  44. MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>");
  45. MODULE_DESCRIPTION("Freescale MMA7455L I2C accelerometer driver");
  46. MODULE_LICENSE("GPL v2");