From patchwork Thu Jun 20 22:12:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2758911 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 979CFC0AB2 for ; Thu, 20 Jun 2013 22:14:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7B9320226 for ; Thu, 20 Jun 2013 22:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45DB020205 for ; Thu, 20 Jun 2013 22:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965423Ab3FTWO0 (ORCPT ); Thu, 20 Jun 2013 18:14:26 -0400 Received: from mail-bk0-f43.google.com ([209.85.214.43]:37093 "EHLO mail-bk0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965232Ab3FTWO0 (ORCPT ); Thu, 20 Jun 2013 18:14:26 -0400 Received: by mail-bk0-f43.google.com with SMTP id jm2so3142110bkc.16 for ; Thu, 20 Jun 2013 15:14:24 -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:x-mailer:in-reply-to:references; bh=iVq7gapxN0irwPZkPtSmwRyYEJGRZG7PxWUgcdl61lU=; b=QQ/UPaBf959R2GGH7ZSOPKTgNy/OyvU+vIKFJj7t9cm5V+MLY/y9dWlHpjPkitg2a3 pcx8T9tqrXNB/8wC1iqoDv56tQIuxSePqDQ8bBo1xdvjg7M/4ChhqwCvngayuEgJDRAu yyox6M7Jn2q3ybT9TpwZlZO6LYi0wTyHxgqRrDcd0rWa+Sks7GVpHitpOMu2Vm0viUMm unfLA1hUsW9JyWypAAMcVVtd380YcGSDMbA5VLr6xPkYD2budOdkrOmfdbBvtuZi05lj TAEShag3kyAtk76w5mS1CoqAqFvf7EFI5rWZc9VYkCeUFWot/1BerFPvV606Vp4UAVeN gfCw== X-Received: by 10.205.113.134 with SMTP id ew6mr405784bkc.182.1371766464198; Thu, 20 Jun 2013 15:14:24 -0700 (PDT) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id fc7sm864232bkc.3.2013.06.20.15.14.22 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Jun 2013 15:14:23 -0700 (PDT) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, Kukjin Kim , Arnd Bergmann , Olof Johansson , Sylwester Nawrocki , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Mark Brown , Thomas Abraham , Thierry Reding , Tomasz Figa Subject: [PATCH v2 12/18] ARM: SAMSUNG: Rework private data handling in dev-backlight Date: Fri, 21 Jun 2013 00:12:57 +0200 Message-Id: <1371766383-29077-13-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1371766383-29077-1-git-send-email-tomasz.figa@gmail.com> References: <1371766383-29077-1-git-send-email-tomasz.figa@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-8.1 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 This patch modifies dev-backlight helpers to get private data using container_of instead of abusing platform_data field of PWM device. Signed-off-by: Tomasz Figa --- arch/arm/plat-samsung/dev-backlight.c | 51 ++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/arch/arm/plat-samsung/dev-backlight.c b/arch/arm/plat-samsung/dev-backlight.c index 5f197dc..e467a01 100644 --- a/arch/arm/plat-samsung/dev-backlight.c +++ b/arch/arm/plat-samsung/dev-backlight.c @@ -20,13 +20,18 @@ #include #include +struct samsung_bl_drvdata { + struct platform_pwm_backlight_data plat_data; + struct samsung_bl_gpio_info *gpio_info; +}; + static int samsung_bl_init(struct device *dev) { int ret = 0; - struct platform_device *timer_dev = - container_of(dev->parent, struct platform_device, dev); - struct samsung_bl_gpio_info *bl_gpio_info = - timer_dev->dev.platform_data; + struct platform_pwm_backlight_data *pdata = dev->platform_data; + struct samsung_bl_drvdata *drvdata = container_of(pdata, + struct samsung_bl_drvdata, plat_data); + struct samsung_bl_gpio_info *bl_gpio_info = drvdata->gpio_info; ret = gpio_request(bl_gpio_info->no, "Backlight"); if (ret) { @@ -42,10 +47,10 @@ static int samsung_bl_init(struct device *dev) static void samsung_bl_exit(struct device *dev) { - struct platform_device *timer_dev = - container_of(dev->parent, struct platform_device, dev); - struct samsung_bl_gpio_info *bl_gpio_info = - timer_dev->dev.platform_data; + struct platform_pwm_backlight_data *pdata = dev->platform_data; + struct samsung_bl_drvdata *drvdata = container_of(pdata, + struct samsung_bl_drvdata, plat_data); + struct samsung_bl_gpio_info *bl_gpio_info = drvdata->gpio_info; s3c_gpio_cfgpin(bl_gpio_info->no, S3C_GPIO_OUTPUT); gpio_free(bl_gpio_info->no); @@ -60,12 +65,14 @@ static void samsung_bl_exit(struct device *dev) * for their specific boards */ -static struct platform_pwm_backlight_data samsung_dfl_bl_data __initdata = { - .max_brightness = 255, - .dft_brightness = 255, - .pwm_period_ns = 78770, - .init = samsung_bl_init, - .exit = samsung_bl_exit, +static struct samsung_bl_drvdata samsung_dfl_bl_data __initdata = { + .plat_data = { + .max_brightness = 255, + .dft_brightness = 255, + .pwm_period_ns = 78770, + .init = samsung_bl_init, + .exit = samsung_bl_exit, + }, }; static struct platform_device samsung_dfl_bl_device __initdata = { @@ -82,6 +89,7 @@ void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, { int ret = 0; struct platform_device *samsung_bl_device; + struct samsung_bl_drvdata *samsung_bl_drvdata; struct platform_pwm_backlight_data *samsung_bl_data; samsung_bl_device = kmemdup(&samsung_dfl_bl_device, @@ -91,17 +99,19 @@ void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, return; } - samsung_bl_data = s3c_set_platdata(&samsung_dfl_bl_data, - sizeof(struct platform_pwm_backlight_data), samsung_bl_device); - if (!samsung_bl_data) { + samsung_bl_drvdata = kmemdup(&samsung_dfl_bl_data, + sizeof(samsung_dfl_bl_data), GFP_KERNEL); + if (!samsung_bl_drvdata) { printk(KERN_ERR "%s: no memory for platform dev\n", __func__); goto err_data; } + samsung_bl_device->dev.platform_data = &samsung_bl_drvdata->plat_data; + samsung_bl_drvdata->gpio_info = gpio_info; + samsung_bl_data = &samsung_bl_drvdata->plat_data; /* Copy board specific data provided by user */ samsung_bl_data->pwm_id = bl_data->pwm_id; - samsung_bl_device->dev.parent = - &s3c_device_timer[samsung_bl_data->pwm_id].dev; + samsung_bl_device->dev.parent = &samsung_device_pwm.dev; if (bl_data->max_brightness) samsung_bl_data->max_brightness = bl_data->max_brightness; @@ -122,9 +132,6 @@ void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, if (bl_data->check_fb) samsung_bl_data->check_fb = bl_data->check_fb; - /* Keep the GPIO info for future use */ - s3c_device_timer[samsung_bl_data->pwm_id].dev.platform_data = gpio_info; - /* Register the specific PWM timer dev for Backlight control */ ret = platform_device_register( &s3c_device_timer[samsung_bl_data->pwm_id]);