Skip to contentSkip to conversation

nvmem: hide unused nvmem_find_cell_by_index function

PATCH In review Arnd Bergmann 3 participants 3 messages Oct 2, 2018 – Oct 3, 2018 NVMEM framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmem: hide unused nvmem_find_cell_by_index function

nvmem_find_cell_by_index() is only called from inside an #ifdef, so we get a build warning without CONFIG_OF:

drivers/nvmem/core.c:496:1: error: 'nvmem_find_cell_by_index' defined but not used [-Werror=unused-function]

Move it into the same #ifdef as the caller to avoid the warning.

Fixes e888d445ac33 ("nvmem: resolve cells from DT at registration time")
---
 drivers/nvmem/core.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/nvmem/core.c +16 -16
index cc815bb2eebd..f99fb74a646e 100644
@@ -492,22 +492,6 @@ static int nvmem_add_cells_from_table(struct nvmem_device *nvmem)
 	return rval;
 }
 
-static struct nvmem_cell *
-nvmem_find_cell_by_index(struct nvmem_device *nvmem, int index)
-{
-	struct nvmem_cell *cell = NULL;
-	int i = 0;
-
-	mutex_lock(&nvmem_mutex);
-	list_for_each_entry(cell, &nvmem->cells, node) {
-		if (index == i++)
-			break;
-	}
-	mutex_unlock(&nvmem_mutex);
-
-	return cell;
-}
-
 static struct nvmem_cell *
 nvmem_find_cell_by_name(struct nvmem_device *nvmem, const char *cell_id)
 {
@@ -972,6 +956,22 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
 }
 
 #if IS_ENABLED(CONFIG_OF)
+static struct nvmem_cell *
+nvmem_find_cell_by_index(struct nvmem_device *nvmem, int index)
+{
+	struct nvmem_cell *cell = NULL;
+	int i = 0;
+
+	mutex_lock(&nvmem_mutex);
+	list_for_each_entry(cell, &nvmem->cells, node) {
+		if (index == i++)
+			break;
+	}
+	mutex_unlock(&nvmem_mutex);
+
+	return cell;
+}
+
 /**
  * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
  *
Signature · 1 line
2.18.0
#1 lore raw

wt., 2 paź 2018 o 23:11 Arnd Bergmann <[email protected]> napisał(a):

Quoted 65 lines

nvmem_find_cell_by_index() is only called from inside an #ifdef, so we get a build warning without CONFIG_OF:

drivers/nvmem/core.c:496:1: error: 'nvmem_find_cell_by_index' defined but not used [-Werror=unused-function]

Move it into the same #ifdef as the caller to avoid the warning.

Fixes e888d445ac33 ("nvmem: resolve cells from DT at registration time")
---
 drivers/nvmem/core.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/nvmem/core.c +16 -17
index cc815bb2eebd..f99fb74a646e 100644
@@ -492,22 +492,6 @@ static int nvmem_add_cells_from_table(struct nvmem_device *nvmem)
        return rval;
 }
 
-static struct nvmem_cell *
-nvmem_find_cell_by_index(struct nvmem_device *nvmem, int index)
-{
-       struct nvmem_cell *cell = NULL;
-       int i = 0;
-
-       mutex_lock(&nvmem_mutex);
-       list_for_each_entry(cell, &nvmem->cells, node) {
-               if (index == i++)
-                       break;
-       }
-       mutex_unlock(&nvmem_mutex);
-
-       return cell;
-}
-
 static struct nvmem_cell *
 nvmem_find_cell_by_name(struct nvmem_device *nvmem, const char *cell_id)
 {
@@ -972,6 +956,22 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
 }
 
 #if IS_ENABLED(CONFIG_OF)
+static struct nvmem_cell *
+nvmem_find_cell_by_index(struct nvmem_device *nvmem, int index)
+{
+       struct nvmem_cell *cell = NULL;
+       int i = 0;
+
+       mutex_lock(&nvmem_mutex);
+       list_for_each_entry(cell, &nvmem->cells, node) {
+               if (index == i++)
+                       break;
+       }
+       mutex_unlock(&nvmem_mutex);
+
+       return cell;
+}
+
 /**
  * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
  *
--
Quoted 2 lines

2.18.0

Srinivas,

I think this is even better than __maybe_unused so if you're fine I won't resend my patch tomorrow.

Thanks,
Bart

Acked-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 9 lines · Arnd Bergmann

nvmem_find_cell_by_index() is only called from inside an #ifdef, so we get a build warning without CONFIG_OF:

drivers/nvmem/core.c:496:1: error: 'nvmem_find_cell_by_index' defined but not used [-Werror=unused-function]

Move it into the same #ifdef as the caller to avoid the warning.

Fixes e888d445ac33 ("nvmem: resolve cells from DT at registration time")

Missing Reported-by: other than that..