From: brgl@bgdev.pl (Bartosz Golaszewski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 01/16] nvmem: remove unused APIs
Date: Fri, 7 Sep 2018 12:07:35 +0200 [thread overview]
Message-ID: <20180907100750.14564-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl>
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Remove all APIs dealing with nvmem_cell_info. There are no users and
this part of the subsystem will be reworked.
This patch temprarily disables support for non-DT users.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/nvmem/core.c | 212 ++-------------------------------
include/linux/nvmem-consumer.h | 26 ----
include/linux/nvmem-provider.h | 13 --
3 files changed, 12 insertions(+), 239 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index aa1657831b70..bb475c2688f9 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -282,23 +282,6 @@ static struct nvmem_device *of_nvmem_find(struct device_node *nvmem_np)
return to_nvmem_device(d);
}
-static struct nvmem_cell *nvmem_find_cell(const char *cell_id)
-{
- struct nvmem_cell *p;
-
- mutex_lock(&nvmem_cells_mutex);
-
- list_for_each_entry(p, &nvmem_cells, node)
- if (!strcmp(p->name, cell_id)) {
- mutex_unlock(&nvmem_cells_mutex);
- return p;
- }
-
- mutex_unlock(&nvmem_cells_mutex);
-
- return NULL;
-}
-
static void nvmem_cell_drop(struct nvmem_cell *cell)
{
mutex_lock(&nvmem_cells_mutex);
@@ -326,82 +309,6 @@ static void nvmem_cell_add(struct nvmem_cell *cell)
mutex_unlock(&nvmem_cells_mutex);
}
-static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem,
- const struct nvmem_cell_info *info,
- struct nvmem_cell *cell)
-{
- cell->nvmem = nvmem;
- cell->offset = info->offset;
- cell->bytes = info->bytes;
- cell->name = info->name;
-
- cell->bit_offset = info->bit_offset;
- cell->nbits = info->nbits;
-
- if (cell->nbits)
- cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
- BITS_PER_BYTE);
-
- if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
- dev_err(&nvmem->dev,
- "cell %s unaligned to nvmem stride %d\n",
- cell->name, nvmem->stride);
- return -EINVAL;
- }
-
- return 0;
-}
-
-/**
- * nvmem_add_cells() - Add cell information to an nvmem device
- *
- * @nvmem: nvmem device to add cells to.
- * @info: nvmem cell info to add to the device
- * @ncells: number of cells in info
- *
- * Return: 0 or negative error code on failure.
- */
-int nvmem_add_cells(struct nvmem_device *nvmem,
- const struct nvmem_cell_info *info,
- int ncells)
-{
- struct nvmem_cell **cells;
- int i, rval;
-
- cells = kcalloc(ncells, sizeof(*cells), GFP_KERNEL);
- if (!cells)
- return -ENOMEM;
-
- for (i = 0; i < ncells; i++) {
- cells[i] = kzalloc(sizeof(**cells), GFP_KERNEL);
- if (!cells[i]) {
- rval = -ENOMEM;
- goto err;
- }
-
- rval = nvmem_cell_info_to_nvmem_cell(nvmem, &info[i], cells[i]);
- if (rval) {
- kfree(cells[i]);
- goto err;
- }
-
- nvmem_cell_add(cells[i]);
- }
-
- /* remove tmp array */
- kfree(cells);
-
- return 0;
-err:
- while (i--)
- nvmem_cell_drop(cells[i]);
-
- kfree(cells);
-
- return rval;
-}
-EXPORT_SYMBOL_GPL(nvmem_add_cells);
-
/*
* nvmem_setup_compat() - Create an additional binary entry in
* drivers sys directory, to be backwards compatible with the older
@@ -516,9 +423,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
goto err_device_del;
}
- if (config->cells)
- nvmem_add_cells(nvmem, config->cells, config->ncells);
-
return nvmem;
err_device_del:
@@ -618,32 +522,19 @@ int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
EXPORT_SYMBOL(devm_nvmem_unregister);
-static struct nvmem_device *__nvmem_device_get(struct device_node *np,
- struct nvmem_cell **cellp,
- const char *cell_id)
+static struct nvmem_device *__nvmem_device_get(struct device_node *np)
{
struct nvmem_device *nvmem = NULL;
- mutex_lock(&nvmem_mutex);
-
- if (np) {
- nvmem = of_nvmem_find(np);
- if (!nvmem) {
- mutex_unlock(&nvmem_mutex);
- return ERR_PTR(-EPROBE_DEFER);
- }
- } else {
- struct nvmem_cell *cell = nvmem_find_cell(cell_id);
+ if (!np)
+ return ERR_PTR(-EINVAL);
- if (cell) {
- nvmem = cell->nvmem;
- *cellp = cell;
- }
+ mutex_lock(&nvmem_mutex);
- if (!nvmem) {
- mutex_unlock(&nvmem_mutex);
- return ERR_PTR(-ENOENT);
- }
+ nvmem = of_nvmem_find(np);
+ if (!nvmem) {
+ mutex_unlock(&nvmem_mutex);
+ return ERR_PTR(-EPROBE_DEFER);
}
nvmem->users++;
@@ -706,7 +597,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
if (!nvmem_np)
return ERR_PTR(-EINVAL);
- return __nvmem_device_get(nvmem_np, NULL, NULL);
+ return __nvmem_device_get(nvmem_np);
}
EXPORT_SYMBOL_GPL(of_nvmem_device_get);
#endif
@@ -810,18 +701,6 @@ struct nvmem_device *devm_nvmem_device_get(struct device *dev, const char *id)
}
EXPORT_SYMBOL_GPL(devm_nvmem_device_get);
-static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id)
-{
- struct nvmem_cell *cell = NULL;
- struct nvmem_device *nvmem;
-
- nvmem = __nvmem_device_get(NULL, &cell, cell_id);
- if (IS_ERR(nvmem))
- return ERR_CAST(nvmem);
-
- return cell;
-}
-
#if IS_ENABLED(CONFIG_OF)
/**
* of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
@@ -857,7 +736,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
if (!nvmem_np)
return ERR_PTR(-EINVAL);
- nvmem = __nvmem_device_get(nvmem_np, NULL, NULL);
+ nvmem = __nvmem_device_get(nvmem_np);
of_node_put(nvmem_np);
if (IS_ERR(nvmem))
return ERR_CAST(nvmem);
@@ -926,19 +805,10 @@ EXPORT_SYMBOL_GPL(of_nvmem_cell_get);
*/
struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id)
{
- struct nvmem_cell *cell;
-
- if (dev->of_node) { /* try dt first */
- cell = of_nvmem_cell_get(dev->of_node, cell_id);
- if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER)
- return cell;
- }
-
- /* NULL cell_id only allowed for device tree; invalid otherwise */
- if (!cell_id)
+ if (!dev->of_node)
return ERR_PTR(-EINVAL);
- return nvmem_cell_get_from_list(cell_id);
+ return of_nvmem_cell_get(dev->of_node, cell_id);
}
EXPORT_SYMBOL_GPL(nvmem_cell_get);
@@ -1227,64 +1097,6 @@ int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val)
}
EXPORT_SYMBOL_GPL(nvmem_cell_read_u32);
-/**
- * nvmem_device_cell_read() - Read a given nvmem device and cell
- *
- * @nvmem: nvmem device to read from.
- * @info: nvmem cell info to be read.
- * @buf: buffer pointer which will be populated on successful read.
- *
- * Return: length of successful bytes read on success and negative
- * error code on error.
- */
-ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf)
-{
- struct nvmem_cell cell;
- int rc;
- ssize_t len;
-
- if (!nvmem)
- return -EINVAL;
-
- rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
- if (rc)
- return rc;
-
- rc = __nvmem_cell_read(nvmem, &cell, buf, &len);
- if (rc)
- return rc;
-
- return len;
-}
-EXPORT_SYMBOL_GPL(nvmem_device_cell_read);
-
-/**
- * nvmem_device_cell_write() - Write cell to a given nvmem device
- *
- * @nvmem: nvmem device to be written to.
- * @info: nvmem cell info to be written.
- * @buf: buffer to be written to cell.
- *
- * Return: length of bytes written or negative error code on failure.
- * */
-int nvmem_device_cell_write(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf)
-{
- struct nvmem_cell cell;
- int rc;
-
- if (!nvmem)
- return -EINVAL;
-
- rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
- if (rc)
- return rc;
-
- return nvmem_cell_write(&cell, buf, cell.bytes);
-}
-EXPORT_SYMBOL_GPL(nvmem_device_cell_write);
-
/**
* nvmem_device_read() - Read from a given nvmem device
*
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index 4e85447f7860..7e9fb5a19d91 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -21,14 +21,6 @@ struct device_node;
struct nvmem_cell;
struct nvmem_device;
-struct nvmem_cell_info {
- const char *name;
- unsigned int offset;
- unsigned int bytes;
- unsigned int bit_offset;
- unsigned int nbits;
-};
-
#if IS_ENABLED(CONFIG_NVMEM)
/* Cell based interface */
@@ -50,10 +42,6 @@ int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset,
size_t bytes, void *buf);
int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset,
size_t bytes, void *buf);
-ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf);
-int nvmem_device_cell_write(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf);
#else
@@ -116,20 +104,6 @@ static inline void devm_nvmem_device_put(struct device *dev,
{
}
-static inline ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info,
- void *buf)
-{
- return -ENOSYS;
-}
-
-static inline int nvmem_device_cell_write(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info,
- void *buf)
-{
- return -ENOSYS;
-}
-
static inline int nvmem_device_read(struct nvmem_device *nvmem,
unsigned int offset, size_t bytes,
void *buf)
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 24def6ad09bb..cc8556e3c825 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -16,7 +16,6 @@
#include <linux/errno.h>
struct nvmem_device;
-struct nvmem_cell_info;
typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset,
void *val, size_t bytes);
typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
@@ -52,8 +51,6 @@ struct nvmem_config {
const char *name;
int id;
struct module *owner;
- const struct nvmem_cell_info *cells;
- int ncells;
bool read_only;
bool root_only;
nvmem_reg_read_t reg_read;
@@ -77,9 +74,6 @@ struct nvmem_device *devm_nvmem_register(struct device *dev,
int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem);
-int nvmem_add_cells(struct nvmem_device *nvmem,
- const struct nvmem_cell_info *info,
- int ncells);
#else
static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
@@ -105,12 +99,5 @@ devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
}
-static inline int nvmem_add_cells(struct nvmem_device *nvmem,
- const struct nvmem_cell_info *info,
- int ncells)
-{
- return -ENOSYS;
-}
-
#endif /* CONFIG_NVMEM */
#endif /* ifndef _LINUX_NVMEM_PROVIDER_H */
--
2.18.0
next prev parent reply other threads:[~2018-09-07 10:07 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 10:07 [PATCH v2 00/16] nvmem: rework of the subsystem for non-DT users Bartosz Golaszewski
2018-09-07 10:07 ` Bartosz Golaszewski [this message]
2018-09-10 7:32 ` [PATCH v2 01/16] nvmem: remove unused APIs Srinivas Kandagatla
2018-09-10 7:58 ` Bartosz Golaszewski
2018-09-10 8:09 ` Srinivas Kandagatla
2018-09-10 8:43 ` Bartosz Golaszewski
2018-09-10 9:55 ` Srinivas Kandagatla
2018-09-10 11:31 ` Bartosz Golaszewski
2018-09-10 11:47 ` Srinivas Kandagatla
2018-09-10 12:18 ` Boris Brezillon
2018-09-10 12:22 ` Bartosz Golaszewski
2018-09-10 13:23 ` Srinivas Kandagatla
2018-09-07 10:07 ` [PATCH v2 02/16] nvmem: remove the global cell list Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 03/16] nvmem: use kref Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 04/16] nvmem: lpc18xx_eeprom: use devm_nvmem_register() Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 05/16] nvmem: sunxi_sid: " Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 06/16] nvmem: mxs-ocotp: " Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 07/16] nvmem: change the signature of nvmem_unregister() Bartosz Golaszewski
2018-09-10 7:33 ` Srinivas Kandagatla
2018-09-07 10:07 ` [PATCH v2 08/16] nvmem: provide nvmem_dev_name() Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 09/16] nvmem: remove the name field from struct nvmem_device Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 10/16] nvmem: add a notifier chain Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 11/16] nvmem: add support for cell info Bartosz Golaszewski
2018-09-10 7:32 ` Srinivas Kandagatla
2018-09-10 7:36 ` Boris Brezillon
2018-09-10 8:53 ` Srinivas Kandagatla
2018-09-07 10:07 ` [PATCH v2 12/16] nvmem: resolve cells from DT at registration time Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 13/16] nvmem: add support for cell lookups from machine code Bartosz Golaszewski
2018-09-10 7:32 ` Srinivas Kandagatla
2018-09-10 8:17 ` Bartosz Golaszewski
2018-09-10 8:23 ` Boris Brezillon
2018-09-10 8:55 ` Srinivas Kandagatla
2018-09-10 9:45 ` Bartosz Golaszewski
2018-09-10 9:49 ` Boris Brezillon
2018-09-10 9:50 ` Srinivas Kandagatla
2018-09-10 11:26 ` Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 14/16] Documentation: nvmem: document cell tables and lookup entries Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 15/16] nvmem: use SPDX license identifiers Bartosz Golaszewski
2018-09-07 10:07 ` [PATCH v2 16/16] nvmem: make the naming of arguments in nvmem_cell_get() consistent Bartosz Golaszewski
2018-09-10 7:54 ` [PATCH v2 00/16] nvmem: rework of the subsystem for non-DT users Srinivas Kandagatla
2018-09-10 8:24 ` Bartosz Golaszewski
2018-09-10 10:02 ` Srinivas Kandagatla
2018-09-10 14:58 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180907100750.14564-2-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).