From patchwork Wed Jun 23 18:24:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12340309 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 B43C6C48BC2 for ; Wed, 23 Jun 2021 18:27:04 +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 82BC7610F7 for ; Wed, 23 Jun 2021 18:27:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82BC7610F7 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=3GKbemxSOQC1Y3Yk5uLQqXeC1ceC9Ms+F+hWvDhHhAo=; b=e3pzmxY0Dmx4Bo WiB+BPeDULwH9e6/02O6g4dFeaK1CBCGz5gBZN9vbJzteHm6QfcNKn5GPYFC1bw9zqk5S/2t5q+Ic kmjcXk7zQXAuSKuEb6nH/EaYPwJDtyEgh8NyuKJFfLDfFRtN8zQbA6r1A+QxJCGuHKIuv3tpTNJ2F mGtB+3VZocVmMrWdHz+W8tASE16hJTkipi9/PbwLC9SKUI7b2IrrNfJnCRBr3lo5kAsfYFGqvZ4lt fJCV76fX0VmM8a0UNUcMB5CHLR9EJAKVESmYKQj0Q3cjSzGLJ3L0EL6/O4WDnrOZbMPQDfqjyo69p vQcas/1NNqyxN62oa6VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7YD-00BcBb-Rr; Wed, 23 Jun 2021 18:24:38 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7Y5-00Bc9o-BT for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 18:24:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472668; 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=Htp54BK0JGPxX8hRg4+dCEnU8CurZfr6H6uRpE1E1JA=; b=g7sSqpuLZmm90Xjm+OHcjhjcVgDlvM9RlGlTak8l1vlKjAbwawWX+rSHg6NwuYUFCZsnUp kiXA4Z29R3wwzLae+tvlY1OGIydyHPMwUEJWG6V8YnnVT4dAd7ckPHgMRJ5r6ShJNzSbDl 7/T9TxCYQQir5yU6jyr1ZPNdChVFcsY= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-239-A1Z1kB8aP_-30yOiURSLKw-1; Wed, 23 Jun 2021 14:24:26 -0400 X-MC-Unique: A1Z1kB8aP_-30yOiURSLKw-1 Received: by mail-oi1-f199.google.com with SMTP id a29-20020a544e1d0000b02901eef9e4a58cso2257042oiy.3 for ; Wed, 23 Jun 2021 11:24:26 -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=Htp54BK0JGPxX8hRg4+dCEnU8CurZfr6H6uRpE1E1JA=; b=L9yvhK5OZ+jhCw8ZqE2W2cXtOMTSV2ugEuw/IUEzMNozK7l2B43L9cjdG/9Onpa+n8 /sXxzuxRVYV1GRqd+ApyKVhuL4hSiy4mcWAjc3OgCyjLCrbdBhXPujpXb/iv/xot6Q3d quHaMHZyHepVjgxjE+rZwm2wM++pFC8zmtAj19Uw0yIHwlCl60lkWeQcD9yvhKiNAce7 s4RvUQPeb/3N7jYwjUvxY+oytBFYotG2Z81XtINGmziq30LCyHzFNBO63yFrizP9Si1l ZYat/LOV+Abt7WqWyl7n3C2AfmZsLKACgu/obNz7IPRg1CzaQqGE6mbkamKst+5HDLy2 5w8A== X-Gm-Message-State: AOAM531AF3M7wVbYGM+CERKlMlB4hvjT9Jp0FsVTa0p+qBcBwgIU00Zm zjp9mNtaoey0dUhuK96FlwxF3cRmZ6Ez0OpjBPM4rplMd6IZrJnzLBZVBBr8haN8xMVhRub7Ow2 0n6Q0l9Ep6PdvKmhsnqgfD4hqp6cVr7ooLAQ= X-Received: by 2002:a9d:4006:: with SMTP id m6mr1091547ote.130.1624472666218; Wed, 23 Jun 2021 11:24:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF6Hb/fcM8IvALNCl6D5hK6kIQQYZrMClGzUljQpEiNs53aD0YD3Vsj5TzZ9p5+6KcUhipMQ== X-Received: by 2002:a9d:4006:: with SMTP id m6mr1091530ote.130.1624472666056; Wed, 23 Jun 2021 11:24:26 -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 l24sm105186oii.45.2021.06.23.11.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:24:25 -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 v3 1/7] fpga-mgr: wrap the write_init() op Date: Wed, 23 Jun 2021 11:24:04 -0700 Message-Id: <20210623182410.3787784-3-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210623182410.3787784-1-trix@redhat.com> References: <20210623182410.3787784-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-20210623_112429_528954_4093D734 X-CRM114-Status: GOOD ( 14.85 ) 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_init() op if there is nothing for it do. So add a wrapper and move the op checking. Default to success. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index ecb4c3c795fa5..87bbb940c9504 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -69,6 +69,14 @@ void fpga_image_info_free(struct fpga_image_info *info) } EXPORT_SYMBOL_GPL(fpga_image_info_free); +static int fpga_mgr_write_init(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t count) +{ + if (mgr->mops && mgr->mops->write_init) + return mgr->mops->write_init(mgr, info, buf, count); + return 0; +} /* * Call the low level driver's write_init function. This will do the * device-specific things to get the FPGA into the state where it is ready to @@ -83,9 +91,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr, mgr->state = FPGA_MGR_STATE_WRITE_INIT; if (!mgr->mops->initial_header_size) - ret = mgr->mops->write_init(mgr, info, NULL, 0); + ret = fpga_mgr_write_init(mgr, info, NULL, 0); else - ret = mgr->mops->write_init( + ret = fpga_mgr_write_init( mgr, info, buf, min(mgr->mops->initial_header_size, count)); if (ret) { @@ -569,7 +577,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, int id, ret; if (!mops || !mops->write_complete || !mops->state || - !mops->write_init || (!mops->write && !mops->write_sg) || + (!mops->write && !mops->write_sg) || (mops->write && mops->write_sg)) { dev_err(parent, "Attempt to register without fpga_manager_ops\n"); return NULL;