Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp229999imn; Fri, 1 Jul 2022 13:51:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vgOEXVvFHsk9mxAiuclEx68dO+rRx8OhfMnlFgIy2caAx9CpbvjCmF1MZD5Me3KNa8P+F4 X-Received: by 2002:a05:6402:1694:b0:435:79d2:a441 with SMTP id a20-20020a056402169400b0043579d2a441mr21838402edv.55.1656708678461; Fri, 01 Jul 2022 13:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656708678; cv=none; d=google.com; s=arc-20160816; b=X6r0eJZ+hUHyuZgq+KVi7chH51qrdK1H0NH1MeKpIq9m9z/0GsRv6k5z/0i0HAhE6i 0nTLKNoJsxEXdYG9ylj4+nB6cSJbR/NOz8KWjG2up7MhriyiDvePPtkcOExCb4Htz9gf ZGAA5Uexem0u8CfVFmXsRQ3vWNd5u6d5neaLgzzJnwi6IS7SVZXbvqEwSHAXxnHgRyhq +VR6sPb5dE+O93DNKYUxuu4YcCTRN2WpfVqfAOEgCO1IgVCRmIBVFxkBvydrPekbFGjP oJg/wm/rZasJflWtsrQSvtk5g50SWbCfID+icPMfQ6m2O931HL58DTpuj8xw9pyxdbvk hSBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Yp9XN4S+Opt5OiPcD1GcnJhSinyAA39zjfk4/yaqO8s=; b=urIDfOb37CrEWo8AWIQ329ScKXgwBIoWk9OGIM5nrJSO+ISgEgE50dTN08vH7oPu8g KWhnEpBOzFg8Ozg7G3UugpQkhvdkiM9rzpm6kNS7/HggTt+uQj98/xKzzIZzuZIAorf3 lFQJkHLNIZByWaW9T1lWES4LUAA2ePGV3nS/pL+g15FiHXd131fLhx4WLjPKES+cokap CiHYjWwnzz09Ef/BriDBcPOLydYf0Vw1es+fEZlidvXWZLYj4+eH3L8sKwYLz6smo+B2 PGEdwsc5AMpKoXAZCDt8w7OwXGMvTiVPW9cs2iWePJ9ZbJfx40QWCvxt0+pdlMoOXkgp pKxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SSa3GZ+C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b60-20020a509f42000000b00435dde2e25asi2302901edf.263.2022.07.01.13.50.52; Fri, 01 Jul 2022 13:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SSa3GZ+C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbiGAUm2 (ORCPT + 99 others); Fri, 1 Jul 2022 16:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbiGAUmY (ORCPT ); Fri, 1 Jul 2022 16:42:24 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6983D5A2F6; Fri, 1 Jul 2022 13:42:23 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id d145so2757156ybh.1; Fri, 01 Jul 2022 13:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Yp9XN4S+Opt5OiPcD1GcnJhSinyAA39zjfk4/yaqO8s=; b=SSa3GZ+C8FrgSyg1dfnwW60dlyF0osSJcGZGmfieTSZO8LN1tTnuBZvrpmznVl6l5B IgQmQe4055mdbiFozpxMvnggCiMyc7NOrvfm29fp9LbuZ5i5ON/B8m2J5GXb5vWVA6c0 RewnXDqM8bApuZzbq6JtS4ZDUAhrXph9cYmjL7knYaBXHm/BBAXDwNZa1cdzz/6Ej2IG Nz7sdgqorS24+OA2LMNycsTyc5r3QxbSzQCNOBWWKXmM0MNeZkST886/Rkqe5ab/udOX y+NeJom41Oze0ooJeXmmFQBDfTWqcBjfimdSVuFjjTTbaXAuFIg3+jp92fXuR96azOE4 e51Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Yp9XN4S+Opt5OiPcD1GcnJhSinyAA39zjfk4/yaqO8s=; b=3kmXpcnAPO8TLXIAZG2/bOiI5Ax9fmc76lE3ztVEsoS82Vu9ngW4oDDBWJL7RZdum1 iBL53yxOu6F7V4+3J30WDx7sZIoHwbjYfEPbQqjVFFrl8a8FTcTYx6pQvNPhWngSHdxD g1oybV9ym5KtC3WhHecJMkGbTl/a+hjP/o79Xr3gb4jQPiKpX7bS/iJR7Rm9JNqJzokJ 0boBA6yZXXL0B4F3vBpWAuBl2uNqYtub8lGl8KEY+1K3pYNyMdmZOCWH1TSfdf8MCRlx nHd6z8Tpyz0x8kgKzbgTo64ClHb2ATWB4v4byXdNkgRCOKKiQKQiC0DyG7b8omGh2VZz lWdw== X-Gm-Message-State: AJIora8rAQge/vk2uq3brrtRSmSCU2kDk51BDz7KrmQ33Pu851+TVBSa 7225rCYsNnAVn2RxLjQiIkReX4dniGd+tb8TMf4= X-Received: by 2002:a05:6902:1142:b0:66d:999a:81a7 with SMTP id p2-20020a056902114200b0066d999a81a7mr13475371ybu.460.1656708142638; Fri, 01 Jul 2022 13:42:22 -0700 (PDT) MIME-Version: 1.0 References: <20220701192609.3970317-1-colin.foster@in-advantage.com> <20220701192609.3970317-2-colin.foster@in-advantage.com> <20220701203453.GB3327062@euler> In-Reply-To: <20220701203453.GB3327062@euler> From: Andy Shevchenko Date: Fri, 1 Jul 2022 22:41:43 +0200 Message-ID: Subject: Re: [PATCH v12 net-next 1/9] mfd: ocelot: add helper to get regmap from a resource To: Colin Foster Cc: devicetree , Linux Kernel Mailing List , netdev , linux-arm Mailing List , "open list:GPIO SUBSYSTEM" , Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , Microchip Linux Driver Support , Linus Walleij , Wolfram Sang , Terry Bowman , katie.morris@in-advantage.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 1, 2022 at 10:35 PM Colin Foster wrote: > On Fri, Jul 01, 2022 at 10:23:36PM +0200, Andy Shevchenko wrote: > > On Fri, Jul 1, 2022 at 9:26 PM Colin Foster > > wrote: ... > > > + res = platform_get_resource(pdev, IORESOURCE_MEM, index); > > > + if (res) { > > > + regs = devm_ioremap_resource(dev, res); > > > + if (IS_ERR(regs)) > > > + return ERR_CAST(regs); > > > > Why can't it be devm_platform_get_and_ioremap_resource() here? > > It can... but it invokes prints of "invalid resource" during > initialization. > > Here it was implied that I should break the function call out: > https://patchwork.kernel.org/project/netdevbpf/patch/20220628081709.829811-2-colin.foster@in-advantage.com/#24917551 Perhaps a comment in the code, so nobody will try to optimize this in the future. > > > + return devm_regmap_init_mmio(dev, regs, config); > > > + } ... > > > + return (map) ? map : ERR_PTR(-ENOENT); > > > > Too many parentheses. > > > > Also you may use short form of ternary operator: > > > > return map ?: ERR_PTR(-ENOENT); > > Agreed, and I didn't know about that operator. When Vladimir suggested > it I thought it was a typo. I should've known better. It's easy to remember by thinking of "X ?: Y" as "X _or_ Y". -- With Best Regards, Andy Shevchenko