Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1235382ybs; Mon, 25 May 2020 10:27:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNyeiZ56+IgZ9V0eWouRWNaCRv9elVQijA1LU4daFZGOLSReYgDe+f4geSWrJWNvXozLrp X-Received: by 2002:a17:906:1cc6:: with SMTP id i6mr18949037ejh.552.1590427673777; Mon, 25 May 2020 10:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590427673; cv=none; d=google.com; s=arc-20160816; b=x1P+7j5H0NDKbyNJTKS3ZZ+1YpRJT+8pnn7tRwNtt0TENlW4z+EKzbOEnylWJD1gnf 1oRJmkOcXBHrcNZX9AcnkIKRcAmFQ0mGKkrZhlo+tFOtCTNXaSDUwcQRDvg4P7BvOpTR ueZmYCL/84Rqy01EPiF0KRyzCSkzR0mBO9Yi+qDQJVMyF5bAD3OaG9W0cyTQES6j7CSQ aTLC0rQjpbonBbgdEcL+mOWwVOEK9cnyyI1QMCOngk+JW9wcuCo+F1zPL1ATD6iDVwSm reBuGAeOL4YIiijWuJhdZYXk1vosKhPe6KV7Hvz1o8L8YOiuH4rYUk3sOHx38q9JlDTm mBiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=mbBog8MzvKNaCFrg6v3gH2zfw8FxJzmofUMGKb8FS/g=; b=SYi+fah3KRJNbwSCMW42le7VE5uvLCTc2eoD5w0FAlQLJQsdZbaj3ejFYee4dNsaAy MaKFwxIo+jeC7U4LxkwyvauNV3kSwY13GNr1f1lWb3Up83ekdD2lopVZzBAHLGVfzS3O coXKQvSujh6+d5mO2fe1Mk90e372XOKcSvjXkcchPbgfWf2hHbdJNn6S6JL59S6Du2rg wcjhWsKbmuoMToByZCDwu0FbSRCDe1odb/8gGzoRg8TUI70/uKGCTP0WSOMDAFdV0eMm AvkE5PqsiMb/IonAzQ4ZZFUXRniGfckdigN8cRcWPusTBPPxITWU7ySUXTU3Osuip0ge G8Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0DVJ6z9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cy16si9615522edb.442.2020.05.25.10.27.28; Mon, 25 May 2020 10:27:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0DVJ6z9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389211AbgEYJOg (ORCPT + 99 others); Mon, 25 May 2020 05:14:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389165AbgEYJOg (ORCPT ); Mon, 25 May 2020 05:14:36 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF86EC08C5C1 for ; Mon, 25 May 2020 02:14:34 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id f18so152724qkh.1 for ; Mon, 25 May 2020 02:14:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=mbBog8MzvKNaCFrg6v3gH2zfw8FxJzmofUMGKb8FS/g=; b=0DVJ6z9JKI1z7qc5wvYtWKBdWUwkPufux2KDtFjfGcSQ/HTpdUgeir5ke8EkWrN1R7 ve3AXV7RcFUNLSFRrY/oKTXPnL+Km7rbGnfX9zVZkztjocTEWi29DoZ2fwrLU7ga1XS+ cjuKR3w7aaZ8Dk6O99Yq1vWrMpSe/IhLTid3NgNnkJ1KlZKrzA9xFl2Nv/q9ho+2ud34 rTsBQp9XcHO60AIHSFIeJs+r1Dtwi2Dh5oUQvXwzAFGk1eEs/QFRZ7QrzpWNsG1A1TNL 5KCUDJ9SfSp+ljXONaUJQPltaPBLGiYWRvoO+hiUl3Fon5Kbg2JNFPnEm0PEHZpxuBr+ Bzvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=mbBog8MzvKNaCFrg6v3gH2zfw8FxJzmofUMGKb8FS/g=; b=QujRSRoMOHB0o4phtoSygKOa3X0AWyGbGRn0Hlb3lTRS3AYZUW3IFb/fYysZY7G1ZZ EEzkRfTenRbwv/tdLw7euxn8U14J/hWtAzkllXUgcEuh11XkURq+Do7y/3AEtoT+Xkr/ CEmvveldd7M/mYc9b3XpJlpsQjtvugV36E2LrkjgK8j+JZiI8IXDbdP8qntfn6snZWNF oqZoh33wgH2sH0upoPwy62NojJc7mV/JzynkZDJQY71N64m5+fd3j13UPTCYnGJ/G8S/ ewoU166LqWl45LAVwvIlI+4iMqnV2nXfrsXHcjyjxHByWESahD0EFtmtQiO0omdvyUeb FOlQ== X-Gm-Message-State: AOAM533SgiIvYHd+Zvsf/vYTW1qEptoAyFDG3jr3mzswcwkGuhvlvSM+ RjzUd7QNv3ZMEsmW080PDav5/3X4hzKaELG10x1KNw== X-Received: by 2002:a37:dd6:: with SMTP id 205mr3478129qkn.323.1590398074097; Mon, 25 May 2020 02:14:34 -0700 (PDT) MIME-Version: 1.0 References: <1590120740-22912-1-git-send-email-yangtiezhu@loongson.cn> <1590120740-22912-2-git-send-email-yangtiezhu@loongson.cn> <874ks7okk4.fsf@belgarion.home> <3382c1df-1429-ecd3-70b6-35bc00343608@loongson.cn> In-Reply-To: <3382c1df-1429-ecd3-70b6-35bc00343608@loongson.cn> From: Bartosz Golaszewski Date: Mon, 25 May 2020 11:14:23 +0200 Message-ID: Subject: Re: [PATCH 2/3] gpio: pxa: Fix return value of pxa_gpio_probe() To: Tiezhu Yang Cc: Robert Jarzmik , Linus Walleij , Ray Jui , bcm-kernel-feedback-list@broadcom.com, linux-gpio , LKML , Xuefeng Li Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sob., 23 maj 2020 o 05:25 Tiezhu Yang napisa=C5=82= (a): > > On 05/23/2020 03:07 AM, Robert Jarzmik wrote: > > Tiezhu Yang writes: > > > >> When call function devm_platform_ioremap_resource(), we should use IS_= ERR() > >> to check the return value and return PTR_ERR() if failed. > >> > >> Fixes: 542c25b7a209 ("drivers: gpio: pxa: use devm_platform_ioremap_re= source()") > >> Signed-off-by: Tiezhu Yang > >> --- > >> drivers/gpio/gpio-pxa.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c > >> index 1361270..0cb6600 100644 > >> --- a/drivers/gpio/gpio-pxa.c > >> +++ b/drivers/gpio/gpio-pxa.c > >> @@ -660,8 +660,8 @@ static int pxa_gpio_probe(struct platform_device *= pdev) > >> pchip->irq1 =3D irq1; > >> > >> gpio_reg_base =3D devm_platform_ioremap_resource(pdev, 0); > >> - if (!gpio_reg_base) > >> - return -EINVAL; > >> + if (IS_ERR(gpio_reg_base)) > >> + return PTR_ERR(gpio_reg_base); > > As far as I know, devm_platform_ioremap_resource() could return NULL wh= ich is > > not handled by this test (unless __devm_ioremap() semantics changed sin= ce I had > > a look). > > Hi Robert, > > In the function __devm_ioremap_resource(), if __devm_ioremap returns NULL= , > it will return IOMEM_ERR_PTR(-ENOMEM). > > devm_platform_ioremap_resource() > devm_ioremap_resource() > __devm_ioremap_resource() > __devm_ioremap() > > static void __iomem * > __devm_ioremap_resource(struct device *dev, const struct resource *res, > enum devm_ioremap_type type) > { > ... > dest_ptr =3D __devm_ioremap(dev, res->start, size, type); > if (!dest_ptr) { > dev_err(dev, "ioremap failed for resource %pR\n", res); > devm_release_mem_region(dev, res->start, size); > dest_ptr =3D IOMEM_ERR_PTR(-ENOMEM); > } > > return dest_ptr; > } > > And also, we can see the comment of devm_ioremap_resource(): > > Usage example: > > res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); > base =3D devm_ioremap_resource(&pdev->dev, res); > if (IS_ERR(base)) > return PTR_ERR(base); > > > > > Therefore, this patch is incorrect, or rather incomplete. > > So I think this patch is correct, do I miss something? > > Yes, this patch is correct. Applied for fixes. Bart