From patchwork Thu Jan 4 21:14:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 10145645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 983E66034B for ; Thu, 4 Jan 2018 21:17:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E928200DF for ; Thu, 4 Jan 2018 21:17:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A9412674B; Thu, 4 Jan 2018 21:17:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 121E628A7A for ; Thu, 4 Jan 2018 21:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752732AbeADVPE (ORCPT ); Thu, 4 Jan 2018 16:15:04 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:41005 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753199AbeADVPD (ORCPT ); Thu, 4 Jan 2018 16:15:03 -0500 Received: by mail-wm0-f65.google.com with SMTP id g75so5884831wme.0 for ; Thu, 04 Jan 2018 13:15:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=n4kLBMRUE2TNUamr1fqcp0hvjaZroYdl+GekuWsA8BU=; b=WmHhOjByy85HMPHSNcBOJHWjmhEadJmgb6v9vqCGJHcEJNvhLLcLKk8mEw/Mlp/w9q XxDrY/IIoRyk43Yv+x6WjXVEgcQQEmV0+wO0Mteu/bBtnsBOa2mAKAJc49y8eieag/BZ KDBpIjMEQTBf++p6A46vta+wHRUg07C3W6CT1K9A+Z+tdTfIk4GiE1LbiIRQPjPP/SUj 2oXqoW+cGmbujzRaWzBKwcTpOxgxQMmoZE77tz892mJ11UaFgOV4vtqbzoDOR1PTIt1t LeKx6lF4vpMoBJkAIVB6TeARNe6p6u7jegkaB8qvikM2Kx5/GQfajg3i0wKOV2CZ/J3o vu4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=n4kLBMRUE2TNUamr1fqcp0hvjaZroYdl+GekuWsA8BU=; b=lbwAP/IxVyR0QJGrqJBfkzuNk08v039KJ58uOAodPNBOZtCiXux7w1XMBD3Top+4UG 9EM/ICYKO6zqIs8MDn+5yY0/W7YXTRT6pGzgIOwEg2+AZ9K0xe2SsJ2n1tqB5X9Qxzeo M+BQFrdqibWOuF9peQJy0KKYoys/XR1RW+Nb1jfE/V1RpHj5cRpDtGL0qObV/1glfT25 dWwdWxQFG7K9tJXpkikwjdQxCQZV4RuFBTfb6r8xIIbqMuWKOwnT1zF7ntPBzSay+Hex kcaOBwX6jqeaQ/saZBoxxWX+VBh5GvOH/X94vGhDOKJwwoWvBjcGr9hQjvgP2mjTWsw2 ueew== X-Gm-Message-State: AKGB3mLSZbB06sorihow8+XMWyKCG2+hQvRsxdjCF3QEBrAhTLTUm1VN R8i49d+2umVKGeoSJT4Rg821YA== X-Google-Smtp-Source: ACJfBotfLKxRiJTyFE2ZvcH9BEajwPssMx8Dn2TVqfybe6Zwszb7BZG8ugf0ZHLiSrD9HcalpZZs4A== X-Received: by 10.28.108.14 with SMTP id h14mr549333wmc.32.1515100502109; Thu, 04 Jan 2018 13:15:02 -0800 (PST) Received: from localhost.localdomain ([5.170.75.100]) by smtp.gmail.com with ESMTPSA id y124sm4119145wmb.42.2018.01.04.13.15.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jan 2018 13:15:01 -0800 (PST) From: Michael Trimarchi To: artlomiej Zolnierkiewicz Cc: Stefan Agner , Michael Trimarchi , Shawn Guo , linux-fbdev@vger.kernel.org Subject: [RFC PATCH] fbdev: mxsfb: use framebuffer_alloc in the correct way Date: Thu, 4 Jan 2018 22:14:58 +0100 Message-Id: <1515100498-23066-1-git-send-email-michael@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP framebuffer_alloc allocated the fb_info struct plus the extra par and set fb_info->par pointer equal to this extra par. We can refer the mxcfb_info from fb_info->par Signed-off-by: Michael Trimarchi --- drivers/video/fbdev/mxsfb.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 79b1dc7..fa24ddc 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -169,7 +169,6 @@ struct mxsfb_devdata { }; struct mxsfb_info { - struct fb_info fb_info; struct platform_device *pdev; struct clk *clk; struct clk *clk_axi; @@ -208,7 +207,7 @@ static const struct mxsfb_devdata mxsfb_devdata[] = { }, }; -#define to_imxfb_host(x) (container_of(x, struct mxsfb_info, fb_info)) +#define to_imxfb_host(x) (((struct fb_info *)(x))->par) /* mask and shift depends on architecture */ static inline u32 set_hsync_pulse_width(struct mxsfb_info *host, unsigned val) @@ -622,10 +621,10 @@ static struct fb_ops mxsfb_ops = { .fb_imageblit = cfb_imageblit, }; -static int mxsfb_restore_mode(struct mxsfb_info *host, +static int mxsfb_restore_mode(struct fb_info *fb_info, struct fb_videomode *vmode) { - struct fb_info *fb_info = &host->fb_info; + struct mxsfb_info *host = to_imxfb_host(fb_info); unsigned line_count; unsigned period; unsigned long pa, fbsize; @@ -726,10 +725,10 @@ static int mxsfb_restore_mode(struct mxsfb_info *host, return ret; } -static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host, +static int mxsfb_init_fbinfo_dt(struct fb_info *fb_info, struct fb_videomode *vmode) { - struct fb_info *fb_info = &host->fb_info; + struct mxsfb_info *host = to_imxfb_host(fb_info); struct fb_var_screeninfo *var = &fb_info->var; struct device *dev = &host->pdev->dev; struct device_node *np = host->pdev->dev.of_node; @@ -805,12 +804,12 @@ static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host, return ret; } -static int mxsfb_init_fbinfo(struct mxsfb_info *host, +static int mxsfb_init_fbinfo(struct fb_info *fb_info, struct fb_videomode *vmode) { int ret; + struct mxsfb_info *host = to_imxfb_host(fb_info); struct device *dev = &host->pdev->dev; - struct fb_info *fb_info = &host->fb_info; struct fb_var_screeninfo *var = &fb_info->var; dma_addr_t fb_phys; void *fb_virt; @@ -824,7 +823,7 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host, fb_info->fix.visual = FB_VISUAL_TRUECOLOR, fb_info->fix.accel = FB_ACCEL_NONE; - ret = mxsfb_init_fbinfo_dt(host, vmode); + ret = mxsfb_init_fbinfo_dt(fb_info, vmode); if (ret) return ret; @@ -843,16 +842,16 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host, fb_info->screen_base = fb_virt; fb_info->screen_size = fb_info->fix.smem_len = fb_size; - if (mxsfb_restore_mode(host, vmode)) + if (mxsfb_restore_mode(fb_info, vmode)) memset(fb_virt, 0, fb_size); return 0; } -static void mxsfb_free_videomem(struct mxsfb_info *host) +static void mxsfb_free_videomem(struct fb_info *fb_info) { + struct mxsfb_info *host = to_imxfb_host(fb_info); struct device *dev = &host->pdev->dev; - struct fb_info *fb_info = &host->fb_info; dma_free_wc(dev, fb_info->screen_size, fb_info->screen_base, fb_info->fix.smem_start); @@ -941,7 +940,7 @@ static int mxsfb_probe(struct platform_device *pdev) goto fb_release; } - ret = mxsfb_init_fbinfo(host, mode); + ret = mxsfb_init_fbinfo(fb_info, mode); if (ret != 0) goto fb_release; @@ -988,7 +987,7 @@ static int mxsfb_remove(struct platform_device *pdev) mxsfb_disable_controller(fb_info); unregister_framebuffer(fb_info); - mxsfb_free_videomem(host); + mxsfb_free_videomem(fb_info); framebuffer_release(fb_info);