msm_device.c revision baaff307
11.5Sthorpej/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
21.1Sfvdl
31.1Sfvdl/*
41.1Sfvdl * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
51.1Sfvdl *
61.1Sfvdl * Permission is hereby granted, free of charge, to any person obtaining a
71.1Sfvdl * copy of this software and associated documentation files (the "Software"),
81.1Sfvdl * to deal in the Software without restriction, including without limitation
91.1Sfvdl * the rights to use, copy, modify, merge, publish, distribute, sublicense,
101.1Sfvdl * and/or sell copies of the Software, and to permit persons to whom the
111.1Sfvdl * Software is furnished to do so, subject to the following conditions:
121.1Sfvdl *
131.1Sfvdl * The above copyright notice and this permission notice (including the next
141.1Sfvdl * paragraph) shall be included in all copies or substantial portions of the
151.1Sfvdl * Software.
161.1Sfvdl *
171.1Sfvdl * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
181.3Sagc * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
191.1Sfvdl * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
201.1Sfvdl * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
211.1Sfvdl * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
221.1Sfvdl * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
231.1Sfvdl * SOFTWARE.
241.1Sfvdl *
251.1Sfvdl * Authors:
261.1Sfvdl *    Rob Clark <robclark@freedesktop.org>
271.1Sfvdl */
281.1Sfvdl
291.1Sfvdl#ifdef HAVE_CONFIG_H
301.1Sfvdl# include <config.h>
311.1Sfvdl#endif
321.1Sfvdl
331.1Sfvdl#include <sys/types.h>
341.1Sfvdl#include <sys/stat.h>
351.1Sfvdl#include <unistd.h>
361.1Sfvdl
371.1Sfvdl#include "msm_priv.h"
381.1Sfvdl
391.5Sthorpejstatic void msm_device_destroy(struct fd_device *dev)
401.1Sfvdl{
411.1Sfvdl	struct msm_device *msm_dev = to_msm_device(dev);
421.1Sfvdl	free(msm_dev);
431.1Sfvdl}
441.5Sthorpej
45static struct fd_device_funcs funcs = {
46		.bo_new_handle = msm_bo_new_handle,
47		.bo_from_handle = msm_bo_from_handle,
48		.pipe_new = msm_pipe_new,
49		.destroy = msm_device_destroy,
50};
51
52struct fd_device * msm_device_new(int fd)
53{
54	struct msm_device *msm_dev;
55	struct fd_device *dev;
56
57	msm_dev = calloc(1, sizeof(*msm_dev));
58	if (!msm_dev)
59		return NULL;
60
61	dev = &msm_dev->base;
62	dev->funcs = &funcs;
63
64	return dev;
65}
66