diff --git a/drivers/bus/mhi/core/mhi_init.c b/drivers/bus/mhi/core/mhi_init.c index 408eec3e1cc4..59aa6ac6358c 100755 --- a/drivers/bus/mhi/core/mhi_init.c +++ b/drivers/bus/mhi/core/mhi_init.c @@ -330,12 +330,24 @@ static const struct attribute_group mhi_sysfs_group = { .attrs = mhi_sysfs_attrs, }; -void mhi_create_sysfs(struct mhi_controller *mhi_cntrl) +int mhi_create_sysfs(struct mhi_controller *mhi_cntrl) { - sysfs_create_group(&mhi_cntrl->mhi_dev->dev.kobj, &mhi_sysfs_group); - if (mhi_cntrl->mhi_tsync) - sysfs_create_group(&mhi_cntrl->mhi_dev->dev.kobj, - &mhi_tsync_group); + int ret; + + ret = sysfs_create_group(&mhi_cntrl->mhi_dev->dev.kobj, + &mhi_sysfs_group); + if (ret) + return ret; + + if (mhi_cntrl->mhi_tsync) { + ret = sysfs_create_group(&mhi_cntrl->mhi_dev->dev.kobj, + &mhi_tsync_group); + if (ret) + sysfs_remove_group(&mhi_cntrl->mhi_dev->dev.kobj, + &mhi_sysfs_group); + } + + return ret; } void mhi_destroy_sysfs(struct mhi_controller *mhi_cntrl) diff --git a/drivers/bus/mhi/core/mhi_internal.h b/drivers/bus/mhi/core/mhi_internal.h index 3efe2ef28298..9743cf0043df 100755 --- a/drivers/bus/mhi/core/mhi_internal.h +++ b/drivers/bus/mhi/core/mhi_internal.h @@ -848,7 +848,7 @@ int mhi_get_capability_offset(struct mhi_controller *mhi_cntrl, u32 capability, u32 *offset); void *mhi_to_virtual(struct mhi_ring *ring, dma_addr_t addr); int mhi_init_sfr(struct mhi_controller *mhi_cntrl); -void mhi_create_sysfs(struct mhi_controller *mhi_cntrl); +int mhi_create_sysfs(struct mhi_controller *mhi_cntrl); void mhi_destroy_sysfs(struct mhi_controller *mhi_cntrl); int mhi_early_notify_device(struct device *dev, void *data); void mhi_write_reg_offload(struct mhi_controller *mhi_cntrl, diff --git a/drivers/bus/mhi/core/mhi_pm.c b/drivers/bus/mhi/core/mhi_pm.c index 54fec3cd1056..784b49f336c5 100755 --- a/drivers/bus/mhi/core/mhi_pm.c +++ b/drivers/bus/mhi/core/mhi_pm.c @@ -540,7 +540,11 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl) mhi_special_events_pending(mhi_cntrl); /* setup sysfs nodes for userspace votes */ - mhi_create_sysfs(mhi_cntrl); + ret = mhi_create_sysfs(mhi_cntrl); + if (ret) { + MHI_ERR("Failed to create sysfs nodes with ret:%d\n", ret); + goto error_sysfs_create; + } mhi_special_events_pending(mhi_cntrl); @@ -549,6 +553,7 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl) /* add supported devices */ mhi_create_devices(mhi_cntrl); +error_sysfs_create: read_lock_bh(&mhi_cntrl->pm_lock); error_mission_mode: