xref: /openbmc/u-boot/drivers/mtd/mtd-uclass.c (revision fd0bc623)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
4  */
5 
6 #include <common.h>
7 #include <dm.h>
8 #include <dm/device-internal.h>
9 #include <errno.h>
10 #include <mtd.h>
11 
12 /**
13  * mtd_probe - Probe the device @dev if not already done
14  *
15  * @dev: U-Boot device to probe
16  *
17  * @return 0 on success, an error otherwise.
18  */
19 int mtd_probe(struct udevice *dev)
20 {
21 	if (device_active(dev))
22 		return 0;
23 
24 	return device_probe(dev);
25 }
26 
27 /*
28  * Implement a MTD uclass which should include most flash drivers.
29  * The uclass private is pointed to mtd_info.
30  */
31 
32 UCLASS_DRIVER(mtd) = {
33 	.id		= UCLASS_MTD,
34 	.name		= "mtd",
35 	.per_device_auto_alloc_size = sizeof(struct mtd_info),
36 };
37