Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp385602ybt; Mon, 6 Jul 2020 11:42:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/bBCkzKDl00HqdNA2dZhC9t6qU5GfGIYeBwvlITH9AnV9Ia1R0xY53TFJ70djVmvg6J5f X-Received: by 2002:a05:6402:a58:: with SMTP id bt24mr58903254edb.333.1594060925833; Mon, 06 Jul 2020 11:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594060925; cv=none; d=google.com; s=arc-20160816; b=xjF8V/as9pkaMwEJ+rr9hREJDHrkOrDV6nlxnB4MaV4gChkk1uD0LxmQKns0lm7CC8 RgHJ6mMJEpE1M8dG7Zr/5ne6GNcFUKROul5JJo1+7/f/VlE+Lw9qRKHJxbjFmu0o8OPk 3ZWyrBnicBqIVovEYcWy8pYdRpkRD97T+tnEQo0uvX2a8wEi4EXI6fcRDbK4LzIbx5x9 l73mr54iShn/sOYkYub7FW4vNgpXHB92/84peIPqgdmAabl4e6GD8lEaF7F9O9+r8Eza ZdFwqQ6evKQilyj3+nos0kSChbDCXdRnZGHHxnocHlKhC3nPTC4iPzj5EEpbLidhx4S3 FIlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=xxbtpDYO7o+J4ydWraoGh8klQqditXoauTnZTzvhmHg=; b=Nm+n+bzicn37yZODubxUJjS/hwa8g4Dl6OPrV+KcjAqI0XoefmLzTnbNd9TnixJMEH hAOBsOoCCJb+9Ydn29EbX/SsdOwuCuztd92E3hHzc5uDfScSS75LpMT1yvyKMaCfWOPG 6Cbc8ClWwaDmA5VxnS5tNBMLxtSdAyF1LJCJkl7rCCo/3kpFcibND0tM4HKX69yyp6lc 5RlLR0kPbKswVKdliV0QnkFqegomsR0cquM2+PFz1aPw95vDwRTjp/UXt7mOJ3tGmnF5 hdYEsVhbCrLImK9BGYY41LH02Um7evbS4ZhYe9NsSU3dUXcbLiVXAFPyyOl30OJg0zjl ZsnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uNc6pW6p; 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 cz22si12937895edb.148.2020.07.06.11.41.42; Mon, 06 Jul 2020 11:42:05 -0700 (PDT) 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=uNc6pW6p; 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 S1730096AbgGFSkG (ORCPT + 99 others); Mon, 6 Jul 2020 14:40:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:40058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729842AbgGFSkD (ORCPT ); Mon, 6 Jul 2020 14:40:03 -0400 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5F416207C4; Mon, 6 Jul 2020 18:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594060802; bh=GCzjI5LNoEYSHBzDGeERWoVoi65qdJkPvvM8agbWZJs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=uNc6pW6pEw9WAHZwQsD1YUi1tX+QGaA9mBT8oOELvl/1DZcXiF3JRphX2BdFezDaq 6GGpP76mQSF0TuxLVNdhODTfyKVOeS+ibt5CZ/qu5aJEZQDxE4lN/hJddzHHOjgM0+ RRKo8OKLGNaz1fu8Xof5bZQifk1gO+S9SLcbV3GE= Date: Mon, 6 Jul 2020 11:40:00 -0700 From: Jakub Kicinski To: Florian Fainelli Cc: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Michal Kubecek , linux-kernel@vger.kernel.org (open list) Subject: Re: [PATCH net-next v2 3/3] net: ethtool: Remove PHYLIB direct dependency Message-ID: <20200706114000.223e27eb@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20200706042758.168819-4-f.fainelli@gmail.com> References: <20200706042758.168819-1-f.fainelli@gmail.com> <20200706042758.168819-4-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 5 Jul 2020 21:27:58 -0700 Florian Fainelli wrote: > + ops = ethtool_phy_ops; > + if (!ops || !ops->start_cable_test) { nit: don't think member-by-member checking is necessary. We don't expect there to be any alternative versions of the ops, right? > + ret = -EOPNOTSUPP; > + goto out_rtnl; > + } > + > ret = ethnl_ops_begin(dev); > if (ret < 0) > goto out_rtnl; > > - ret = phy_start_cable_test(dev->phydev, info->extack); > + ret = ops->start_cable_test(dev->phydev, info->extack); nit: my personal preference would be to hide checking the ops and calling the member in a static inline helper. Note that we should be able to remove this from phy.h now: #if IS_ENABLED(CONFIG_PHYLIB) int phy_start_cable_test(struct phy_device *phydev, struct netlink_ext_ack *extack); int phy_start_cable_test_tdr(struct phy_device *phydev, struct netlink_ext_ack *extack, const struct phy_tdr_config *config); #else static inline int phy_start_cable_test(struct phy_device *phydev, struct netlink_ext_ack *extack) { NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support"); return -EOPNOTSUPP; } static inline int phy_start_cable_test_tdr(struct phy_device *phydev, struct netlink_ext_ack *extack, const struct phy_tdr_config *config) { NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support"); return -EOPNOTSUPP; } #endif We could even risk a direct call: #if IS_REACHABLE(CONFIG_PHYLIB) static inline int do_x() { return __do_x(); } #else static inline int do_x() { if (!ops) return -EOPNOTSUPP; return ops->do_x(); } #endif But that's perhaps doing too much...