From patchwork Mon Nov 18 10:57:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 3195991 Return-Path: X-Original-To: patchwork-linux-fbdev@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 D6FC6C045B for ; Mon, 18 Nov 2013 10:57:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B58D02066A for ; Mon, 18 Nov 2013 10:57:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00B2720704 for ; Mon, 18 Nov 2013 10:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751281Ab3KRK5U (ORCPT ); Mon, 18 Nov 2013 05:57:20 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:37168 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751172Ab3KRK5T (ORCPT ); Mon, 18 Nov 2013 05:57:19 -0500 Received: from ukl by metis.ext.pengutronix.de with local (Exim 4.72) (envelope-from ) id 1ViMW2-00037T-5O; Mon, 18 Nov 2013 11:57:14 +0100 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: linux-fbdev@vger.kernel.org, kernel@pengutronix.de, Jonathan Austin , linux-arm-kernel@lists.infradead.org Date: Mon, 18 Nov 2013 11:57:11 +0100 Message-Id: <1384772231-20993-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 1.8.4.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ukl@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Subject: [PATCH] RFC: framebuffer: provide generic get_fb_unmapped_area X-SA-Exim-Version: 4.2.1 (built Mon, 22 Mar 2010 06:51:10 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: linux-fbdev@vger.kernel.org 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 This patch makes mmapping the simple-framebuffer device work on a no-MMU ARM target. The code is mostly taken from arch/blackfin/kernel/sys_bfin.c. Note this is only tested on this no-MMU machine and I don't know enough about framebuffers and mm to decide if this patch is sane. Also I'm unsure about the size check because it triggers if userspace page aligns the len parameter. (I don't know how usual it is to do, I'd say it's wrong, but my test program (fbtest by Geert Uytterhoeven) does it.) Signed-off-by: Uwe Kleine-König --- drivers/video/fbmem.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index dacaf74..70b328c 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c @@ -1483,6 +1483,24 @@ __releases(&info->lock) return 0; } +#ifdef HAVE_ARCH_FB_UNMAPPED_AREA +#define fb_get_unmapped_area get_fb_unmapped_area +#else +unsigned long fb_get_unmapped_area(struct file *filp, unsigned long orig_addr, + unsigned long len, unsigned long pgoff, unsigned long flags) +{ + struct fb_info * const info = filp->private_data; + unsigned long screen_size = info->screen_size ?: info->fix.smem_len; + + if (len > screen_size) { + pr_info("%lu > %lu (%lu, %lu)\n", len, screen_size, info->screen_size, info->fix.smem_len); + return -EINVAL; + } + + return (unsigned long)info->screen_base; +} +#endif + static const struct file_operations fb_fops = { .owner = THIS_MODULE, .read = fb_read, @@ -1494,9 +1512,7 @@ static const struct file_operations fb_fops = { .mmap = fb_mmap, .open = fb_open, .release = fb_release, -#ifdef HAVE_ARCH_FB_UNMAPPED_AREA - .get_unmapped_area = get_fb_unmapped_area, -#endif + .get_unmapped_area = fb_get_unmapped_area, #ifdef CONFIG_FB_DEFERRED_IO .fsync = fb_deferred_io_fsync, #endif