From patchwork Tue Oct 28 00:01:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 5167011 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3BE329F349 for ; Tue, 28 Oct 2014 00:02:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C8812017A for ; Tue, 28 Oct 2014 00:02:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5620320211 for ; Tue, 28 Oct 2014 00:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752965AbaJ1ACg (ORCPT ); Mon, 27 Oct 2014 20:02:36 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:59279 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929AbaJ1ACd (ORCPT ); Mon, 27 Oct 2014 20:02:33 -0400 Received: by mail-wi0-f174.google.com with SMTP id q5so7846525wiv.7 for ; Mon, 27 Oct 2014 17:02:31 -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=+2a826fElVFrD9sHKE/hJZ914qCzuuFPEwvlRhnnZ2M=; b=oXS9bLwCqLZoFEGTG3uyZbJDDrjsYCGrB4VA8rg+S2qxMaubGuIHTP9ICRmTVFquAR GjuX1NQxtAc2qrvheU5Kp5SWR9m7M7u07sTIAlVZpuEcQ21Yeca38C2sPWjswX84hspB yL1ihJxJ6MGu9WeV6Dga2SmcqbBUqmk2dvNnnP+T9CIL3v08WJAnGZjylcXpogvNRScD I2q6uP7L5wdqFIQYSqR4Z/e3tQMUoyAqzX15EKTs6Uny3ltaKqEmGLJZG8vjzvKLCaEV ImSXIvCPG3m+st4ozDqMCGiMym1W7S0IZRHWaTwAsNJ444oGplOsb9gR1ElyHtPNYNEu zXAA== X-Received: by 10.180.187.66 with SMTP id fq2mr590732wic.58.1414454551745; Mon, 27 Oct 2014 17:02:31 -0700 (PDT) Received: from fangorn.rup.mentorg.com (nat-min.mentorg.com. [139.181.32.34]) by mx.google.com with ESMTPSA id fq1sm13495340wib.12.2014.10.27.17.02.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Oct 2014 17:02:30 -0700 (PDT) From: Dmitry Eremin-Solenikov To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-spi@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: Andrea Adami , Russell King , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Linus Walleij , Alexandre Courbot , Dmitry Torokhov , Bryan Wu , Richard Purdie , Samuel Ortiz , Lee Jones , Mark Brown , Jingoo Han , Liam Girdwood Subject: [PATCH 03/15] leds: port locomo leds driver to new locomo core Date: Tue, 28 Oct 2014 03:01:56 +0300 Message-Id: <1414454528-24240-4-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1414454528-24240-1-git-send-email-dbaryshkov@gmail.com> References: <1414454528-24240-1-git-send-email-dbaryshkov@gmail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.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 | 104 +++++++++++++++++++++++++++------------------ 2 files changed, 62 insertions(+), 43 deletions(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index a210338..22ebf1c 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -69,7 +69,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..acb288f 100644 --- a/drivers/leds/leds-locomo.c +++ b/drivers/leds/leds-locomo.c @@ -11,87 +11,107 @@ #include #include #include -#include +#include #include +#include +#include +#include -#include -#include +struct locomo_led { + struct led_classdev led; + void __iomem *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); + struct locomo_led *led = container_of(led_cdev, struct locomo_led, led); unsigned long flags; local_irq_save(flags); if (value) - locomo_writel(LOCOMO_LPT_TOFH, locomo_dev->mapbase + offset); + writew(LOCOMO_LPT_TOFH, led->reg); else - locomo_writel(LOCOMO_LPT_TOFL, locomo_dev->mapbase + offset); + writew(LOCOMO_LPT_TOFL, led->reg); local_irq_restore(flags); } -static void locomoled_brightness_set0(struct led_classdev *led_cdev, - enum led_brightness value) +static int locomo_led_register( + struct locomo_led *led, + struct device *dev, + const char *name, + const char *trigger, + void __iomem *reg) { - locomoled_brightness_set(led_cdev, value, LOCOMO_LPT0); + led->led.name = name; + led->led.default_trigger = trigger; + led->led.brightness_set = locomoled_brightness_set; + led->reg = reg; + + return led_classdev_register(dev, &led->led); } -static void locomoled_brightness_set1(struct led_classdev *led_cdev, - enum led_brightness value) +static int locomoled_probe(struct platform_device *pdev) { - locomoled_brightness_set(led_cdev, value, LOCOMO_LPT1); -} + int ret; + struct resource *mem; + void __iomem *regs; + struct locomo_led *leds; -static struct led_classdev locomo_led0 = { - .name = "locomo:amber:charge", - .default_trigger = "main-battery-charging", - .brightness_set = locomoled_brightness_set0, -}; + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mem) + return -EINVAL; -static struct led_classdev locomo_led1 = { - .name = "locomo:green:mail", - .default_trigger = "nand-disk", - .brightness_set = locomoled_brightness_set1, -}; + regs = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(regs)) + return PTR_ERR(regs); -static int locomoled_probe(struct locomo_dev *ldev) -{ - int ret; + leds = devm_kzalloc(&pdev->dev, 2 * sizeof(*leds), GFP_KERNEL); + if (!leds) + return -ENOMEM; + + platform_set_drvdata(pdev, leds); - ret = led_classdev_register(&ldev->dev, &locomo_led0); + ret = locomo_led_register(leds, + &pdev->dev, + "locomo:amber:charge", + "main-battery-charging", + regs + LOCOMO_LPT0); if (ret < 0) return ret; - ret = led_classdev_register(&ldev->dev, &locomo_led1); + ret = locomo_led_register(leds + 1, + &pdev->dev, + "locomo:green:mail", + "nand-disk", + regs + LOCOMO_LPT1); if (ret < 0) - led_classdev_unregister(&locomo_led0); + led_classdev_unregister(&leds[0].led); return ret; } -static int locomoled_remove(struct locomo_dev *dev) +static int locomoled_remove(struct platform_device *pdev) { - led_classdev_unregister(&locomo_led0); - led_classdev_unregister(&locomo_led1); + struct locomo_led *leds = platform_get_drvdata(pdev); + + led_classdev_unregister(&leds[0].led); + led_classdev_unregister(&leds[1].led); + 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");