Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp629778rwb; Fri, 23 Sep 2022 01:48:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/F7GAo57fVs9F9dxfAvsQ9RMFupo7Y85MxLp5URLg3PrHSJjmqaWeYHgZ1B4y94DoIlU+ X-Received: by 2002:a17:906:5a71:b0:770:8625:489e with SMTP id my49-20020a1709065a7100b007708625489emr6166005ejc.405.1663922938095; Fri, 23 Sep 2022 01:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663922938; cv=none; d=google.com; s=arc-20160816; b=Tapu3hA0HNGPWXdLNZoUlFK1eC83/e7IWsjit8owJmdKkZwU2F6FMWrqiSdauoQWCf bWVqrWM3S+51yyFUr0XAMQmon+aELEFPLdZSKAiPiioQJyYCxhj3mTzwu+2NpO5oDxeL Tsb7HJmjnYPtRuk7AhU7Io1b12ZgzZpavxJPXtY6qihzOqqh9dmhfNFTOWeu3u8c4rc5 BCCyTpY+2Ty8uECoMiLeOHx+Xx/ofT9SkmUEmdx40ig1e8mk1WNhJY31mD7EJxeZKMn3 fDuSPk9Ol/iPcd49WiAMuk3fvgETPU8vaBinEmYGKShJB3H0O6Il8+Q5hBRRmdcicnHD CFqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:from:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date; bh=bcBVu/Nq3BQeDYzxCCWCNxw2yYIKwpt0ZC2SHSOuNVc=; b=aqO5JGEzDaR9G+6I6p5a+2QMcvw4YfK6nLkGKIi6FXZJkdomcqmw+YkMuDmeq1UyVK /NJws12gdX+PpCxnGxZZLOoVjWoXW3oj3nefe7Hc7hp15jwW4W8GJei8ciSYeuJx3Ztv h+eZ5CnzMAzIdYRVdmV0K/N3jYL2cSJlNVJef/suwGfBCGr0lGe1Lvv1jW55OWmnuihR nlFOsYGsGfMcfpS4fOVS+QHZFWzC0eOAi2SSsPvzxdsN7fTD5mhoAQJIzfx+cAkXqNIl EILD4/Yt0yYVpIRN/0dIN3xhwPKM95ebDhaNWe3Vu7RNOMc3NCs7ds9CYEtJj8/NaIWb Q+VA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a05640250c800b00451e0d930dfsi7960595edb.497.2022.09.23.01.48.33; Fri, 23 Sep 2022 01:48:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbiIWITa (ORCPT + 99 others); Fri, 23 Sep 2022 04:19:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbiIWIT3 (ORCPT ); Fri, 23 Sep 2022 04:19:29 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E96612C1DA for ; Fri, 23 Sep 2022 01:19:26 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1obdtu-0008WU-3O; Fri, 23 Sep 2022 10:19:10 +0200 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1obdtt-0007PY-2R; Fri, 23 Sep 2022 10:19:09 +0200 Date: Fri, 23 Sep 2022 10:19:09 +0200 To: Ivan Bornyakov Cc: Xu Yilun , mdf@kernel.org, hao.wu@intel.com, trix@redhat.com, dg@emlix.com, j.zink@pengutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-fpga@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, system@metrotek.ru Subject: Re: [PATCH v12 1/2] fpga: lattice-sysconfig-spi: add Lattice sysCONFIG FPGA manager Message-ID: <20220923081909.GO986@pengutronix.de> References: <20220919134750.25197-1-i.bornyakov@metrotek.ru> <20220919134750.25197-2-i.bornyakov@metrotek.ru> <20220923071638.45hylqvajn74j6mk@h-e2.ddg> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220923071638.45hylqvajn74j6mk@h-e2.ddg> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) From: Sascha Hauer X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 23, 2022 at 10:16:38AM +0300, Ivan Bornyakov wrote: > On Fri, Sep 23, 2022 at 02:24:46PM +0800, Xu Yilun wrote: > > On 2022-09-19 at 16:47:49 +0300, Ivan Bornyakov wrote: > > > Add support to the FPGA manager for programming Lattice ECP5 FPGA over > > > slave SPI sysCONFIG interface. > > > > > > sysCONFIG interface core functionality is separate from both ECP5 and > > > SPI specifics, so support for other FPGAs with different port types can > > > be added in the future. > > > > > > Signed-off-by: Ivan Bornyakov > > > --- > > > drivers/fpga/Kconfig | 11 + > > > drivers/fpga/Makefile | 2 + > > > drivers/fpga/lattice-sysconfig-spi.c | 153 ++++++++++ > > > drivers/fpga/lattice-sysconfig.c | 408 +++++++++++++++++++++++++++ > > > drivers/fpga/lattice-sysconfig.h | 40 +++ > > > 5 files changed, 614 insertions(+) > > > create mode 100644 drivers/fpga/lattice-sysconfig-spi.c > > > create mode 100644 drivers/fpga/lattice-sysconfig.c > > > create mode 100644 drivers/fpga/lattice-sysconfig.h > > > > > > diff --git a/drivers/fpga/lattice-sysconfig-spi.c b/drivers/fpga/lattice-sysconfig-spi.c > > > new file mode 100644 > > > index 000000000000..d015b796adf7 > > > --- /dev/null > > > +++ b/drivers/fpga/lattice-sysconfig-spi.c > > > > > > ... snip ... > > > > > > +static int sysconfig_isc_enable(struct sysconfig_priv *priv) > > > +{ > > > + u8 isc_enable[] = SYSCONFIG_ISC_ENABLE; > > > + u32 status; > > > + int ret; > > > + > > > + ret = sysconfig_cmd_write(priv, isc_enable, sizeof(isc_enable)); > > > + if (ret) > > > + return ret; > > > + > > > + ret = sysconfig_poll_status(priv, &status); > > > + if (ret || (status & SYSCONFIG_STATUS_FAIL)) > > > + return ret ? : -EFAULT; > > > > If (ret == 0 && status == SYSCONFIG_STATUS_FAIL), still return 0? > > > > No, -EFAULT should be returned in that case. Am I overlooked something? No, you don't, but writing this a bit less terse makes it far more readable: ret = sysconfig_poll_status(priv, &status); if (ret) return ret; if (status & SYSCONFIG_STATUS_FAIL) return -EFAULT; Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |