Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934726Ab3DSXHc (ORCPT ); Fri, 19 Apr 2013 19:07:32 -0400 Received: from mail-vc0-f171.google.com ([209.85.220.171]:49501 "EHLO mail-vc0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934183Ab3DSXHb (ORCPT ); Fri, 19 Apr 2013 19:07:31 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 19 Apr 2013 16:07:29 -0700 X-Google-Sender-Auth: Z16OMMLTGTyIQuckDNia1SEjcig Message-ID: Subject: Re: Device driver memory 'mmap()' function helper cleanup From: Linus Torvalds To: Michel Lespinasse Cc: Linux Kernel Mailing List , Clemens Ladisch , Arnd Bergmann , Takashi Iwai , Mauro Carvalho Chehab Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1100 Lines: 23 On Fri, Apr 19, 2013 at 8:43 AM, Michel Lespinasse wrote: > > Just a suggestion: when file->f_op->mmap returns an error code, > mmap_region() currently has to call unmap_region() to undo any partial > mappings that might have been created by the device driver. Would it > make more sense to ask that the few drivers that create such messes to > clean up after themselves on their error paths ? No. We basically want to assume the least competence humanly (simianly?) possible from driver writers. The problem the helper is trying to solve is exactly the fact that driver writers shouldn't have to even know about all the subtleties with page offsets etc. So if a driver returns an error code, we should assume they screwed up potentially half-way and clean up. We should *not* assume that we don't need to. Linus -- 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/