Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4909361rwb; Mon, 21 Nov 2022 13:42:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Odr9EOiiRyJztQoptqAkBTtuZQHE8rEhDnzhIPGGStUecCOjI95Z9JMd8kP1T+Eosuxr4 X-Received: by 2002:a05:6402:4011:b0:461:96ba:b9c with SMTP id d17-20020a056402401100b0046196ba0b9cmr18446378eda.353.1669066961262; Mon, 21 Nov 2022 13:42:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669066961; cv=none; d=google.com; s=arc-20160816; b=0IeCmqqQSzS0W879nJyar2oiyAw9wIiEaiwu8wuqSEekoHVDLxmk6P60KTIS6qbScv U4zblz8NnxwTwqftudZARM+1YS3X+NSXToninbwjCbt0Veo25rK6Fo4lELu6DKq/e0ps E42i/05Xo3xhRydPdpbBWqjonMaLOdRosQTDffSB+NpWSN6pYvWIsmXg1+ydVogVS6rf 1alcALFx/79L3jwyfo1Ud0PEfB7ZMLv0Sm5ExIwogcrmT6EYASyMUobvwSMajkUEraGs K5V/2iEwdh3x/OowZQhbSd4sZe/FNoSff3VQtYCZQCm0W4sItZvAcVV1NudGom5I869T H4AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MrnT+eSbey2CG+aPSBBnxrMG7unNpVOnktkqfmkzqVU=; b=GE4Z8E109NhbW/QMawF06u9rkEMOl421qpEaIitI3FL/5ZptCvtaryLaadMbF3Aaox JlM2t/5Eu2bc2H6OEZHvwfaC0cSZs3Z9tM17tTieEEa6Yg5n24zTUKSRDlpbw7YkV9rr cxcakNZI4wwmaR9BXhc4meVeV7ztgocmNvQ7bbmcAdKNGyKPp9B9lvjX6Sdk698NTaSr Ulnrla5dphJTZl4tKN+zkfXKxOXNalW5HUSL7xEJia/Hcag47+Pi7a8OE6UvpOCr2gqH Q7IxodQ/MwJTprRM/CU/foWdtF8F085EKSb9ciCtDssDUvbUvUGCIyyRjL9C5KLaQZO/ 9Qew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="n6ChiPX/"; 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 n9-20020a05640205c900b0044615ee1b6fsi10749522edx.218.2022.11.21.13.42.18; Mon, 21 Nov 2022 13:42:41 -0800 (PST) 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="n6ChiPX/"; 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 S231642AbiKUVdU (ORCPT + 92 others); Mon, 21 Nov 2022 16:33:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231739AbiKUVdK (ORCPT ); Mon, 21 Nov 2022 16:33:10 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFF9F10B5F; Mon, 21 Nov 2022 13:33:08 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id gv23so31526839ejb.3; Mon, 21 Nov 2022 13:33:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MrnT+eSbey2CG+aPSBBnxrMG7unNpVOnktkqfmkzqVU=; b=n6ChiPX/0X6KmY7+2o4+fswG5u7ei9vyDif1QYvCokDRZtasfbHHoM1gqpfPC1kNns aw1mNKF3DlH/d+46jwy7UVuURA/jwPqAv6+siGb+IAFnL1jMOiV0dlbnH94tpdyYcUhq IAqz6alY2BEUzJbBeIhxt9br1EZ5o3Ol30/8dBh1H96brOgmV7noZ4Nnc8izd1zMzOQq NOBKdUmTKsO/KrzrjeuP+OOtCbE3GaEyGmS64OrQyiC0NRcX28WONs89jJkk8kApqJC0 YYJG3xma3lsIFG2+tyQbXB6xwl/L1Dy1lS5nuIXcmPenWMA71Fd5+10ORiM1+eBY9IRC G6yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MrnT+eSbey2CG+aPSBBnxrMG7unNpVOnktkqfmkzqVU=; b=6zlQ2kVvWzhWVeazc8vecX/OjN+k90Erz2Sa+ocPSNTSFL0rxpF/onN38nCBG9Pg9Z 4s73P3dpaiU7e+OCUVSZ1d7THRyiRn7XuNUY7ITHlc1TNvFAp5wj/TwvmAHE2OvezKG1 sJoqxno+TlY1b6KhwDz7EhyEnnf2HRd3jAiT48vUelg3XTlwoSbao9mY+DjVs/vtyVOa zbRS7i93ZSGy2L0SyAdY2Xl/laqoKMkPjQAgJvkefeY3v5ZHOIGVYs5vju6cr83Rkbz9 ofawEy7OVidNPoQM/OliXRihBVoYqEVqjo0cyw1l0IuMHV3zfTseOQW7pRVjfbwWqlc0 r+VA== X-Gm-Message-State: ANoB5pmJoqBs2v0CncftXkN0DFDEGXwdoElLi7UjU1PSnN+wt12EYRd6 h8X3V6bxh+laM6+0EPRu1Y8= X-Received: by 2002:a17:906:b0cd:b0:78d:8c6b:397b with SMTP id bk13-20020a170906b0cd00b0078d8c6b397bmr4210221ejb.364.1669066387317; Mon, 21 Nov 2022 13:33:07 -0800 (PST) Received: from skbuf ([188.26.57.184]) by smtp.gmail.com with ESMTPSA id cn16-20020a0564020cb000b0045c010d0584sm5644221edb.47.2022.11.21.13.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 13:33:06 -0800 (PST) Date: Mon, 21 Nov 2022 23:33:04 +0200 From: Vladimir Oltean To: Arun Ramadoss Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, Tristram.Ha@microchip.com, richardcochran@gmail.com Subject: Re: [RFC Patch net-next v2 2/8] net: dsa: microchip: adding the posix clock support Message-ID: <20221121213304.vytvbfvikuwcw3oi@skbuf> References: <20221121154150.9573-1-arun.ramadoss@microchip.com> <20221121154150.9573-1-arun.ramadoss@microchip.com> <20221121154150.9573-3-arun.ramadoss@microchip.com> <20221121154150.9573-3-arun.ramadoss@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221121154150.9573-3-arun.ramadoss@microchip.com> <20221121154150.9573-3-arun.ramadoss@microchip.com> 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 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, Nov 21, 2022 at 09:11:44PM +0530, Arun Ramadoss wrote: > +int ksz_ptp_clock_register(struct dsa_switch *ds) > +{ > + /* Register the PTP Clock */ > + ptp_data->clock = ptp_clock_register(&ptp_data->caps, dev->dev); > + if (IS_ERR_OR_NULL(ptp_data->clock)) > + return PTR_ERR(ptp_data->clock); > +} > + > +void ksz_ptp_clock_unregister(struct dsa_switch *ds) > +{ > + struct ksz_device *dev = ds->priv; > + struct ksz_ptp_data *ptp_data = &dev->ptp_data; > + > + if (IS_ERR_OR_NULL(ptp_data->clock)) > + return; > + > + ptp_clock_unregister(ptp_data->clock); > +} API usage seems to be incorrect here (probably copied from sja1105 which is written by me and also incorrect, yay). The intention with IS_ERR_OR_NULL() is for the caller to return 0 (success) when ptp_clock_register() returns NULL (when PTP support is compiled out), and this will not make the driver fail to probe. There isn't a reason to use IS_ERR_OR_NULL() in the normal unregister code path, because the code won't get there in the IS_ERR() case. So a simple "if (ptp_data->clock) ptp_clock_unregister(ptp_data->clock)" would do.