Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3321214rwd; Sat, 10 Jun 2023 05:49:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sFVGsrHBgfQ9IFoeVkEhFxSE47FL2gExprGD1Y0YTpyJVlqo1XkuACm/Fvt7U1lfGAU5N X-Received: by 2002:a05:6a00:99b:b0:658:c1a9:becc with SMTP id u27-20020a056a00099b00b00658c1a9beccmr5501889pfg.12.1686401350324; Sat, 10 Jun 2023 05:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686401350; cv=none; d=google.com; s=arc-20160816; b=sVAI8A55wmTYzoDmUv4ohqnX7TmwW+rpoEriS6MwWWGCO1LtXNVtH4iVWxupYdf54+ jQ08yvazn92aA+NWWpgv636w5FPoCvs9H8/sn9zM6tdkfVkPvS+GZO2fPHcBSs9AWSWq bQXW7LUkGYByPrJJEB5+FdM+obWlhE3Z/HNks3YeVevxlEE7dcPVkmTx1GZG1rpAuLKQ wHNGqFiQEHX1WY/hL/dp/nB5OUIZSs5e5xURlECPcUeylXv4JKDSM/b+a7QuPUYHOpFU XYhMKZkQM6ruAiy90A6rr+f+IXa6QvOko7r3gyRpQaF1Ff/cEiG9yMvwkmRJb+amwAo2 6fLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=zf7g/lr78i/6foxSt5E0cew9w6Xu1ollzXpCt9LuA1E=; b=wWiMAY4aoHCT6yf4XDfvpNHthnK+fZltWXVAqYgsZ4HJLixNQ/dLeyg8MYTXntCu6s J4xlWOORZRN50wLs43xqOCB74tkLF1yQByhDhRZ46fCjR1bAGwhIYu//DtfwhBsWogpH lq39CUaVDD7ayLqHaJmPEEhaDHz0fYZfvztXY93hXB2U4bJ8U88CEVNUe8+4s0slx51S kWaEZsbZ8HBjYUvuRbSB081nnm1RP94mtKVO+h+4rGWYhISqkI4Lx3i7IUWbLKCStiJB n8uLl011IF4NkdGQQBrTPEL9ax98nkuypqWawhW9aouXY/I0JA+ux5fNm6Yw8zxIOsIE cnLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lp01q9Fq; dkim=neutral (no key) header.i=@linutronix.de; 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=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t22-20020a639556000000b005406e766072si4230162pgn.576.2023.06.10.05.48.58; Sat, 10 Jun 2023 05:49:10 -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=@linutronix.de header.s=2020 header.b=lp01q9Fq; dkim=neutral (no key) header.i=@linutronix.de; 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=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230415AbjFJMUP (ORCPT + 99 others); Sat, 10 Jun 2023 08:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjFJMUO (ORCPT ); Sat, 10 Jun 2023 08:20:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722A03594 for ; Sat, 10 Jun 2023 05:20:13 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686399611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zf7g/lr78i/6foxSt5E0cew9w6Xu1ollzXpCt9LuA1E=; b=lp01q9Fq+YZbf13jlVUbe83aSS446/+/M94kP+K16+YqlQl6u0vbKzv0UvsSkxL6e6n9+0 fF7PnPvIUJB8tDEDXEOMtdKyL8FJ92qZPr/gGzDZ7msFxdVjog+Oa2Bd/9VYdp9utfKioC KVxE3a4Zhquiiq6SiILp2FBTK+JIItJqP4fFILfZNk0+5z+f63y6wy7Ecs9+38PzODIc/M 6uoeQnzjWyYltS4YpdDnZhu3YDfzJkqqItskyZJHAZGkOYHG32R9Y+h7+R52OApT+1tA9t 6JrVqfVelfbfrw/58iznX46Lj8r6XsLGc7X2EOKdgBJh7WCYq0BZoGxFr9iCIQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686399611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zf7g/lr78i/6foxSt5E0cew9w6Xu1ollzXpCt9LuA1E=; b=NCznKgf3V31LKMvlumBL2hQx7W/esVxX8IxORqWL9dUjUjbpgMwZCK0/slu52isT1HUkWP iw14UTcBga26XUDw== To: Li zeming , jstultz@google.com, sboyd@kernel.org Cc: linux-kernel@vger.kernel.org, Li zeming Subject: Re: [PATCH] time: alarmtimer: Optimization function return value In-Reply-To: <20230609180955.4357-1-zeming@nfschina.com> References: <20230609180955.4357-1-zeming@nfschina.com> Date: Sat, 10 Jun 2023 14:20:10 +0200 Message-ID: <871qija4qt.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Sat, Jun 10 2023 at 02:09, Li zeming wrote: > if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) > - return -1; > + return -EPERM; I know you are only replacing the -1, but EPERM does not make any sense here. It's not a permission problem, it's the lack of a feature. So the proper code is -ENODEV. > if (!device_may_wakeup(rtc->dev.parent)) > - return -1; > + return -EPERM; Ditto > pdev = platform_device_register_data(dev, "alarmtimer", > PLATFORM_DEVID_AUTO, NULL, 0); > @@ -104,7 +104,7 @@ static int alarmtimer_rtc_add_device(struct device *dev) > spin_lock_irqsave(&rtcdev_lock, flags); > if (!IS_ERR(pdev) && !rtcdev) { > if (!try_module_get(rtc->owner)) { > - ret = -1; > + ret = -EPERM; Same here. But this error case is broken because it does not undo the device_init_wakeup(&pdev->dev, true); So this needs + device_init_wakeup(&pdev->dev, false); before the goto > goto unlock; > } > > @@ -113,7 +113,7 @@ static int alarmtimer_rtc_add_device(struct device *dev) > get_device(dev); > pdev = NULL; > } else { > - ret = -1; > + ret = -EPERM; ENODEV > } So please do not blindly replace something without actually analysing it. There is a reason why these things are not just "fixed" with a script. Thanks, tglx