comparison packages/io/flash/current/src/legacy_dev.c @ 2816:422d0a343b4d

* include/flash.h: Modest API change: cyg_flash_init() no longer takes a printf function argument. Instead two new API functions are available: cyg_flash_set_printf() and cyg_flash_set_global_printf(). * src/flash.c (CHATTER): Don't attempt output if printf function is NULL. (cyg_flash_init): No longer takes printf arg. (cyg_flash_set_printf): New. Set per-device printf function, locking if needed. (cyg_flash_set_global_printf): New. Set printf function for all devices, locking if needed. * src/flashiodev.c (flashiodev_init): cyg_flash_init no longer takes printf arg, and we can leave global printf at default. * src/flashiodevlegacy.c (flashiodev_init): Ditto. * src/legacy_api.c (flash_init): cyg_flash_init no longer takes printf arg. So call cyg_flash_set_global_printf as well. * src/legacy_dev.c (legacy_flash_init): legacy drivers can't handle NULL printf function, so provide a dummy. * doc/flash.sgml: Document removal of printf functionality of cyg_flash_init() and document cyg_flash_set_printf() and cyg_flash_set_global_printf().
author jlarmour
date Thu, 19 Feb 2009 00:14:26 +0000
parents 74dbf4c3f2e1
children
comparison
equal deleted inserted replaced
2815:3cd309d2d829 2816:422d0a343b4d
6 // 6 //
7 //========================================================================== 7 //==========================================================================
8 // ####ECOSGPLCOPYRIGHTBEGIN#### 8 // ####ECOSGPLCOPYRIGHTBEGIN####
9 // ------------------------------------------- 9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System. 10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 2004, 2006 Free Software Foundation, Inc. 11 // Copyright (C) 2004, 2006, 2009 Free Software Foundation, Inc.
12 // 12 //
13 // eCos is free software; you can redistribute it and/or modify it under 13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free 14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later 15 // Software Foundation; either version 2 or (at your option) any later
16 // version. 16 // version.
79 externC code_fun flash_program_buf; 79 externC code_fun flash_program_buf;
80 externC code_fun flash_read_buf; 80 externC code_fun flash_read_buf;
81 externC code_fun flash_lock_block; 81 externC code_fun flash_lock_block;
82 externC code_fun flash_unlock_block; 82 externC code_fun flash_unlock_block;
83 83
84 static int dummy_printf( const char *fmt, ... ) {return 0;}
85
84 // Initialize the device 86 // Initialize the device
85 static int 87 static int
86 legacy_flash_init (struct cyg_flash_dev *dev) 88 legacy_flash_init (struct cyg_flash_dev *dev)
87 { 89 {
88 int err; 90 int err;
89 static cyg_flash_block_info_t block_info[1]; 91 static cyg_flash_block_info_t block_info[1];
90 92
91 flash_info.pf = dev->pf; 93 // Legacy device drivers can't handle NULL printf function
94 if (NULL != dev->pf)
95 flash_info.pf = dev->pf;
96 else
97 flash_info.pf = &dummy_printf;
92 98
93 err=flash_hwr_init(); 99 err=flash_hwr_init();
94 100
95 if (!err) { 101 if (!err) {
96 dev->start = (cyg_flashaddr_t)flash_info.start; 102 dev->start = (cyg_flashaddr_t)flash_info.start;