Skip to contentSkip to conversation

bus: hisi_lpc: remove unused head file in hisi_lpc.c

PATCH In review [email protected] 4 participants 11 messages Apr 22, 2025 – Apr 23, 2025 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH v2 1/3 bus: hisi_lpc: remove unused head file in hisi_lpc.c

In reply to a message not in the archive

From: Pei Xiao <[email protected]>

linux/console.h,linux/pci.h,linux/slab.h
are not used, removes it.

---
changes in v2: fix build error in i386

---
 drivers/bus/hisi_lpc.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/bus/hisi_lpc.c +0 -3
index 53dd1573e323..f0ef9680ad66 100644
@@ -7,17 +7,14 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/logic_pio.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
-#include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
 
 #define DRV_NAME "hisi-lpc"
 
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 3/3 lib: logic_pio: Add detailed comments for find_io_range() and logic_pio_trans_cpuaddr()

In reply to a message not in the archive

From: Pei Xiao <[email protected]>

Add comments that we were previously overlooked for find_io_range() and logic_pio_trans_cpuaddr().

---
changes in v2: fix returns differ

---
 lib/logic_pio.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
lib/logic_pio.c +17 -1
index db3ad65ccc48..44ba50386714 100644
@@ -141,7 +141,15 @@ struct logic_pio_hwaddr *find_io_range_by_fwnode(const struct fwnode_handle *fwn
 }
 EXPORT_SYMBOL(find_io_range_by_fwnode);
 
-/* Return a registered range given an input PIO token */
+/**
+ * find_io_range - find a registered range by PIO
+ * @pio: logical PIO value
+ *
+ * Traverse the io_range_list to find the registered node for @pio.
+ * The input PIO should be unique in the whole logical PIO space.
+ *
+ * Returns a registered range, NULL otherwise.
+ */
 static struct logic_pio_hwaddr *find_io_range(unsigned long pio)
 {
 	struct logic_pio_hwaddr *range, *found_range = NULL;
@@ -209,6 +217,14 @@ unsigned long logic_pio_trans_hwaddr(const struct fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL(logic_pio_trans_hwaddr);
 
+/**
+ * logic_pio_trans_cpuaddr - translate CPU address to logical PIO
+ * @addr: Host-relative CPU address
+ *
+ * translate CPU address to logical PIO
+ *
+ * Returns Logical PIO value if successful, ~0UL otherwise
+ */
 unsigned long logic_pio_trans_cpuaddr(resource_size_t addr)
 {
 	struct logic_pio_hwaddr *range;
Signature · 1 line
2.25.1
#6 lore raw

PATCH 2/3 lib: logic_pio: export function symbol in logic_pio

In reply to a message not in the archive

From: Pei Xiao <[email protected]>

export some function via EXPORT_SYMBOL, convenient to use in kernel modules in the future if somebody went to use this lib. This is one reason for this library exists.

---
 lib/logic_pio.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/logic_pio.c +6 -0
index e29496a38d06..db3ad65ccc48 100644
@@ -99,6 +99,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range)
 	mutex_unlock(&io_range_mutex);
 	return ret;
 }
+EXPORT_SYMBOL(logic_pio_register_range);
 
 /**
  * logic_pio_unregister_range - unregister a logical PIO range for a host
@@ -113,6 +114,7 @@ void logic_pio_unregister_range(struct logic_pio_hwaddr *range)
 	mutex_unlock(&io_range_mutex);
 	synchronize_rcu();
 }
+EXPORT_SYMBOL(logic_pio_unregister_range);
 
 /**
  * find_io_range_by_fwnode - find logical PIO range for given FW node
@@ -137,6 +139,7 @@ struct logic_pio_hwaddr *find_io_range_by_fwnode(const struct fwnode_handle *fwn
 
 	return found_range;
 }
+EXPORT_SYMBOL(find_io_range_by_fwnode);
 
 /* Return a registered range given an input PIO token */
 static struct logic_pio_hwaddr *find_io_range(unsigned long pio)
@@ -177,6 +180,7 @@ resource_size_t logic_pio_to_hwaddr(unsigned long pio)
 
 	return (resource_size_t)~0;
 }
