Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3460242imm; Tue, 29 May 2018 07:38:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpsi4HuA0/BjlSkWayDMbkZ+9WOCPcsoHjK4C9KA4L4flZW8tmJUykYmluL2TOxdr68Zj8/ X-Received: by 2002:a65:4289:: with SMTP id j9-v6mr14028687pgp.136.1527604703330; Tue, 29 May 2018 07:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527604703; cv=none; d=google.com; s=arc-20160816; b=JgeQR0s60zmWYM68rihwRYlnstMCH34esRFVHYFIOg9NihNxwEne1BKfApE81tOC7f NGv43Zv23NbD1bDeR6J1dCbex6TCt2ORRpayU95QBGqkNBWCA/CE2HzT4FggDeK6DHQ6 U5/RrZ3KMUqLtjKwZMB8Ha130w5r5EnIqsxLs6O3KVavsGWszWhaTDxHXXYjneDTGeVd v9kyiWXWOsiYTbb2JZ1uPx/RugPhEi9mT8h8Gwh+53ll3AafzdOCyB9rC0S0hsjS5bqy LLrqfUqH1jsZEEudaNN6iTGYp/rDHERXEHwNt4rYkRSpJ4OQIV2N7YcJdfYybPeFBVgx 77Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=LxX0f2dtpgPcvcTdGcDWxHPeTA0G0PQYuvDrpHlIKaE=; b=PHolEZ/QkV6hgUZJrWqqedOBCbBHx4eQEMon5DqbSNyus1yFPk0LQdDDeg2ddyaAzs d9KWIFv+5+2/ME2uJQjDO6GiQZc5sOa+9HWA+rzhWJECsiRled0yLVpnX1W1q/NCbDvg FwaLt/5R4ocazcSZonMpU4gKTmpGa08xaH4PpQ6oYCSxBBLqNgYVdAcEzauhPRlHNraC yck86OapP3TBh1Hy/lxzOiAIw+J8xB7LIc22AhjHPVBmNTxv7nOP9nGb/dEGvnrdtdDh MLEis6AyJJZ3dMt/WKccUeQxPjGnIOhiLDk0jYWdr5n55jG6h/wRXX6w/yRKosHn0YTm 6QfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5-v6si32947088pfi.96.2018.05.29.07.38.08; Tue, 29 May 2018 07:38:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934979AbeE2Ogm (ORCPT + 99 others); Tue, 29 May 2018 10:36:42 -0400 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:22292 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754903AbeE2Ogk (ORCPT ); Tue, 29 May 2018 10:36:40 -0400 X-IronPort-AV: E=Sophos;i="5.49,456,1520924400"; d="scan'208";a="14656652" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 May 2018 07:36:39 -0700 Received: from [10.159.245.112] (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Tue, 29 May 2018 07:36:38 -0700 Subject: Re: [PATCH v4 5/6] spi: at91-usart: add driver for at91-usart as spi To: Radu Pirea , Andy Shevchenko CC: Mark Brown , , Lee Jones , Richard Genoud , Rob Herring , Mark Rutland , Greg Kroah-Hartman , linux-spi , linux-arm Mailing List , Linux Kernel Mailing List , devicetree , "open list:SERIAL DRIVERS" , Ludovic Desroches References: <20180525171941.26766-1-radu.pirea@microchip.com> <20180525171941.26766-6-radu.pirea@microchip.com> <110bb353-b131-348c-8e26-9863b074142d@microchip.com> From: Nicolas Ferre Organization: microchip Message-ID: <0c529082-722c-14d8-7a04-dfeb63d5de92@microchip.com> Date: Tue, 29 May 2018 16:34:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <110bb353-b131-348c-8e26-9863b074142d@microchip.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/05/2018 at 16:28, Radu Pirea wrote: > > > On 05/28/2018 11:21 AM, Andy Shevchenko wrote: >> On Fri, May 25, 2018 at 8:19 PM, Radu Pirea wrote: >>> This is the driver for at91-usart in spi mode. The USART IP can be configured >>> to work in many modes and one of them is SPI. [..] >>> +static int at91_usart_gpio_setup(struct platform_device *pdev) >>> +{ >> >>> + struct device_node *np = pdev->dev.parent->of_node; >> >> Your driver is not OF specific as far as I can see. Drop all these >> device_node stuff and change API calls respectively. > > Ok. What do you suggest to use instead of OF API to get the count of > cs-gpios and to read their values one by one? As Alexandre said, we can make this driver OF specific. What could be interesting is to use the gpio descriptors API and not the older one. This would allow us to have far more control over the gpio that we use in our drivers (Ludovic is converting our drivers to only use gpiod structures). Regards, Nicolas > >> >>> + int i; >> >>> + int ret = 0; >>> + int nb = 0; >> >> What happened to indentation? >> >> Redundnant assignment for both. >> >>> + if (!np) >>> + return -EINVAL; >>> + >>> + nb = of_gpio_named_count(np, "cs-gpios"); >>> + for (i = 0; i < nb; i++) { >>> + int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); >>> + >>> + if (cs_gpio < 0) >>> + return cs_gpio; >>> + >>> + if (gpio_is_valid(cs_gpio)) { >>> + ret = devm_gpio_request_one(&pdev->dev, cs_gpio, >>> + GPIOF_DIR_OUT, >>> + dev_name(&pdev->dev)); >>> + if (ret) >>> + return ret; >>> + } >>> + } >>> + >>> + return 0; >>> +} [..] -- Nicolas Ferre