summaryrefslogtreecommitdiffstats
path: root/sys/dev/nand/nandsim.c
blob: aeb35f352b76110629ed01c83bcb95702ce1fd9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
/*-
 * Copyright (C) 2009-2012 Semihalf
 * 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.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/* Simulated NAND controller driver */

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/malloc.h>

#include <dev/nand/nand.h>
#include <dev/nand/nandsim.h>
#include <dev/nand/nandsim_chip.h>
#include <dev/nand/nandsim_log.h>
#include <dev/nand/nandsim_swap.h>

struct sim_param sim;
struct sim_ctrl_conf ctrls[MAX_SIM_DEV];

static struct cdev *nandsim_dev;
static d_ioctl_t nandsim_ioctl;

static void nandsim_init_sim_param(struct sim_param *);
static int nandsim_create_ctrl(struct sim_ctrl *);
static int nandsim_destroy_ctrl(int);
static int nandsim_ctrl_status(struct sim_ctrl *);
static int nandsim_create_chip(struct sim_chip *);
static int nandsim_destroy_chip(struct sim_ctrl_chip *);
static int nandsim_chip_status(struct sim_chip *);
static int nandsim_start_ctrl(int);
static int nandsim_stop_ctrl(int);
static int nandsim_inject_error(struct sim_error *);
static int nandsim_get_block_state(struct sim_block_state *);
static int nandsim_set_block_state(struct sim_block_state *);
static int nandsim_modify(struct sim_mod *);
static int nandsim_dump(struct sim_dump *);
static int nandsim_restore(struct sim_dump *);
static int nandsim_freeze(struct sim_ctrl_chip *);
static void nandsim_print_log(struct sim_log *);
static struct nandsim_chip *get_nandsim_chip(uint8_t, uint8_t);

static struct cdevsw nandsim_cdevsw = {
	.d_version =    D_VERSION,
	.d_ioctl =      nandsim_ioctl,
	.d_name =       "nandsim",
};

int
nandsim_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
    int flags, struct thread *td)
{
	int ret = 0;

	switch (cmd) {
	case NANDSIM_SIM_PARAM:
		nandsim_init_sim_param((struct sim_param *)data);
		break;
	case NANDSIM_CREATE_CTRL:
		ret = nandsim_create_ctrl((struct sim_ctrl *)data);
		break;
	case NANDSIM_DESTROY_CTRL:
		ret = nandsim_destroy_ctrl(*(int *)data);
		break;
	case NANDSIM_STATUS_CTRL:
		ret = nandsim_ctrl_status((struct sim_ctrl *)data);
		break;
	case NANDSIM_CREATE_CHIP:
		ret = nandsim_create_chip((struct sim_chip *)data);
		break;
	case NANDSIM_DESTROY_CHIP:
		ret = nandsim_destroy_chip((struct sim_ctrl_chip *)data);
		break;
	case NANDSIM_STATUS_CHIP:
		ret = nandsim_chip_status((struct sim_chip *)data);
		break;
	case NANDSIM_MODIFY:
		ret = nandsim_modify((struct sim_mod *)data);
		break;
	case NANDSIM_START_CTRL:
		ret = nandsim_start_ctrl(*(int *)data);
		break;
	case NANDSIM_STOP_CTRL:
		ret = nandsim_stop_ctrl(*(int *)data);
		break;
	case NANDSIM_INJECT_ERROR:
		ret = nandsim_inject_error((struct sim_error *)data);
		break;
	case NANDSIM_SET_BLOCK_STATE:
		ret = nandsim_set_block_state((struct sim_block_state *)data);
		break;
	case NANDSIM_GET_BLOCK_STATE:
		ret = nandsim_get_block_state((struct sim_block_state *)data);
		break;
	case NANDSIM_PRINT_LOG:
		nandsim_print_log((struct sim_log *)data);
		break;
	case NANDSIM_DUMP:
		ret = nandsim_dump((struct sim_dump *)data);
		break;
	case NANDSIM_RESTORE:
		ret = nandsim_restore((struct sim_dump *)data);
		break;
	case NANDSIM_FREEZE:
		ret = nandsim_freeze((struct sim_ctrl_chip *)data);
		break;
	default:
		ret = EINVAL;
		break;
	}

	return (ret);
}

static void
nandsim_init_sim_param(struct sim_param *param)
{

	if (!param)
		return;

	nand_debug(NDBG_SIM,"log level:%d output %d", param->log_level,
	    param->log_output);
	nandsim_log_level = param->log_level;
	nandsim_log_output = param->log_output;
}

static int
nandsim_create_ctrl(struct sim_ctrl *ctrl)
{
	struct sim_ctrl_conf *sim_ctrl;

	nand_debug(NDBG_SIM,"create controller num:%d cs:%d",ctrl->num,
	    ctrl->num_cs);

	if (ctrl->num >= MAX_SIM_DEV) {
		return (EINVAL);
	}

	sim_ctrl = &ctrls[ctrl->num];
	if(sim_ctrl->created)
		return (EEXIST);

	sim_ctrl->num = ctrl->num;
	sim_ctrl->num_cs = ctrl->num_cs;
	sim_ctrl->ecc = ctrl->ecc;
	memcpy(sim_ctrl->ecc_layout, ctrl->ecc_layout,
	    MAX_ECC_BYTES * sizeof(ctrl->ecc_layout[0]));
	strlcpy(sim_ctrl->filename, ctrl->filename,
	    FILENAME_SIZE);
	sim_ctrl->created = 1;

	return (0);
}

static int
nandsim_destroy_ctrl(int ctrl_num)
{

	nand_debug(NDBG_SIM,"destroy controller num:%d", ctrl_num);

	if (ctrl_num >= MAX_SIM_DEV) {
		return (EINVAL);
	}

	if (!ctrls[ctrl_num].created) {
		return (ENODEV);
	}

	if (ctrls[ctrl_num].running) {
		return (EBUSY);
	}

	memset(&ctrls[ctrl_num], 0, sizeof(ctrls[ctrl_num]));

	return (0);
}

static int
nandsim_ctrl_status(struct sim_ctrl *ctrl)
{

	nand_debug(NDBG_SIM,"status controller num:%d cs:%d",ctrl->num,
	    ctrl->num_cs);

	if (ctrl->num >= MAX_SIM_DEV) {
		return (EINVAL);
	}

	ctrl->num_cs = ctrls[ctrl->num].num_cs;
	ctrl->ecc = ctrls[ctrl->num].ecc;
	memcpy(ctrl->ecc_layout, ctrls[ctrl->num].ecc_layout,
	    MAX_ECC_BYTES * sizeof(ctrl->ecc_layout[0]));
	strlcpy(ctrl->filename, ctrls[ctrl->num].filename,
	    FILENAME_SIZE);
	ctrl->running = ctrls[ctrl->num].running;
	ctrl->created = ctrls[ctrl->num].created;

	return (0);
}

static int
nandsim_create_chip(struct sim_chip *chip)
{
	struct sim_chip *sim_chip;

	nand_debug(NDBG_SIM,"create chip num:%d at ctrl:%d", chip->num,
	    chip->ctrl_num);

	if (chip->ctrl_num >= MAX_SIM_DEV ||
	    chip->num >= MAX_CTRL_CS) {
		return (EINVAL);
	}

	if (ctrls[chip->ctrl_num].chips[chip->num]) {
		return (EEXIST);
	}

	sim_chip = malloc(sizeof(*sim_chip), M_NANDSIM,
	    M_WAITOK);
	if (sim_chip == NULL) {
		return (ENOMEM);
	}

	memcpy(sim_chip, chip, sizeof(*sim_chip));
	ctrls[chip->ctrl_num].chips[chip->num] = sim_chip;
	sim_chip->created = 1;

	return (0);
}

static int
nandsim_destroy_chip(struct sim_ctrl_chip *chip)
{
	struct sim_ctrl_conf *ctrl_conf;

	nand_debug(NDBG_SIM,"destroy chip num:%d at ctrl:%d", chip->chip_num,
	    chip->ctrl_num);

	if (chip->ctrl_num >= MAX_SIM_DEV ||
	    chip->chip_num >= MAX_CTRL_CS)
		return (EINVAL);

	ctrl_conf = &ctrls[chip->ctrl_num];

	if (!ctrl_conf->created || !ctrl_conf->chips[chip->chip_num])
		return (ENODEV);

	if (ctrl_conf->running)
		return (EBUSY);

	free(ctrl_conf->chips[chip->chip_num], M_NANDSIM);
	ctrl_conf->chips[chip->chip_num] = NULL;

	return (0);
}

static int
nandsim_chip_status(struct sim_chip *chip)
{
	struct sim_ctrl_conf *ctrl_conf;

	nand_debug(NDBG_SIM,"status for chip num:%d at ctrl:%d", chip->num,
	    chip->ctrl_num);

	if (chip->ctrl_num >= MAX_SIM_DEV &&
	    chip->num >= MAX_CTRL_CS)
		return (EINVAL);

	ctrl_conf = &ctrls[chip->ctrl_num];
	if (!ctrl_conf->chips[chip->num])
		chip->created = 0;
	else
		memcpy(chip, ctrl_conf->chips[chip->num], sizeof(*chip));

	return (0);
}

static int
nandsim_start_ctrl(int num)
{
	device_t nexus, ndev;
	devclass_t nexus_devclass;
	int ret = 0;

	nand_debug(NDBG_SIM,"start ctlr num:%d", num);

	if (num >= MAX_SIM_DEV)
		return (EINVAL);

	if (!ctrls[num].created)
		return (ENODEV);

	if (ctrls[num].running)
		return (EBUSY);

	/* We will add our device as a child of the nexus0 device */
	if (!(nexus_devclass = devclass_find("nexus")) ||
	    !(nexus = devclass_get_device(nexus_devclass, 0)))
		return (EFAULT);

	/*
	 * Create a newbus device representing this frontend instance
	 *
	 * XXX powerpc nexus doesn't implement bus_add_child, so child
	 * must be added by device_add_child().
	 */
#if defined(__powerpc__)
	ndev = device_add_child(nexus, "nandsim", num);
#else
	ndev = BUS_ADD_CHILD(nexus, 0, "nandsim", num);
#endif
	if (!ndev)
		return (EFAULT);

	mtx_lock(&Giant);
	ret = device_probe_and_attach(ndev);
	mtx_unlock(&Giant);

	if (ret == 0) {
		ctrls[num].sim_ctrl_dev = ndev;
		ctrls[num].running = 1;
	}

	return (ret);
}

static int
nandsim_stop_ctrl(int num)
{
	device_t nexus;
	devclass_t nexus_devclass;
	int ret = 0;

	nand_debug(NDBG_SIM,"stop controller num:%d", num);

	if (num >= MAX_SIM_DEV) {
		return (EINVAL);
	}

	if (!ctrls[num].created || !ctrls[num].running) {
		return (ENODEV);
	}

	/* We will add our device as a child of the nexus0 device */
	if (!(nexus_devclass = devclass_find("nexus")) ||
	    !(nexus = devclass_get_device(nexus_devclass, 0))) {
		return (ENODEV);
	}

	mtx_lock(&Giant);
	if (ctrls[num].sim_ctrl_dev) {
		ret = device_delete_child(nexus, ctrls[num].sim_ctrl_dev);
		ctrls[num].sim_ctrl_dev = NULL;
	}
	mtx_unlock(&Giant);

	ctrls[num].running = 0;

	return (ret);
}

static struct nandsim_chip *
get_nandsim_chip(uint8_t ctrl_num, uint8_t chip_num)
{
	struct nandsim_softc *sc;

	if (!ctrls[ctrl_num].sim_ctrl_dev)
		return (NULL);

	sc = device_get_softc(ctrls[ctrl_num].sim_ctrl_dev);
	return (sc->chips[chip_num]);
}

static void
nandsim_print_log(struct sim_log *sim_log)
{
	struct nandsim_softc *sc;
	int len1, len2;

	if (!ctrls[sim_log->ctrl_num].sim_ctrl_dev)
		return;

	sc = device_get_softc(ctrls[sim_log->ctrl_num].sim_ctrl_dev);
	if (sc->log_buff) {
		len1 = strlen(&sc->log_buff[sc->log_idx + 1]);
		if (len1 >= sim_log->len)
			len1 = sim_log->len;
		copyout(&sc->log_buff[sc->log_idx + 1], sim_log->log, len1);
		len2 = strlen(sc->log_buff);
		if (len2 >= (sim_log->len - len1))
			len2 = (sim_log->len - len1);
		copyout(sc->log_buff, &sim_log->log[len1], len2);
		sim_log->len = len1 + len2;
	}
}

static int
nandsim_inject_error(struct sim_error *error)
{
	struct nandsim_chip *chip;
	struct block_space *bs;
	struct onfi_params *param;
	int page, page_size, block, offset;

	nand_debug(NDBG_SIM,"inject error for chip %d at ctrl %d\n",
	    error->chip_num, error->ctrl_num);

	if (error->ctrl_num >= MAX_SIM_DEV ||
	    error->chip_num >= MAX_CTRL_CS)
		return (EINVAL);

	if (!ctrls[error->ctrl_num].created || !ctrls[error->ctrl_num].running)
		return (ENODEV);

	chip = get_nandsim_chip(error->ctrl_num, error->chip_num);
	param = &chip->params;
	page_size = param->bytes_per_page + param->spare_bytes_per_page;
	block = error->page_num / param->pages_per_block;
	page = error->page_num % param->pages_per_block;

	bs = get_bs(chip->swap, block, 1);
	if (!bs)
		return (EINVAL);

	offset = (page * page_size) + error->column;
	memset(&bs->blk_ptr[offset], error->pattern, error->len);

	return (0);
}

static int
nandsim_set_block_state(struct sim_block_state *bs)
{
	struct onfi_params *params;
	struct nandsim_chip *chip;
	int blocks;

	nand_debug(NDBG_SIM,"set block state for %d:%d block %d\n",
	    bs->chip_num, bs->ctrl_num, bs->block_num);

	if (bs->ctrl_num >= MAX_SIM_DEV ||
	    bs->chip_num >= MAX_CTRL_CS)
		return (EINVAL);

	chip = get_nandsim_chip(bs->ctrl_num, bs->chip_num);
	params = &chip->params;
	blocks = params->luns * params->blocks_per_lun;

	if (bs->block_num > blocks)
		return (EINVAL);

	chip->blk_state[bs->block_num].is_bad = bs->state;

	if (bs->wearout >= 0)
		chip->blk_state[bs->block_num].wear_lev = bs->wearout;

	return (0);
}

static int
nandsim_get_block_state(struct sim_block_state *bs)
{
	struct onfi_params *params;
	struct nandsim_chip *chip;
	int blocks;

	if (bs->ctrl_num >= MAX_SIM_DEV ||
	    bs->chip_num >= MAX_CTRL_CS)
		return (EINVAL);

	nand_debug(NDBG_SIM,"get block state for %d:%d block %d\n",
	    bs->chip_num, bs->ctrl_num, bs->block_num);

	chip = get_nandsim_chip(bs->ctrl_num, bs->chip_num);
	params = &chip->params;
	blocks = params->luns * params->blocks_per_lun;

	if (bs->block_num > blocks)
		return (EINVAL);

	bs->state = chip->blk_state[bs->block_num].is_bad;
	bs->wearout = chip->blk_state[bs->block_num].wear_lev;

	return (0);
}

static int
nandsim_dump(struct sim_dump *dump)
{
	struct nandsim_chip *chip;
	struct block_space *bs;
	int blk_size;

	nand_debug(NDBG_SIM,"dump chip %d %d\n", dump->ctrl_num, dump->chip_num);

	if (dump->ctrl_num >= MAX_SIM_DEV ||
	    dump->chip_num >= MAX_CTRL_CS)
		return (EINVAL);

	chip = get_nandsim_chip(dump->ctrl_num, dump->chip_num);
	blk_size = chip->cg.block_size +
	    (chip->cg.oob_size * chip->cg.pgs_per_blk);

	bs = get_bs(chip->swap, dump->block_num, 0);
	if (!bs)
		return (EINVAL);

	if (dump->len > blk_size)
		dump->len = blk_size;

	copyout(bs->blk_ptr, dump->data, dump->len);

	return (0);
}

static int
nandsim_restore(struct sim_dump *dump)
{
	struct nandsim_chip *chip;
	struct block_space *bs;
	int blk_size;

	nand_debug(NDBG_SIM,"restore chip %d %d\n", dump->ctrl_num,
	    dump->chip_num);

	if (dump->ctrl_num >= MAX_SIM_DEV ||
	    dump->chip_num >= MAX_CTRL_CS)
		return (EINVAL);

	chip = get_nandsim_chip(dump->ctrl_num, dump->chip_num);
	blk_size = chip->cg.block_size +
	    (chip->cg.oob_size * chip->cg.pgs_per_blk);

	bs = get_bs(chip->swap, dump->block_num, 1);
	if (!bs)
		return (EINVAL);

	if (dump->len > blk_size)
		dump->len = blk_size;


	copyin(dump->data, bs->blk_ptr, dump->len);

	return (0);
}

static int
nandsim_freeze(struct sim_ctrl_chip *ctrl_chip)
{
	struct nandsim_chip *chip;

	if (ctrl_chip->ctrl_num >= MAX_SIM_DEV ||
	    ctrl_chip->chip_num >= MAX_CTRL_CS)
		return (EINVAL);

	chip = get_nandsim_chip(ctrl_chip->ctrl_num, ctrl_chip->chip_num);
	nandsim_chip_freeze(chip);

	return (0);
}

static int
nandsim_modify(struct sim_mod *mod)
{
	struct sim_chip *sim_conf = NULL;
	struct nandsim_chip *sim_chip = NULL;

	nand_debug(NDBG_SIM,"modify ctlr %d chip %d", mod->ctrl_num,
	    mod->chip_num);

	if (mod->field != SIM_MOD_LOG_LEVEL) {
		if (mod->ctrl_num >= MAX_SIM_DEV ||
		    mod->chip_num >= MAX_CTRL_CS)
			return (EINVAL);

		sim_conf = ctrls[mod->ctrl_num].chips[mod->chip_num];
		sim_chip = get_nandsim_chip(mod->ctrl_num, mod->chip_num);
	}

	switch (mod->field) {
	case SIM_MOD_LOG_LEVEL:
		nandsim_log_level = mod->new_value;
		break;
	case SIM_MOD_ERASE_TIME:
		sim_conf->erase_time = sim_chip->erase_delay = mod->new_value;
		break;
	case SIM_MOD_PROG_TIME:
		sim_conf->prog_time = sim_chip->prog_delay = mod->new_value;
		break;
	case SIM_MOD_READ_TIME:
		sim_conf->read_time = sim_chip->read_delay = mod->new_value;
		break;
	case SIM_MOD_ERROR_RATIO:
		sim_conf->error_ratio = mod->new_value;
		sim_chip->error_ratio = mod->new_value;
		break;
	default:
		break;
	}

	return (0);
}
static int
nandsim_modevent(module_t mod __unused, int type, void *data __unused)
{
	struct sim_ctrl_chip chip_ctrl;
	int i, j;

	switch (type) {
	case MOD_LOAD:
		nandsim_dev = make_dev(&nandsim_cdevsw, 0,
		    UID_ROOT, GID_WHEEL, 0666, "nandsim.ioctl");
		break;
	case MOD_UNLOAD:
		for (i = 0; i < MAX_SIM_DEV; i++) {
			nandsim_stop_ctrl(i);
			chip_ctrl.ctrl_num = i;
			for (j = 0; j < MAX_CTRL_CS; j++) {
				chip_ctrl.chip_num = j;
				nandsim_destroy_chip(&chip_ctrl);
			}
			nandsim_destroy_ctrl(i);
		}
		destroy_dev(nandsim_dev);
		break;
	case MOD_SHUTDOWN:
		break;
	default:
		return (EOPNOTSUPP);
	}
	return (0);
}

DEV_MODULE(nandsim, nandsim_modevent, NULL);
MODULE_VERSION(nandsim, 1);
MODULE_DEPEND(nandsim, nand, 1, 1, 1);
MODULE_DEPEND(nandsim, alq, 1, 1, 1);
OpenPOWER on IntegriCloud