From patchwork Thu Sep 4 14:46:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 4846531 Return-Path: X-Original-To: patchwork-linux-media@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 542A0C0338 for ; Thu, 4 Sep 2014 14:47:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AADB520268 for ; Thu, 4 Sep 2014 14:47:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9738820211 for ; Thu, 4 Sep 2014 14:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752993AbaIDOq7 (ORCPT ); Thu, 4 Sep 2014 10:46:59 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:35030 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988AbaIDOq6 (ORCPT ); Thu, 4 Sep 2014 10:46:58 -0400 Received: from 200-100-75-232.dial-up.telesp.net.br ([200.100.75.232] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPYJM-0008VZ-Mw; Thu, 04 Sep 2014 14:46:56 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1XPYJE-0003RB-Vp; Thu, 04 Sep 2014 11:46:48 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil Subject: [PATCH 3/3] [media] tw68: don't assume that pagesize is always 4096 Date: Thu, 4 Sep 2014 11:46:47 -0300 Message-Id: <5bbc05f52d23b17cc0faa81a2e5d4f2a344aaaa9.1409841955.git.m.chehab@samsung.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 code implicitly assumes that pagesize is 4096, but this is not true on all archs, as the PAGE_SHIFT can be different than 12 on all those architectures: alpha, arc, arm64, cris, frv, hexagon,ia64, m68k, metag, microblaze, mips, openrisc, parisc, powerpc, sh, sparc and tile. The real constrant here seems to be to limit the buffer size to 4MB. So, fix the code to reflect that, in a way that it will keep working with differnt values for PAGE_SIZE. Signed-off-by: Mauro Carvalho Chehab diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c index 4dd38578cf1b..66658accdca9 100644 --- a/drivers/media/pci/tw68/tw68-video.c +++ b/drivers/media/pci/tw68/tw68-video.c @@ -366,7 +366,7 @@ static int tw68_buffer_pages(int size) { size = PAGE_ALIGN(size); size += PAGE_SIZE; /* for non-page-aligned buffers */ - size /= 4096; + size /= PAGE_SIZE; return size; } @@ -376,7 +376,7 @@ static int tw68_buffer_count(unsigned int size, unsigned int count) { unsigned int maxcount; - maxcount = 1024 / tw68_buffer_pages(size); + maxcount = (4096 * 1024 / PAGE_SIZE) / tw68_buffer_pages(size); if (count > maxcount) count = maxcount; return count;