From patchwork Thu Jan 21 18:33:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 60097 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp172946lbb; Thu, 21 Jan 2016 10:34:02 -0800 (PST) X-Received: by 10.98.14.81 with SMTP id w78mr63072786pfi.26.1453401242164; Thu, 21 Jan 2016 10:34:02 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n86si3530795pfi.154.2016.01.21.10.34.01; Thu, 21 Jan 2016 10:34:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759793AbcAUSeA (ORCPT + 7 others); Thu, 21 Jan 2016 13:34:00 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:33190 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759645AbcAUSeA (ORCPT ); Thu, 21 Jan 2016 13:34:00 -0500 Received: by mail-wm0-f49.google.com with SMTP id 123so185906621wmz.0 for ; Thu, 21 Jan 2016 10:33:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Wmiu/HMadxzXXOocOSV+F2AzD/y5hcRctK0FIiqV52Y=; b=YEYTtjlQ+X9uxJQt0VDBzynhkhnEwhKUCCKoA9cwNy+vFQBfvmMmDs73N8OoJT8Oxa sM523XpRFMdOUtbUqJayxi3NYaHjuOu9i1MF/mYse8VbMl15G5qUdBq9b7m8500Kcktn FydHevN2PHyWQ3ame+eIOwc1jg69XKDHX7VqQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Wmiu/HMadxzXXOocOSV+F2AzD/y5hcRctK0FIiqV52Y=; b=aPN+eToGSVqX1Y/3YohSsczou+dqL4Ronq5Ml2DbcW5lHIMox27+jGs3F9T3xoBS95 N5FUgJd5pxiC7alYcHLG1XFyza6ERhLMDvkUCbHwGulHrYt3TlKjXP/gSVZlc9HWVKTV X3KWmbMGGqJ75SAlz62MMlax1bbiQXHxO1gTznpZmpwC2SCbcM20zwB3dCs/VK6Nne94 x4SZty3BCwA4LLnGGsE1pEgJVmMceYWE49w/w8sVXwMIESj7uTQ8VdlSmqKJp/0HqOf0 3cgMKzwuqfpUG2wlDNWxvmVsOxROAfn88AiF33jHIKOvIk2bfsb2sfd+l3z1tnE1Vdgd KmGw== X-Gm-Message-State: ALoCoQmvp9aM0K3pmB/sc/WI3+jz/HpyJoL2o7vhETcpKnPCkj/NjPkHZOdQcZ2knqCJeO7AVSJmqAVJs3CJXm1HxRDKDAZe/A== X-Received: by 10.194.157.165 with SMTP id wn5mr50931133wjb.41.1453401238765; Thu, 21 Jan 2016 10:33:58 -0800 (PST) Received: from localhost.localdomain (host-92-13-246-184.as43234.net. [92.13.246.184]) by smtp.gmail.com with ESMTPSA id x189sm3836060wmg.1.2016.01.21.10.33.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jan 2016 10:33:57 -0800 (PST) From: Srinivas Kandagatla To: Andy Gross , linux-spi@vger.kernel.org Cc: David Brown , Mark Brown , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH] spi: qup: provide proper bus numbers Date: Thu, 21 Jan 2016 18:33:47 +0000 Message-Id: <1453401227-27135-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This driver reuses pdev->id for spi bus numbers resulting in random or very large bus numbering when used with device trees. pdev->id is not the correct choice when using device trees. So add code to get bus numbers via device tree aliases and if it fails then generate a unique bus number. Without this patch the driver get a random and useless bus number. Signed-off-by: Srinivas Kandagatla --- drivers/spi/spi-qup.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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-qup.c b/drivers/spi/spi-qup.c index 810a7fa..2bc67a9 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c @@ -127,6 +127,8 @@ #define SPI_DELAY_THRESHOLD 1 #define SPI_DELAY_RETRY 10 +static atomic_t spi_qup_next_id = ATOMIC_INIT(0); + struct spi_qup { void __iomem *base; struct device *dev; @@ -759,7 +761,7 @@ static int spi_qup_probe(struct platform_device *pdev) struct device *dev; void __iomem *base; u32 max_freq, iomode, num_cs; - int ret, irq, size; + int ret, irq, size, bus_num; dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -816,7 +818,15 @@ static int spi_qup_probe(struct platform_device *pdev) else master->num_chipselect = num_cs; - master->bus_num = pdev->id; + if (dev->of_node) + bus_num = of_alias_get_id(dev->of_node, "spi"); + else + bus_num = pdev->id; + + if (bus_num < 0) + bus_num = atomic_inc_return(&spi_qup_next_id) - 1; + + master->bus_num = bus_num; master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); master->max_speed_hz = max_freq;