From patchwork Sun Apr 6 09:02:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Palmer X-Patchwork-Id: 3943151 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F17E1BFF02 for ; Sun, 6 Apr 2014 09:03:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02C2B20386 for ; Sun, 6 Apr 2014 09:03:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 321302037A for ; Sun, 6 Apr 2014 09:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753380AbaDFJC4 (ORCPT ); Sun, 6 Apr 2014 05:02:56 -0400 Received: from mail-vc0-f176.google.com ([209.85.220.176]:38432 "EHLO mail-vc0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750989AbaDFJCz (ORCPT ); Sun, 6 Apr 2014 05:02:55 -0400 Received: by mail-vc0-f176.google.com with SMTP id lc6so4267968vcb.7 for ; Sun, 06 Apr 2014 02:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=7h5s9WRoxpHWflk6f5ri6pmi0WC4KFlhSQcW0vOICs0=; b=EIpNYYJ5AnY1qFmZbYToTiJ5PRBD8qPZcE37UylLR37QSn3JWk5SwLBNUDlbweu24j hlzIlVfdPIQuTBOzrqhifLQNXzn+vjKePbUPPskpH1IjO9SppdvHFNhYMP3gSiolrY83 Qmr0qqCho6ll6WQlBNHtD6PEes/ICL8Be3UcYgHlpLDT7YCi2jgUXnAp6sq80pnSEOsB z0IdwQR6sRx1wiOVJPnn3IH68gqGcA+dbqUlgtFIBF2CR7tUn77ntZD+I0oEIE8n3SFm Ai/rzmU4bzjpVIeYHpoPXN6AOS/IxY2T6b0H+kHFTlE4rE19XCzIiL+cIxxC/Ww0KwNj iJqw== MIME-Version: 1.0 X-Received: by 10.52.241.106 with SMTP id wh10mr5575103vdc.16.1396774974666; Sun, 06 Apr 2014 02:02:54 -0700 (PDT) Received: by 10.52.188.38 with HTTP; Sun, 6 Apr 2014 02:02:54 -0700 (PDT) Date: Sun, 6 Apr 2014 18:02:54 +0900 Message-ID: Subject: [RFC] Making spi usable on machines without DMA From: Daniel Palmer To: linux-spi@vger.kernel.org Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, I'm writing a driver for the SPI controller in the DragonBall m68k based SoCs. Currently the kernel fails to link because of undefined symbols in spi.c because the platform doesn't have DMA and therefor doesn't provide some DMA related symbols. I have attached below my workaround for this that seems to work enough for my driver to get probed. Is this change acceptable? I'm not sure if my driver for the SPI controller will end up in the mainline kernel as the only user for it is me but it seems like some of my fixes for these chips will get merged so the probability is a little higher than zero. { @@ -686,6 +688,9 @@ static int spi_map_msg(struct spi_master *master, struct spi_message *msg) } } +#ifndef HAVE_DMA + return 0; +#else if (!master->can_dma) return 0; @@ -719,6 +724,7 @@ static int spi_map_msg(struct spi_master *master, struct spi_message *msg) master->cur_msg_mapped = true; return 0; +#endif } static int spi_unmap_msg(struct spi_master *master, struct spi_message *msg) @@ -726,6 +732,9 @@ static int spi_unmap_msg(struct spi_master *master, struct spi_message *msg) struct spi_transfer *xfer; struct device *tx_dev, *rx_dev; +#ifndef HAVE_DMA + return 0; +#else if (!master->cur_msg_mapped || !master->can_dma) return 0; @@ -741,6 +750,7 @@ static int spi_unmap_msg(struct spi_master *master, struct spi_message *msg) } return 0; +#endif } /* --- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 4eb9bf0..ae309de 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -580,6 +580,7 @@ static void spi_set_cs(struct spi_device *spi, bool enable) spi->master->set_cs(spi, !enable); } +#ifdef HAVE_DMA static int spi_map_buf(struct spi_master *master, struct device *dev, struct sg_table *sgt, void *buf, size_t len, enum dma_data_direction dir) @@ -636,6 +637,7 @@ static void spi_unmap_buf(struct spi_master *master, struct device *dev, sg_free_table(sgt); } } +#endif static int spi_map_msg(struct spi_master *master, struct spi_message *msg)