linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] bus: bt1-apb: Include linux/io.h
@ 2020-05-28 14:50 Serge Semin
  2020-05-28 14:50 ` [PATCH 2/6] bus: bt1-apb: Fix show/store callback identations Serge Semin
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Serge Semin @ 2020-05-28 14:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Serge Semin, Serge Semin, Alexey Malahov, Olof Johansson,
	Andy Shevchenko, soc, linux-kernel

It must be included since we are using readl() method here.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Olof Johansson <olof@lixom.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: soc@kernel.org
---
 drivers/bus/bt1-apb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c
index abccd1dfc544..839f1add2236 100644
--- a/drivers/bus/bt1-apb.c
+++ b/drivers/bus/bt1-apb.c
@@ -15,6 +15,7 @@
 #include <linux/atomic.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/nmi.h>
 #include <linux/of.h>
 #include <linux/regmap.h>
-- 
2.26.2


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

* [PATCH 2/6] bus: bt1-apb: Fix show/store callback identations
  2020-05-28 14:50 [PATCH 1/6] bus: bt1-apb: Include linux/io.h Serge Semin
@ 2020-05-28 14:50 ` Serge Semin
  2020-05-28 14:50 ` [PATCH 3/6] bus: bt1-apb: Use PTR_ERR_OR_ZERO to return from request-regs method Serge Semin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Serge Semin @ 2020-05-28 14:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Serge Semin, Serge Semin, Alexey Malahov, Olof Johansson,
	Andy Shevchenko, soc, linux-kernel

After fixing the sysfs calback return value the functions argumnets
identations have been left as before the fix. That made the
argments declarations being unaligned with respect to the space
surrounded by the parentheses.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Olof Johansson <olof@lixom.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: soc@kernel.org
---
 drivers/bus/bt1-apb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c
index 839f1add2236..59ec5e7077e8 100644
--- a/drivers/bus/bt1-apb.c
+++ b/drivers/bus/bt1-apb.c
@@ -311,15 +311,15 @@ static ssize_t timeout_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(timeout);
 
-static ssize_t inject_error_show(struct device *dev, struct device_attribute *attr,
-			     char *buf)
+static ssize_t inject_error_show(struct device *dev,
+				 struct device_attribute *attr, char *buf)
 {
 	return scnprintf(buf, PAGE_SIZE, "Error injection: nodev irq\n");
 }
 
 static ssize_t inject_error_store(struct device *dev,
-			      struct device_attribute *attr,
-			      const char *data, size_t count)
+				  struct device_attribute *attr,
+				  const char *data, size_t count)
 {
 	struct bt1_apb *apb = dev_get_drvdata(dev);
 
-- 
2.26.2


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

* [PATCH 3/6] bus: bt1-apb: Use PTR_ERR_OR_ZERO to return from request-regs method
  2020-05-28 14:50 [PATCH 1/6] bus: bt1-apb: Include linux/io.h Serge Semin
  2020-05-28 14:50 ` [PATCH 2/6] bus: bt1-apb: Fix show/store callback identations Serge Semin
@ 2020-05-28 14:50 ` Serge Semin
  2020-05-28 14:50 ` [PATCH 4/6] bus: bt1-apb: Use sysfs_streq instead of strncmp Serge Semin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Serge Semin @ 2020-05-28 14:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Serge Semin, Serge Semin, Alexey Malahov, Olof Johansson,
	Andy Shevchenko, soc, linux-kernel

Indeed it's more optimal to use the PTR_ERR_OR_ZERO() macro there instead
of having two return points.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Olof Johansson <olof@lixom.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: soc@kernel.org
---
 drivers/bus/bt1-apb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c
index 59ec5e7077e8..7e57fc2af745 100644
--- a/drivers/bus/bt1-apb.c
+++ b/drivers/bus/bt1-apb.c
@@ -164,12 +164,10 @@ static int bt1_apb_request_regs(struct bt1_apb *apb)
 	}
 
 	apb->res = devm_platform_ioremap_resource_byname(pdev, "nodev");
