Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4264371imu; Mon, 14 Jan 2019 18:57:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN6lT//ZmGwM2j29CKTFTAlwDS2nXQElLvVRGNFwMEXUo5EZVMWS0CZMcBBqoEDvaAzuKYgV X-Received: by 2002:a62:2f06:: with SMTP id v6mr1710542pfv.216.1547521058576; Mon, 14 Jan 2019 18:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521058; cv=none; d=google.com; s=arc-20160816; b=weVKbAu7QE59z46hcJ6wc8XG+INS5/NYPZ7IlzJXHS/Jg6MqrPkNd2nmJzts4zg+Iw VW91kCC/hjypxidKz5q+E5Xb3r5BfAM22yVOoeVdmoqIX43XkpzypurqSq2cuZcVWtpO IBvgP2TAm2dMgh71AO/ywmEXqHJZ9dZjOVU7FHpyNouhwptqtfgqwPS7ciR/UrA/LgvE mOe3W0B7HcVGU6K5okzJSshryGQ7mdM0IrOnjg0abrmiat224FzG6MKDW3MicJGfthBM csEGk03h3Yjd9QNBF8EVvFBWRq9ekYRerg0Q5zujxxZlILd60IUOB4MGQC9K4EifUVmf voAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject :smtp-origin-cluster:cc:to:smtp-origin-hostname:from :smtp-origin-hostprefix:dkim-signature; bh=aESUuSfO+VQO3WJHfZNYu/4Qorm+v9KumqWN5Cx3Eng=; b=aSECUCGji7auK+MtWaQnJ3uNnY+AtgEO3AHLygYY7Z9mP2V8iz4+Q0x7aVl1E+1jm5 D44YRCcaOJN2crEOK48fP20t5r0N4bOb9vEGxT2RekmVQY3C+9NaHQ0K9elq4WaKtmI3 XDc5r4AbOLyyaCavAZ8EXwjQOK8UmcKWsap1iqrdej8RCMYXzu+NWLUltAwnXWQjllI4 WTYr3zfX9P7sUDhLx7marP1fONWcjtKaY2iFMDu2qFi21tAi3sMEVt2mMUpikDO85N1i 74J2R2p3VFgnQffDT4LkUZgiBr54wbuHweuJbH+6HHQhWtNecujZARrs6PhpUm/W/Z8Q oVyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=K6mAHjf+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si700197plo.270.2019.01.14.18.57.23; Mon, 14 Jan 2019 18:57:38 -0800 (PST) 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; dkim=pass header.i=@fb.com header.s=facebook header.b=K6mAHjf+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbfAOBv6 (ORCPT + 99 others); Mon, 14 Jan 2019 20:51:58 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:47096 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbfAOBv6 (ORCPT ); Mon, 14 Jan 2019 20:51:58 -0500 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0F1mFtx011695 for ; Mon, 14 Jan 2019 17:51:56 -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 mx0a-00082601.pphosted.com with ESMTP id 2q15e604p6-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 14 Jan 2019 17:51:56 -0800 Received: from mx-out.facebook.com (2620:10d:c0a1:3::13) by mail.thefacebook.com (2620:10d:c021:18::173) 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 , , , CC: , "openbmc @ lists . ozlabs . org" 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 Content-Type: text/plain 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) { -- 2.17.1