From patchwork Fri Jun 25 19:51:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CD39C49EAB for ; Fri, 25 Jun 2021 19:55:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF75461445 for ; Fri, 25 Jun 2021 19:55:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF75461445 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wQK8YVNQwtooPQT6Wr49qW79aNdRwz/Y2jUHMzHHEKw=; b=vZhVM42QojW4pZ UlboAwp2uJqzp+29msDhu20gcTcB+ZGzoBLkWRzE1YlhYTRrGQ3pJJ4vhPFxdIfYVwdaUiuN/pX9J UKP0XU+r9jY61+iV5mV7W1+47Hwl6fyBcNOHq6YsbCanj09TeQc76gZpAp66NRnTYfcnFflmYGLkY Qw82fSa6sOassFcub3NrSOrS25L64GLj7pBp+fpsgiVwt8T4QBbhQOWHXTY0q/bOvlWvTJzZ4bXM4 xCXtHVeQ3HRIhRsyeOCvJJPelxzCXM0kg367LVFTmr+WqMPzrlDqU2VFnkzYwrdWvzXufv7AI749O NN8xSLKG74QeGZd+zdpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrtS-002ivU-8s; Fri, 25 Jun 2021 19:53:38 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrsE-002iXy-Rj for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 19:52:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624650741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4aYp4hJz/EjjMi3xPniOC0g0VH/UB+PZgaBhiQVtvD8=; b=cVnK/KsA4xcDxWV1tLBEnX4BFD1/ZWhl8kr76HBQ/UZ2VSMtBnMXXv36lFZwaavnOQHYyX 2BPHadeooAXmUmRPSJ2s/7i5zt088D5SRaMjgi7IDNybmLoyF11LTTFHR3tnSQrzkwU/Xv 45aYAsQx8o3Xh2Ebi1jokRC+ymCkoHc= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-cL-FZV5HMdqPIieBdrcA1g-1; Fri, 25 Jun 2021 15:52:20 -0400 X-MC-Unique: cL-FZV5HMdqPIieBdrcA1g-1 Received: by mail-ot1-f69.google.com with SMTP id e14-20020a0568301f2eb0290405cba3beedso6560056oth.13 for ; Fri, 25 Jun 2021 12:52:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4aYp4hJz/EjjMi3xPniOC0g0VH/UB+PZgaBhiQVtvD8=; b=lKCTurAutU58aK/S52eGDvwGnQz6mgl6lfvyP8fjwor6Q98uCFIt+a6pB/oZNJaO8i fd2oZz/0kZ9gtOSQ7aywec/48sJ0IjebtIlr3+wCSCjd3GtJHcFSRxJFK6oge2+oLied VbRh00R6sIN3TY9gb12vY5HGEC1a6ksn+Z/TmrgJz1EmfPud8uZ1IfL+7Yayuxpjvc+8 5RPYaDD98sw4u+AUUSDx4YoIpBvM4mm6h8KwdSfFZG7u+SMPqsdh/UfhX6X6R2EM5JdL unw1Sd+nOZ2Glxr6TENBESDds4ZVikIQRuCHHAn5D74mK0KU3QJKiooSHZBtalA9APdV yJmQ== X-Gm-Message-State: AOAM5302aBZ6CIwEimkNGHu61cFwFERfGMlpjV9gLWbKYDn6FMKMSCkr IskkB1/4FvV3nSei1AwqEMvdjvEY9bCZZowyGzRIf6em4jwS3ihHCiW7qcOZJAMbIB47hFCZSdc NHEPLI0CmdEI6bxUUD/dWaRvTAWsKTr5bMAs= X-Received: by 2002:a05:6808:bc1:: with SMTP id o1mr12878397oik.176.1624650739896; Fri, 25 Jun 2021 12:52:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypIr38r6Xwat7SHOutFdWdtMBZB5yIHYyEpbFVr7YNiZOiaRsU1APN36mLAM8st0Os4NeZUA== X-Received: by 2002:a05:6808:bc1:: with SMTP id o1mr12878390oik.176.1624650739792; Fri, 25 Jun 2021 12:52:19 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id o25sm1535446ood.20.2021.06.25.12.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:19 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v4 7/7] fpga-mgr: wrap the write_sg() op Date: Fri, 25 Jun 2021 12:51:48 -0700 Message-Id: <20210625195148.837230-9-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210625195148.837230-1-trix@redhat.com> References: <20210625195148.837230-1-trix@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210625_125223_017525_29203EBA X-CRM114-Status: GOOD ( 13.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix An FPGA manager should not be required to provide a write_sg function. Move the op check to the wrapper. Default to -EOPNOTSUP so its users will fail gracefully. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 077c0f9edbe4c..aa30889e23208 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -83,6 +83,14 @@ static inline int fpga_mgr_write_init(struct fpga_manager *mgr, return 0; } +static inline int fpga_mgr_write_sg(struct fpga_manager *mgr, + struct sg_table *sgt) +{ + if (mgr->mops->write_sg) + return mgr->mops->write_sg(mgr, sgt); + return -EOPNOTSUPP; +} + /** * fpga_image_info_alloc - Allocate an FPGA image info struct * @dev: owning device @@ -225,7 +233,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, /* Write the FPGA image to the FPGA. */ mgr->state = FPGA_MGR_STATE_WRITE; if (mgr->mops->write_sg) { - ret = mgr->mops->write_sg(mgr, sgt); + ret = fpga_mgr_write_sg(mgr, sgt); } else { struct sg_mapping_iter miter;