-	if (IS_ERR(apb->res)) {
+	if (IS_ERR(apb->res))
 		dev_err(apb->dev, "Couldn't map reserved region\n");
-		return PTR_ERR(apb->res);
-	}
 
-	return 0;
+	return PTR_ERR_OR_ZERO(apb->res);
 }
 
 static int bt1_apb_request_rst(struct bt1_apb *apb)
-- 
2.26.2


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

* [PATCH 4/6] bus: bt1-apb: Use sysfs_streq instead of strncmp
  2020-05-28 14:50 [PATCH 1/6] bus: bt1-apb: Include linux/io.h Serge Semin
  2020-05-28 14:50 ` [PATCH 2/6] bus: bt1-apb: Fix show/store callback identations Serge Semin
  2020-05-28 14:50 ` [PATCH 3/6] bus: bt1-apb: Use PTR_ERR_OR_ZERO to return from request-regs method Serge Semin
@ 2020-05-28 14:50 ` Serge Semin
  2020-05-28 14:50 ` [PATCH 5/6] bus: bt1-axi: Optimize the return points in the driver Serge Semin
  2020-05-28 14:50 ` [PATCH 6/6] bus: bt1-axi: Use sysfs_streq instead of strncmp Serge Semin
  4 siblings, 0 replies; 6+ messages in thread
From: Serge Semin @ 2020-05-28 14:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Serge Semin, Serge Semin, Alexey Malahov, Olof Johansson,
	Andy Shevchenko, soc, linux-kernel

There is a ready-to-use method to compare a retrieved from a sysfs node
string with another string. It treats both NUL and newline-then-NUL as
equivalent string terminations. So use it instead of manually truncating
the line length in the strncmp() method.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Olof Johansson <olof@lixom.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: soc@kernel.org
---
 drivers/bus/bt1-apb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c
index 7e57fc2af745..b25ff941e7c7 100644
--- a/drivers/bus/bt1-apb.c
+++ b/drivers/bus/bt1-apb.c
@@ -325,9 +325,9 @@ static ssize_t inject_error_store(struct device *dev,
 	 * Either dummy read from the unmapped address in the APB IO area
 	 * or manually set the IRQ status.
 	 */
-	if (!strncmp(data, "nodev", 5))
+	if (sysfs_streq(data, "nodev"))
 		readl(apb->res);
-	else if (!strncmp(data, "irq", 3))
+	else if (sysfs_streq(data, "irq"))
 		regmap_update_bits(apb->regs, APB_EHB_ISR, APB_EHB_ISR_PENDING,
 				   APB_EHB_ISR_PENDING);
 	else
-- 
2.26.2


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

* [PATCH 5/6] bus: bt1-axi: Optimize the return points in the driver
  2020-05-28 14:50 [PATCH 1/6] bus: bt1-apb: Include linux/io.h Serge Semin
                   ` (2 preceding siblings ...)
  2020-05-28 14:50 ` [PATCH 4/6] bus: bt1-apb: Use sysfs_streq instead of strncmp Serge Semin
@ 2020-05-28 14:50 ` Serge Semin
  2020-05-28 14:50 ` [PATCH 6/6] bus: bt1-axi: Use sysfs_streq instead of strncmp Serge Semin
  4 siblings, 0 replies; 6+ messages in thread
From: Serge Semin @ 2020-05-28 14:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Serge Semin, Serge Semin, Alexey Malahov, Olof Johansson,
	Andy Shevchenko, soc, linux-kernel

It's better to have a single return statement where it's applicable
instead of returning from a conditional statement if-clause. Let's
do this in the request registers, clock and IRQ methods.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Olof Johansson <olof@lixom.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: soc@kernel.org
---
 drivers/bus/bt1-axi.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/bus/bt1-axi.c b/drivers/bus/bt1-axi.c
index 2005f9174118..c194d9a2bbeb 100644
--- a/drivers/bus/bt1-axi.c
+++ b/drivers/bus/bt1-axi.c
@@ -124,12 +124,10 @@ static int bt1_axi_request_regs(struct bt1_axi *axi)
 	}
 
 	axi->qos_regs = devm_platform_ioremap_resource_byname(pdev, "qos");
-	if (IS_ERR(axi->qos_regs)) {
+	if (IS_ERR(axi->qos_regs))
 		dev_err(dev, "Couldn't map AXI-bus QoS registers\n");
-		return PTR_ERR(axi->qos_regs);
-	}
 
-	return 0;
+	return PTR_ERR_OR_ZERO(axi->qos_regs);
 }
 
 static int bt1_axi_request_rst(struct bt1_axi *axi)
@@ -173,12 +171,10 @@ static int bt1_axi_request_clk(struct bt1_axi *axi)
 	}
 
 	ret = devm_add_action_or_reset(axi->dev, bt1_axi_disable_clk, axi);
-	if (ret) {
+	if (ret)
 		dev_err(axi->dev, "Can't add AXI clock disable action\n");
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int bt1_axi_request_irq(struct bt1_axi *axi)
@@ -192,12 +188,10 @@ static int bt1_axi_request_irq(struct bt1_axi *axi)
 
 	ret = devm_request_irq(axi->dev, axi->irq, bt1_axi_isr, IRQF_SHARED,
 			       "bt1-axi", axi);
-	if (ret) {
+	if (ret)
 		dev_err(axi->dev, "Couldn't request AXI EHB IRQ\n");
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static ssize_t count_show(struct device *dev,
-- 
2.26.2


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

* [PATCH 6/6] bus: bt1-axi: Use sysfs_streq instead of strncmp
  2020-05-28 14:50 [PATCH 1/6] bus: bt1-apb: Include linux/io.h Serge Semin
                   ` (3 preceding siblings ...)
  2020-05-28 14:50 ` [PATCH 5/6] bus: bt1-axi: Optimize the return points in the driver Serge Semin
@ 2020-05-28 14:50 ` Serge Semin
  4 siblings, 0 replies; 6+ messages in thread
