From patchwork Thu May 28 14:50:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11576017 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A68A913 for ; Thu, 28 May 2020 14:50:59 +0000 (UTC) Received: by mail.kernel.org (Postfix) id 341322084C; Thu, 28 May 2020 14:50:59 +0000 (UTC) Delivered-To: soc@kernel.org Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by mail.kernel.org (Postfix) with ESMTP id EBA972075F for ; Thu, 28 May 2020 14:50:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBA972075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=Sergey.Semin@baikalelectronics.ru Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 3289880307C0; Thu, 28 May 2020 14:50:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oi3CD9VmS7XJ; Thu, 28 May 2020 17:50:57 +0300 (MSK) From: Serge Semin To: Arnd Bergmann List-Id: CC: Serge Semin , Serge Semin , Alexey Malahov , Olof Johansson , Andy Shevchenko , , Subject: [PATCH 1/6] bus: bt1-apb: Include linux/io.h Date: Thu, 28 May 2020 17:50:45 +0300 Message-ID: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) It must be included since we are using readl() method here. Signed-off-by: Serge Semin Cc: Alexey Malahov Cc: Olof Johansson Cc: Andy Shevchenko 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 #include #include +#include #include #include #include From patchwork Thu May 28 14:50:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11576019 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 827531667 for ; Thu, 28 May 2020 14:50:59 +0000 (UTC) Received: by mail.kernel.org (Postfix) id 7C82920888; Thu, 28 May 2020 14:50:59 +0000 (UTC) Delivered-To: soc@kernel.org Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by mail.kernel.org (Postfix) with ESMTP id 424912075F for ; Thu, 28 May 2020 14:50:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 424912075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=Sergey.Semin@baikalelectronics.ru Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 8A8D58030839; Thu, 28 May 2020 14:50:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d34vhtuaL0fr; Thu, 28 May 2020 17:50:58 +0300 (MSK) From: Serge Semin To: Arnd Bergmann List-Id: CC: Serge Semin , Serge Semin , Alexey Malahov , Olof Johansson , Andy Shevchenko , , Subject: [PATCH 2/6] bus: bt1-apb: Fix show/store callback identations Date: Thu, 28 May 2020 17:50:46 +0300 Message-ID: <20200528145050.5203-2-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> References: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) 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 Cc: Alexey Malahov Cc: Olof Johansson Cc: Andy Shevchenko 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); From patchwork Thu May 28 14:50:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11576021 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13ABE913 for ; Thu, 28 May 2020 14:51:00 +0000 (UTC) Received: by mail.kernel.org (Postfix) id 0BCD220897; Thu, 28 May 2020 14:51:00 +0000 (UTC) Delivered-To: soc@kernel.org Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by mail.kernel.org (Postfix) with ESMTP id C6B682075F for ; Thu, 28 May 2020 14:50:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6B682075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=Sergey.Semin@baikalelectronics.ru Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 2C5DA803083A; Thu, 28 May 2020 14:50:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KL80_MTOXDx5; Thu, 28 May 2020 17:50:58 +0300 (MSK) From: Serge Semin To: Arnd Bergmann List-Id: CC: Serge Semin , Serge Semin , Alexey Malahov , Olof Johansson , Andy Shevchenko , , Subject: [PATCH 3/6] bus: bt1-apb: Use PTR_ERR_OR_ZERO to return from request-regs method Date: Thu, 28 May 2020 17:50:47 +0300 Message-ID: <20200528145050.5203-3-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> References: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) 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 Cc: Alexey Malahov Cc: Olof Johansson Cc: Andy Shevchenko 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) From patchwork Thu May 28 14:50:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11576023 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B57A7913 for ; Thu, 28 May 2020 14:51:00 +0000 (UTC) Received: by mail.kernel.org (Postfix) id B07DC2089D; Thu, 28 May 2020 14:51:00 +0000 (UTC) Delivered-To: soc@kernel.org Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by mail.kernel.org (Postfix) with ESMTP id 7771B2075F for ; Thu, 28 May 2020 14:51:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7771B2075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=Sergey.Semin@baikalelectronics.ru Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id AA28E80307C3; Thu, 28 May 2020 14:50:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4CaP9DcyhWGQ; Thu, 28 May 2020 17:50:59 +0300 (MSK) From: Serge Semin To: Arnd Bergmann List-Id: CC: Serge Semin , Serge Semin , Alexey Malahov , Olof Johansson , Andy Shevchenko , , Subject: [PATCH 4/6] bus: bt1-apb: Use sysfs_streq instead of strncmp Date: Thu, 28 May 2020 17:50:48 +0300 Message-ID: <20200528145050.5203-4-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> References: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) 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 Cc: Alexey Malahov Cc: Olof Johansson Cc: Andy Shevchenko 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 From patchwork Thu May 28 14:50:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11576025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F1C01667 for ; Thu, 28 May 2020 14:51:01 +0000 (UTC) Received: by mail.kernel.org (Postfix) id 3A5B1208DB; Thu, 28 May 2020 14:51:01 +0000 (UTC) Delivered-To: soc@kernel.org Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by mail.kernel.org (Postfix) with ESMTP id 002B32075F for ; Thu, 28 May 2020 14:51:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 002B32075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=Sergey.Semin@baikalelectronics.ru Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 5A4EB80307CB; Thu, 28 May 2020 14:51:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 70hDWOJs3K_k; Thu, 28 May 2020 17:50:59 +0300 (MSK) From: Serge Semin To: Arnd Bergmann List-Id: CC: Serge Semin , Serge Semin , Alexey Malahov , Olof Johansson , Andy Shevchenko , , Subject: [PATCH 5/6] bus: bt1-axi: Optimize the return points in the driver Date: Thu, 28 May 2020 17:50:49 +0300 Message-ID: <20200528145050.5203-5-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> References: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) 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 Cc: Alexey Malahov Cc: Olof Johansson Cc: Andy Shevchenko 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, From patchwork Thu May 28 14:50:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11576027 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FA1A913 for ; Thu, 28 May 2020 14:51:01 +0000 (UTC) Received: by mail.kernel.org (Postfix) id 77CDF2075F; Thu, 28 May 2020 14:51:01 +0000 (UTC) Delivered-To: soc@kernel.org Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by mail.kernel.org (Postfix) with ESMTP id 3D88C208E4 for ; Thu, 28 May 2020 14:51:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D88C208E4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=Sergey.Semin@baikalelectronics.ru Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id EE29D80307C7; Thu, 28 May 2020 14:51:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q9qy3OZCWlf6; Thu, 28 May 2020 17:51:00 +0300 (MSK) From: Serge Semin To: Arnd Bergmann List-Id: CC: Serge Semin , Serge Semin , Alexey Malahov , Olof Johansson , Andy Shevchenko , , Subject: [PATCH 6/6] bus: bt1-axi: Use sysfs_streq instead of strncmp Date: Thu, 28 May 2020 17:50:50 +0300 Message-ID: <20200528145050.5203-6-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> References: <20200528145050.5203-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) 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 Cc: Alexey Malahov Cc: Olof Johansson Cc: Andy Shevchenko 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;