mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
spi: Tidy up get/set of device node
This code is a bit odd in that it only reads and updates the livetree version of the device ofnode. This means it won't work with flattree. Update the code to work as it was presumably intended. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a53f6fad7e
commit
e2a7cfe9d5
5 changed files with 36 additions and 6 deletions
|
@ -1173,7 +1173,7 @@ static int spinand_probe(struct udevice *dev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
|
sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
|
||||||
spinand->slave = slave;
|
spinand->slave = slave;
|
||||||
spinand_set_of_node(spinand, dev->node.np);
|
spinand_set_ofnode(spinand, dev->node);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = spinand_init(spinand);
|
ret = spinand_init(spinand);
|
||||||
|
|
|
@ -332,15 +332,14 @@ struct mtd_info {
|
||||||
};
|
};
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_DM)
|
#if IS_ENABLED(CONFIG_DM)
|
||||||
static inline void mtd_set_of_node(struct mtd_info *mtd,
|
static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
|
||||||
const struct device_node *np)
|
|
||||||
{
|
{
|
||||||
mtd->dev->node.np = np;
|
mtd->dev->node = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
|
static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
|
||||||
{
|
{
|
||||||
return mtd->dev->node.np;
|
return mtd->dev->node;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct device_node;
|
struct device_node;
|
||||||
|
|
|
@ -389,6 +389,7 @@ static inline int nanddev_unregister(struct nand_device *nand)
|
||||||
return mtd_device_unregister(nand->mtd);
|
return mtd_device_unregister(nand->mtd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __UBOOT__
|
||||||
/**
|
/**
|
||||||
* nanddev_set_of_node() - Attach a DT node to a NAND device
|
* nanddev_set_of_node() - Attach a DT node to a NAND device
|
||||||
* @nand: NAND device
|
* @nand: NAND device
|
||||||
|
@ -412,6 +413,19 @@ static inline const struct device_node *nanddev_get_of_node(struct nand_device *
|
||||||
{
|
{
|
||||||
return mtd_get_of_node(nand->mtd);
|
return mtd_get_of_node(nand->mtd);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* nanddev_set_of_node() - Attach a DT node to a NAND device
|
||||||
|
* @nand: NAND device
|
||||||
|
* @node: ofnode
|
||||||
|
*
|
||||||
|
* Attach a DT node to a NAND device.
|
||||||
|
*/
|
||||||
|
static inline void nanddev_set_ofnode(struct nand_device *nand, ofnode node)
|
||||||
|
{
|
||||||
|
mtd_set_ofnode(nand->mtd, node);
|
||||||
|
}
|
||||||
|
#endif /* __UBOOT__ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nanddev_offs_to_pos() - Convert an absolute NAND offset into a NAND position
|
* nanddev_offs_to_pos() - Convert an absolute NAND offset into a NAND position
|
||||||
|
|
|
@ -352,6 +352,7 @@ struct spi_nor {
|
||||||
u32 erase_size;
|
u32 erase_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef __UBOOT__
|
||||||
static inline void spi_nor_set_flash_node(struct spi_nor *nor,
|
static inline void spi_nor_set_flash_node(struct spi_nor *nor,
|
||||||
const struct device_node *np)
|
const struct device_node *np)
|
||||||
{
|
{
|
||||||
|
@ -363,6 +364,7 @@ device_node *spi_nor_get_flash_node(struct spi_nor *nor)
|
||||||
{
|
{
|
||||||
return mtd_get_of_node(&nor->mtd);
|
return mtd_get_of_node(&nor->mtd);
|
||||||
}
|
}
|
||||||
|
#endif /* __UBOOT__ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct spi_nor_hwcaps - Structure for describing the hardware capabilies
|
* struct spi_nor_hwcaps - Structure for describing the hardware capabilies
|
||||||
|
|
|
@ -412,6 +412,7 @@ spinand_to_nand(struct spinand_device *spinand)
|
||||||
return &spinand->base;
|
return &spinand->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __UBOOT__
|
||||||
/**
|
/**
|
||||||
* spinand_set_of_node - Attach a DT node to a SPI NAND device
|
* spinand_set_of_node - Attach a DT node to a SPI NAND device
|
||||||
* @spinand: SPI NAND device
|
* @spinand: SPI NAND device
|
||||||
|
@ -424,6 +425,20 @@ static inline void spinand_set_of_node(struct spinand_device *spinand,
|
||||||
{
|
{
|
||||||
nanddev_set_of_node(&spinand->base, np);
|
nanddev_set_of_node(&spinand->base, np);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* spinand_set_of_node - Attach a DT node to a SPI NAND device
|
||||||
|
* @spinand: SPI NAND device
|
||||||
|
* @node: ofnode
|
||||||
|
*
|
||||||
|
* Attach a DT node to a SPI NAND device.
|
||||||
|
*/
|
||||||
|
static inline void spinand_set_ofnode(struct spinand_device *spinand,
|
||||||
|
ofnode node)
|
||||||
|
{
|
||||||
|
nanddev_set_ofnode(&spinand->base, node);
|
||||||
|
}
|
||||||
|
#endif /* __UBOOT__ */
|
||||||
|
|
||||||
int spinand_match_and_init(struct spinand_device *dev,
|
int spinand_match_and_init(struct spinand_device *dev,
|
||||||
const struct spinand_info *table,
|
const struct spinand_info *table,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue