From patchwork Tue Apr 14 13:40:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pelle Nilsson X-Patchwork-Id: 6216221 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E0A6A9F2EC for ; Tue, 14 Apr 2015 13:40:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D8C2202DD for ; Tue, 14 Apr 2015 13:40:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A316201D3 for ; Tue, 14 Apr 2015 13:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753291AbbDNNkg (ORCPT ); Tue, 14 Apr 2015 09:40:36 -0400 Received: from mail6.surf-town.net ([212.97.132.46]:37484 "EHLO mailgw14.surf-town.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752883AbbDNNkf (ORCPT ); Tue, 14 Apr 2015 09:40:35 -0400 Received: by mailgw14.surf-town.net (Postfix, from userid 65534) id 9C1DF3E0C6; Tue, 14 Apr 2015 15:40:32 +0200 (CEST) Received: from localhost (unknown [127.0.0.1]) by mailgw14.surf-town.net (Postfix) with ESMTP id 17F963E41D; Tue, 14 Apr 2015 15:40:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mailgw14.surf-town.net X-Spam-Score: -1.44 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from mailgw14.surf-town.net ([127.0.0.1]) by localhost (mailgw14.surf-town.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ujzENlbE7UH0; Tue, 14 Apr 2015 15:40:29 +0200 (CEST) Received: from btc-laptop-1.KnC.local (unknown [194.18.61.26]) (Authenticated sender: per.nilsson@xelmo.com) by mailgw14.surf-town.net (Postfix) with ESMTPSA id AAEDE3E207; Tue, 14 Apr 2015 15:40:22 +0200 (CEST) From: Pelle Nilsson To: broonie@kernel.org Cc: ezequiel@vanguardiasur.com.ar, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, nios2-dev@lists.rocketboards.org Subject: [PATCH v2] spi: bitbang: Make setup_transfer() callback optional Date: Tue, 14 Apr 2015 15:40:17 +0200 Message-Id: <1429018817-18117-1-git-send-email-per.nilsson@xelmo.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428919685-14190-1-git-send-email-per.nilsson@xelmo.com> References: <1428919685-14190-1-git-send-email-per.nilsson@xelmo.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some controller drivers have no need of this callback (spi-altera even causes a NULL pointer dereference because it doesn't register the callback, falsely assuming that it is already optional). Fixes: 30af9b558a56 ("spi/bitbang: Drop empty setup() functions") Signed-off-by: Pelle Nilsson Reviewed-by: Ezequiel Garcia --- drivers/spi/spi-bitbang.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c index 5ef6638..840a498 100644 --- a/drivers/spi/spi-bitbang.c +++ b/drivers/spi/spi-bitbang.c @@ -180,7 +180,6 @@ int spi_bitbang_setup(struct spi_device *spi) { struct spi_bitbang_cs *cs = spi->controller_state; struct spi_bitbang *bitbang; - int retval; unsigned long flags; bitbang = spi_master_get_devdata(spi->master); @@ -197,9 +196,11 @@ int spi_bitbang_setup(struct spi_device *spi) if (!cs->txrx_word) return -EINVAL; - retval = bitbang->setup_transfer(spi, NULL); - if (retval < 0) - return retval; + if (bitbang->setup_transfer) { + int retval = bitbang->setup_transfer(spi, NULL); + if (retval < 0) + return retval; + } dev_dbg(&spi->dev, "%s, %u nsec/bit\n", __func__, 2 * cs->nsecs); @@ -295,9 +296,11 @@ static int spi_bitbang_transfer_one(struct spi_master *master, /* init (-1) or override (1) transfer params */ if (do_setup != 0) { - status = bitbang->setup_transfer(spi, t); - if (status < 0) - break; + if (bitbang->setup_transfer) { + status = bitbang->setup_transfer(spi, t); + if (status < 0) + break; + } if (do_setup == -1) do_setup = 0; }