14f5e7dd7Smrg/*
24f5e7dd7Smrg * (C) Copyright IBM Corporation 2007
34f5e7dd7Smrg * All Rights Reserved.
44f5e7dd7Smrg *
54f5e7dd7Smrg * Permission is hereby granted, free of charge, to any person obtaining a
64f5e7dd7Smrg * copy of this software and associated documentation files (the "Software"),
74f5e7dd7Smrg * to deal in the Software without restriction, including without limitation
84f5e7dd7Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub
94f5e7dd7Smrg * license, and/or sell copies of the Software, and to permit persons to whom
104f5e7dd7Smrg * the Software is furnished to do so, subject to the following conditions:
114f5e7dd7Smrg *
124f5e7dd7Smrg * The above copyright notice and this permission notice (including the next
134f5e7dd7Smrg * paragraph) shall be included in all copies or substantial portions of the
144f5e7dd7Smrg * Software.
154f5e7dd7Smrg *
164f5e7dd7Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
174f5e7dd7Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
184f5e7dd7Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
194f5e7dd7Smrg * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
204f5e7dd7Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
214f5e7dd7Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
224f5e7dd7Smrg * DEALINGS IN THE SOFTWARE.
234f5e7dd7Smrg */
2449310723Smrg#ifdef HAVE_CONFIG_H
2549310723Smrg#include "config.h"
2649310723Smrg#endif
274f5e7dd7Smrg
284f5e7dd7Smrg#include <sys/types.h>
294f5e7dd7Smrg#include <sys/mman.h>
304f5e7dd7Smrg#include <errno.h>
314f5e7dd7Smrg
324f5e7dd7Smrg#include "pciaccess.h"
334f5e7dd7Smrg#include "pciaccess_private.h"
344f5e7dd7Smrg
354f5e7dd7Smrg/**
364f5e7dd7Smrg * \file common_map.c
374f5e7dd7Smrg * Platform independent memory map routines.
384f5e7dd7Smrg *
394f5e7dd7Smrg * \author Ian Romanick <idr@us.ibm.com>
404f5e7dd7Smrg */
414f5e7dd7Smrg
424f5e7dd7Smrg/**
434f5e7dd7Smrg * Unmap the specified region using the munmap.
444f5e7dd7Smrg *
454f5e7dd7Smrg * \param dev    Device whose memory region is to be mapped.
464f5e7dd7Smrg * \param map    Memory mapping that is to be undone.
474f5e7dd7Smrg *
484f5e7dd7Smrg * \return
494f5e7dd7Smrg * Zero on success or an \c errno value on failure.
504f5e7dd7Smrg *
514f5e7dd7Smrg * \sa pci_device_unmap_range
524f5e7dd7Smrg */
534f5e7dd7Smrg_pci_hidden int
544f5e7dd7Smrgpci_device_generic_unmap_range(struct pci_device *dev,
554f5e7dd7Smrg			       struct pci_device_mapping *map)
564f5e7dd7Smrg{
574f5e7dd7Smrg    return (munmap(map->memory, map->size) == -1) ? errno : 0;
584f5e7dd7Smrg}
59