From patchwork Thu Jul 31 17:33:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 34680 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CDA132188F for ; Thu, 31 Jul 2014 16:48:43 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id 29sf10564419yhl.10 for ; Thu, 31 Jul 2014 09:48:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=TcfkPc+CXDJFOYXYXBHWur34q0x3S6L3xhHbQ5EVQqA=; b=b/K5k61klQGQQ8wrroS0txp+pq2T4zAyMKOJgM6p9sxPMkTN7LPBszh+oylNo1caU8 hC2ovkoJmLoYfwE+IdxOcZhPHaLR7tx1HI6DSrhmW1rn5bhGIcjGjT930uN6zyRoJoSP C2tm9un04DqF3ZazFB5VDddFTq6QuZJBawcm9qcNrn+uo6BtGmhedm9nh09y1aWreW42 fqkVWShZOyIAzd4r3oxPv5wFz0mS8GUZdDjkkg2wgi+gyG2ouX1Z32Nc48VKoXER2oTM oK/ZMgFEW2GpznMwxZG+UrkJx4TfXFmij4SA9u0xt0Z8Qfq5fU9nNwOT0XT11Cqsk/MY PjDQ== X-Gm-Message-State: ALoCoQkNEsp4qWUGzPKOgfB/yU8q5ugO7zNNZ2Z8NNo/BgJOIXbneAm2Jsu/m1OyQUpl+/kCBW8W X-Received: by 10.236.206.51 with SMTP id k39mr1738057yho.23.1406825323664; Thu, 31 Jul 2014 09:48:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.117 with SMTP id i108ls1106790qgf.76.gmail; Thu, 31 Jul 2014 09:48:43 -0700 (PDT) X-Received: by 10.52.26.173 with SMTP id m13mr10631038vdg.69.1406825323600; Thu, 31 Jul 2014 09:48:43 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id sb10si4985576vdc.89.2014.07.31.09.48.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 31 Jul 2014 09:48:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so4699410vcb.1 for ; Thu, 31 Jul 2014 09:48:43 -0700 (PDT) X-Received: by 10.52.120.38 with SMTP id kz6mr3335946vdb.86.1406825323459; Thu, 31 Jul 2014 09:48:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp33450vcb; Thu, 31 Jul 2014 09:48:42 -0700 (PDT) X-Received: by 10.68.194.229 with SMTP id hz5mr5801103pbc.91.1406825322315; Thu, 31 Jul 2014 09:48:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc15si3302625pdb.17.2014.07.31.09.48.41 for ; Thu, 31 Jul 2014 09:48:42 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752751AbaGaQsi (ORCPT + 6 others); Thu, 31 Jul 2014 12:48:38 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:45319 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752741AbaGaQsf (ORCPT ); Thu, 31 Jul 2014 12:48:35 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s6VGm7PS027835; Thu, 31 Jul 2014 11:48:07 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s6VGm7VN014236; Thu, 31 Jul 2014 11:48:07 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Thu, 31 Jul 2014 11:48:07 -0500 Received: from localhost (dlep60.itg.ti.com [157.170.170.21]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s6VGm6bc017121; Thu, 31 Jul 2014 11:48:06 -0500 From: Grygorii Strashko To: , Mark Brown , CC: , Rob Herring , Ian Campbell , , Murali Karicheri , Grygorii Strashko Subject: [PATCH 1/2] spi: davinci: fix to support more than 2 chip selects Date: Thu, 31 Jul 2014 20:33:14 +0300 Message-ID: <1406827995-30913-2-git-send-email-grygorii.strashko@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1406827995-30913-1-git-send-email-grygorii.strashko@ti.com> References: <1406827995-30913-1-git-send-email-grygorii.strashko@ti.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Murali Karicheri Currently, the driver defines SPI_MAX_CHIPSELECT as 2 and use per device array bytes_per_word based on this. This breaks if num_chipselect per device is greater than 2. This patch fix this and allocate memory for this array based on num_chipselect. It's preparation patch to enable GPIO CS feature for Davinci SPI. Signed-off-by: Murali Karicheri Signed-off-by: Grygorii Strashko --- drivers/spi/spi-davinci.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 50f7509..2477af4 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -38,8 +38,6 @@ #define SPI_NO_RESOURCE ((resource_size_t)-1) -#define SPI_MAX_CHIPSELECT 2 - #define CS_DEFAULT 0xFF #define SPIFMT_PHASE_MASK BIT(16) @@ -142,7 +140,7 @@ struct davinci_spi { void (*get_rx)(u32 rx_data, struct davinci_spi *); u32 (*get_tx)(struct davinci_spi *); - u8 bytes_per_word[SPI_MAX_CHIPSELECT]; + u8 *bytes_per_word; }; static struct davinci_spi_config davinci_spi_default_cfg; @@ -876,6 +874,14 @@ static int davinci_spi_probe(struct platform_device *pdev) /* pdata in dspi is now updated and point pdata to that */ pdata = &dspi->pdata; + dspi->bytes_per_word = devm_kzalloc(&pdev->dev, + sizeof(*dspi->bytes_per_word) * + pdata->num_chipselect, GFP_KERNEL); + if (dspi->bytes_per_word == NULL) { + ret = -ENOMEM; + goto free_master; + } + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (r == NULL) { ret = -ENOENT;