1e88f27b3Smrg/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */ 2e88f27b3Smrg 3e88f27b3Smrg/* 4e88f27b3Smrg * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org> 5e88f27b3Smrg * 6e88f27b3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7e88f27b3Smrg * copy of this software and associated documentation files (the "Software"), 8e88f27b3Smrg * to deal in the Software without restriction, including without limitation 9e88f27b3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10e88f27b3Smrg * and/or sell copies of the Software, and to permit persons to whom the 11e88f27b3Smrg * Software is furnished to do so, subject to the following conditions: 12e88f27b3Smrg * 13e88f27b3Smrg * The above copyright notice and this permission notice (including the next 14e88f27b3Smrg * paragraph) shall be included in all copies or substantial portions of the 15e88f27b3Smrg * Software. 16e88f27b3Smrg * 17e88f27b3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18e88f27b3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19e88f27b3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20e88f27b3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21e88f27b3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22e88f27b3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23e88f27b3Smrg * SOFTWARE. 24e88f27b3Smrg * 25e88f27b3Smrg * Authors: 26e88f27b3Smrg * Rob Clark <robclark@freedesktop.org> 27e88f27b3Smrg */ 28e88f27b3Smrg 29e88f27b3Smrg#include <sys/types.h> 30e88f27b3Smrg#include <sys/stat.h> 31e88f27b3Smrg#include <unistd.h> 32e88f27b3Smrg 33e88f27b3Smrg#include "msm_priv.h" 34e88f27b3Smrg 35e88f27b3Smrgstatic void msm_device_destroy(struct fd_device *dev) 36e88f27b3Smrg{ 37e88f27b3Smrg struct msm_device *msm_dev = to_msm_device(dev); 38e88f27b3Smrg free(msm_dev); 39e88f27b3Smrg} 40e88f27b3Smrg 413f012e29Smrgstatic const struct fd_device_funcs funcs = { 42e88f27b3Smrg .bo_new_handle = msm_bo_new_handle, 43e88f27b3Smrg .bo_from_handle = msm_bo_from_handle, 44e88f27b3Smrg .pipe_new = msm_pipe_new, 45e88f27b3Smrg .destroy = msm_device_destroy, 46e88f27b3Smrg}; 47e88f27b3Smrg 48e6188e58Smrgdrm_private struct fd_device * msm_device_new(int fd) 49e88f27b3Smrg{ 50e88f27b3Smrg struct msm_device *msm_dev; 51e88f27b3Smrg struct fd_device *dev; 52e88f27b3Smrg 53e88f27b3Smrg msm_dev = calloc(1, sizeof(*msm_dev)); 54e88f27b3Smrg if (!msm_dev) 55e88f27b3Smrg return NULL; 56e88f27b3Smrg 57e88f27b3Smrg dev = &msm_dev->base; 58e88f27b3Smrg dev->funcs = &funcs; 59e88f27b3Smrg 60d8807b2fSmrg dev->bo_size = sizeof(struct msm_bo); 61d8807b2fSmrg 62e88f27b3Smrg return dev; 63e88f27b3Smrg} 64