From patchwork Sat Jul 6 15:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13725864 X-Patchwork-Delegate: kw@linux.com Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A3CEA93D; Sat, 6 Jul 2024 15:07:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720278480; cv=none; b=pm54UDQK/YvQGmix1u1TYfTLELQ8FUzWQ4NXRHcvcjGxbC84TEkD5rQRJJWEf1c/diXW/mi+R5UcRwUizkOlBWM5yV5zmrM5eNEuDbGn1xFqxnOffMFqj/G2G3zeT+Dlm15o4W4IJA+gI12Zqt6JqgpDFLdnCN5rgRyH05QYrKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720278480; c=relaxed/simple; bh=GzegKvDmy28OsgYrvwumczSzNZ4lFHQDEzhh6CtatVU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tPpyfZxjOEtz7nnkTYxFLsvFtUD1Z8ZtPTHkLidttBQAdn3c0Hq8UmwiQigAZZ0F547yWZAScRmORFEw73UByERJJ6JxOU0UBz1VcNVSG5Yed66p+5Ck+WuO7CfLOQn2xpZW+LNcajvE+4vNFX+Xkk12b1jKGfxoY6NF2C8MAJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ScRftX0b; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ScRftX0b" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-367940c57ddso1555912f8f.3; Sat, 06 Jul 2024 08:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720278477; x=1720883277; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=UT9BnAFcxutpgK4IXGhba1ZOikJaXe7Gk3G+5TB5Xzw=; b=ScRftX0bwnCY2gqXDq+Fd4hiO5MtlBiDzsZGePWFDPiWBDuJkctu5tGdtiArUjtHWm NoolVhXGQ0Enf3RRlZBFUhfxvIDIZXm0+2poThy3IyZr3dJyzkZVAFMjLD8bEudOnAXV iW9xwZF/tSrCB/fuaZDUgk5DYVggwzwVl3/n9jXCT65iLp0X2tNeDqYzHtOEzB1otnCF LIWf9pQJPldljLsnkJtGtOMjjYOSpRPDIYyM+W8O+LbSSsfzJihRqen5GSpCb9Wu/FVu g1XnErPbsQi2tZW0MQh59+FKY66LRKbU3E4/R3II4llodwSCWPPGXceXf4uM0ht9OdlX 9UPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720278477; x=1720883277; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UT9BnAFcxutpgK4IXGhba1ZOikJaXe7Gk3G+5TB5Xzw=; b=ImhN61trhpJhmS0vri8piKYvUh+fSZDv/OCzfkz+5SRJCnTIehGK4qKYX2iDI2GNTZ Ch7VaZpF8MLVvbZZ+bgp3VSjciUDeMJPlmYjFTEGY1lipLGkcK9yNAIfVdBCp3dQp3cU zrSatGvbT5m1Tfp6AVIiBIe7jEpSUIBdDRjtKMDbmZZrzdy51wfR2PABm9bbzADzNgF3 57RPOKt0SMhIE8kY7kdeBQEQ+UEpNWIt+KuCnk3o0SeTC8FrtuVMOaL93Vj3oVuQdlHK tNOyR5m3MjqB4pjbMehyWpW6Na40APF5kiehi55bF1aw7WuuvFH0+LT15nQaz8Qnd4n3 NbeA== X-Forwarded-Encrypted: i=1; AJvYcCU6VxoT2kIjBp7yT0CPd2Sbjxe+YQ+KiLTx2yrFzYM4553vc8CKlz667TDNCzyge8HbsiJjaf2mP/8dBRfgsitz2AcGdhi7g8BvQC0x X-Gm-Message-State: AOJu0YwNYBIrJm0sQ+NT//NWpW4yL6ckCL8GVITIzzJj3coZWi2CoOuf gPVIKwK8bFRZ8TgVtUDtqkdp9PQZAcxDhIb4zsk7vsC42Ef9eVui X-Google-Smtp-Source: AGHT+IFNejYDpmn4Dgs5oaRMvslRRq6vk0geYOqWMt4BFT3Z/EABwywzWcNVunZ/kEoRlvkMRwFEwA== X-Received: by 2002:a05:6000:1845:b0:366:eb47:41f9 with SMTP id ffacd0b85a97d-3679dd30decmr5737214f8f.29.1720278476618; Sat, 06 Jul 2024 08:07:56 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-d11b-8ec4-ea76-796c.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:d11b:8ec4:ea76:796c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367a1805e53sm5896437f8f.22.2024.07.06.08.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jul 2024 08:07:56 -0700 (PDT) From: Javier Carrasco Date: Sat, 06 Jul 2024 17:07:46 +0200 Subject: [PATCH 1/2] PCI: kirin: use dev_err_probe() in probe error paths Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240706-pcie-kirin-dev_err_probe-v1-1-56df797fb8ee@gmail.com> References: <20240706-pcie-kirin-dev_err_probe-v1-0-56df797fb8ee@gmail.com> In-Reply-To: <20240706-pcie-kirin-dev_err_probe-v1-0-56df797fb8ee@gmail.com> To: Xiaowei Song , Binghui Wang , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Jonathan Cameron , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1720278473; l=2711; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=GzegKvDmy28OsgYrvwumczSzNZ4lFHQDEzhh6CtatVU=; b=rjiucIMo8sYfJzLoy6mNbZA0XUw5YdRZrLpXrBsKm9WzGdpNFR5qVHd0Hcr6X/ykUpqIHjvf/ F6YLNN6T3VGDP6qgHKIUtx/MYSJWX21wNJvMv9mcMikDNhaWEkHnXTg X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= dev_err_probe() is used in some probe error paths, yet the "dev_err() + return" pattern is used in some others. Use dev_err_probe() in all error paths with that construction. Suggested-by: Jonathan Cameron Signed-off-by: Javier Carrasco --- drivers/pci/controller/dwc/pcie-kirin.c | 39 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index 0a29136491b8..da8091f6b22b 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -216,10 +216,8 @@ static int hi3660_pcie_phy_start(struct hi3660_pcie_phy *phy) usleep_range(PIPE_CLK_WAIT_MIN, PIPE_CLK_WAIT_MAX); reg_val = kirin_apb_phy_readl(phy, PCIE_APB_PHY_STATUS0); - if (reg_val & PIPE_CLK_STABLE) { - dev_err(dev, "PIPE clk is not stable\n"); - return -EINVAL; - } + if (reg_val & PIPE_CLK_STABLE) + return dev_err_probe(dev, -EINVAL, "PIPE clk is not stable\n"); return 0; } @@ -371,10 +369,9 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie, if (ret < 0) return 0; - if (ret > MAX_PCI_SLOTS) { - dev_err(dev, "Too many GPIO clock requests!\n"); - return -EINVAL; - } + if (ret > MAX_PCI_SLOTS) + return dev_err_probe(dev, -EINVAL, + "Too many GPIO clock requests!\n"); pcie->n_gpio_clkreq = ret; @@ -421,16 +418,14 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie, } pcie->num_slots++; - if (pcie->num_slots > MAX_PCI_SLOTS) { - dev_err(dev, "Too many PCI slots!\n"); - return -EINVAL; - } + if (pcie->num_slots > MAX_PCI_SLOTS) + return dev_err_probe(dev, -EINVAL, + "Too many PCI slots!\n"); ret = of_pci_get_devfn(child); - if (ret < 0) { - dev_err(dev, "failed to parse devfn: %d\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, + "failed to parse devfn: %d\n", ret); slot = PCI_SLOT(ret); @@ -729,16 +724,12 @@ static int kirin_pcie_probe(struct platform_device *pdev) struct dw_pcie *pci; int ret; - if (!dev->of_node) { - dev_err(dev, "NULL node\n"); - return -EINVAL; - } + if (!dev->of_node) + return dev_err_probe(dev, -EINVAL, "NULL node\n"); data = of_device_get_match_data(dev); - if (!data) { - dev_err(dev, "OF data missing\n"); - return -EINVAL; - } + if (!data) + return dev_err_probe(dev, -EINVAL, "OF data missing\n"); kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); if (!kirin_pcie) From patchwork Sat Jul 6 15:07:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13725865 X-Patchwork-Delegate: kw@linux.com Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7ADB13AD06; Sat, 6 Jul 2024 15:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720278481; cv=none; b=bsRHEmbeY7WrHMuUw3ikNisb7+LLsT9YsAAwDdHTNE+ZWVqOOwK8rqx2TCI+K0IVA2YnGYZ9gJ1gl7crHwQtBm11tKsG/6WW1GSavQGqCFJY9Eun7XlKlF+Xy6/nYwgrTbz30ondwliGZ07h6Zk4L3YfD43MZFibdo7S2vPzwzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720278481; c=relaxed/simple; bh=Aj0FTMQ6ziAfGNoL39PuVZNWcf3cIo8t3fpEww1eCso=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q7vGkvEGgUoq4zWhU4/JfySf9XmXhz6g3a0nhXZEPX73u93g8V3EMDNPXAc/9/umH2rKeFbfPh8cb9EGJu2wy7W/W2+j4/niVb285fVumuhJ+awKoHocq5v8TD6D+jf4e+IGJlUJETb+AscDinQHE4l7zZHV1BSO50jbqjTJdAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MiHeHYf0; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MiHeHYf0" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-36796aee597so1528331f8f.1; Sat, 06 Jul 2024 08:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720278478; x=1720883278; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AjL3qyowNZJyDqoLGtKUFEYrHzdrW4lz2WRY4ZZz4uw=; b=MiHeHYf0aocvMNnZINVibEZ2cRAmXQxYi1hqu+ySLha9udeZlLPCDmD/lu90dp9HBD ynXEwfoiMONWTNpP3ZPlpetKQVvjFAV2wSdYt2aKUrcV1CYwcOs6uV/236c/oHTroT4a bqOU6w8dqiVpPXNtJXxe8+cdZ4yn0AjgJ2rDqFI6plKmm1dXiI+IZObHPrJ/gIOKCkK6 USv8lvoARWs4fqXRJcnKxGEN2CmqVC0IdaG5SYvvSX0Og/L3Dj9dlxBGca7vCdMVhHsL MiMKGcteJWZpa1Dy7ult0vKbrELcmm6nZwTGTA05SkxHqtGivPg9G1gK7mGxEB95g/NB Lt5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720278478; x=1720883278; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AjL3qyowNZJyDqoLGtKUFEYrHzdrW4lz2WRY4ZZz4uw=; b=bq/nnDdPbcPbaAkWgy50nCG5T6i7anboGIx/Qnx5XDrmdA9Bqsvd+sloQOxxxvhw0G tAa2ZJRCU9BvyU44FcwHKCaIJFmAliWDrbynqzkK/q4gky9ILj5MxNtQKAavOCVGbnLe dUGeKYyTDrwcUmlYFzjWZKvjiDk5Iiy8W9jwR6Y2YPMryyvGcM9gC4LHVKL3LfJ0Llg0 wTz0Rvc2LqCvyfQejqcya7PNWZIyD3ouJtLIZJmKtGX2V37IyQL86c23WZyFrW5bnA1u 2GhlQQa95APKAhfitP0e1tDefsXhanraJXrZlyOcNnTUR1IOql00HVuy61BnZa0gtqYQ mpXQ== X-Forwarded-Encrypted: i=1; AJvYcCUCcgSuImvudBreN0YSwP9mMbF1VNZLVW5IaZepNiD2T3yek+zYe5DZ3imDmtEtMDfLrxD0heVy8s+u9Is6QNZBkO/gz9/Tp3tP5KMW X-Gm-Message-State: AOJu0YyRJNp7vTGksJoqYlvdx+LlAwGk4CX4rtGrWoOmc2TOjb5brjJM AKYAjEVArXT8i/KaOKv7hYqt1Bmt6LK5iL/nWJBC4UsvoPCxyJl+ X-Google-Smtp-Source: AGHT+IG6jSeqx5EZbXOPart54XwPBHNDh2n6ekhDnLKyOfX6o+3EF0gaUeYCKKE1pQDgw8IwtSKPuA== X-Received: by 2002:a5d:6502:0:b0:367:9ac6:d56a with SMTP id ffacd0b85a97d-3679dd723c6mr5002757f8f.59.1720278478034; Sat, 06 Jul 2024 08:07:58 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-d11b-8ec4-ea76-796c.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:d11b:8ec4:ea76:796c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367a1805e53sm5896437f8f.22.2024.07.06.08.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jul 2024 08:07:57 -0700 (PDT) From: Javier Carrasco Date: Sat, 06 Jul 2024 17:07:47 +0200 Subject: [PATCH 2/2] PCI: kirin: use for_each_available_child_of_node_scoped() Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240706-pcie-kirin-dev_err_probe-v1-2-56df797fb8ee@gmail.com> References: <20240706-pcie-kirin-dev_err_probe-v1-0-56df797fb8ee@gmail.com> In-Reply-To: <20240706-pcie-kirin-dev_err_probe-v1-0-56df797fb8ee@gmail.com> To: Xiaowei Song , Binghui Wang , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Jonathan Cameron , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1720278473; l=1398; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=Aj0FTMQ6ziAfGNoL39PuVZNWcf3cIo8t3fpEww1eCso=; b=6m1K/lU7liwiBGvKjtNORkPhwp23OJWS4+tSb1IyB5y7ffKdbG3RhP4hrrrgTAEL3r/aXdu6v WdfjQ2GvuvdBWAbDr3mhwBoRoWq1F2n6g6EwaYYduDNR2pavO5x+UA9 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The scoped version of the macro automatically decrements the child node refcount on early exits, removing the need for the `goto` and `of_node_put()`. Signed-off-by: Javier Carrasco --- drivers/pci/controller/dwc/pcie-kirin.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index da8091f6b22b..ac0aacb11489 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -447,7 +447,7 @@ static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie, struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *child, *node = dev->of_node; + struct device_node *node = dev->of_node; void __iomem *apb_base; int ret; @@ -472,17 +472,13 @@ static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie, return ret; /* Parse OF children */ - for_each_available_child_of_node(node, child) { + for_each_available_child_of_node_scoped(node, child) { ret = kirin_pcie_parse_port(kirin_pcie, pdev, child); if (ret) - goto put_node; + return ret; } return 0; - -put_node: - of_node_put(child); - return ret; } static void kirin_pcie_sideband_dbi_w_mode(struct kirin_pcie *kirin_pcie,