Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1172841imu; Thu, 20 Dec 2018 11:23:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/X7FsP507n2g3jyfX4JG1fQccEnYvcWXsLu+qvrlwPqsONArNm9coEWocqHVLZoBtlFiFmC X-Received: by 2002:a17:902:bcc7:: with SMTP id o7mr25786520pls.281.1545333790418; Thu, 20 Dec 2018 11:23:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545333790; cv=none; d=google.com; s=arc-20160816; b=ly1S5ClhmTKsCKH6QaKS4JnCVaHbh/9goyveTjPIlYpgf4AvTN0l3E02HzBPlj9RH+ JXhRFtTjH+7kkAfyM9CUiv+BNWXEu7v3r2pQsV5VN0UeEi5U3pKqq7Yfc+FU/zHc9p3F oegS2yoehShhe2xqHHQG9+v23s3qnnTxTRhsKQNvK6dqbqiqRYqFp9uP6WUWDuzTDcOJ rhRJULiI8ak/Mk1/8WU0Pmf/j+vhb/Uep8NO8paaOdv8PKpDZ7/91LMk7exA2CUhpHfI ydi/Wt6hbfQDp1h3qLxgjb70KlgUbLV5lsSCrvBmTs2IAbw0dw9mQLGIZvf8uR2n7XSA p1Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=/wtVSIU1u8jkniyVCmf9tdEnnLzL0IulpduUFjvvCK8=; b=e0Cqb7gyIf1bDx/Qfn+yGmzb9yThxDXpQ5FvRsNKtc4bgJuHmi8nUMrbeVWmFkMibT sTKPuao4asPxSD/oZiCvDi3Cm2m77/XsbiMMD5ggfWpHy33SQgAS1MUSAfQ++WDVqRAe bzkWhAoQARo28P6YdpvO9+oQzFil4+ds8P05VqAcEgcuhrNtnwVV4YBhSTggrcmEtOut XCASaJJadJSU7CdYfaVs0yRbUy5cCkoRF7HcsJzYoge8pctje+xTDVY4w+OdbpC/DA9A K9qJZgmosXikexXkh62tvadiW5/1nIGIvLe5UuZnopFxiBYbqSQpDBl43oUx+hJRPKai jn7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=BjFE794U; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j61si19098495plb.232.2018.12.20.11.22.55; Thu, 20 Dec 2018 11:23:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=BjFE794U; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731096AbeLTLiF (ORCPT + 99 others); Thu, 20 Dec 2018 06:38:05 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:42995 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727990AbeLTLiE (ORCPT ); Thu, 20 Dec 2018 06:38:04 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181220113803euoutp02ad1c32e8b262821933a8c5e7f3730fbf~yB4N2Gv770610606106euoutp02N for ; Thu, 20 Dec 2018 11:38:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181220113803euoutp02ad1c32e8b262821933a8c5e7f3730fbf~yB4N2Gv770610606106euoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1545305883; bh=/wtVSIU1u8jkniyVCmf9tdEnnLzL0IulpduUFjvvCK8=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=BjFE794UuI9MuzvIm3YGXcLukyrJeiTlxRtR44ChQ4SseyMjOR2gtyR7r4kxlgbxt Yv+XfZJWJduWQj1Kb2DRpmz6oYnL4Ip2MnZSI2VcwRMpkBEDEofauBqTYfdDhQktMc 1ZWw3GnLDQlVnQsmgoygWrGn3P9ZH5J4aZ5QCXiA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181220113802eucas1p1e9ecf87e8492337bad2269605244fe90~yB4MuBWvu1592515925eucas1p1H; Thu, 20 Dec 2018 11:38:02 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id AA.FC.04294.91F7B1C5; Thu, 20 Dec 2018 11:38:01 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20181220113801eucas1p1c8485c363200952f23a2a35e06d85842~yB4LvSiD91724317243eucas1p1B; Thu, 20 Dec 2018 11:38:01 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20181220113800eusmtrp12021081b24e59575dfd7e3e20d8bc4ef~yB4LgJ2Mg2144921449eusmtrp1t; Thu, 20 Dec 2018 11:38:00 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-08-5c1b7f1962e0 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 69.24.04284.81F7B1C5; Thu, 20 Dec 2018 11:38:00 +0000 (GMT) Received: from [106.120.43.17] (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20181220113800eusmtip17949c581ea817caa20a3aa79d9b22a6d~yB4LBQtK11857618576eusmtip1E; Thu, 20 Dec 2018 11:38:00 +0000 (GMT) Subject: Re: [PATCH v4 1/3] driver core: add probe_err log helper To: Greg Kroah-Hartman Cc: Bartlomiej Zolnierkiewicz , Marek Szyprowski , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Javier Martinez Canillas , linux-arm-kernel@lists.infradead.org, andy.shevchenko@gmail.com, Mark Brown , Russell King - ARM Linux From: Andrzej Hajda Message-ID: Date: Thu, 20 Dec 2018 12:37:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181220111403.GB10978@kroah.com> Content-Transfer-Encoding: 7bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUhTYRTHfbzbvdfR5G4qO2pkDgwsfE3lgmFKfbjUl1KIUqGmXpzlpmxq mR+0hFKTWoamQzNZaWhhvm26smCr1NR8W1qWWTgsxSGhlVJGXq+S337n/M//Of8DD4lJ+4Re ZJo6i9WoFelyXCQwvlp9E+CZ750YPGMMpud0VkS3VDYL6fIvdpwuNDTjdF1FA6JbZ8aF9Ji5 Gqct5d2IfvRiiqBrlsuxaBEzNj6CMV36KYJpbSzGmec1Dwmm7V4+s/jsLc5cb29EzFLrrmNk vOhACpuelsNqgqLOiJQTZR9RZpXkgsWmwwrQd3EJciGBCgNb0ygqQSJSSj1A0D0ySvDFMgKb 6ZuAL5YQ1Pe+dt6ytDV2YLzQgMBqc2z6HQjs0xMEN+VGxcDk0Dzi2J3aDzcG9RvvYtQvZzDa F4WcgFP+sNb2HudYTEVB4WwJxrGA8oOrs7c32IM6CUXTTZszEuirsgs4dqGCwFDEezHKB0yO aoxnGUzaa525ZUBNEjC0fAfxuQ/DmmmI4NkN5nvaN3kn9N8qFfCc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nHCPGmJFZWpRblxxeV5qQWH2I0 BXpuIrOUaHI+MJXklcQbmhqaW1gamhubG5tZKInznjeojBISSE8sSc1OTS1ILYLpY+LglGpg ZIrgv64m4f3inalX2J1Lm64fCcrZtHae/Ry55BlRe61VTTR/xj5393/CsPahJtvkM+LK3Kc2 M7i2LBPbPXHle7OMtp3nJi6XYp17W8Ykx+Js3ZWvndsLVENlzJ48u2Y/g1vfa4aCjf70Fes7 cwymHGIXL7550uW7qujhRnm/faFSK03r1+i9UmIpzkg01GIuKk4EABycEB7tAgAA X-CMS-MailID: 20181220113801eucas1p1c8485c363200952f23a2a35e06d85842 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181220102259eucas1p2f748c68e01cd4e09a266da879722e218 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181220102259eucas1p2f748c68e01cd4e09a266da879722e218 References: <20181220102247.4911-1-a.hajda@samsung.com> <20181220102247.4911-2-a.hajda@samsung.com> <20181220111403.GB10978@kroah.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.12.2018 12:14, Greg Kroah-Hartman wrote: > On Thu, Dec 20, 2018 at 11:22:45AM +0100, Andrzej Hajda wrote: >> During probe every time driver gets resource it should usually check for error >> printk some message if it is not -EPROBE_DEFER and return the error. This >> pattern is simple but requires adding few lines after any resource acquisition >> code, as a result it is often omited or implemented only partially. >> probe_err helps to replace such code sequences with simple call, so code: >> if (err != -EPROBE_DEFER) >> dev_err(dev, ...); >> return err; >> becomes: >> return probe_err(dev, err, ...); > Can you show a driver being converted to use this to show if it really > will save a bunch of lines and make things simpler? Usually you are > requesting lots of resources so you need to do more than just return, > you need to clean stuff up first. I have posted sample conversion patch (generated by cocci) in previous version of this patchset [1]. I did not re-posted it again as it is quite big patch and it will not be applied without prior splitting it per subsystem. Regarding stuff cleaning: devm_* usually makes it unnecessary, but also even with necessary cleaning you can profit from probe_err, you just calls it without leaving probe - you have still handled correctly probe deferring. Here is sample usage (taken from beginning of the mentioned patch): --- diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 4b900fc659f7..52e891fe1586 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -581,11 +581,8 @@ int ahci_platform_init_host(struct platform_device *pdev, int i, irq, n_ports, rc; irq = platform_get_irq(pdev, 0); - if (irq <= 0) { - if (irq != -EPROBE_DEFER) - dev_err(dev, "no irq\n"); - return irq; - } + if (irq <= 0) + return probe_err(dev, irq, "no irq\n"); --- And there is plenty of such places, with new version of cocci script I can locate about 2700 such cases, and it is still far from completeness. [1]: https://lore.kernel.org/lkml/20181016072244.1216-4-a.hajda@samsung.com/T/#u Regards Andrzej