Skip to content

Commit

Permalink
nvmem: change the signature of nvmem_unregister()
Browse files Browse the repository at this point in the history
We switched the nvmem framework to using kref instead of manually
checking the current number of users in nvmem_unregister() so this
function can no longer fail. We also converted all remaining users
that still checked the return value of nvmem_unregister() to using
devm_nvmem_register(). Make the routine return void.

Signed-off-by: Bartosz Golaszewski <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
brgl authored and gregkh committed Sep 28, 2018
1 parent 7d9f9f2 commit bf58e88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
8 changes: 2 additions & 6 deletions drivers/nvmem/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,20 +553,16 @@ static void nvmem_device_release(struct kref *kref)
* nvmem_unregister() - Unregister previously registered nvmem device
*
* @nvmem: Pointer to previously registered nvmem device.
*
* Return: Will be an negative on error or a zero on success.
*/
int nvmem_unregister(struct nvmem_device *nvmem)
void nvmem_unregister(struct nvmem_device *nvmem)
{
kref_put(&nvmem->refcnt, nvmem_device_release);

return 0;
}
EXPORT_SYMBOL_GPL(nvmem_unregister);

static void devm_nvmem_release(struct device *dev, void *res)
{
WARN_ON(nvmem_unregister(*(struct nvmem_device **)res));
nvmem_unregister(*(struct nvmem_device **)res);
}

/**
Expand Down
9 changes: 3 additions & 6 deletions include/linux/nvmem-provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct nvmem_config {
#if IS_ENABLED(CONFIG_NVMEM)

struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
int nvmem_unregister(struct nvmem_device *nvmem);
void nvmem_unregister(struct nvmem_device *nvmem);

struct nvmem_device *devm_nvmem_register(struct device *dev,
const struct nvmem_config *cfg);
Expand All @@ -87,10 +87,7 @@ static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
return ERR_PTR(-ENOSYS);
}

static inline int nvmem_unregister(struct nvmem_device *nvmem)
{
return -ENOSYS;
}
static inline void nvmem_unregister(struct nvmem_device *nvmem) {}

static inline struct nvmem_device *
devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
Expand All @@ -101,7 +98,7 @@ devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
static inline int
devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
{
return nvmem_unregister(nvmem);
return -ENOSYS;

}

Expand Down

0 comments on commit bf58e88

Please sign in to comment.