Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9759220ybi; Wed, 24 Jul 2019 09:27:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWVYhU/xDPivDKyWvPp2/RRvOwyy5WW56i0yn2VTBh+j2MayQQFgM/+C6cK9vP6dRO971T X-Received: by 2002:a62:6454:: with SMTP id y81mr11728093pfb.13.1563985639086; Wed, 24 Jul 2019 09:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563985639; cv=none; d=google.com; s=arc-20160816; b=MfAZ9xOgkll0iM6Cxusyl0syXh8XgfAoPrzyN2CxGWdjI2NrqBaYSoJJ3Cy4RndmhV KkPGvt5y8t3vThIA/9d30psDDawUFLBx6kJZDgdV/2Bt+CuiPR5P2p+zMLOR1wPbvJrA 0bkxeAlGbptpt5b2puYOuNJgvCfkG4+TtlVuLSCnkOi9woVko09Ehamwc7zM7BVRPvw7 E4HH5cxsDWFWTo0G6WDuimfG+iPBBvq2N5/ZIL09vvdsWuq438C4i3stX0+cHIpJG2WH CZNAW03arMU4yA4fS2oXZ6M79WLqNpdzzdAGwxnAOcUjGndgIiAjixby5mne2UtoNjDl oqTA== 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; bh=Uw5ieDuf/WxT2QinjAfj12uwNhpSEyPAn73tdIopdZA=; b=WDiLD9SDFDGIFl8fstzezI8FEfTCp41nAEpg/O653wwkr4mEHACbuFeOkUJ/dtZvpZ hMpg4ieyG8TSmA5Z0wEqCxuSl8J38w+1my5KIp+UOZXaiRsEWfeo+0+2X981vYIThB6m T7tpWW11Tt7F2Y9d86tmMX9jfclM1Zrh2V/Q+XU7tuVmAuP6SARfSOVdyok4mp/F0XWT sty/+ylL3An4Q14mm4tTO8JqQj/kmLRLyG2kEL1Dl/d5n6jaWMiEqEnoAHUnF6d4RfNS mdwP+e3ohE9SGxDa4t22qwT9julm1frbip+pPhSagZ3VHaswHuDHyzvBlx3+SYUlYMUV o9Yw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s189si13824640pgb.272.2019.07.24.09.27.04; Wed, 24 Jul 2019 09:27:19 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728408AbfGXOEr (ORCPT + 99 others); Wed, 24 Jul 2019 10:04:47 -0400 Received: from mga07.intel.com ([134.134.136.100]:24682 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726472AbfGXOEr (ORCPT ); Wed, 24 Jul 2019 10:04:47 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 24 Jul 2019 07:04:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,303,1559545200"; d="scan'208";a="345110232" Received: from hao-dev.bj.intel.com (HELO localhost) ([10.238.157.65]) by orsmga005.jf.intel.com with ESMTP; 24 Jul 2019 07:04:44 -0700 Date: Wed, 24 Jul 2019 21:47:46 +0800 From: Wu Hao To: Greg KH 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: <20190724134746.GD8463@hao-dev> References: <1563857495-26692-1-git-send-email-hao.wu@intel.com> <1563857495-26692-3-git-send-email-hao.wu@intel.com> <20190724093357.GA29532@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190724093357.GA29532@kroah.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 24, 2019 at 11:33:57AM +0200, Greg KH wrote: > 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. I see, you're right, it saves everybody's time on reading, very important. I will fix this and keep it in mind. Thank you. Hao > > thanks, > > greg k-h