From patchwork Mon Apr 27 23:55:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 6284651 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D85159F1C2 for ; Mon, 27 Apr 2015 23:58:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDF2420384 for ; Mon, 27 Apr 2015 23:58:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9C78420304 for ; Mon, 27 Apr 2015 23:58:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9D2E226575E; Tue, 28 Apr 2015 01:58:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id C19EB26576D; Tue, 28 Apr 2015 01:57:04 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id E4FAD265770; Tue, 28 Apr 2015 01:57:02 +0200 (CEST) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by alsa0.perex.cz (Postfix) with ESMTP id 4D8FF264F50 for ; Tue, 28 Apr 2015 01:56:37 +0200 (CEST) Received: by pacyx8 with SMTP id yx8so145449847pac.1 for ; Mon, 27 Apr 2015 16:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nFEp2bRhJGKytlv9g6rPiUt+Xzu3GxGMrcPodxYhOcY=; b=FjeGtrAHdw1Kna3OnPALruzTg5XE60JnhDVH89OW7i8YQoYio2qUOcP3N883jJvbC5 VlL2vhMU5xzze8vCkdamBo7Mwiw000dqElFlJSg8qZ2j16TImRG1ZaheGc7NTQYiGsb8 D6rVImej2SxDNDpCHKJYOZgdS1NjNtBo5r8FSNqv4txh+33FTJCNq7AcT/W+9pn+bVoo mdkSzeDu5Nf1PkrP1xdGjRUU3SQVlLh6NUm7bD55o5NITBB0qv3GuoJzaYWwsQ/2dzGi 1kIB2Kqt8jnmXBmK/sN/QbcanLK8JaVqpkCSWJo/NuE5ghW8XP5JM16KhBJDVraC0HM6 5bww== X-Received: by 10.70.35.201 with SMTP id k9mr26297811pdj.128.1430178996360; Mon, 27 Apr 2015 16:56:36 -0700 (PDT) Received: from fangorn.rup.mentorg.com (nat-min.mentorg.com. [139.181.32.34]) by mx.google.com with ESMTPSA id pv2sm20428375pbb.12.2015.04.27.16.56.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Apr 2015 16:56:35 -0700 (PDT) From: Dmitry Eremin-Solenikov To: Russell King , Daniel Mack , Robert Jarzmik , Linus Walleij , Alexandre Courbot , Wolfram Sang , Dmitry Torokhov , Bryan Wu , Richard Purdie , Samuel Ortiz , Lee Jones , Mark Brown , Jingoo Han , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Liam Girdwood , Andrea Adami Date: Tue, 28 Apr 2015 02:55:39 +0300 Message-Id: <1430178954-11138-3-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1430178954-11138-1-git-send-email-dbaryshkov@gmail.com> References: <1430178954-11138-1-git-send-email-dbaryshkov@gmail.com> Cc: linux-arm-kernel@lists.infradead.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-spi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org Subject: [alsa-devel] [PATCH v2 02/17] leds: port locomo leds driver to new locomo core X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Adapt locomo leds driver to new locomo core setup. Signed-off-by: Dmitry Eremin-Solenikov --- drivers/leds/Kconfig | 1 - drivers/leds/leds-locomo.c | 119 +++++++++++++++++++++++---------------------- 2 files changed, 61 insertions(+), 59 deletions(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 966b960..4b4650b 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -79,7 +79,6 @@ config LEDS_LM3642 config LEDS_LOCOMO tristate "LED Support for Locomo device" depends on LEDS_CLASS - depends on SHARP_LOCOMO help This option enables support for the LEDs on Sharp Locomo. Zaurus models SL-5500 and SL-5600. diff --git a/drivers/leds/leds-locomo.c b/drivers/leds/leds-locomo.c index 80ba048..7fde812 100644 --- a/drivers/leds/leds-locomo.c +++ b/drivers/leds/leds-locomo.c @@ -9,89 +9,92 @@ */ #include -#include -#include -#include #include - -#include -#include +#include +#include +#include +#include + +struct locomo_led { + struct led_classdev led; + struct regmap *regmap; + unsigned int reg; +}; static void locomoled_brightness_set(struct led_classdev *led_cdev, - enum led_brightness value, int offset) + enum led_brightness value) { - struct locomo_dev *locomo_dev = LOCOMO_DEV(led_cdev->dev->parent); - unsigned long flags; + struct locomo_led *led = container_of(led_cdev, struct locomo_led, led); - local_irq_save(flags); - if (value) - locomo_writel(LOCOMO_LPT_TOFH, locomo_dev->mapbase + offset); - else - locomo_writel(LOCOMO_LPT_TOFL, locomo_dev->mapbase + offset); - local_irq_restore(flags); + regmap_write(led->regmap, led->reg, + value ? LOCOMO_LPT_TOFH : LOCOMO_LPT_TOFL); } -static void locomoled_brightness_set0(struct led_classdev *led_cdev, - enum led_brightness value) +static int locomo_led_register( + struct device *dev, + struct locomo_led *led, + const char *name, + const char *trigger, + struct regmap *regmap, + unsigned int reg) { - locomoled_brightness_set(led_cdev, value, LOCOMO_LPT0); + led->led.name = name; + led->led.flags = LED_CORE_SUSPENDRESUME; + led->led.default_trigger = trigger; + led->led.brightness_set = locomoled_brightness_set; + led->regmap = regmap; + led->reg = reg; + + return devm_led_classdev_register(dev, &led->led); } -static void locomoled_brightness_set1(struct led_classdev *led_cdev, - enum led_brightness value) -{ - locomoled_brightness_set(led_cdev, value, LOCOMO_LPT1); -} - -static struct led_classdev locomo_led0 = { - .name = "locomo:amber:charge", - .default_trigger = "main-battery-charging", - .brightness_set = locomoled_brightness_set0, -}; - -static struct led_classdev locomo_led1 = { - .name = "locomo:green:mail", - .default_trigger = "nand-disk", - .brightness_set = locomoled_brightness_set1, -}; - -static int locomoled_probe(struct locomo_dev *ldev) +static int locomoled_probe(struct platform_device *pdev) { int ret; - - ret = led_classdev_register(&ldev->dev, &locomo_led0); + struct locomo_led *leds; + struct regmap *regmap; + + leds = devm_kzalloc(&pdev->dev, 2 * sizeof(*leds), GFP_KERNEL); + if (!leds) + return -ENOMEM; + + regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!regmap) + return -ENODEV; + + ret = locomo_led_register( + &pdev->dev, + leds, + "locomo:amber:charge", + "main-battery-charging", + regmap, + LOCOMO_LPT0); if (ret < 0) return ret; - ret = led_classdev_register(&ldev->dev, &locomo_led1); + ret = locomo_led_register( + &pdev->dev, + leds + 1, + "locomo:green:mail", + "mmc0", + regmap, + LOCOMO_LPT1); if (ret < 0) - led_classdev_unregister(&locomo_led0); - - return ret; -} + return ret; -static int locomoled_remove(struct locomo_dev *dev) -{ - led_classdev_unregister(&locomo_led0); - led_classdev_unregister(&locomo_led1); return 0; } -static struct locomo_driver locomoled_driver = { - .drv = { - .name = "locomoled" +static struct platform_driver locomoled_driver = { + .driver = { + .name = "locomo-led" }, - .devid = LOCOMO_DEVID_LED, .probe = locomoled_probe, - .remove = locomoled_remove, }; -static int __init locomoled_init(void) -{ - return locomo_driver_register(&locomoled_driver); -} -module_init(locomoled_init); +module_platform_driver(locomoled_driver); MODULE_AUTHOR("John Lenz "); MODULE_DESCRIPTION("Locomo LED driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:locomo-led");