Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp28517pxb; Mon, 11 Apr 2022 17:53:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynpatJNSmVu8mSFiiI9u7JkBt+v+YTJhP9vHj1v1l1mFs8SJicASxwINa2q9OB5yN61D9w X-Received: by 2002:a63:7ce:0:b0:39c:c85c:9574 with SMTP id 197-20020a6307ce000000b0039cc85c9574mr19819928pgh.55.1649724805114; Mon, 11 Apr 2022 17:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649724805; cv=none; d=google.com; s=arc-20160816; b=wIYG9EPmpLq4xoDhG0cSy4epB42eqKnobytn0mYauBT2hVhTPuazcsSDOD/qDWYZbc y7Uj27QowNrwRoIA6jkY5WIQtVDXElyEcRIxX8nmjhZYI73DaBQS8Ig6qgeMn7urd/RK zRaWzIei1NT6c87oEJYpzgcTIbnG2g3GhH52onIaNdYaYlaMPuBx7ETJoaHfAisutEAE G6bFI/M9ANK72aO2NpPbynJRfwyPBh2crIXGqkcQQoOWSLsQGjxxM0W+9F6UxbE+JZdO FvvaFjboeudM29hg2SbnteC7pRVo01QnPIJQxBuwcRJFAYJ5mA/MSlKrVPWnY138NXY+ rDzw== 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=hq9f5/RKeqFPfe01WxjMVIHowJsKBfJmwCx5QvdPw1A=; b=fDyAANItaCbHeUxJ2TDgOtPwt5nP3vgxZeBqmzDFHz/Ir0nPlv5LqEZ8FVoN371k6W leBwEIuqyoVbUQXHX7dZEOz77L3yR1Xb1ZHaW8T5rbf/ZfbDBf7je4sk2XaG0OmEGsr7 ozncfq09B6AgS182HZX6dTc2LYjglqRfv0sx3g1quC0BHDAgnYyReernKVrE6vJmvn3E /XCq+xToyZAR82YIAzOT0WIzhGk6uee7eGujHQ2h9+G3snqA0VCKy6wp64DUqyq4tA7S UZm4n1mruuLRH4uY0zU60CbOkjIGkxR2LOYvp3qe9qbYmMSiDtw2760pQycVtgJJ3KmC fILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=q7qbmDs1; 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 j12-20020aa7928c000000b004fa94f26b43si9896128pfa.319.2022.04.11.17.53.10; Mon, 11 Apr 2022 17:53:25 -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=q7qbmDs1; 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 S1348707AbiDKQzw (ORCPT + 99 others); Mon, 11 Apr 2022 12:55:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243965AbiDKQzt (ORCPT ); Mon, 11 Apr 2022 12:55:49 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18C3035AA6; Mon, 11 Apr 2022 09:53:35 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id s18so9684342ejr.0; Mon, 11 Apr 2022 09:53:35 -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=hq9f5/RKeqFPfe01WxjMVIHowJsKBfJmwCx5QvdPw1A=; b=q7qbmDs1dVWdTOe6VYfzmW5Hff9GRPCexV+KafoUs4J4l8gBflhswSYlelDdbTETyC jZyxwSDKViY8H0/Wc6/IuTK70Hg52/z5gsdZyKfC7lcLdhTmX4n10VgiyNvzSQh/5LOT 6Ct4gvmWALz/zr5I8uolBr4Iq+EqIChUhTIDJDgS7kSX8WG6hLW4ndHviGkI1/4UUc7o dd1Xu1dAGi4+vlddV531nJPW0oB4h2L/HyxaBt0D155u3YIujD0NJCqLNoevSG9va9Cw pDUnzccVhbWv0bJuvRw2XS8P0J8rL1cUIAMjbnUCRHuEQaSzsQ1/fgH+JQ8/8SHG4utm UcRA== 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=hq9f5/RKeqFPfe01WxjMVIHowJsKBfJmwCx5QvdPw1A=; b=n5T3gOpEjXzdBMR7xKmaZDapyTeHPUKvB6vpZyIUh4SQX+Gfi5BtQUqr1CHxU1MxT0 d2QuSC+qicgMxQjdmkj3C38RGxCXdePRqXDknjrPddHwlTudpgVDiROy2opL5ogm1I7Q cS8zxJ6urFgnhE02TVoVvQO0JCyX2CAJkSNOorOMRLsta1q8IBu8ibLDSBAwWEr7spaz GblZ3hs5ThMwsPP3f7cY6EwXZJLBuo8p8CP6IIWiqTf+F8bW8Foaakh9pN02wwYPGYfP R+BNH+7i/rW5OAjqSxlUGe1ZDuXnDHqO1kT/zwZdM7KRfb9bdTnmn3iE+NmLkEBKNBtl T8qw== X-Gm-Message-State: AOAM532C7nXumIFB6zVYFYRn4OkqQ70SXH1O/RMFYbJJUYZzbyXF3il7 EGZ2bhHvJAZvN3Vy4OYr9sBdWYdiMwy+SYNsZ3Y= X-Received: by 2002:a17:907:628e:b0:6d9:c6fa:6168 with SMTP id nd14-20020a170907628e00b006d9c6fa6168mr30782381ejc.132.1649696013529; Mon, 11 Apr 2022 09:53:33 -0700 (PDT) MIME-Version: 1.0 References: <1836398.tdWV9SEqCh@kreacher> In-Reply-To: From: Andy Shevchenko Date: Mon, 11 Apr 2022 19:49:20 +0300 Message-ID: Subject: Re: [PATCH v1] PM: runtime: Avoid device usage count underflows To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Linux PM , LKML , Ulf Hansson , Alan Stern 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 Mon, Apr 11, 2022 at 6:17 PM Rafael J. Wysocki wrote: > On Mon, Apr 11, 2022 at 5:09 PM Andy Shevchenko > wrote: > > On Wed, Apr 6, 2022 at 11:49 PM Rafael J. Wysocki wrote: ... > > > + retval = rpm_drop_usage_count(dev); > > > + if (retval > 0) { > > > trace_rpm_usage_rcuidle(dev, rpmflags); > > > return 0; > > > + } else if (retval < 0) { > > > + return retval; > > > } > > > > Can be written in a form > > > > if (retval < 0) > > return retval; > > if (retval > 0) { > > trace_rpm_usage_rcuidle(dev, rpmflags); > > return 0; > > } > > > > I know. > > And why would it be better? Depends on the perception: a) less characters to parse (no 'else'); b) checking for errors first, which seems more or less standard pattern. -- With Best Regards, Andy Shevchenko