mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-12 01:14:25 +00:00
RDMA/core: Implement IB device rename function
Generic implementation of IB device rename function. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
dbace111e5
commit
d21943dd19
2 changed files with 26 additions and 0 deletions
|
@ -87,6 +87,7 @@ int ib_device_register_sysfs(struct ib_device *device,
|
||||||
int (*port_callback)(struct ib_device *,
|
int (*port_callback)(struct ib_device *,
|
||||||
u8, struct kobject *));
|
u8, struct kobject *));
|
||||||
void ib_device_unregister_sysfs(struct ib_device *device);
|
void ib_device_unregister_sysfs(struct ib_device *device);
|
||||||
|
int ib_device_rename(struct ib_device *ibdev, const char *name);
|
||||||
|
|
||||||
typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port,
|
typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port,
|
||||||
struct net_device *idev, void *cookie);
|
struct net_device *idev, void *cookie);
|
||||||
|
|
|
@ -171,6 +171,31 @@ static struct ib_device *__ib_device_get_by_name(const char *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ib_device_rename(struct ib_device *ibdev, const char *name)
|
||||||
|
{
|
||||||
|
struct ib_device *device;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!strcmp(name, dev_name(&ibdev->dev)))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
mutex_lock(&device_mutex);
|
||||||
|
list_for_each_entry(device, &device_list, core_list) {
|
||||||
|
if (!strcmp(name, dev_name(&device->dev))) {
|
||||||
|
ret = -EEXIST;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = device_rename(&ibdev->dev, name);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
strlcpy(ibdev->name, name, IB_DEVICE_NAME_MAX);
|
||||||
|
out:
|
||||||
|
mutex_unlock(&device_mutex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int alloc_name(struct ib_device *ibdev, const char *name)
|
static int alloc_name(struct ib_device *ibdev, const char *name)
|
||||||
{
|
{
|
||||||
unsigned long *inuse;
|
unsigned long *inuse;
|
||||||
|
|
Loading…
Add table
Reference in a new issue