Skip to contentSkip to conversation

nubus: Rename pde_data var to fix conflict with external function

PATCH In review Geert Uytterhoeven 4 participants 4 messages Nov 25, 2021 Nubus

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nubus: Rename pde_data var to fix conflict with external function

In file included from drivers/nubus/proc.c:24:
drivers/nubus/proc.c: In function ‘nubus_proc_rsrc_show’:
./include/linux/proc_fs.h:123:21: error: called object ‘pde_data’ is not a function or function pointer
123 | #define PDE_DATA(i) pde_data(i)

      |                     ^~~~~~~~
drivers/nubus/proc.c:112:13: note: in expansion of macro ‘PDE_DATA’
  112 |  pde_data = PDE_DATA(inode);
      |             ^~~~~~~~

drivers/nubus/proc.c:110:30: note: declared here
110 | struct nubus_proc_pde_data *pde_data;
| ^~~~~~~~

Fix this by renaming the local variable to "pde". Do this everywhere for consistency.

Reported-by [email protected]
Fixes e7e935db128e724f ("fs: proc: store PDE()->data into inode->i_private")

---
Not fixed by commit 5de6353a96bec91d ("proc: remove PDE_DATA() completely"), which just removes the macro indirection.

---
 drivers/nubus/proc.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/nubus/proc.c +18 -18
