From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Masney Subject: Re: [PATCH v5 3/3] backlight: lm3630a: add firmware node support Date: Tue, 23 Apr 2019 12:00:19 -0400 Message-ID: <20190423160019.GA10501@basecamp> References: <20190418151143.26068-1-masneyb@onstation.org> <20190418151143.26068-4-masneyb@onstation.org> <20190423140150.GA10071@basecamp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Dan Murphy Cc: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, robh+dt@kernel.org, jacek.anaszewski@gmail.com, pavel@ucw.cz, mark.rutland@arm.com, b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, jonathan@marek.ca List-Id: linux-leds@vger.kernel.org On Tue, Apr 23, 2019 at 10:31:41AM -0500, Dan Murphy wrote: > On 4/23/19 9:01 AM, Brian Masney wrote: > > On Tue, Apr 23, 2019 at 08:49:20AM -0500, Dan Murphy wrote: > >>> +static int lm3630a_parse_led_sources(struct fwnode_handle *node, > >>> + int default_led_sources) > >>> +{ > >>> + u32 sources[LM3630A_NUM_SINKS]; > >>> + int ret, num_sources, i; > >>> + > >>> + num_sources = fwnode_property_read_u32_array(node, "led-sources", NULL, > >>> + 0); > >>> + if (num_sources < 0) > >>> + return default_led_sources; > >>> + else if (num_sources > ARRAY_SIZE(sources)) > >>> + return -EINVAL; > >>> + > >>> + ret = fwnode_property_read_u32_array(node, "led-sources", sources, > >>> + num_sources); > >>> + if (ret) > >>> + return ret; > >>> + > >>> + for (i = 0; i < num_sources; i++) { > >>> + if (sources[i] < LM3630A_SINK_0 || sources[i] > LM3630A_SINK_1) > >>> + return -EINVAL; > >>> + > >>> + ret |= BIT(sources[i]); > >>> + } > >>> + > >>> + return ret; > >>> +} > >>> + > >>> +static int lm3630a_parse_bank(struct lm3630a_platform_data *pdata, > >>> + struct fwnode_handle *node, int *seen_led_sources) > >> > >> Why is seen_led_sources passed in here? > >> It is initialized on the stack in lm3630a_parse_node but the variable is never referenced in that API. > > > > It's to see all of the led-sources that are configured across all of the > > banks. If it is just in lm3630a_parse_bank(), then it won't catch the > > following invalid configuration: > > > > Ok I see what it is for now. > > Not sure why it is declared as a pointer though. It's so that lm3630a_parse_bank() can update that value with the led-sources that have been seen. Otherwise, the changes wouldn't make their way back out to the outer function. Brian From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Masney Date: Tue, 23 Apr 2019 16:00:19 +0000 Subject: Re: [PATCH v5 3/3] backlight: lm3630a: add firmware node support Message-Id: <20190423160019.GA10501@basecamp> List-Id: References: <20190418151143.26068-1-masneyb@onstation.org> <20190418151143.26068-4-masneyb@onstation.org> <20190423140150.GA10071@basecamp> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dan Murphy Cc: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, robh+dt@kernel.org, jacek.anaszewski@gmail.com, pavel@ucw.cz, mark.rutland@arm.com, b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, jonathan@marek.ca On Tue, Apr 23, 2019 at 10:31:41AM -0500, Dan Murphy wrote: > On 4/23/19 9:01 AM, Brian Masney wrote: > > On Tue, Apr 23, 2019 at 08:49:20AM -0500, Dan Murphy wrote: > >>> +static int lm3630a_parse_led_sources(struct fwnode_handle *node, > >>> + int default_led_sources) > >>> +{ > >>> + u32 sources[LM3630A_NUM_SINKS]; > >>> + int ret, num_sources, i; > >>> + > >>> + num_sources = fwnode_property_read_u32_array(node, "led-sources", NULL, > >>> + 0); > >>> + if (num_sources < 0) > >>> + return default_led_sources; > >>> + else if (num_sources > ARRAY_SIZE(sources)) > >>> + return -EINVAL; > >>> + > >>> + ret = fwnode_property_read_u32_array(node, "led-sources", sources, > >>> + num_sources); > >>> + if (ret) > >>> + return ret; > >>> + > >>> + for (i = 0; i < num_sources; i++) { > >>> + if (sources[i] < LM3630A_SINK_0 || sources[i] > LM3630A_SINK_1) > >>> + return -EINVAL; > >>> + > >>> + ret |= BIT(sources[i]); > >>> + } > >>> + > >>> + return ret; > >>> +} > >>> + > >>> +static int lm3630a_parse_bank(struct lm3630a_platform_data *pdata, > >>> + struct fwnode_handle *node, int *seen_led_sources) > >> > >> Why is seen_led_sources passed in here? > >> It is initialized on the stack in lm3630a_parse_node but the variable is never referenced in that API. > > > > It's to see all of the led-sources that are configured across all of the > > banks. If it is just in lm3630a_parse_bank(), then it won't catch the > > following invalid configuration: > > > > Ok I see what it is for now. > > Not sure why it is declared as a pointer though. It's so that lm3630a_parse_bank() can update that value with the led-sources that have been seen. Otherwise, the changes wouldn't make their way back out to the outer function. Brian