Skip to contentSkip to conversation

nand_get_device() and nand_release_device()

U-Boot Timur Tabi 2 participants 2 messages May 7, 2012 – May 15, 2012

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

Scott,

As you know, the P1022 has this weird LBC/DIU muxing problem. I'd like to add support for the 'nand' command while the DIU is active. Looking at the NAND code, I see functions nand_get_device() and nand_release_device(). What is the idea behind these functions? Would it make sense to do something like this:

static int __board_start_nand(void)

{
	return 0;
}

int board_start_nand(void) __attribute__((weak, alias("__board_start_nand")));

static void __board_finish_nand(void)
{
}
void board_finish_nand(void) __attribute__((weak,
alias("__board_finish_nand")));

static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state)

{
	chip->state = new_state;

	return board_start_nand();
}

static void nand_release_device(struct mtd_info *mtd)

{
	struct nand_chip *chip = mtd->priv;

	board_finish_nand();

	/* De-select the NAND device */
	chip->select_chip(mtd, -1);
}
Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#1 lore raw
Quoted 6 lines · Timur Tabi

Scott,

As you know, the P1022 has this weird LBC/DIU muxing problem. I'd like to add support for the 'nand' command while the DIU is active. Looking at the NAND code, I see functions nand_get_device() and nand_release_device(). What is the idea behind these functions?

In U-Boot they don't do much. In Linux they handle locking

Quoted 26 lines

Would it
make sense to do something like this:

static int __board_start_nand(void)

{
	return 0;
}

int board_start_nand(void) __attribute__((weak, alias("__board_start_nand")));

static void __board_finish_nand(void)
{
}
void board_finish_nand(void) __attribute__((weak,
alias("__board_finish_nand")));

static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state)

{
	chip->state = new_state;

	return board_start_nand();
}

static void nand_release_device(struct mtd_info *mtd)

Quoted 9 lines
{
	struct nand_chip *chip = mtd->priv;

	board_finish_nand();

	/* De-select the NAND device */
	chip->select_chip(mtd, -1);
}

What's wrong with the existing select_chip interface?

And if something new is needed, please use the function pointer interface rather than weak symbols, and do it first in Linux.

-Scott