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