Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp674803pxb; Thu, 12 Nov 2020 13:26:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiUbw9vDfymty58I5SOFVppkxmp+6zpioYSlkkT8gXylyf2cpw6wCiTXBwoYGgzuJWvp2l X-Received: by 2002:a05:6402:3066:: with SMTP id bs6mr1985233edb.79.1605216389832; Thu, 12 Nov 2020 13:26:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605216389; cv=none; d=google.com; s=arc-20160816; b=zCQPxFw5NglMPy2EWlZKhHH0dLt5pB5xwBBgSIO3NhZ6Unwx08ymlBKTvyqV0o8tqR REZMgx9mOPMRabjiP/+T8e9JbYPohE7un2yvXnMNLLTUilaC/Aa5HjKXqnzRSt6q+aJY MRDDLRhAAOhz75oxlRilLWFbZazFCLDUokffVCG0hZMp0oLtDmiUK7U/n+HZtND+RPHt VIyYusu2W3GFxXtoqEwUkI8P9kYueBIfvZzRyfLYnMND21+D2jPYBMxiVDy+c3YFeCfA wzHULOdJCGwSA+WQVC0LK6TWm09D8eT4esMzHi9Ctp5NGGIXL76gwbNCXY1ooRUGexhi dYdw== 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=un1Fvha3p9HrxO3brSDpe1UBxsEGl42DdoONcDMVykU=; b=ZSrp1o2tgqlvM+HDo9Rl79qqc7sVVMJUytAqzjcMRRrRlMoV67Bo0HQm+CbSmh6roZ F6chO8Ea8J1SF72F78u1gV7dA1gVH76isvbbt+DWYDbU7ccO0qMtNZMi1aDjuZMi6feR wRaW3JeZPW7IZ+7gn+ITBjZm5t6h5/uq5rBOyYZqG5rNn5VN8AfDsQG+rLLOND1od8f/ o4gGo9pp5OALbheSatquffKpOreqgTPsvHQBATXz73N3ZyETnpxkS2axlC8P0D/euyzv BIIiv2DFugElg5yccpMR/xJeXc7u7KdmaoncOHp8hdPofWSBAHxzMz+inHOpu6K/zDI1 OdyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e7w8M0MR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si4505973eja.517.2020.11.12.13.26.06; Thu, 12 Nov 2020 13:26:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e7w8M0MR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbgKLVVm (ORCPT + 99 others); Thu, 12 Nov 2020 16:21:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:45772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbgKLVVl (ORCPT ); Thu, 12 Nov 2020 16:21:41 -0500 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0A6302222F; Thu, 12 Nov 2020 21:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605216100; bh=aNzlXeKDeO/FWCYy+g3S3nGSWQBqBxHvUVIXEM+dZps=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=e7w8M0MRTPxNspmPyUL1EqtTOopZyHn17Pb6t6P6R4hJBgpejfhf+KkJRbgBsDyDN Ag7ZiS0kmrQ2eSAHi4FrqJxdshtEUTpvvk/D+JQZAvE1QBK/SmIAk0s7ckIRmGXnFO 8SKFvylmFFo97YVOG9r5jWLEMfOk+FLpnlaawrEk= Received: by mail-oi1-f173.google.com with SMTP id c80so8057269oib.2; Thu, 12 Nov 2020 13:21:39 -0800 (PST) X-Gm-Message-State: AOAM531Y7zL0ZpMeAxnvSzIxSC25yVvEFic/om/772xmyk5hMENxeatV igJuKocdwdBwoD+uTjzvGhgZ8O/Ofgzbj7f4dm8= X-Received: by 2002:a54:4597:: with SMTP id z23mr458428oib.0.1605216099110; Thu, 12 Nov 2020 13:21:39 -0800 (PST) MIME-Version: 1.0 References: <20201111080027.7830f756@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20201112181954.GD21010@hoboy.vegasvil.org> In-Reply-To: <20201112181954.GD21010@hoboy.vegasvil.org> From: Arnd Bergmann Date: Thu, 12 Nov 2020 22:21:21 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Re: [PATCH V4 net-bugfixs] net/ethernet: Update ret when ptp_clock is ERROR To: Richard Cochran Cc: =?UTF-8?B?546L5pOO?= , Jakub Kicinski , Grygorii Strashko , "David S. Miller" , Samuel Zou , Kurt Kanzenbach , Ivan Khoronzhuk , Networking , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 12, 2020 at 7:19 PM Richard Cochran wrote: > > On Thu, Nov 12, 2020 at 09:25:12AM +0100, Arnd Bergmann wrote: > > This is not really getting any better. If Richard is worried about > > Kconfig getting changed here, I would suggest handling the > > case of PTP being disabled by returning an error early on in the > > function, like > > > > struct am65_cpts *am65_cpts_create(struct device *dev, void __iomem *regs, > > struct device_node *node) > > { > > struct am65_cpts *cpts; > > int ret, i; > > > > if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK)) > > return -ENODEV; > > No, please, no. That only adds confusion. The NULL return value > already signals that the compile time support was missing. That was > the entire point of this... > > * ptp_clock_register() - register a PTP hardware clock driver > * > * @info: Structure describing the new clock. > * @parent: Pointer to the parent device of the new clock. > * > * Returns a valid pointer on success or PTR_ERR on failure. If PHC > * support is missing at the configuration level, this function > * returns NULL, and drivers are expected to gracefully handle that > * case separately. The problem is that the caller doesn't handle that case gracefully, but it instead wants to return an error after all. I don't see a good solution either; as far as I'm concerned we should never be building code that fails if PTP_1588_CLOCK is disabled when it cannot do anything sensible in that configuration. I agree that the 'imply' keyword in Kconfig is what made this a lot worse, and it would be best to replace that with normal dependencies. It would be possible to have a ptp_clock_register_optional() interface in addition to ptp_clock_register(), which could then be changed to return an error. Some other subsystems follow this pattern, but it's not any less confusing either. Arnd