Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753679AbbHZSyz (ORCPT ); Wed, 26 Aug 2015 14:54:55 -0400 Received: from www.linutronix.de ([62.245.132.108]:57138 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751988AbbHZSyy (ORCPT ); Wed, 26 Aug 2015 14:54:54 -0400 Date: Wed, 26 Aug 2015 20:54:21 +0200 (CEST) From: Thomas Gleixner To: Shenwei Wang cc: "shawn.guo@linaro.org" , "jason@lakedaemon.net" , "sudeep.holla@arm.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Huang Anson Subject: RE: [PATCH 1/1] irqchip: imx-gpcv2: Simplify the implemenation In-Reply-To: Message-ID: References: <1440604166-2624-1-git-send-email-shenwei.wang@freescale.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1370 Lines: 45 On Wed, 26 Aug 2015, Shenwei Wang wrote: > > From: Thomas Gleixner [mailto:tglx@linutronix.de] > > > + cd = imx_gpcv2_instance; > > > + if (!cd) > > > return 0; > > > > > > + for (i = 0; i < IMR_NUM; i++) { > > > + reg = cd->gpc_base + cd->cpu2wakeup + i * 4; > > > + cd->wakeup_sources[i] = readl_relaxed(reg); > > > + } > > > + > > > if (sources) > > > - *sources = imx_gpcv2_instance->wakeup_sources; > > > + *sources = cd->wakeup_sources; > > > > > > return IMR_NUM; > > > > You do not need the intermediate storage at all. > > > > u32 imx_gpcv2_get_wakeup_source(u32 *sources) { > > if (sources) { > > for (i = 0; i < IMR_NUM; i++) { > > reg = cd->gpc_base + cd->cpu2wakeup + i * 4; > > sources[i] = readl_relaxed(reg); > > } > > } > > .... > > Using the intermediate storage here can make the caller a little easier, > because the caller does not need to malloc the memory before the call. > Especially the caller does not even know how many memory to allocate > In the beginning. Fair enough, but why do you need that case where sources can be NULL just to return IMR_NUM? Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/