Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp269941ybi; Wed, 29 May 2019 21:04:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+bSdE8z5wzHj5OHG/CZfk2Gf3tjjpN8AFFBaDlWa2lYI5nee4Akooa7+cpyr21Y6FTAk4 X-Received: by 2002:a63:5d45:: with SMTP id o5mr1901721pgm.40.1559189044825; Wed, 29 May 2019 21:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189044; cv=none; d=google.com; s=arc-20160816; b=fO34DZBkH1c1gyCYTLKv1IVxHJC3hYnLx+752Vbql4krdlljM7gbMP0tLAd3EITaYg tAOAkFqcKF68Bg7ukmF53sewmGFZ9xDd8TLUSC6cVoalove/4Q1EfVwRBXIlyCYn/JZC UC5m4Rq9tpqKXfljIaX53Ey8gamUX422FI9IqnvMGl4qZgg/DqMPAAg2yZGCCBxbydoh Hiss6m3v3rAcEbjz3gzEH1ko46PVNyamVQfCJq/x+AdHkp78okmu34khq0LgEGQPAtY+ 9b665Tzb7RWIEOkMgaiIhYRtUO5lDNxEla6ob6/IcyWK+DrXXMGt5uDTZJRFKWJIBeeL 387A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:cc:to:from:date:references :in-reply-to:message-id:mime-version:user-agent:dkim-signature :dkim-signature; bh=qyIi9G9ln+NMQWurPQHYWug6XmoD14N6qzo4ZOFsaOY=; b=S4I3MRV1CEaLL7MwaeAeA/IYp4pV/IMsZKiXyZD6emy9m9ioIEBsBM3WW/L0xddX4B cr928M5JkLNaGZft+FqjivD/WM9aKpGqjAMkapdk+e2pT/0B4bYx7tTvna7ke1DCGfTI fJ9m8pQ6PdLlee/kC/9Z3I0EIrYSUQSGrxA2AhXKJ8NKD9w489MUkwKfMnizLrjDY78z ZTayZi/7hUP7B0rXDLCBFB6XXltPcNqHr9w+C1l5WgqtCaTAzunVZNkubqLlwOIDafy2 mmbtH89LZxeWwMpT/1dVOUFimXUhDAq84pnEcLFjUchEV5hNE/qteH1PI8WSP2c35WBA 5H5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=Bqih8YLn; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LZC8KP36; 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 r4si1932646pgv.195.2019.05.29.21.03.47; Wed, 29 May 2019 21:04:04 -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; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=Bqih8YLn; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LZC8KP36; 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 S1731683AbfE3EC1 (ORCPT + 99 others); Thu, 30 May 2019 00:02:27 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:57365 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbfE3ECM (ORCPT ); Thu, 30 May 2019 00:02:12 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id DAB2C21FA7; Thu, 30 May 2019 00:02:10 -0400 (EDT) Received: from imap2 ([10.202.2.52]) by compute4.internal (MEProxy); Thu, 30 May 2019 00:02:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm2; bh=qyIi9G9ln+NMQWurPQHYWug6XmoD14N 6qzo4ZOFsaOY=; b=Bqih8YLnL2VC2g+8JAzRNlikdAjAGB7W19vPi3fcYrRVV7e o/CrIuGMifez0eB8jpJNdT/3Ft6BTkjteYu/PwkWi01a8DKDkcxN1P3pn6oMKBFs QRvzEDSWFKBrsCoa3SRTzrFKDibbndeWhntyz4zOaSlwIpq0ectk3a025ay5jSQT IXXQO64v5jlt5iGoKPVKlIiiOZ4lbqqrmriyFTSQ0U+UvHVVzQFcBX0oatx8djiK aiFoiK4XTJ0+WlhzIQIWgdlROF+y+cWorvXm6ky2NC8EEBB24O/kx6NDl1ihPd3n 1LqP34eLwfFJJKdtc2FrWTctonW4g1OYa3kQ7Sg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=qyIi9G 9ln+NMQWurPQHYWug6XmoD14N6qzo4ZOFsaOY=; b=LZC8KP36MjQNGAwMOKxclA pMXHy4rTEv/bM4O19IlKlhkg9CFwS42Cx2e4A5D0hbprPIJbPeWhiNmWO5Otx2s/ aqemrxMMLW0cIC0iI+fsUjAEiacuz7Wm6SxDcUGaZZxjqYYObOHR7ziyUESY3io5 H1RMZP6OGTEjHBJLIF1gQ4q78rAzWB50aXrpJTDcqn+FWmmlGpUk3eszmyrvUlSA xrpmD1q12nFIBQ8Fs6ZEt26rRxykBm0jnLLTmUJkvwaatyjkMX2BcDcycnU17kam tTR+n0YwzNrDn+6ejRMleun6pKTb6oOosyUqte84SY+tThZ1MghWLd1mVFYJvp6w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddvkedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdetnhgu rhgvficulfgvfhhfvghrhidfuceorghnughrvgifsegrjhdrihgurdgruheqnecurfgrrh grmhepmhgrihhlfhhrohhmpegrnhgurhgvfiesrghjrdhiugdrrghunecuvehluhhsthgv rhfuihiivgeptd X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 33313E00A1; Thu, 30 May 2019 00:02:09 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.6-555-g49357e1-fmstable-20190528v2 Mime-Version: 1.0 Message-Id: In-Reply-To: <20190529172103.1130525-1-vijaykhemka@fb.com> References: <20190529172103.1130525-1-vijaykhemka@fb.com> Date: Thu, 30 May 2019 13:32:08 +0930 From: "Andrew Jeffery" To: "Vijay Khemka" , "Joel Stanley" , "Patrick Venture" , "Olof Johansson" , "Arnd Bergmann" , linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: "Sai Dasari" , "Greg Kroah-Hartman" Subject: Re: [PATCH] soc: aspeed: lpc-ctrl: make parameter optional Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 May 2019, at 02:51, Vijay Khemka wrote: > Makiing Typo here, but I'd prefer to see this patch go in, so > memory-region and flash as optional parameter in device > tree if user needs to use these parameter through ioctl then > need to define in devicetree. > > Signed-off-by: Vijay Khemka Reviewed-by: Andrew Jeffery > --- > drivers/soc/aspeed/aspeed-lpc-ctrl.c | 58 +++++++++++++++++----------- > 1 file changed, 36 insertions(+), 22 deletions(-) > > diff --git a/drivers/soc/aspeed/aspeed-lpc-ctrl.c > b/drivers/soc/aspeed/aspeed-lpc-ctrl.c > index a024f8042259..aca13779764a 100644 > --- a/drivers/soc/aspeed/aspeed-lpc-ctrl.c > +++ b/drivers/soc/aspeed/aspeed-lpc-ctrl.c > @@ -68,6 +68,7 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, > unsigned int cmd, > unsigned long param) > { > struct aspeed_lpc_ctrl *lpc_ctrl = file_aspeed_lpc_ctrl(file); > + struct device *dev = file->private_data; > void __user *p = (void __user *)param; > struct aspeed_lpc_ctrl_mapping map; > u32 addr; > @@ -90,6 +91,12 @@ 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) { > + dev_dbg(dev, "Didn't find reserved memory\n"); > + return -ENXIO; > + } > + > map.size = lpc_ctrl->mem_size; > > return copy_to_user(p, &map, sizeof(map)) ? -EFAULT : 0; > @@ -126,9 +133,18 @@ static long aspeed_lpc_ctrl_ioctl(struct file > *file, unsigned int cmd, > return -EINVAL; > > if (map.window_type == ASPEED_LPC_CTRL_WINDOW_FLASH) { > + if (!lpc_ctrl->pnor_size) { > + dev_dbg(dev, "Didn't find host pnor flash\n"); > + return -ENXIO; > + } > 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) { > + dev_dbg(dev, "Didn't find reserved memory\n"); > + return -ENXIO; > + } > addr = lpc_ctrl->mem_base; > size = lpc_ctrl->mem_size; > } else { > @@ -196,17 +212,17 @@ static int aspeed_lpc_ctrl_probe(struct > platform_device *pdev) > if (!lpc_ctrl) > return -ENOMEM; > > + /* If flash is described in device tree then store */ > node = of_parse_phandle(dev->of_node, "flash", 0); > if (!node) { > - dev_err(dev, "Didn't find host pnor flash node\n"); > - return -ENODEV; > - } > - > - rc = of_address_to_resource(node, 1, &resm); > - of_node_put(node); > - if (rc) { > - dev_err(dev, "Couldn't address to resource for flash\n"); > - return rc; > + dev_dbg(dev, "Didn't find host pnor flash node\n"); > + } else { > + rc = of_address_to_resource(node, 1, &resm); > + of_node_put(node); > + if (rc) { > + dev_err(dev, "Couldn't address to resource for flash\n"); > + return rc; > + } > } > > lpc_ctrl->pnor_size = resource_size(&resm); > @@ -214,22 +230,22 @@ 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; > - } > + dev_dbg(dev, "Didn't find reserved memory\n"); > + } else { > + 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 -ENXIO; > + } > > - 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)) { > @@ -258,8 +274,6 @@ static int aspeed_lpc_ctrl_probe(struct > platform_device *pdev) > goto err; > } > > - dev_info(dev, "Loaded at %pr\n", &resm); > - > return 0; > > err: > -- > 2.17.1 > >