public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio
@ 2025-04-23  3:15 Pei Xiao
  2025-04-23  3:17 ` [PATCH v3 1/2] bus: hisi_lpc: clean up included headers Pei Xiao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pei Xiao @ 2025-04-23  3:15 UTC (permalink / raw)
  To: john.g.garry, linux-kernel, andriy.shevchenko, xuwei5, robh,
	xiaopeitux
  Cc: Pei Xiao

1.clean up included headers
2.add and clean up comment in logic_lib

Pei Xiao (2):
  bus: hisi_lpc: clean up included headers
  lib/logic_pio: add and clean up comment in logic_lib

 drivers/bus/hisi_lpc.c | 13 +++++++++----
 lib/logic_pio.c        | 37 ++++++++++++++++++++++++++++---------
 2 files changed, 37 insertions(+), 13 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] bus: hisi_lpc: clean up included headers
  2025-04-23  3:15 [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio Pei Xiao
@ 2025-04-23  3:17 ` Pei Xiao
  2025-04-23  3:22 ` [PATCH v3 2/2] lib/logic_pio: add and clean up comment in logic_lib Pei Xiao
  2025-04-23 16:53 ` [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Pei Xiao @ 2025-04-23  3:17 UTC (permalink / raw)
  To: xiaopei01
  Cc: andriy.shevchenko, john.g.garry, linux-kernel, robh, xiaopeitux,
	xuwei5

Revise header inclusions to improve code organization and build hygiene:

1. Remove unnecessary headers:
   - console.h (no console related functions)
   - of.h (OF specific code handled by of_platform.h)
   - pci.h (no PCI dependencies)
   - slab.h (no memory allocation helpers used)

2. Add required headers:
   - bits.h for bit manipulation macros
   - err.h for error handling helpers
   - ioport.h for I/O resource management
   - property.h for device property interfaces
   - spinlock.h for locking primitives
   - types.h for explicit type definitions
   - asm/byteorder.h for endianness handling

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
changes in v3: according to Andy Shevchenko's suggestion.
changes in v2: fix build error 
---
 drivers/bus/hisi_lpc.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c
index 53dd1573e323..4911afdac316 100644
--- a/drivers/bus/hisi_lpc.c
+++ b/drivers/bus/hisi_lpc.c
@@ -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"
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] lib/logic_pio: add and clean up comment in logic_lib
  2025-04-23  3:15 [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio Pei Xiao
  2025-04-23  3:17 ` [PATCH v3 1/2] bus: hisi_lpc: clean up included headers Pei Xiao
@ 2025-04-23  3:22 ` Pei Xiao
  2025-04-23 16:53 ` [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Pei Xiao @ 2025-04-23  3:22 UTC (permalink / raw)
  To: xiaopei01
  Cc: andriy.shevchenko, john.g.garry, linux-kernel, robh, xiaopeitux,
	xuwei5

1.Add comments that we were previously overlooked for find_io_range()
and logic_pio_trans_cpuaddr().
2.clean up other comment according to kernel-doc

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
changes in v3: add Return section add cleanup
changes in v2: Returns to Return 
---
 lib/logic_pio.c | 37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/lib/logic_pio.c b/lib/logic_pio.c
index e29496a38d06..5a080baf2001 100644
--- a/lib/logic_pio.c
+++ b/lib/logic_pio.c
@@ -24,11 +24,12 @@ static DEFINE_MUTEX(io_range_mutex);
  * logic_pio_register_range - register logical PIO range for a host
  * @new_range: pointer to the IO range to be registered.
  *
- * Returns 0 on success, the error code in case of failure.
+ * Register a new IO range node in the IO range list.
+ *
+ * Return: 0 on success, the error code in case of failure.
  * If the range already exists, -EEXIST will be returned, which should be
  * considered a success.
  *
- * Register a new IO range node in the IO range list.
  */
 int logic_pio_register_range(struct logic_pio_hwaddr *new_range)
 {
@@ -118,9 +119,9 @@ void logic_pio_unregister_range(struct logic_pio_hwaddr *range)
  * find_io_range_by_fwnode - find logical PIO range for given FW node
  * @fwnode: FW node handle associated with logical PIO range
  *
- * Returns pointer to node on success, NULL otherwise.
- *
  * Traverse the io_range_list to find the registered node for @fwnode.
+ *
+ * Return: pointer to node on success, NULL otherwise.
  */
 struct logic_pio_hwaddr *find_io_range_by_fwnode(const struct fwnode_handle *fwnode)
 {
@@ -138,7 +139,15 @@ struct logic_pio_hwaddr *find_io_range_by_fwnode(const struct fwnode_handle *fwn
 	return found_range;
 }
 
-/* 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.
+ *
+ * Return: a registered range, NULL otherwise.
+ */
 static struct logic_pio_hwaddr *find_io_range(unsigned long pio)
 {
 	struct logic_pio_hwaddr *range, *found_range = NULL;
@@ -162,10 +171,10 @@ static struct logic_pio_hwaddr *find_io_range(unsigned long pio)
  * logic_pio_to_hwaddr - translate logical PIO to HW address
  * @pio: logical PIO value
  *
- * Returns HW address if valid, ~0 otherwise.
- *
  * Translate the input logical PIO to the corresponding hardware address.
  * The input PIO should be unique in the whole logical PIO space.
+ *
+ * Return: HW address if valid, ~0 otherwise.
  */
 resource_size_t logic_pio_to_hwaddr(unsigned long pio)
 {
@@ -179,12 +188,14 @@ resource_size_t logic_pio_to_hwaddr(unsigned long pio)
 }
 
 /**
- * logic_pio_trans_hwaddr - translate HW address to logical PIO
+ * logic_pio_trans_hwaddr - translate HW address to logical PIO by fwnode
  * @fwnode: FW node reference for the host
  * @addr: Host-relative HW address
  * @size: size to translate
  *
- * Returns Logical PIO value if successful, ~0UL otherwise
+ * Translate HW address by fwnode to logical PIO
+ *
+ * Return: Logical PIO value if successful, ~0UL otherwise
  */
 unsigned long logic_pio_trans_hwaddr(const struct fwnode_handle *fwnode,
 				     resource_size_t addr, resource_size_t size)
@@ -204,6 +215,14 @@ unsigned long logic_pio_trans_hwaddr(const struct fwnode_handle *fwnode,
 	return addr - range->hw_start + range->io_start;
 }
 
+/**
+ * logic_pio_trans_cpuaddr - translate CPU address to logical PIO
+ * @addr: Host-relative CPU address
+ *
+ * translate CPU address to logical PIO
+ *
+ * Return: Logical PIO value if successful, ~0UL otherwise
+ */
 unsigned long logic_pio_trans_cpuaddr(resource_size_t addr)
 {
 	struct logic_pio_hwaddr *range;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio
  2025-04-23  3:15 [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio Pei Xiao
  2025-04-23  3:17 ` [PATCH v3 1/2] bus: hisi_lpc: clean up included headers Pei Xiao
  2025-04-23  3:22 ` [PATCH v3 2/2] lib/logic_pio: add and clean up comment in logic_lib Pei Xiao
@ 2025-04-23 16:53 ` Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2025-04-23 16:53 UTC (permalink / raw)
  To: Pei Xiao; +Cc: john.g.garry, linux-kernel, xuwei5, robh, xiaopeitux

On Wed, Apr 23, 2025 at 11:15:34AM +0800, Pei Xiao wrote:
> 1.clean up included headers
> 2.add and clean up comment in logic_lib

LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-23 16:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23  3:15 [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio Pei Xiao
2025-04-23  3:17 ` [PATCH v3 1/2] bus: hisi_lpc: clean up included headers Pei Xiao
2025-04-23  3:22 ` [PATCH v3 2/2] lib/logic_pio: add and clean up comment in logic_lib Pei Xiao
2025-04-23 16:53 ` [PATCH v3 0/2] clean up hisi_lpc and lib/logic_pio Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox