Linux Audio

Check our new training course

Loading...
v6.13.7
 1/* SPDX-License-Identifier: GPL-2.0-or-later */
 2/*
 3 * Header file for SCSI device handler infrastructure.
 4 *
 5 * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu>
 6 *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 7 * Copyright IBM Corporation, 2007
 8 *      Authors:
 9 *               Chandra Seetharaman <sekharan@us.ibm.com>
10 *               Mike Anderson <andmike@linux.vnet.ibm.com>
11 */
12
13#include <scsi/scsi_device.h>
14
15enum {
16	SCSI_DH_OK = 0,
17	/*
18	 * device errors
19	 */
20	SCSI_DH_DEV_FAILED,	/* generic device error */
21	SCSI_DH_DEV_TEMP_BUSY,
22	SCSI_DH_DEV_UNSUPP,	/* device handler not supported */
23	SCSI_DH_DEVICE_MAX,	/* max device blkerr definition */
24
25	/*
26	 * transport errors
27	 */
28	SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1,
29	SCSI_DH_CONN_FAILURE,
30	SCSI_DH_TRANSPORT_MAX,	/* max transport blkerr definition */
31
32	/*
33	 * driver and generic errors
34	 */
35	SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1,	/* generic error */
36	SCSI_DH_INVALID_IO,
37	SCSI_DH_RETRY,		/* retry the req, but not immediately */
38	SCSI_DH_IMM_RETRY,	/* immediately retry the req */
39	SCSI_DH_TIMED_OUT,
40	SCSI_DH_RES_TEMP_UNAVAIL,
41	SCSI_DH_DEV_OFFLINED,
42	SCSI_DH_NOMEM,
43	SCSI_DH_NOSYS,
44	SCSI_DH_DRIVER_MAX,
45};
46
47typedef void (*activate_complete)(void *, int);
48struct scsi_device_handler {
49	/* Used by the infrastructure */
50	struct list_head list; /* list of scsi_device_handlers */
51
52	/* Filled by the hardware handler */
53	struct module *module;
54	const char *name;
55	enum scsi_disposition (*check_sense)(struct scsi_device *,
56					     struct scsi_sense_hdr *);
57	int (*attach)(struct scsi_device *);
58	void (*detach)(struct scsi_device *);
59	int (*activate)(struct scsi_device *, activate_complete, void *);
60	blk_status_t (*prep_fn)(struct scsi_device *, struct request *);
61	int (*set_params)(struct scsi_device *, const char *);
62	void (*rescan)(struct scsi_device *);
63};
64
65#ifdef CONFIG_SCSI_DH
66extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
67extern int scsi_dh_attach(struct request_queue *, const char *);
68extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
69extern int scsi_dh_set_params(struct request_queue *, const char *);
70#else
71static inline int scsi_dh_activate(struct request_queue *req,
72					activate_complete fn, void *data)
73{
74	fn(data, 0);
75	return 0;
76}
77static inline int scsi_dh_attach(struct request_queue *req, const char *name)
78{
79	return SCSI_DH_NOSYS;
80}
81static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
82							gfp_t gfp)
83{
84	return NULL;
85}
86static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
87{
88	return -SCSI_DH_NOSYS;
89}
90#endif
v4.17
 
  1/*
  2 * Header file for SCSI device handler infrastruture.
  3 *
  4 * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu>
  5 *
  6 * This program is free software; you can redistribute it and/or modify it
  7 * under the terms of the GNU General Public License as published by the
  8 * Free Software Foundation; either version 2 of the License, or (at your
  9 * option) any later version.
 10 *
 11 * This program is distributed in the hope that it will be useful, but
 12 * WITHOUT ANY WARRANTY; without even the implied warranty of
 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14 * General Public License for more details.
 15 *
 16 * You should have received a copy of the GNU General Public License along
 17 * with this program; if not, write to the Free Software Foundation, Inc.,
 18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 19 *
 20 * Copyright IBM Corporation, 2007
 21 *      Authors:
 22 *               Chandra Seetharaman <sekharan@us.ibm.com>
 23 *               Mike Anderson <andmike@linux.vnet.ibm.com>
 24 */
 25
 26#include <scsi/scsi_device.h>
 27
 28enum {
 29	SCSI_DH_OK = 0,
 30	/*
 31	 * device errors
 32	 */
 33	SCSI_DH_DEV_FAILED,	/* generic device error */
 34	SCSI_DH_DEV_TEMP_BUSY,
 35	SCSI_DH_DEV_UNSUPP,	/* device handler not supported */
 36	SCSI_DH_DEVICE_MAX,	/* max device blkerr definition */
 37
 38	/*
 39	 * transport errors
 40	 */
 41	SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1,
 42	SCSI_DH_CONN_FAILURE,
 43	SCSI_DH_TRANSPORT_MAX,	/* max transport blkerr definition */
 44
 45	/*
 46	 * driver and generic errors
 47	 */
 48	SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1,	/* generic error */
 49	SCSI_DH_INVALID_IO,
 50	SCSI_DH_RETRY,		/* retry the req, but not immediately */
 51	SCSI_DH_IMM_RETRY,	/* immediately retry the req */
 52	SCSI_DH_TIMED_OUT,
 53	SCSI_DH_RES_TEMP_UNAVAIL,
 54	SCSI_DH_DEV_OFFLINED,
 55	SCSI_DH_NOMEM,
 56	SCSI_DH_NOSYS,
 57	SCSI_DH_DRIVER_MAX,
 58};
 59
 60typedef void (*activate_complete)(void *, int);
 61struct scsi_device_handler {
 62	/* Used by the infrastructure */
 63	struct list_head list; /* list of scsi_device_handlers */
 64
 65	/* Filled by the hardware handler */
 66	struct module *module;
 67	const char *name;
 68	int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
 
 69	int (*attach)(struct scsi_device *);
 70	void (*detach)(struct scsi_device *);
 71	int (*activate)(struct scsi_device *, activate_complete, void *);
 72	int (*prep_fn)(struct scsi_device *, struct request *);
 73	int (*set_params)(struct scsi_device *, const char *);
 74	void (*rescan)(struct scsi_device *);
 75};
 76
 77#ifdef CONFIG_SCSI_DH
 78extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
 79extern int scsi_dh_attach(struct request_queue *, const char *);
 80extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
 81extern int scsi_dh_set_params(struct request_queue *, const char *);
 82#else
 83static inline int scsi_dh_activate(struct request_queue *req,
 84					activate_complete fn, void *data)
 85{
 86	fn(data, 0);
 87	return 0;
 88}
 89static inline int scsi_dh_attach(struct request_queue *req, const char *name)
 90{
 91	return SCSI_DH_NOSYS;
 92}
 93static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
 94							gfp_t gfp)
 95{
 96	return NULL;
 97}
 98static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
 99{
100	return -SCSI_DH_NOSYS;
101}
102#endif