IB/umad: Refactor code to use cdev_device_add()
Refactor code to use cdev_device_add() and do other minor refactors while
modifying these functions as below.
1. Instead of returning generic -1, return an actual error for
ib_umad_init_port().
2. Introduce and use ib_umad_init_port_dev() for sm and umad char devices.
3. Instead of kobj, use more light weight kref to refcount ib_umad_device.
4. Use modern cdev_device_add() single code cut down three steps of
cdev_add(), device_create(). This further helps to move device sysfs
files to class attributes in subsequent patch.
5. Remove few empty lines while refactoring these functions.
6. Use sizeof() instead of sizeof to avoid checkpatch warning.
7. Use struct_size() for calculation of ib_umad_port.
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Jack Morgenstein <jackm@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>