From patchwork Wed Nov 21 11:08:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10692393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D23513BF for ; Wed, 21 Nov 2018 11:06:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C2632B830 for ; Wed, 21 Nov 2018 11:06:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8038E2B854; Wed, 21 Nov 2018 11:06:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HK_RANDOM_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 227FD2B832 for ; Wed, 21 Nov 2018 11:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729557AbeKUVkR (ORCPT ); Wed, 21 Nov 2018 16:40:17 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35307 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728114AbeKUVkQ (ORCPT ); Wed, 21 Nov 2018 16:40:16 -0500 Received: by mail-lj1-f195.google.com with SMTP id x85-v6so4461719ljb.2; Wed, 21 Nov 2018 03:06:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xJzcdWUi5g1mmy1o8VxmoXAad6mTqA99FbBKb9Bxfrc=; b=r7kVjeMexgP6f9JebK5xtWxEWBrGaxE9aO7UAIPB/mkfz4LHZ5rZH+1b8rKYohtZlb X35+qLvQE4gUhVFlIQp7AbPOC6H45bVsAFgE1CLkLO4Eo1yoOvAITMQd7IWe9YvKK3+n 5Fnlxx4G335qYD00tikii/PZ72X3efGwJq7fRnjLk0MptiDINzN4yx4vzb5odvcd/bSI 2tcxAUKsBBacBnZvbRbjgrSnoDnP5f7hLugH9IWMbIOzwDGqLU77ecaommjrYaMkWclZ yYOMUtRFWbTbRlUW6m6hcPYgucMnZ13Upc8t6MKCSQqF+PARmsl6zmWOK1n04eEWTk0x mVIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xJzcdWUi5g1mmy1o8VxmoXAad6mTqA99FbBKb9Bxfrc=; b=VxKFYnJC95XE5xUsdaFv3zhiPs9Drz/IZiYanyGPHa5DBFsErlrteqpQXYPrtnccRn vDBHjBRHatFmed7NQ2kvy+65L9TVcftfkMJLxW/jcLFlRMNSxqAxQsCFSAls2gT2+Xzv 7w5WycH98TDra94uvNUF7vc2nNm5C4E4Oi69W+IVfYtetbVPaIl9ZmwlN5eQLs0q+IJR 24KaPVs09gSwWoRRn/ZgIuWBK0kFR/YytUsupF7hmYVayStitBO3yOg7asOQVOMLLYYq BFLqKhColL9YSDjK1Ie7sxefQtC7D4F2L74bXP1AMq0e9TZOyew9H6t87WuhH6D3YxKK P6vQ== X-Gm-Message-State: AA+aEWYaPymhPTmPYr5ZnHs4N8la2zDUhiVIrROguw82mvGzyzkAgRU2 uTE42QxV6rqn0NCUBJhc/4c= X-Google-Smtp-Source: AFSGD/UxF4+6EgaFA+wlF99Claii+6Jao8pyHQxGqPr3OZRx9RKbJ/gQQiNoxL7Rl1quD08TtXxBpw== X-Received: by 2002:a2e:81a:: with SMTP id 26-v6mr4019750lji.14.1542798376943; Wed, 21 Nov 2018 03:06:16 -0800 (PST) Received: from z50.intranet (78-10-164-223.static.ip.netia.com.pl. [78.10.164.223]) by smtp.gmail.com with ESMTPSA id x11sm7280047lfd.81.2018.11.21.03.06.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:06:16 -0800 (PST) From: Janusz Krzysztofik To: Boris Brezillon , Miquel Raynal Cc: Tony Lindgren , Aaro Koskinen , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Linus Walleij , linux-mtd@lists.infradead.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v4 2/4] mtd: rawnand: ams-delta: Request data port GPIO resource Date: Wed, 21 Nov 2018 12:08:04 +0100 Message-Id: <20181121110806.32076-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181121110806.32076-1-jmkrzyszt@gmail.com> References: <20180813223448.21316-1-jmkrzyszt@gmail.com> <20181121110806.32076-1-jmkrzyszt@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Data port used by the driver is actually an OMAP MPUIO device, already under control of gpio-omap driver. For that reason we used to not request the memory region of the port as that would fail because the region is already busy. Despite that, we are still accessing the port by just ioremapping it and performing read/write operations. Moreover, we are doing that without any proteciton from other users legally manipulating the port pins over GPIO API. The plan is to convert the driver to access the port over GPIO consumer API. Before that happens, already prevent from other users accessing the port pins by requesting an array of its GPIO descriptors. Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon Reviewed-by: Linus Walleij --- drivers/mtd/nand/raw/ams-delta.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index f8eb4a419e77..bb50dda05654 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -190,6 +190,7 @@ static int ams_delta_init(struct platform_device *pdev) struct mtd_info *mtd; struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); void __iomem *io_base; + struct gpio_descs *data_gpiods; int err = 0; if (!res) @@ -275,8 +276,14 @@ static int ams_delta_init(struct platform_device *pdev) goto err_unmap; } - /* Initialize data port direction to a known state */ - ams_delta_dir_input(priv, true); + /* Request array of data pins, initialize them as input */ + data_gpiods = devm_gpiod_get_array(&pdev->dev, "data", GPIOD_IN); + if (IS_ERR(data_gpiods)) { + err = PTR_ERR(data_gpiods); + dev_err(&pdev->dev, "data GPIO request failed: %d\n", err); + goto err_unmap; + } + priv->data_in = true; /* Initialize the NAND controller object embedded in ams_delta_nand. */ priv->base.ops = &ams_delta_ops;