aboutsummaryrefslogtreecommitdiffstats
path: root/fs/afs/misc.c
blob: e4fce66d76e03e6d91e97ee34b51a5e848a0bfa2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10/*
 * HP Human Interface Loop Master Link Controller driver.
 *
 * Copyright (c) 2001 Brian S. Julin
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions, and the following disclaimer,
 *    without modification.
 * 2. The name of the author may not be used to endorse or promote products
 *    derived from this software wit/* misc.c: miscellaneous bits
 *
 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * 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; either version
 * 2 of the License, or (at your option) any later version.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/errno.h>
#include "errors.h"
#include "internal.h"

/*****************************************************************************/
/*
 * convert an AFS abort code to a Linux error number
 */
int afs_abort_to_error(int abortcode)
{
	switch (abortcode) {
	case VSALVAGE:		return -EIO;
	case VNOVNODE:		return -ENOENT;
	case VNOVOL:		return -ENXIO;
	case VVOLEXISTS:	return -EEXIST;
	case VNOSERVICE:	return -EIO;
	case VOFFLINE:		return -ENOENT;
	case VONLINE:		return -EEXIST;
	case VDISKFULL:		return -ENOSPC;
	case VOVERQUOTA:	return -EDQUOT;
	case VBUSY:		return -EBUSY;
	case VMOVED:		return -ENXIO;
	default:		return -EIO;
	}

} /* end afs_abort_to_error() */
ILSE_EXPECT_LAST, /* HILSE_EXPECT_LAST as above but dev field should be first * undiscovered/inoperational device. */ HILSE_EXPECT_DISC }; typedef int (hilse_func) (hil_mlc *mlc, int arg); struct hilse_node { enum hilse_act act; /* How to process this node */ union { hilse_func *func; /* Function to call if HILSE_FUNC */ hil_packet packet; /* Packet to send or to compare */ } object; int arg; /* Timeout in usec or parm for func */ int good; /* Node to jump to on success */ int bad; /* Node to jump to on error */ int ugly; /* Node to jump to on timeout */ }; /* Methods for back-end drivers, e.g. hp_sdc_mlc */ typedef int (hil_mlc_cts) (hil_mlc *mlc); typedef void (hil_mlc_out) (hil_mlc *mlc); typedef int (hil_mlc_in) (hil_mlc *mlc, suseconds_t timeout); struct hil_mlc_devinfo { uint8_t idd[16]; /* Device ID Byte and Describe Record */ uint8_t rsc[16]; /* Security Code Header and Record */ uint8_t exd[16]; /* Extended Describe Record */ uint8_t rnm[16]; /* Device name as returned by RNM command */ }; struct hil_mlc_serio_map { hil_mlc *mlc; int di_revmap; int didx; }; /* How many (possibly old/detached) devices the we try to keep track of */ #define HIL_MLC_DEVMEM 16 struct hil_mlc { struct list_head list; /* hil_mlc is organized as linked list */ rwlock_t lock; void *priv; /* Data specific to a particular type of MLC */ int seidx; /* Current node in state engine */ int istarted, ostarted; hil_mlc_cts *cts;