minimal.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /* Copyright (c) 2016-2018 Mellanox Technologies. All rights reserved */
  3. #include <linux/i2c.h>
  4. #include <linux/kernel.h>
  5. #include <linux/module.h>
  6. #include <linux/mod_devicetable.h>
  7. #include <linux/types.h>
  8. #include "core.h"
  9. #include "i2c.h"
  10. static const char mlxsw_minimal_driver_name[] = "mlxsw_minimal";
  11. static const struct mlxsw_config_profile mlxsw_minimal_config_profile;
  12. static struct mlxsw_driver mlxsw_minimal_driver = {
  13. .kind = mlxsw_minimal_driver_name,
  14. .priv_size = 1,
  15. .profile = &mlxsw_minimal_config_profile,
  16. };
  17. static const struct i2c_device_id mlxsw_minimal_i2c_id[] = {
  18. { "mlxsw_minimal", 0},
  19. { },
  20. };
  21. static struct i2c_driver mlxsw_minimal_i2c_driver = {
  22. .driver.name = "mlxsw_minimal",
  23. .class = I2C_CLASS_HWMON,
  24. .id_table = mlxsw_minimal_i2c_id,
  25. };
  26. static int __init mlxsw_minimal_module_init(void)
  27. {
  28. int err;
  29. err = mlxsw_core_driver_register(&mlxsw_minimal_driver);
  30. if (err)
  31. return err;
  32. err = mlxsw_i2c_driver_register(&mlxsw_minimal_i2c_driver);
  33. if (err)
  34. goto err_i2c_driver_register;
  35. return 0;
  36. err_i2c_driver_register:
  37. mlxsw_core_driver_unregister(&mlxsw_minimal_driver);
  38. return err;
  39. }
  40. static void __exit mlxsw_minimal_module_exit(void)
  41. {
  42. mlxsw_i2c_driver_unregister(&mlxsw_minimal_i2c_driver);
  43. mlxsw_core_driver_unregister(&mlxsw_minimal_driver);
  44. }
  45. module_init(mlxsw_minimal_module_init);
  46. module_exit(mlxsw_minimal_module_exit);
  47. MODULE_LICENSE("Dual BSD/GPL");
  48. MODULE_AUTHOR("Vadim Pasternak <vadimp@mellanox.com>");
  49. MODULE_DESCRIPTION("Mellanox minimal driver");
  50. MODULE_DEVICE_TABLE(i2c, mlxsw_minimal_i2c_id);