/*****************************************************************************/
/* Copyright (c) 2008 NXP B.V.                                               */
/*                                                                           */
/* This program is free software; you can redistribute it and/or modify      */
/* it under the terms of the GNU General Public License as published by      */
/* the Free Software Foundation, using version 2 of the License.             */
/*                                                                           */
/* This program is distributed in the hope that it will be useful,           */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the              */
/* GNU General Public License for more details.                              */
/*                                                                           */
/* You should have received a copy of the GNU General Public License         */
/* along with this program; if not, write to the Free Software               */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307       */
/* USA.                                                                      */
/*                                                                           */
/*****************************************************************************/
/*

Rev Date       Author      Comments
--------------------------------------------------------------------------------
  2 20070312   iwillis     Fixed stack corruption problem
  3 20080205   batelaan    Update file copyright/license text
  4 20080327   laird       Update prototypes.
--------------------------------------------------------------------------------
*/

#include "common.h"
#include <linux/init.h>
#include <linux/device.h>
#include <linux/firmware.h>

static struct device ghost_device = {
	.bus_id    = "nxp-0",
};

tmErrorCode_t tmosalRequestFirmware(const char *name, uint8_t *firmware, uint32_t buffer_size, uint32_t *recovered_size)
{
	int          err;
    struct       firmware fw;

	fw.data = firmware;
	fw.size = 0;
        
	err = request_firmware_known_size(&fw, buffer_size, name, &ghost_device);

	if (err)
	{
		return TM_ERR_NO_RESOURCES;
	}
	*recovered_size = fw.size;
	
	return TM_OK;
}
EXPORT_SYMBOL(tmosalRequestFirmware);

int osal_firmware_submodule_init(void)
{
	return device_register(&ghost_device);
}

void osal_firmware_submodule_uninit(void)
{
}
