From patchwork Tue Jan 15 01:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Khemka X-Patchwork-Id: 10763761 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 B3928139A for ; Tue, 15 Jan 2019 01:52:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A43E82C1E8 for ; Tue, 15 Jan 2019 01:52:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2A5B2C1EB; Tue, 15 Jan 2019 01:52:04 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 357C72C1E9 for ; Tue, 15 Jan 2019 01:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zoQbAjDPCSE3byq/SJvcSy1zFoUuwhTE/m6LjIEVtIY=; b=rz8vo+PEwQyQ8q 1/NN50WPjPZWeaB0ltX4+YYDk2RJCfwsqEuMIsJ1mJpveSfXsrl7JzlIyvhhHnvqZs6yWEO2mLcEu 2V9s/e0XJShZ3u+pIYivZeTRUgDW07k+eKFOvRpSn4zE2zrCDkYb7lfQXIFmLJf1CGpggru2YrYSn atPmfSOhJ/VFsPQysB0f4tEQf3oUlu3GlxIJDPSr/iAC3+dctUlD/YDTueX9VR2zFh072bBvXCTrl 5qqNfaifuQrTrDAs1/vGn0XMg3/MxEN+c9zaLKaSRqT1jdV2i1y6paTWQBPtNuHL7QQuzTEppVwUH jhMI30BKN4cfiTdcoUUQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjDtX-0001Hd-J4; Tue, 15 Jan 2019 01:51:59 +0000 Received: from mx0b-00082601.pphosted.com ([67.231.153.30] helo=mx0a-00082601.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjDtT-0001HA-AN for linux-arm-kernel@lists.infradead.org; Tue, 15 Jan 2019 01:51:57 +0000 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.27/8.16.0.27) with SMTP id x0F1pdQs019896 for ; Mon, 14 Jan 2019 17:51:51 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=aESUuSfO+VQO3WJHfZNYu/4Qorm+v9KumqWN5Cx3Eng=; b=K6mAHjf+a+e9GhY9Kbnlnxttghx4jcME2yvdwg43rtx7rcn+PorBQkmhihz1p1ZnrBOi aGUkevggchlVaslK/bt9k8DuruKTCmA+E7yPYvcAT2lsTE6I7VK9npju3k3I02cfmTi7 JMY8EIkmOGteHDZ2AAy4BAoliwd7K/Zz8lQ= Received: from maileast.thefacebook.com ([199.201.65.23]) by m0089730.ppops.net with ESMTP id 2q141p8juk-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 14 Jan 2019 17:51:51 -0800 Received: from mx-out.facebook.com (2620:10d:c0a1:3::13) by mail.thefacebook.com (2620:10d:c021:18::175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1531.3; Mon, 14 Jan 2019 17:51:51 -0800 Received: by devvm4117.prn2.facebook.com (Postfix, from userid 167582) id 8373675BEF45; Mon, 14 Jan 2019 17:51:48 -0800 (PST) Smtp-Origin-Hostprefix: devvm From: Vijay Khemka Smtp-Origin-Hostname: devvm4117.prn2.facebook.com To: Arnd Bergmann , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , , , Smtp-Origin-Cluster: prn2c23 Subject: [PATCH] misc: aspeed-lpc-ctrl: make memory-region optional Date: Mon, 14 Jan 2019 17:51:46 -0800 Message-ID: <20190115015146.2412785-1-vijaykhemka@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-15_01:, , signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190114_175155_472423_B89DF527 X-CRM114-Status: GOOD ( 14.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "openbmc @ lists . ozlabs . org" , vijaykhemka@fb.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Makiing memory-region as optional parameter in device tree if user needs to use memory-region then define in devicetree. Signed-off-by: Vijay Khemka --- drivers/misc/aspeed-lpc-ctrl.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/misc/aspeed-lpc-ctrl.c b/drivers/misc/aspeed-lpc-ctrl.c index a024f8042259..20507f0764fb 100644 --- a/drivers/misc/aspeed-lpc-ctrl.c +++ b/drivers/misc/aspeed-lpc-ctrl.c @@ -90,6 +90,10 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd, if (map.window_id != 0) return -EINVAL; + /* If memory-region is not described in device tree */ + if (!lpc_ctrl->mem_size) + return -EINVAL; + map.size = lpc_ctrl->mem_size; return copy_to_user(p, &map, sizeof(map)) ? -EFAULT : 0; @@ -129,6 +133,10 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd, addr = lpc_ctrl->pnor_base; size = lpc_ctrl->pnor_size; } else if (map.window_type == ASPEED_LPC_CTRL_WINDOW_MEMORY) { + /* If memory-region is not described in device tree */ + if (!lpc_ctrl->mem_size) + return -EINVAL; + addr = lpc_ctrl->mem_base; size = lpc_ctrl->mem_size; } else { @@ -214,22 +222,20 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, lpc_ctrl); + /* If memory-region is described in device tree then store */ node = of_parse_phandle(dev->of_node, "memory-region", 0); - if (!node) { - dev_err(dev, "Didn't find reserved memory\n"); - return -EINVAL; - } + if (node) { + rc = of_address_to_resource(node, 0, &resm); + of_node_put(node); + if (rc) { + dev_err(dev, "Couldn't address to resource for reserved memory\n"); + return -ENOMEM; + } - rc = of_address_to_resource(node, 0, &resm); - of_node_put(node); - if (rc) { - dev_err(dev, "Couldn't address to resource for reserved memory\n"); - return -ENOMEM; + lpc_ctrl->mem_size = resource_size(&resm); + lpc_ctrl->mem_base = resm.start; } - lpc_ctrl->mem_size = resource_size(&resm); - lpc_ctrl->mem_base = resm.start; - lpc_ctrl->regmap = syscon_node_to_regmap( pdev->dev.parent->of_node); if (IS_ERR(lpc_ctrl->regmap)) {