Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966084Ab3DQJpy (ORCPT ); Wed, 17 Apr 2013 05:45:54 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:35074 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753260Ab3DQJpw (ORCPT ); Wed, 17 Apr 2013 05:45:52 -0400 X-Sasl-enc: W0QWL2rrdYobrIIQigUWvwVEZaV5GButr1LwHbi5Bhyq 1366191951 Message-ID: <516E6F4E.9030808@ladisch.de> Date: Wed, 17 Apr 2013 11:45:50 +0200 From: Clemens Ladisch User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: Arnd Bergmann CC: Linus Torvalds , Linux Kernel Mailing List , Takashi Iwai , Mauro Carvalho Chehab Subject: Re: Device driver memory 'mmap()' function helper cleanup References: <201304171115.51509.arnd@arndb.de> In-Reply-To: <201304171115.51509.arnd@arndb.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1846 Lines: 60 Arnd Bergmann wrote: > On Wednesday 17 April 2013, Linus Torvalds wrote: >> Anyway, I'm attaching the untested patch to several drivers. Guys, >> mind taking a look? > > I took a look at the hpet_mmap function, which still contains this check: > > if (((vma->vm_end - vma->vm_start) != PAGE_SIZE) || vma->vm_pgoff) > return -EINVAL; > > As far as I can tell, this check is implied by the new code in > vm_iomap_memory as the len argument passed here is PAGE_SIZE, so you > can remove another three lines in hpet_mmap. Yes indeed. > > [...] I just have this untested patch-collection for a few random > > drivers (picked across a few different driver subsystems, just to make > > it interesting). I did that largely just to check the different use > > cases, but I don't actually tend to *use* all that many fancy drivers, > > so I don't have much of a way of testing it. Any more-or-less recent x86 machine has HPET, so you could enable CONFIG_HPET(_MMAP) and try the (completely untested) program below. Regards, Clemens --8<---------------------------------------------------------------->8-- #include #include #include #include int main(void) { int fd = open("/dev/hpet", O_RDONLY); if (fd == -1) { perror("/dev/hpet"); return 1; } const volatile unsigned int *ptr = mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { perror("mmap"); return 1; } printf("frequency: %.5f MHz\n", 1e9 / ptr[1]); for (;;) { printf("\rcounter: %08x", ptr[60]); fflush(stdout); usleep(123456); } } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/