mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
lightnvm: allow targets to use sysfs
In order to register through the sysfs interface, a driver needs to know its kobject. On a disk structure, this happens when the partition information is added (device_add_disk), which for lightnvm takes place after the target has been initialized. This means that on target initialization, the kboject has not been created yet. This patch adds a target function to let targets initialize their own kboject as a child of the disk kobject. Signed-off-by: Javier González <[email protected]> Added exit typedef and passed gendisk instead of void pointer for exit. Signed-off-by: Matias Bjørling <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
deccf5a52e
commit
9a69b0ed62
2 changed files with 15 additions and 0 deletions
|
|
@ -289,6 +289,9 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
|
|||
set_capacity(tdisk, tt->capacity(targetdata));
|
||||
add_disk(tdisk);
|
||||
|
||||
if (tt->sysfs_init && tt->sysfs_init(tdisk))
|
||||
goto err_sysfs;
|
||||
|
||||
t->type = tt;
|
||||
t->disk = tdisk;
|
||||
t->dev = tgt_dev;
|
||||
|
|
@ -298,6 +301,9 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
|
|||
mutex_unlock(&dev->mlock);
|
||||
|
||||
return 0;
|
||||
err_sysfs:
|
||||
if (tt->exit)
|
||||
tt->exit(targetdata);
|
||||
err_init:
|
||||
put_disk(tdisk);
|
||||
err_queue:
|
||||
|
|
@ -320,6 +326,9 @@ static void __nvm_remove_target(struct nvm_target *t)
|
|||
del_gendisk(tdisk);
|
||||
blk_cleanup_queue(q);
|
||||
|
||||
if (tt->sysfs_exit)
|
||||
tt->sysfs_exit(tdisk);
|
||||
|
||||
if (tt->exit)
|
||||
tt->exit(tdisk->private_data);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue