/*
* ds.c -- 16-bit PCMCIA core support
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* The initial developer of the original code is David A. Hinds
* <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
*
* (C) 1999 David A. Hinds
* (C) 2003 - 2006 Dominik Brodowski
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/list.h>
#include <linux/delay.h>
#include <linux/workqueue.h>
#include <linux/crc32.h>
#include <linux/firmware.h>
#include <linux/kref.h>
#define IN_CARD_SERVICES
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
#include <pcmcia/ss.h>
#include "cs_internal.h"
#include "ds_internal.h"
/*====================================================================*/
/* Module parameters */
MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
MODULE_DESCRIPTION("PCMCIA Driver Services");
MODULE_LICENSE("GPL");
#ifdef DEBUG
int ds_pc_debug;
module_param_named(pc_debug, ds_pc_debug, int, 0644);
#define ds_dbg(lvl, fmt, arg...) do { \
if (ds_pc_debug > (lvl)) \
printk(KERN_DEBUG "ds: " fmt , ## arg); \
} while (0)
#else
#define ds_dbg(lvl, fmt, arg...) do { } while (0)
#endif
spinlock_t pcmcia_dev_list_lock;
/*====================================================================*/
/* code which was in cs.c before */
/* String tables for error messages */
typedef struct lookup_t {
int key;
char *msg;
} lookup_t;
static const lookup_t error_table[] = {
{ CS_SUCCESS, "Operation succeeded" },
{ CS_BAD_ADAPTER, "Bad adapter" },
{ CS_BAD_ATTRIBUTE, "Bad attribute", },
{ CS_BAD_BASE, "Bad base address" },
{ CS_BAD_EDC, "Bad EDC" },
{ CS_BAD_IRQ, "Bad IRQ" },
{ CS_BAD_OFFSET, "Bad offset" },
{ CS_BAD_PAGE, "Bad page number" },
{ CS_READ_FAILURE, "Read failure" },
{ CS_BAD_SIZE, "Bad size" },
{ CS_BAD_SOCKET, "Bad socket" },
{ CS_BAD_TYPE, "Bad type" },
{ CS_BAD_VCC, "Bad Vcc" },
{ CS_BAD_VPP, "Bad Vpp" },
{ CS_BAD_WINDOW, "Bad window" },
{ CS_WRITE_FAILURE, "Write failure" },
{ CS_NO_CARD, "No card present" },
{ CS_UNSUPPORTED_FUNCTION, "Usupported function" },
{ CS_UNSUPPORTED_MODE, "Unsupported mode" },
{ CS_BAD_SPEED, "Bad speed" },
{ CS_BUSY, "Resource busy" },
{ CS_GENERAL_FAILURE, "General failure" },
{ CS_WRITE_PROTECTED, "Write protected" },
{ CS_BAD_ARG_LENGTH, "Bad argument length" },
{ CS_BAD_ARGS, "Bad arguments" },
{ CS_CONFIGURATION_LOCKED, "Configuration locked" },
{ CS_IN_USE, "Resource in use" },
{ CS_NO_MORE_ITEMS, "No more items" },
{ CS_OUT_OF_RESOURCE, "Out of resource" },
{ CS_BAD_HANDLE, "Bad handle" },
{ CS_BAD_TUPLE, "Bad CIS tuple" }
};
static const lookup_t service_table[] = {
{ AccessConfigurationRegister, "AccessConfigurationRegister" },
{ AddSocketServices, "AddSocketServices" },
{ AdjustResourceInfo, "AdjustResourceInfo" },
{ CheckEraseQueue, "CheckEraseQueue" },
{ CloseMemory, "CloseMemory" },
{ DeregisterClient, "DeregisterClient" },
{ DeregisterEraseQueue, "DeregisterEraseQueue" },
{ GetCardServicesInfo, "GetCardServicesInfo" },
{ GetClientInfo, "GetClientInfo" },
{ GetConfigurationInfo, "GetConfigurationInfo" },
{ GetEventMask, "GetEventMask" },
{ GetFirstClient, "GetFirstClient" },
{ GetFirstRegion, "GetFirstRegion" },
{ GetFirstTuple, "GetFirstTuple" },
{ GetNextClient, "GetNextClient" },
{ GetNextRegion, "GetNextRegion" },
{ GetNextTuple, "GetNextTuple" },
{ GetStatus, "GetStatus" },
{ GetTupleData, "GetTupleData" },
{ MapMemPage, "MapMemPage" },
{ ModifyConfiguration, "ModifyConfiguration" },
{ ModifyWindow, "ModifyWindow" },
{ OpenMemory, "OpenMemory" },
{ ParseTuple, "ParseTuple" },
{ ReadMemory, "ReadMemory" },
{ RegisterClient, "RegisterClient" },
{ RegisterEraseQueue, "RegisterEraseQueue" },
{ RegisterMTD, "RegisterMTD" },
{ ReleaseConfiguration, "ReleaseConfiguration" },
{ ReleaseIO, "ReleaseIO" },
{ ReleaseIRQ, "ReleaseIRQ" },
{ ReleaseWindow, "ReleaseWindow" },
{ RequestConfiguration, "RequestConfiguration" },
{ RequestIO, "RequestIO" },
{ RequestIRQ, "RequestIRQ" },
{ RequestSocketMask, "RequestSocketMask" },
{ RequestWindow, "RequestWindow" },
{ ResetCard, "ResetCard" },
{ SetEventMask, "SetEventMask" },
{ ValidateCIS, "ValidateCIS" },
{ WriteMemory, "WriteMemory" },
{ BindDevice, "BindDevice" },
{ BindMTD, "BindMTD" },
{ ReportError, "ReportError" },
{ SuspendCard, "SuspendCard" },
{ ResumeCard, "ResumeCard" },
{ EjectCard, "EjectCard" },
{ InsertCard, "InsertCard" },
{ ReplaceCIS, "ReplaceCIS" }
};
static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err)
{
int i;
char *serv;
if (!p_dev)
printk(KERN_NOTICE);
else
printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id);
for (i = 0; i < ARRAY_SIZE(service_table); i++)
if (service_table[i].key == err->func)
break;
if (i < ARRAY_SIZE(service_ta
|