greybus: connection: clean up connection creation
Add variable for the host cport id rather than overload retval. Remove redundant automatic variable for the id map. Tested-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
2975617421
commit
7c63a827d0
|
@ -152,6 +152,7 @@ gb_connection_create_range(struct greybus_host_device *hd,
|
||||||
{
|
{
|
||||||
struct gb_connection *connection;
|
struct gb_connection *connection;
|
||||||
struct ida *id_map = &hd->cport_id_map;
|
struct ida *id_map = &hd->cport_id_map;
|
||||||
|
int hd_cport_id;
|
||||||
int retval;
|
int retval;
|
||||||
u8 major = 0;
|
u8 major = 0;
|
||||||
u8 minor = 1;
|
u8 minor = 1;
|
||||||
|
@ -170,12 +171,12 @@ gb_connection_create_range(struct greybus_host_device *hd,
|
||||||
if (!connection)
|
if (!connection)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
retval = ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL);
|
hd_cport_id = ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL);
|
||||||
if (retval < 0) {
|
if (hd_cport_id < 0) {
|
||||||
kfree(connection);
|
kfree(connection);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
connection->hd_cport_id = (u16)retval;
|
connection->hd_cport_id = hd_cport_id;
|
||||||
connection->intf_cport_id = cport_id;
|
connection->intf_cport_id = cport_id;
|
||||||
connection->hd = hd;
|
connection->hd = hd;
|
||||||
|
|
||||||
|
@ -200,8 +201,6 @@ gb_connection_create_range(struct greybus_host_device *hd,
|
||||||
|
|
||||||
retval = device_add(&connection->dev);
|
retval = device_add(&connection->dev);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
struct ida *id_map = &connection->hd->cport_id_map;
|
|
||||||
|
|
||||||
ida_simple_remove(id_map, connection->hd_cport_id);
|
ida_simple_remove(id_map, connection->hd_cport_id);
|
||||||
connection->hd_cport_id = CPORT_ID_BAD;
|
connection->hd_cport_id = CPORT_ID_BAD;
|
||||||
put_device(&connection->dev);
|
put_device(&connection->dev);
|
||||||
|
|
Loading…
Reference in New Issue