From patchwork Wed Mar 12 10:35:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3816511 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 AB8AEBF540 for ; Wed, 12 Mar 2014 10:36:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF03520148 for ; Wed, 12 Mar 2014 10:36:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD4C620170 for ; Wed, 12 Mar 2014 10:36:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753562AbaCLKgf (ORCPT ); Wed, 12 Mar 2014 06:36:35 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:65357 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753462AbaCLKgd (ORCPT ); Wed, 12 Mar 2014 06:36:33 -0400 Received: by mail-pd0-f173.google.com with SMTP id z10so898567pdj.32 for ; Wed, 12 Mar 2014 03:36:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=2KVKytfZr8Rzad4M8FI9/c1Q72fdUAbMd0anBwUlcfc=; b=Vg5kTugLIp54Ahpix7GRQWcBf+I4qoy4v8cYqlZUY3uSYgNJd6dqfAmY1ZvfoSWjE3 eyjX6PKmL6rKNzbwgK7dMxJ8gRJ1Fu7D23TzJkcP2QK8NdAn9H1RDw5zEK4MV48qyLjO ElWUnpgKxcG+vp5H92THZHUftRKxCGZcfr8DrK6LDnbvBZ/ePhnZuJxOyBStF/v5DpMH Dv5X6nvMo0UJbhDRuxifQldW0hMSPeoRDPA50th9OCLgO8gF8ZU1H2UL+hBrRmkXb+8/ 2r6pNC/KV3EPv7qSOb3bG79SAIdm46xnDjkFU5iDn19HrdqdvusBEPf3GKNjFk4ZEMdV I8kQ== X-Gm-Message-State: ALoCoQlagG348Is5aNLoEixEfgIDwXNVp4GX1zKmvgEeLmOmn1HdRKRKhj8rDGR8Uuh+YTJiTtN0 X-Received: by 10.66.142.42 with SMTP id rt10mr4020354pab.1.1394620592931; Wed, 12 Mar 2014 03:36:32 -0700 (PDT) Received: from [10.145.55.57] ([60.245.65.194]) by mx.google.com with ESMTPSA id sy2sm5818714pbc.28.2014.03.12.03.35.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Mar 2014 03:36:32 -0700 (PDT) Message-ID: <1394620523.3290.1.camel@phoenix> Subject: [PATCH v2] spi: efm32: Clean up non-DT paths From: Axel Lin To: Mark Brown Cc: Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , linux-spi@vger.kernel.org Date: Wed, 12 Mar 2014 18:35:23 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 This is a DT-only driver, so remove all non-DT paths. of_gpio_named_count() may fail, thus also add checking it's return value. efm32_spi_probe_dt() never fails, make it return void. Signed-off-by: Axel Lin Acked-by: Uwe Kleine-König --- drivers/spi/spi-efm32.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/spi/spi-efm32.c b/drivers/spi/spi-efm32.c index f53bbea..b9983ef 100644 --- a/drivers/spi/spi-efm32.c +++ b/drivers/spi/spi-efm32.c @@ -287,16 +287,13 @@ static u32 efm32_spi_get_configured_location(struct efm32_spi_ddata *ddata) return (reg & REG_ROUTE_LOCATION__MASK) >> __ffs(REG_ROUTE_LOCATION__MASK); } -static int efm32_spi_probe_dt(struct platform_device *pdev, +static void efm32_spi_probe_dt(struct platform_device *pdev, struct spi_master *master, struct efm32_spi_ddata *ddata) { struct device_node *np = pdev->dev.of_node; u32 location; int ret; - if (!np) - return 1; - ret = of_property_read_u32(np, "location", &location); if (!ret) { dev_dbg(&pdev->dev, "using location %u\n", location); @@ -308,7 +305,6 @@ static int efm32_spi_probe_dt(struct platform_device *pdev, } ddata->pdata.location = location; - return 0; } static int efm32_spi_probe(struct platform_device *pdev) @@ -318,9 +314,14 @@ static int efm32_spi_probe(struct platform_device *pdev) int ret; struct spi_master *master; struct device_node *np = pdev->dev.of_node; - unsigned int num_cs, i; + int num_cs, i; + + if (!np) + return -EINVAL; num_cs = of_gpio_named_count(np, "cs-gpios"); + if (num_cs < 0) + return num_cs; master = spi_alloc_master(&pdev->dev, sizeof(*ddata) + num_cs * sizeof(unsigned)); @@ -412,23 +413,7 @@ static int efm32_spi_probe(struct platform_device *pdev) goto err; } - ret = efm32_spi_probe_dt(pdev, master, ddata); - if (ret > 0) { - /* not created by device tree */ - const struct efm32_spi_pdata *pdata = - dev_get_platdata(&pdev->dev); - - if (pdata) - ddata->pdata = *pdata; - else - ddata->pdata.location = - efm32_spi_get_configured_location(ddata); - - master->bus_num = pdev->id; - - } else if (ret < 0) { - goto err_disable_clk; - } + efm32_spi_probe_dt(pdev, master, ddata); efm32_spi_write32(ddata, 0, REG_IEN); efm32_spi_write32(ddata, REG_ROUTE_TXPEN | REG_ROUTE_RXPEN |