/* Returns the number of characters generated on success; otherwise, < 0 on error.  */
static int ppc4xx_edac_generate_plb_message(const struct mem_ctl_info *mci, const struct ppc4xx_ecc_status *status, char *buffer, size_t size)
/* Returns the number of characters generated on success; otherwise, < 0 on error.  */
static int ppc4xx_edac_generate_plb_message(const struct mem_ctl_info *mci, const struct ppc4xx_ecc_status *status, char *buffer, size_t size)
{
	unsigned int master;
	bool read;
	if ((status->besr & SDRAM_BESR_MASK) == 0)
		return 0;
	if ((status->besr & SDRAM_BESR_M0ET_MASK) == SDRAM_BESR_M0ET_NONE)
		return 0;
	read = ((status->besr & SDRAM_BESR_M0RW_MASK) == SDRAM_BESR_M0RW_READ);
	master = SDRAM_BESR_M0ID_DECODE(status->besr);
	return snprintf(buffer, size,
			"%s error w/ PLB master %u \"%s\"; ",
			(read ? "Read" : "Write"),
			master,
			(((master >= SDRAM_PLB_M0ID_FIRST) &&
			  (master <= SDRAM_PLB_M0ID_LAST)) ?
			 ppc4xx_plb_masters[master] : "UNKNOWN"));
}