From: Serge Semin @ 2020-05-28 14:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Serge Semin, Serge Semin, Alexey Malahov, Olof Johansson,
	Andy Shevchenko, soc, linux-kernel

There is a ready-to-use method to compare a retrieved from a sysfs node
string with another string. It treats both NUL and newline-then-NUL as
equivalent string terminations. So use it instead of manually truncating
the line length in the strncmp() method.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Olof Johansson <olof@lixom.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: soc@kernel.org
---
 drivers/bus/bt1-axi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/bt1-axi.c b/drivers/bus/bt1-axi.c
index c194d9a2bbeb..e7a6744acc7b 100644
--- a/drivers/bus/bt1-axi.c
+++ b/drivers/bus/bt1-axi.c
@@ -220,9 +220,9 @@ static ssize_t inject_error_store(struct device *dev,
 	 * error while unaligned writing - the AXI bus write error handled
 	 * by this driver.
 	 */
-	if (!strncmp(data, "bus", 3))
+	if (sysfs_streq(data, "bus"))
 		readb(axi->qos_regs);
-	else if (!strncmp(data, "unaligned", 9))
+	else if (sysfs_streq(data, "unaligned"))
 		writeb(0, axi->qos_regs);
 	else
 		return -EINVAL;
-- 
2.26.2


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

end of thread, other threads:[~2020-05-28 14:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 14:50 [PATCH 1/6] bus: bt1-apb: Include linux/io.h Serge Semin
2020-05-28 14:50 ` [PATCH 2/6] bus: bt1-apb: Fix show/store callback identations Serge Semin
2020-05-28 14:50 ` [PATCH 3/6] bus: bt1-apb: Use PTR_ERR_OR_ZERO to return from request-regs method Serge Semin
2020-05-28 14:50 ` [PATCH 4/6] bus: bt1-apb: Use sysfs_streq instead of strncmp Serge Semin
2020-05-28 14:50 ` [PATCH 5/6] bus: bt1-axi: Optimize the return points in the driver Serge Semin
2020-05-28 14:50 ` [PATCH 6/6] bus: bt1-axi: Use sysfs_streq instead of strncmp Serge Semin

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).