Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9376242ybi; Wed, 24 Jul 2019 03:03:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhYW89PM8e+ubEl4XlgtLT+0sNbfnZOTL/CSxkoToRNeGl9AGDs5g3yBahZ36GFODSBUcn X-Received: by 2002:a63:5d45:: with SMTP id o5mr81758800pgm.40.1563962627834; Wed, 24 Jul 2019 03:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563962627; cv=none; d=google.com; s=arc-20160816; b=rjk9rkc/M9DWPjbyz9ssO99iGWZdom46lZ/scXhy2t41OOIEIypM48f67DZ1pwpWth aZAClmG9ZBs50cwAOht7EmWo51bw7GtweZp1u4xps8F+UaOm6Sz9IXsGxw9W4N44nSgH vD4TmLY90nzDWJAAlDHplXoYuJ/XchfPwgU64OVBcl0cujqQAlfvyaC9F/RI4KeArvB6 3nZOuk1iTw5188TZ1yXuRa1ryV8bmI1tqFLsdp3A5Ymv7lUFXDyxRAzD1ARXGziBx6fz JqHNSMbzXyALocGMiiza+a+MQDmM9Yb/vzFiooX9/8XkJNQfcZgM4//jLDdOjV/b88rv zaQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rLX9nnXbaNKfn3ibdarXGSX1VCFY260z2/x2xI0QgRA=; b=hLrJ4LzhJhUtQKjD83kZz9Ol3KQkHMiptFNzQGXwuQmyhFm1Oyw/3c3gf3ndA7MOvk t3oJAqOU+NwWgTnI5xhixE9qgLeSYivKmdhm9PuuLVjRqjTxlHb0+Y/6hbGbQ23BhrpP iQ1N5/yv7PKzzZdMiCsNX2eM44cf9h6epdWqtYWjeOqNoA1ssMQiKhRplt5zgXfsSN5I bdDp/wTe6UTYJk2zyEBChBIe7Ee+kzQqYGs4DgRqZrnU28ujKrAK9RzVI53I5j6nRGkL /Zkr22df3Wmdu4D+1qAaELT6MPnS60E9LabByl9f8UUkwC23oSHEtLZ9HlbJ9qAurnPB 3thg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R+lCRxoL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si14406671plr.94.2019.07.24.03.03.32; Wed, 24 Jul 2019 03:03:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R+lCRxoL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726869AbfGXJeB (ORCPT + 99 others); Wed, 24 Jul 2019 05:34:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:34318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726351AbfGXJeB (ORCPT ); Wed, 24 Jul 2019 05:34:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 AAFB421926; Wed, 24 Jul 2019 09:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563960840; bh=3cSIO9EZDi3J13tYyRv3TfjK0zuvMILYluyj3HtRV7U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R+lCRxoLNB76QsKlZeG7tXK7idALbdmsQiHPTlBdK8ON/1oNMKvuA6QEXrxEaCROc 0Gh5shjqnao27yA/FVidF5XwQLpjoCcpG967kMPkZQc3QCo5DmnlhrJYfYZPu+RTHO trlrCDn2h8x9MqDb4AqRSE67jRlcFE6u4QVtSqtQ= Date: Wed, 24 Jul 2019 11:33:57 +0200 From: Greg KH To: Wu Hao Cc: mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, atull@kernel.org, Zhang Yi Z , Xu Yilun Subject: Re: [PATCH v3 02/12] fpga: dfl: fme: add DFL_FPGA_FME_PORT_RELEASE/ASSIGN ioctl support. Message-ID: <20190724093357.GA29532@kroah.com> References: <1563857495-26692-1-git-send-email-hao.wu@intel.com> <1563857495-26692-3-git-send-email-hao.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1563857495-26692-3-git-send-email-hao.wu@intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 23, 2019 at 12:51:25PM +0800, Wu Hao wrote: > +/** > + * dfl_fpga_cdev_config_port - configure a port feature dev > + * @cdev: parent container device. > + * @port_id: id of the port feature device. > + * @release: release port or assign port back. > + * > + * This function allows user to release port platform device or assign it back. > + * e.g. to safely turn one port from PF into VF for PCI device SRIOV support, > + * release port platform device is one necessary step. > + */ > +int dfl_fpga_cdev_config_port(struct dfl_fpga_cdev *cdev, int port_id, > + bool release) > +{ > + return release ? detach_port_dev(cdev, port_id) : > + attach_port_dev(cdev, port_id); > +} > +EXPORT_SYMBOL_GPL(dfl_fpga_cdev_config_port); That's a horrible api. Every time you see this call in code, you have to go and look up what "bool" means here. There's no reason for it. Just have 2 different functions, one that attaches a port, and one that detaches it. That way when you read the code that calls this function, you know what it does instantly without having to go look up some api function somewhere else. Write code for people to read first. And you are saving nothing here by trying to do two different things in the same exact function. thanks, greg k-h