index 22fb11da519bfc43..aff1c5d257cd8183 100644
@@ -93,30 +93,30 @@ struct nubus_proc_pde_data {
 static struct nubus_proc_pde_data *
 nubus_proc_alloc_pde_data(unsigned char *ptr, unsigned int size)
 {
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
-	pde_data = kmalloc(sizeof(*pde_data), GFP_KERNEL);
-	if (!pde_data)
+	pde = kmalloc(sizeof(*pde), GFP_KERNEL);
+	if (!pde)
 		return NULL;
 
-	pde_data->res_ptr = ptr;
-	pde_data->res_size = size;
-	return pde_data;
+	pde->res_ptr = ptr;
+	pde->res_size = size;
+	return pde;
 }
 
 static int nubus_proc_rsrc_show(struct seq_file *m, void *v)
 {
 	struct inode *inode = m->private;
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
-	pde_data = pde_data(inode);
-	if (!pde_data)
+	pde = pde_data(inode);
+	if (!pde)
 		return 0;
 
-	if (pde_data->res_size > m->size)
+	if (pde->res_size > m->size)
 		return -EFBIG;
 
-	if (pde_data->res_size) {
+	if (pde->res_size) {
 		int lanes = (int)proc_get_parent_data(inode);
 		struct nubus_dirent ent;
 
@@ -124,11 +124,11 @@ static int nubus_proc_rsrc_show(struct seq_file *m, void *v)
 			return 0;
 
 		ent.mask = lanes;
-		ent.base = pde_data->res_ptr;
+		ent.base = pde->res_ptr;
 		ent.data = 0;
-		nubus_seq_write_rsrc_mem(m, &ent, pde_data->res_size);
+		nubus_seq_write_rsrc_mem(m, &ent, pde->res_size);
 	} else {
-		unsigned int data = (unsigned int)pde_data->res_ptr;
+		unsigned int data = (unsigned int)pde->res_ptr;
 
 		seq_putc(m, data >> 16);
 		seq_putc(m, data >> 8);
@@ -142,18 +142,18 @@ void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir,
 			     unsigned int size)
 {
 	char name[9];
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
 	if (!procdir)
 		return;
 
 	snprintf(name, sizeof(name), "%x", ent->type);
 	if (size)
-		pde_data = nubus_proc_alloc_pde_data(nubus_dirptr(ent), size);
+		pde = nubus_proc_alloc_pde_data(nubus_dirptr(ent), size);
 	else
-		pde_data = NULL;
+		pde = NULL;
 	proc_create_single_data(name, S_IFREG | 0444, procdir,
-			nubus_proc_rsrc_show, pde_data);
+			nubus_proc_rsrc_show, pde);
 }
 
 void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Geert Uytterhoeven

In file included from drivers/nubus/proc.c:24:
drivers/nubus/proc.c: In function ‘nubus_proc_rsrc_show’:
./include/linux/proc_fs.h:123:21: error: called object ‘pde_data’ is not a function or function pointer
123 | #define PDE_DATA(i) pde_data(i)

      |                     ^~~~~~~~
drivers/nubus/proc.c:112:13: note: in expansion of macro ‘PDE_DATA’
  112 |  pde_data = PDE_DATA(inode);
      |             ^~~~~~~~

drivers/nubus/proc.c:110:30: note: declared here
110 | struct nubus_proc_pde_data *pde_data;
| ^~~~~~~~

Quoted 5 lines

Fix this by renaming the local variable to "pde". Do this everywhere for consistency.

Reported-by [email protected]
Fixes e7e935db128e724f ("fs: proc: store PDE()->data into inode->i_private")

Since the commit ID is not stable, Fixes tag is unnecessary.

Quoted 5 lines

---
Not fixed by commit 5de6353a96bec91d ("proc: remove PDE_DATA() completely"), which just removes the macro indirection.
---

My bad. I didn't realize this situation. Thanks for fixing this.

Thanks.

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Geert Uytterhoeven
Quoted 12 lines · Geert Uytterhoeven

In file included from drivers/nubus/proc.c:24:
drivers/nubus/proc.c: In function ‘nubus_proc_rsrc_show’:
./include/linux/proc_fs.h:123:21: error: called object ‘pde_data’ is not a function or function pointer
123 | #define PDE_DATA(i) pde_data(i)

      |                     ^~~~~~~~
drivers/nubus/proc.c:112:13: note: in expansion of macro ‘PDE_DATA’
  112 |  pde_data = PDE_DATA(inode);
      |             ^~~~~~~~

drivers/nubus/proc.c:110:30: note: declared here
110 | struct nubus_proc_pde_data *pde_data;
| ^~~~~~~~

Quoted 6 lines

Fix this by renaming the local variable to "pde". Do this everywhere for consistency.

Reported-by [email protected]
Fixes e7e935db128e724f ("fs: proc: store PDE()->data into inode->i_private")
Quoted 92 lines

---
Not fixed by commit 5de6353a96bec91d ("proc: remove PDE_DATA() completely"), which just removes the macro indirection.

---
 drivers/nubus/proc.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/nubus/proc.c +18 -18
index 22fb11da519bfc43..aff1c5d257cd8183 100644
@@ -93,30 +93,30 @@ struct nubus_proc_pde_data {
 static struct nubus_proc_pde_data *
 nubus_proc_alloc_pde_data(unsigned char *ptr, unsigned int size)
 {
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
-	pde_data = kmalloc(sizeof(*pde_data), GFP_KERNEL);
-	if (!pde_data)
+	pde = kmalloc(sizeof(*pde), GFP_KERNEL);
+	if (!pde)
 		return NULL;
 
-	pde_data->res_ptr = ptr;
-	pde_data->res_size = size;
-	return pde_data;
+	pde->res_ptr = ptr;
+	pde->res_size = size;
+	return pde;
 }
 
 static int nubus_proc_rsrc_show(struct seq_file *m, void *v)
 {
 	struct inode *inode = m->private;
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
-	pde_data = pde_data(inode);
-	if (!pde_data)
+	pde = pde_data(inode);
+	if (!pde)
 		return 0;
 
-	if (pde_data->res_size > m->size)
+	if (pde->res_size > m->size)
 		return -EFBIG;
 
-	if (pde_data->res_size) {
+	if (pde->res_size) {
 		int lanes = (int)proc_get_parent_data(inode);
 		struct nubus_dirent ent;
 
@@ -124,11 +124,11 @@ static int nubus_proc_rsrc_show(struct seq_file *m, void *v)
 			return 0;
 
 		ent.mask = lanes;
-		ent.base = pde_data->res_ptr;
+		ent.base = pde->res_ptr;
 		ent.data = 0;
-		nubus_seq_write_rsrc_mem(m, &ent, pde_data->res_size);
+		nubus_seq_write_rsrc_mem(m, &ent, pde->res_size);
 	} else {
-		unsigned int data = (unsigned int)pde_data->res_ptr;
+		unsigned int data = (unsigned int)pde->res_ptr;
 
 		seq_putc(m, data >> 16);
 		seq_putc(m, data >> 8);
@@ -142,18 +142,18 @@ void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir,
 			     unsigned int size)
 {
 	char name[9];
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
 	if (!procdir)
 		return;
 
 	snprintf(name, sizeof(name), "%x", ent->type);
 	if (size)
-		pde_data = nubus_proc_alloc_pde_data(nubus_dirptr(ent), size);
+		pde = nubus_proc_alloc_pde_data(nubus_dirptr(ent), size);
 	else
-		pde_data = NULL;
+		pde = NULL;
 	proc_create_single_data(name, S_IFREG | 0444, procdir,
-			nubus_proc_rsrc_show, pde_data);
+			nubus_proc_rsrc_show, pde);
 }
 
 void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,
#3 lore raw
In reply to Geert Uytterhoeven

Hi all,

Quoted 100 lines · On Thu, 25 Nov 2021 09:38:08 +0100 Geert Uytterhoeven <[email protected]>…

In file included from drivers/nubus/proc.c:24:
drivers/nubus/proc.c: In function ‘nubus_proc_rsrc_show’:
./include/linux/proc_fs.h:123:21: error: called object ‘pde_data’ is not a function or function pointer
123 | #define PDE_DATA(i) pde_data(i)

      |                     ^~~~~~~~
drivers/nubus/proc.c:112:13: note: in expansion of macro ‘PDE_DATA’
  112 |  pde_data = PDE_DATA(inode);
      |             ^~~~~~~~

drivers/nubus/proc.c:110:30: note: declared here
110 | struct nubus_proc_pde_data *pde_data;
| ^~~~~~~~

Fix this by renaming the local variable to "pde". Do this everywhere for consistency.

Reported-by [email protected]
Fixes e7e935db128e724f ("fs: proc: store PDE()->data into inode->i_private")

---
Not fixed by commit 5de6353a96bec91d ("proc: remove PDE_DATA() completely"), which just removes the macro indirection.

---
 drivers/nubus/proc.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/nubus/proc.c +15 -16
index 22fb11da519bfc43..aff1c5d257cd8183 100644
@@ -93,30 +93,30 @@ struct nubus_proc_pde_data {
 static struct nubus_proc_pde_data *
 nubus_proc_alloc_pde_data(unsigned char *ptr, unsigned int size)
 {
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
-	pde_data = kmalloc(sizeof(*pde_data), GFP_KERNEL);
-	if (!pde_data)
+	pde = kmalloc(sizeof(*pde), GFP_KERNEL);
+	if (!pde)
 		return NULL;
 
-	pde_data->res_ptr = ptr;
-	pde_data->res_size = size;
-	return pde_data;
+	pde->res_ptr = ptr;
+	pde->res_size = size;
+	return pde;
 }
 
 static int nubus_proc_rsrc_show(struct seq_file *m, void *v)
 {
 	struct inode *inode = m->private;
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
-	pde_data = pde_data(inode);
-	if (!pde_data)
+	pde = pde_data(inode);
+	if (!pde)
 		return 0;
 
-	if (pde_data->res_size > m->size)
+	if (pde->res_size > m->size)
 		return -EFBIG;
 
-	if (pde_data->res_size) {
+	if (pde->res_size) {
 		int lanes = (int)proc_get_parent_data(inode);
 		struct nubus_dirent ent;
 
@@ -124,11 +124,11 @@ static int nubus_proc_rsrc_show(struct seq_file *m, void *v)
 			return 0;
 
 		ent.mask = lanes;
-		ent.base = pde_data->res_ptr;
+		ent.base = pde->res_ptr;
 		ent.data = 0;
-		nubus_seq_write_rsrc_mem(m, &ent, pde_data->res_size);
+		nubus_seq_write_rsrc_mem(m, &ent, pde->res_size);
 	} else {
-		unsigned int data = (unsigned int)pde_data->res_ptr;
+		unsigned int data = (unsigned int)pde->res_ptr;
 
 		seq_putc(m, data >> 16);
 		seq_putc(m, data >> 8);
@@ -142,18 +142,18 @@ void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir,
 			     unsigned int size)
 {
 	char name[9];
-	struct nubus_proc_pde_data *pde_data;
+	struct nubus_proc_pde_data *pde;
 
 	if (!procdir)
 		return;
 
 	snprintf(name, sizeof(name), "%x", ent->type);
 	if (size)
-		pde_data = nubus_proc_alloc_pde_data(nubus_dirptr(ent), size);

drivers/nubus/proc.c void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir, · line 159

Quoted 10 lines
drivers/nubus/proc.c +3 -2
+		pde = nubus_proc_alloc_pde_data(nubus_dirptr(ent), size);
 	else
-		pde_data = NULL;
+		pde = NULL;
 	proc_create_single_data(name, S_IFREG | 0444, procdir,
-			nubus_proc_rsrc_show, pde_data);
+			nubus_proc_rsrc_show, pde);
 }
 
 void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,

I will apply that to linux-next today.

Signature · 2 lines
Cheers,
Stephen Rothwell