From patchwork Mon Feb 23 22:08:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Brownell X-Patchwork-Id: 8517 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1NM8Inl008665 for ; Mon, 23 Feb 2009 22:08:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753234AbZBWWIS (ORCPT ); Mon, 23 Feb 2009 17:08:18 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753250AbZBWWIS (ORCPT ); Mon, 23 Feb 2009 17:08:18 -0500 Received: from smtp121.sbc.mail.sp1.yahoo.com ([69.147.64.94]:35635 "HELO smtp121.sbc.mail.sp1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753234AbZBWWIR (ORCPT ); Mon, 23 Feb 2009 17:08:17 -0500 Received: (qmail 2033 invoked from network); 23 Feb 2009 22:08:15 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=pacbell.net; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Subject:Date:User-Agent:Cc:References:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-Disposition:Message-Id; b=mnM+ZOuICMYU4cV0NvDQE2MwoUbDrp+v1kUCaKUst5hWpzA8uvQGVrMTEa2I2oLAMhy1iCN1k2BGD5mt8nomF51xCoCpgZH3+d3KjR5Z6FYO4HFqlUiEqU6JAZqObLmdYHaj74FJ9Iw0PObrbLl2UXVCora1W1ibHd1xw1siu2o= ; Received: from unknown (HELO pogo) (david-b@69.226.224.20 with plain) by smtp121.sbc.mail.sp1.yahoo.com with SMTP; 23 Feb 2009 22:08:15 -0000 X-YMail-OSG: ZyC_yuMVM1nmA40rEXZwjGgABOCsM_1Qi2GUeglJIfTZB0B6vn_cjOn6LsxSK6o.NugIn1bUbm8duRJUQok7CeUbTjinLdpSBXBiAFExbr96HuwFQhF1Dtl33kYFnsdqIrz3PkTtH2TPhXEpUw8RROMuIzKCwX7FuZxqIzOtRgMCqZOav1u9UENWRD5i5KAlPfM- X-Yahoo-Newman-Property: ymail-3 From: David Brownell To: "Kridner, Jason" Subject: Re: leds-gpio broken with current git? Date: Mon, 23 Feb 2009 14:08:14 -0800 User-Agent: KMail/1.9.10 Cc: Koen Kooi , "linux-omap@vger.kernel.org List" References: <7088542D-28A0-4BCA-9583-6BCDDF9E960A@student.utwente.nl> <8F7AF80515AF0D4D93307E594F3CB40E210F49EC@dlee03.ent.ti.com> <200902231304.22137.david-b@pacbell.net> In-Reply-To: <200902231304.22137.david-b@pacbell.net> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200902231408.14387.david-b@pacbell.net> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org On Monday 23 February 2009, David Brownell wrote: > > > Perhaps something broke with Tony's RC1 merge? > > The LEDs are broken for me as well. > > Still works for me.  Did you maybe not enable the twl4030 > GPIO support in Kconfig? Oh, and if you did *not*, please give this patch a try. I've been meaning to test it. - Dave --- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ============== Sometimes it's awkward to make sure that the array in the platform_data handed to the leds-gpio driver has only valid data ... some leds may not be always available, and coping with that currently requires patching or rebuilding the array. This patch fixes that by making it be OK to pass an invalid GPIO (such as "-EINVAL") ... such table entries are skipped. --- drivers/leds/leds-gpio.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -90,13 +90,19 @@ static int gpio_led_probe(struct platfor cur_led = &pdata->leds[i]; led_dat = &leds_data[i]; + /* skip leds that aren't available */ + led_dat->gpio = cur_led->gpio; + if (!gpio_is_valid(led_dat->gpio)) { + dev_dbg(&pdev->dev, "skipping %s\n", cur_led->name); + continue; + } + ret = gpio_request(cur_led->gpio, cur_led->name); if (ret < 0) goto err; led_dat->cdev.name = cur_led->name; led_dat->cdev.default_trigger = cur_led->default_trigger; - led_dat->gpio = cur_led->gpio; led_dat->can_sleep = gpio_cansleep(cur_led->gpio); led_dat->active_low = cur_led->active_low; if (pdata->gpio_blink_set) { @@ -125,6 +131,8 @@ static int gpio_led_probe(struct platfor err: if (i > 0) { for (i = i - 1; i >= 0; i--) { + if (!gpio_is_valid(leds_data[i].gpio)) + continue; led_classdev_unregister(&leds_data[i].cdev); cancel_work_sync(&leds_data[i].work); gpio_free(leds_data[i].gpio); @@ -145,6 +153,8 @@ static int __devexit gpio_led_remove(str leds_data = platform_get_drvdata(pdev); for (i = 0; i < pdata->num_leds; i++) { + if (!gpio_is_valid(leds_data[i].gpio)) + continue; led_classdev_unregister(&leds_data[i].cdev); cancel_work_sync(&leds_data[i].work); gpio_free(leds_data[i].gpio);