From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47A09C433EF for ; Thu, 7 Oct 2021 19:58:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E81761077 for ; Thu, 7 Oct 2021 19:58:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbhJGUAA (ORCPT ); Thu, 7 Oct 2021 16:00:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:41728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241500AbhJGT76 (ORCPT ); Thu, 7 Oct 2021 15:59:58 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 CACC760F6E; Thu, 7 Oct 2021 19:58:01 +0000 (UTC) Date: Thu, 7 Oct 2021 15:58:00 -0400 From: Steven Rostedt To: Leon Romanovsky Cc: "David S . Miller" , Jakub Kicinski , Leon Romanovsky , Ido Schimmel , Ingo Molnar , Jiri Pirko , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, mlxsw@nvidia.com, Moshe Shemesh , netdev@vger.kernel.org, Saeed Mahameed , Salil Mehta , Shay Drory , Tariq Toukan , Yisen Zhuang Subject: Re: [PATCH net-next v3 1/5] devlink: Reduce struct devlink exposure Message-ID: <20211007155800.1ff26948@gandalf.local.home> In-Reply-To: <39692583a2aace1b9e435399344f097c72073522.1633589385.git.leonro@nvidia.com> References: <39692583a2aace1b9e435399344f097c72073522.1633589385.git.leonro@nvidia.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Thu, 7 Oct 2021 09:55:15 +0300 Leon Romanovsky wrote: > +void *devlink_priv(struct devlink *devlink) > +{ > + BUG_ON(!devlink); Do we really want to bring down the kernel in this case? Can't we just have: if (WARN_ON(!devlink)) return NULL; ? Same for the below as well. -- Steve > + return &devlink->priv; > +} > +EXPORT_SYMBOL_GPL(devlink_priv); > + > +struct devlink *priv_to_devlink(void *priv) > +{ > + BUG_ON(!priv); > + return container_of(priv, struct devlink, priv); > +} > +EXPORT_SYMBOL_GPL(priv_to_devlink); > + > +struct device *devlink_to_dev(const struct devlink *devlink) > +{ > + return devlink->dev; > +} > +EXPORT_SYMBOL_GPL(devlink_to_dev); > +