bus: bt1-apb: Include linux/io.h
PATCH 1/6 bus: bt1-apb: Include linux/io.h
It must be included since we are using readl() method here.
--- drivers/bus/bt1-apb.c | 1 + 1 file changed, 1 insertion(+)
drivers/bus/bt1-apb.c +1 -0
@@ -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>
Signature · 1 line
2.26.2
PATCH 2/6 bus: bt1-apb: Fix show/store callback identations
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.
--- drivers/bus/bt1-apb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/bus/bt1-apb.c +4 -4
@@ -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);
Signature · 1 line
2.26.2
PATCH 3/6 bus: bt1-apb: Use PTR_ERR_OR_ZERO to return from request-regs method
In reply to Serge SeminIndeed it's more optimal to use the PTR_ERR_OR_ZERO() macro there instead of having two return points.
--- drivers/bus/bt1-apb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/bus/bt1-apb.c +2 -4
@@ -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)
Signature · 1 line
2.26.2
PATCH 4/6 bus: bt1-apb: Use sysfs_streq instead of strncmp
In reply to Serge SeminThere 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.
--- drivers/bus/bt1-apb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/bt1-apb.c +2 -2
@@ -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
Signature · 1 line
2.26.2
PATCH 5/6 bus: bt1-axi: Optimize the return points in the driver
In reply to Serge SeminIt'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.
--- drivers/bus/bt1-axi.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/bus/bt1-axi.c +6 -12
@@ -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,
Signature · 1 line
2.26.2
PATCH 6/6 bus: bt1-axi: Use sysfs_streq instead of strncmp
In reply to Serge SeminThere 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.
--- drivers/bus/bt1-axi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/bt1-axi.c +2 -2
@@ -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 ;
Signature · 1 line
2.26.2