+EXPORT_SYMBOL(logic_pio_to_hwaddr);
 
 /**
  * logic_pio_trans_hwaddr - translate HW address to logical PIO
@@ -203,6 +207,7 @@ unsigned long logic_pio_trans_hwaddr(const struct fwnode_handle *fwnode,
 	}
 	return addr - range->hw_start + range->io_start;
 }
+EXPORT_SYMBOL(logic_pio_trans_hwaddr);
 
 unsigned long logic_pio_trans_cpuaddr(resource_size_t addr)
 {
@@ -227,6 +232,7 @@ unsigned long logic_pio_trans_cpuaddr(resource_size_t addr)
 
 	return ~0UL;
 }
+EXPORT_SYMBOL(logic_pio_trans_cpuaddr);
 
 #if defined(CONFIG_INDIRECT_PIO) && defined(PCI_IOBASE)
 #define BUILD_LOGIC_IO(bwl, type)					\
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH 2/3 V1] lib: logic_pio: export function symbol in logic_pio

Quoted 3 lines · On Tue, Apr 22, 2025 at 07:31:59PM +0800, [email protected] wrote:

From: Pei Xiao <[email protected]>

export some function via EXPORT_SYMBOL, convenient to use in

Export

Quoted 2 lines

kernel modules in the future if somebody went to use this lib. This is one reason for this library exists.

Can we use namespace from day 1, please?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw

Re: [PATCH 2/3 V1] lib: logic_pio: export function symbol in logic_pio

In reply to [email protected]
Quoted 5 lines · On Tue, Apr 22, 2025 at 07:31:59PM +0800, [email protected] wrote:

From: Pei Xiao <[email protected]>

export some function via EXPORT_SYMBOL, convenient to use in kernel modules in the future if somebody went to use this lib. This is one reason for this library exists.

Btw, why V1?!

Really, stop sending new patches until you assure that the format is correct.

With standard tools this can be simply achieved by running:

git format-patch --cover-letter -v3 --thread ...

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
In reply to [email protected]
Quoted 4 lines · On Tue, Apr 22, 2025 at 07:31:22PM +0800, [email protected] wrote:

From: Pei Xiao <[email protected]>

linux/console.h,linux/pci.h,linux/slab.h
are not used, removes it.

There are more unused and many are missed.
My diff looks like this:

drivers/bus/hisi_lpc.c +9 -4
index 53dd1573e323..4911afdac316 100644
@@ -7,17 +7,22 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/console.h>
+#include <linux/bits.h>
 #include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/io.h>
+#include <linux/ioport.h>
 #include <linux/logic_pio.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of.h>
 #include <linux/of_platform.h>
-#include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+
+#include <asm/byteorder.h>
 
 #define DRV_NAME "hisi-lpc"
 

...

Quoted 12 lines

#include <linux/acpi.h>

(quoted diff) +0 -3
-#include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/logic_pio.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
-#include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Re: [PATCH 3/3 V2] lib: logic_pio: Add detailed comments for find_io_range() and logic_pio_trans_cpuaddr()

In reply to [email protected]
Quoted 4 lines · On Tue, Apr 22, 2025 at 07:32:19PM +0800, [email protected] wrote:

From: Pei Xiao <[email protected]>

Add comments that we were previously overlooked for find_io_range() and logic_pio_trans_cpuaddr().

You effectively ignored part of my comment. Please, run kernel-doc validator and see the result. There are missing "Return:" sections. That's what it will tell you.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH 2/3 V1] lib: logic_pio: export function symbol in logic_pio

In reply to [email protected]
Quoted 7 lines · On 22/04/2025 12:31, [email protected] wrote:

From: Pei Xiao<[email protected]>

export some function via EXPORT_SYMBOL, convenient to use in kernel modules in the future if somebody went to use this lib. This is one reason for this library exists.

No, we don't export just because someone might need this is future.

And, FWIW, EXPORT_SYMBOL_GPL is preferred.

author
#3 lore raw
In reply to Andy Shevchenko
Quoted 26 lines · Andy Shevchenko
Quoted 4 lines · On Tue, Apr 22, 2025 at 07:31:22PM +0800, [email protected] wrote:

From: Pei Xiao <[email protected]>

linux/console.h,linux/pci.h,linux/slab.h
are not used, removes it.

There are more unused and many are missed.
My diff looks like this:

drivers/bus/hisi_lpc.c +4 -2
index 53dd1573e323..4911afdac316 100644
@@ -7,17 +7,22 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/console.h>
+#include <linux/bits.h>
 #include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/io.h>
+#include <linux/ioport.h>
 #include <linux/logic_pio.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of.h>

drivers/bus/hisi_lpc.c line 25

Quoted 10 lines
drivers/bus/hisi_lpc.c +5 -2
 #include <linux/of_platform.h>
-#include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+
+#include <asm/byteorder.h>

Thanks for you help.

I have send v3 : https://lore.kernel.org/lkml/[email protected]/

You are such a helpful and technically skilled expert!

Thanks again!

Pei.

Quoted 18 lines
drivers/bus/hisi_lpc.c +0 -0
 #define DRV_NAME "hisi-lpc"
 
 
...
Quoted 13 lines

#include <linux/acpi.h>

drivers/bus/hisi_lpc.c +0 -3
-#include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/logic_pio.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
-#include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
#10 lore raw

Re: [PATCH 2/3 V1] lib: logic_pio: export function symbol in logic_pio

In reply to John Garry
Quoted 11 lines · John Garry
Quoted 7 lines · On 22/04/2025 12:31, [email protected] wrote:

From: Pei Xiao<[email protected]>

export some function via EXPORT_SYMBOL, convenient to use in kernel modules in the future if somebody went to use this lib. This is one reason for this library exists.

No, we don't export just because someone might need this is future.

Now modify it,Might it be convenient for future people?

People in the future might be able to save some effort here.

Quoted 1 line

And, FWIW, EXPORT_SYMBOL_GPL is preferred.

#11 lore raw

Re: [PATCH 2/3 V1] lib: logic_pio: export function symbol in logic_pio

Quoted 9 lines · Pei Xiao
Quoted 7 lines · John Garry
Quoted 6 lines · On 22/04/2025 12:31, [email protected] wrote:

From: Pei Xiao<[email protected]>

export some function via EXPORT_SYMBOL, convenient to use in kernel modules in the future if somebody went to use this lib. This is one reason for this library exists.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

No, we don't export just because someone might need this is future.

Now modify it,Might it be convenient for future people?

People in the future might be able to save some effort here.

No, absolutely not. The reason we don't is because it enables more out-of-tree rubbish.

Quoted 2 lines
Quoted 2 lines

And, FWIW, EXPORT_SYMBOL_GPL is preferred.