Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / net / ethernet / mellanox / mlxsw / minimal.c
blob3dd16267b76c5237199b5d8e37407265332748d9
1 /*
2 * drivers/net/ethernet/mellanox/mlxsw/minimal.c
3 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2016 Vadim Pasternak <vadimp@mellanox.com>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the names of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * Alternatively, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") version 2 as published by the Free
20 * Software Foundation.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
35 #include <linux/i2c.h>
36 #include <linux/kernel.h>
37 #include <linux/module.h>
38 #include <linux/mod_devicetable.h>
39 #include <linux/types.h>
41 #include "core.h"
42 #include "i2c.h"
44 static const char mlxsw_minimal_driver_name[] = "mlxsw_minimal";
46 static const struct mlxsw_config_profile mlxsw_minimal_config_profile;
48 static struct mlxsw_driver mlxsw_minimal_driver = {
49 .kind = mlxsw_minimal_driver_name,
50 .priv_size = 1,
51 .profile = &mlxsw_minimal_config_profile,
54 static const struct i2c_device_id mlxsw_minimal_i2c_id[] = {
55 { "mlxsw_minimal", 0},
56 { },
59 static struct i2c_driver mlxsw_minimal_i2c_driver = {
60 .driver.name = "mlxsw_minimal",
61 .class = I2C_CLASS_HWMON,
62 .id_table = mlxsw_minimal_i2c_id,
65 static int __init mlxsw_minimal_module_init(void)
67 int err;
69 err = mlxsw_core_driver_register(&mlxsw_minimal_driver);
70 if (err)
71 return err;
73 err = mlxsw_i2c_driver_register(&mlxsw_minimal_i2c_driver);
74 if (err)
75 goto err_i2c_driver_register;
77 return 0;
79 err_i2c_driver_register:
80 mlxsw_core_driver_unregister(&mlxsw_minimal_driver);
82 return err;
85 static void __exit mlxsw_minimal_module_exit(void)
87 mlxsw_i2c_driver_unregister(&mlxsw_minimal_i2c_driver);
88 mlxsw_core_driver_unregister(&mlxsw_minimal_driver);
91 module_init(mlxsw_minimal_module_init);
92 module_exit(mlxsw_minimal_module_exit);
94 MODULE_LICENSE("Dual BSD/GPL");
95 MODULE_AUTHOR("Vadim Pasternak <vadimp@mellanox.com>");
96 MODULE_DESCRIPTION("Mellanox minimal driver");
97 MODULE_DEVICE_TABLE(i2c, mlxsw_minimal_i2c_id);