From 31370942904fc5930500e180f616f9a00729f22c Mon Sep 17 00:00:00 2001 From: Kolja Waschk Date: Thu, 5 Jun 2008 18:48:11 +0000 Subject: [PATCH] Part 1 and 3 of [ 1984813 ] Bus driver cleanup (Hartley Sweeten) git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1272 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 15 ++++++++ jtag/src/bus/au1500.c | 2 +- jtag/src/bus/avr32.c | 7 ++-- jtag/src/bus/bcm1250.c | 37 +++++++++--------- jtag/src/bus/bf533_ezkit.c | 37 +++++++++--------- jtag/src/bus/bf533_stamp.c | 37 +++++++++--------- jtag/src/bus/bf537_stamp.c | 13 ++++--- jtag/src/bus/bf548_ezkit.c | 38 +++++++++---------- jtag/src/bus/bf561_ezkit.c | 37 +++++++++--------- jtag/src/bus/ejtag.c | 37 +++++++++--------- jtag/src/bus/fjmem.c | 6 +-- jtag/src/bus/h7202.c | 36 +++++++++--------- jtag/src/bus/ixp425.c | 38 +++++++++---------- jtag/src/bus/jopcyc.c | 4 +- jtag/src/bus/lh7a400.c | 38 +++++++++---------- jtag/src/bus/mpc5200.c | 2 +- jtag/src/bus/mpc824x.c | 2 +- jtag/src/bus/ppc405ep.c | 37 +++++++++--------- jtag/src/bus/ppc440gx_ebc8.c | 38 +++++++++---------- jtag/src/bus/prototype.c | 7 ++-- jtag/src/bus/pxa2x0.c | 73 +++++++++++++++++------------------- jtag/src/bus/s3c4510x.c | 38 +++++++++---------- jtag/src/bus/sa1110.c | 38 +++++++++---------- jtag/src/bus/sh7727.c | 36 +++++++++--------- jtag/src/bus/sh7750r.c | 36 +++++++++--------- jtag/src/bus/sh7751r.c | 36 +++++++++--------- jtag/src/bus/sharc21065l.c | 35 +++++++++-------- jtag/src/bus/slsup3.c | 2 +- jtag/src/bus/tx4925.c | 39 +++++++++---------- jtag/src/bus/zefant-xs3.c | 7 ++-- 30 files changed, 398 insertions(+), 410 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 4d8ddc36..a5ae536c 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,18 @@ +2008-06-05 Kolja Waschk + + * src/bus/bf548_ezkit.c, src/bus/fjmem.c, src/bus/ppc405ep.c, + src/bus/sh7727.c, src/bus/prototype.c, src/bus/sa1110.c, + src/bus/ppc440gx_ebc8.c, src/bus/sh7750r.c, src/bus/tx4925.c, + src/bus/pxa2x0.c, src/bus/bf533_stamp.c, src/bus/bf533_ezkit.c, + src/bus/bf537_stamp.c, src/bus/ixp425.c, src/bus/avr32.c, + src/bus/zefant-xs3.c, src/bus/h7202.c, src/bus/mpc824x.c, + src/bus/bcm1250.c, src/bus/sharc21065l.c, src/bus/au1500.c, + src/bus/lh7a400.c, src/bus/sh7751r.c, src/bus/mpc5200.c, + src/bus/jopcyc.c, src/bus/slsup3.c, src/bus/bf561_ezkit.c, + src/bus/s3c4510x.c, src/bus/ejtag.c: Partial [ 1984813 ] + Bus driver cleanup: Changed mallocs to callocs, added (NULL) pointer + for *init to the drivers where it was missing (Hartley Sweeten) + 2008-05-29 Kolja Waschk * src/tap/cable/wiggler.c src/tap/cable/generic_usbconn.c, diff --git a/jtag/src/bus/au1500.c b/jtag/src/bus/au1500.c index bc4d6b90..c8dc9ca4 100644 --- a/jtag/src/bus/au1500.c +++ b/jtag/src/bus/au1500.c @@ -125,7 +125,7 @@ static bus_t *au1500_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; diff --git a/jtag/src/bus/avr32.c b/jtag/src/bus/avr32.c index 31fe1b8c..e8d5f211 100644 --- a/jtag/src/bus/avr32.c +++ b/jtag/src/bus/avr32.c @@ -731,12 +731,12 @@ avr32_bus_new (chain_t * chain, char *cmd_params[]) break; } - bus = malloc (sizeof (bus_t)); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &avr32_bus_driver; - bus->params = malloc (sizeof (bus_params_t)); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free (bus); @@ -767,5 +767,6 @@ const bus_driver_t avr32_bus_driver = { avr32_bus_read_next, avr32_bus_read_end, avr32_bus_read, - avr32_bus_write + avr32_bus_write, + NULL }; diff --git a/jtag/src/bus/bcm1250.c b/jtag/src/bus/bcm1250.c index f22576a1..729edbf2 100644 --- a/jtag/src/bus/bcm1250.c +++ b/jtag/src/bus/bcm1250.c @@ -268,24 +268,6 @@ bcm1250_bus_free( bus_t *bus ) free( bus ); } -static bus_t *bcm1250_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t bcm1250_bus = { - "bcm1250", - N_("Broadcom BCM1250 compatible bus driver via BSR"), - bcm1250_bus_new, - bcm1250_bus_free, - bcm1250_bus_printinfo, - bcm1250_bus_prepare, - bcm1250_bus_area, - bcm1250_bus_read_start, - bcm1250_bus_read_next, - bcm1250_bus_read_end, - bcm1250_bus_read, - bcm1250_bus_write, - NULL -}; - static bus_t * bcm1250_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -297,7 +279,7 @@ bcm1250_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; @@ -492,3 +474,20 @@ int bcm1250_ejtag_do(bus_t *bus, uint64_t ad, uint64_t da, int read, int type, return 0; } #endif + +const bus_driver_t bcm1250_bus = { + "bcm1250", + N_("Broadcom BCM1250 compatible bus driver via BSR"), + bcm1250_bus_new, + bcm1250_bus_free, + bcm1250_bus_printinfo, + bcm1250_bus_prepare, + bcm1250_bus_area, + bcm1250_bus_read_start, + bcm1250_bus_read_next, + bcm1250_bus_read_end, + bcm1250_bus_read, + bcm1250_bus_write, + NULL +}; + diff --git a/jtag/src/bus/bf533_ezkit.c b/jtag/src/bus/bf533_ezkit.c index aa0f0b14..e3a08f6f 100644 --- a/jtag/src/bus/bf533_ezkit.c +++ b/jtag/src/bus/bf533_ezkit.c @@ -252,23 +252,6 @@ bf533_ezkit_bus_free( bus_t *bus ) free( bus ); } -static bus_t *bf533_ezkit_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t bf533_ezkit_bus = { - "bf533_ezkit", - N_("Blackfin BF533 EZKit board bus driver"), - bf533_ezkit_bus_new, - bf533_ezkit_bus_free, - bf533_ezkit_bus_printinfo, - bf533_ezkit_bus_prepare, - bf533_ezkit_bus_area, - bf533_ezkit_bus_read_start, - bf533_ezkit_bus_read_next, - bf533_ezkit_bus_read_end, - bf533_ezkit_bus_read, - bf533_ezkit_bus_write -}; - static bus_t * bf533_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -280,12 +263,12 @@ bf533_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &bf533_ezkit_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -379,3 +362,19 @@ bf533_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t bf533_ezkit_bus = { + "bf533_ezkit", + N_("Blackfin BF533 EZKit board bus driver"), + bf533_ezkit_bus_new, + bf533_ezkit_bus_free, + bf533_ezkit_bus_printinfo, + bf533_ezkit_bus_prepare, + bf533_ezkit_bus_area, + bf533_ezkit_bus_read_start, + bf533_ezkit_bus_read_next, + bf533_ezkit_bus_read_end, + bf533_ezkit_bus_read, + bf533_ezkit_bus_write, + NULL +}; diff --git a/jtag/src/bus/bf533_stamp.c b/jtag/src/bus/bf533_stamp.c index 6b5de3e0..88f7f504 100644 --- a/jtag/src/bus/bf533_stamp.c +++ b/jtag/src/bus/bf533_stamp.c @@ -252,23 +252,6 @@ bf533_stamp_bus_free( bus_t *bus ) free( bus ); } -static bus_t *bf533_stamp_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t bf533_stamp_bus = { - "bf533_stamp", - N_("Blackfin BF533 Stamp board bus driver"), - bf533_stamp_bus_new, - bf533_stamp_bus_free, - bf533_stamp_bus_printinfo, - bf533_stamp_bus_prepare, - bf533_stamp_bus_area, - bf533_stamp_bus_read_start, - bf533_stamp_bus_read_next, - bf533_stamp_bus_read_end, - bf533_stamp_bus_read, - bf533_stamp_bus_write -}; - static bus_t * bf533_stamp_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -280,12 +263,12 @@ bf533_stamp_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &bf533_stamp_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -377,3 +360,19 @@ bf533_stamp_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t bf533_stamp_bus = { + "bf533_stamp", + N_("Blackfin BF533 Stamp board bus driver"), + bf533_stamp_bus_new, + bf533_stamp_bus_free, + bf533_stamp_bus_printinfo, + bf533_stamp_bus_prepare, + bf533_stamp_bus_area, + bf533_stamp_bus_read_start, + bf533_stamp_bus_read_next, + bf533_stamp_bus_read_end, + bf533_stamp_bus_read, + bf533_stamp_bus_write, + NULL +}; diff --git a/jtag/src/bus/bf537_stamp.c b/jtag/src/bus/bf537_stamp.c index dab78ce6..8629b31f 100644 --- a/jtag/src/bus/bf537_stamp.c +++ b/jtag/src/bus/bf537_stamp.c @@ -252,11 +252,11 @@ bf537_stamp_bus_new_1( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -385,7 +385,8 @@ const bus_driver_t bf537_stamp_bus = { bf537_stamp_bus_read_next, bf537_stamp_bus_read_end, bf537_stamp_bus_read, - bf537_stamp_bus_write + bf537_stamp_bus_write, + NULL }; #endif @@ -423,7 +424,8 @@ const bus_driver_t bf537_ezkit_bus = { bf537_stamp_bus_read_next, bf537_stamp_bus_read_end, bf537_stamp_bus_read, - bf537_stamp_bus_write + bf537_stamp_bus_write, + NULL }; #endif @@ -461,7 +463,8 @@ const bus_driver_t bf527_ezkit_bus = { bf537_stamp_bus_read_next, bf537_stamp_bus_read_end, bf537_stamp_bus_read, - bf537_stamp_bus_write + bf537_stamp_bus_write, + NULL }; #endif diff --git a/jtag/src/bus/bf548_ezkit.c b/jtag/src/bus/bf548_ezkit.c index 1d95c07d..3f01aac4 100644 --- a/jtag/src/bus/bf548_ezkit.c +++ b/jtag/src/bus/bf548_ezkit.c @@ -237,24 +237,6 @@ bf548_ezkit_bus_free( bus_t *bus ) free( bus ); } -static bus_t *bf548_ezkit_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t bf548_ezkit_bus = { - "bf548_ezkit", - N_("Blackfin BF548 EZ-KIT board bus driver"), - bf548_ezkit_bus_new, - bf548_ezkit_bus_free, - bf548_ezkit_bus_printinfo, - bf548_ezkit_bus_prepare, - bf548_ezkit_bus_area, - bf548_ezkit_bus_read_start, - bf548_ezkit_bus_read_next, - bf548_ezkit_bus_read_end, - bf548_ezkit_bus_read, - bf548_ezkit_bus_write -}; - - static bus_t * bf548_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -266,12 +248,12 @@ bf548_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &bf548_ezkit_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -368,3 +350,19 @@ bf548_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t bf548_ezkit_bus = { + "bf548_ezkit", + N_("Blackfin BF548 EZ-KIT board bus driver"), + bf548_ezkit_bus_new, + bf548_ezkit_bus_free, + bf548_ezkit_bus_printinfo, + bf548_ezkit_bus_prepare, + bf548_ezkit_bus_area, + bf548_ezkit_bus_read_start, + bf548_ezkit_bus_read_next, + bf548_ezkit_bus_read_end, + bf548_ezkit_bus_read, + bf548_ezkit_bus_write, + NULL +}; diff --git a/jtag/src/bus/bf561_ezkit.c b/jtag/src/bus/bf561_ezkit.c index 4e613255..ff6af568 100644 --- a/jtag/src/bus/bf561_ezkit.c +++ b/jtag/src/bus/bf561_ezkit.c @@ -260,23 +260,6 @@ bf561_ezkit_bus_free( bus_t *bus ) free( bus ); } -static bus_t *bf561_ezkit_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t bf561_ezkit_bus = { - "bf561_ezkit", - N_("Blackfin BF561 EZ-KIT board bus driver"), - bf561_ezkit_bus_new, - bf561_ezkit_bus_free, - bf561_ezkit_bus_printinfo, - bf561_ezkit_bus_prepare, - bf561_ezkit_bus_area, - bf561_ezkit_bus_read_start, - bf561_ezkit_bus_read_next, - bf561_ezkit_bus_read_end, - bf561_ezkit_bus_read, - bf561_ezkit_bus_write -}; - static bus_t * bf561_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -288,12 +271,12 @@ bf561_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &bf561_ezkit_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -390,3 +373,19 @@ bf561_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t bf561_ezkit_bus = { + "bf561_ezkit", + N_("Blackfin BF561 EZ-KIT board bus driver"), + bf561_ezkit_bus_new, + bf561_ezkit_bus_free, + bf561_ezkit_bus_printinfo, + bf561_ezkit_bus_prepare, + bf561_ezkit_bus_area, + bf561_ezkit_bus_read_start, + bf561_ezkit_bus_read_next, + bf561_ezkit_bus_read_end, + bf561_ezkit_bus_read, + bf561_ezkit_bus_write, + NULL +}; diff --git a/jtag/src/bus/ejtag.c b/jtag/src/bus/ejtag.c index 77eeb303..bace483c 100644 --- a/jtag/src/bus/ejtag.c +++ b/jtag/src/bus/ejtag.c @@ -453,23 +453,6 @@ ejtag_bus_free( bus_t *bus ) free( bus ); } -static bus_t *ejtag_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t ejtag_bus = { - "ejtag", - N_("EJTAG compatible bus driver via PrAcc"), - ejtag_bus_new, - ejtag_bus_free, - ejtag_bus_printinfo, - ejtag_bus_prepare, - ejtag_bus_area, - ejtag_bus_read_start, - ejtag_bus_read_next, - ejtag_bus_read_end, - ejtag_bus_read, - ejtag_bus_write -}; - static bus_t * ejtag_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -478,12 +461,12 @@ ejtag_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &ejtag_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -495,3 +478,19 @@ ejtag_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t ejtag_bus = { + "ejtag", + N_("EJTAG compatible bus driver via PrAcc"), + ejtag_bus_new, + ejtag_bus_free, + ejtag_bus_printinfo, + ejtag_bus_prepare, + ejtag_bus_area, + ejtag_bus_read_start, + ejtag_bus_read_next, + ejtag_bus_read_end, + ejtag_bus_read, + ejtag_bus_write, + NULL +}; diff --git a/jtag/src/bus/fjmem.c b/jtag/src/bus/fjmem.c index 0673c9d4..dfcc2dd5 100644 --- a/jtag/src/bus/fjmem.c +++ b/jtag/src/bus/fjmem.c @@ -591,7 +591,7 @@ fjmem_query_blocks( chain_t *chain, part_t *part, bus_t *bus ) block_param_t *bl; int nbytes; - if ((bl = (block_param_t *)malloc( sizeof( block_param_t ) )) == NULL) { + if ((bl = (block_param_t *)calloc( 1, sizeof( block_param_t ) )) == NULL) { printf( _("out of memory\n") ); failed |= 1; break; @@ -691,12 +691,12 @@ fjmem_bus_new( chain_t *chain, char *params[] ) if (fjmem_reg_len <= 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &fjmem_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; diff --git a/jtag/src/bus/h7202.c b/jtag/src/bus/h7202.c index 2aa578fb..bb6f7ca7 100644 --- a/jtag/src/bus/h7202.c +++ b/jtag/src/bus/h7202.c @@ -236,23 +236,6 @@ h7202_bus_free( bus_t *bus ) free( bus ); } -static bus_t *h7202_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t h7202_bus = { - "h7202", - "H7202 compatible bus driver via BSR", - h7202_bus_new, - h7202_bus_free, - h7202_bus_printinfo, - h7202_bus_prepare, - h7202_bus_area, - h7202_bus_read_start, - h7202_bus_read_next, - h7202_bus_read_end, - h7202_bus_read, - h7202_bus_write -}; - static bus_t * h7202_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -264,12 +247,12 @@ h7202_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &h7202_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -329,3 +312,18 @@ h7202_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } +const bus_driver_t h7202_bus = { + "h7202", + "H7202 compatible bus driver via BSR", + h7202_bus_new, + h7202_bus_free, + h7202_bus_printinfo, + h7202_bus_prepare, + h7202_bus_area, + h7202_bus_read_start, + h7202_bus_read_next, + h7202_bus_read_end, + h7202_bus_read, + h7202_bus_write, + NULL +}; diff --git a/jtag/src/bus/ixp425.c b/jtag/src/bus/ixp425.c index 19f4bf35..84d3a418 100644 --- a/jtag/src/bus/ixp425.c +++ b/jtag/src/bus/ixp425.c @@ -231,24 +231,6 @@ ixp425_bus_free( bus_t *bus ) free( bus ); } -static bus_t *ixp425_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t ixp425_bus = { - "ixp425", - N_("Intel IXP425 compatible bus driver via BSR"), - ixp425_bus_new, - ixp425_bus_free, - ixp425_bus_printinfo, - ixp425_bus_prepare, - ixp425_bus_area, - ixp425_bus_read_start, - ixp425_bus_read_next, - ixp425_bus_read_end, - ixp425_bus_read, - ixp425_bus_write, - NULL -}; - static bus_t * ixp425_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -260,12 +242,12 @@ ixp425_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &ixp425_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -320,3 +302,19 @@ ixp425_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t ixp425_bus = { + "ixp425", + N_("Intel IXP425 compatible bus driver via BSR"), + ixp425_bus_new, + ixp425_bus_free, + ixp425_bus_printinfo, + ixp425_bus_prepare, + ixp425_bus_area, + ixp425_bus_read_start, + ixp425_bus_read_next, + ixp425_bus_read_end, + ixp425_bus_read, + ixp425_bus_write, + NULL +}; diff --git a/jtag/src/bus/jopcyc.c b/jtag/src/bus/jopcyc.c index 25a77881..ad9066b0 100644 --- a/jtag/src/bus/jopcyc.c +++ b/jtag/src/bus/jopcyc.c @@ -509,12 +509,12 @@ jopcyc_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &jopcyc_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; diff --git a/jtag/src/bus/lh7a400.c b/jtag/src/bus/lh7a400.c index b1d8c567..366447bc 100644 --- a/jtag/src/bus/lh7a400.c +++ b/jtag/src/bus/lh7a400.c @@ -257,24 +257,6 @@ lh7a400_bus_free( bus_t *bus ) free( bus ); } -static bus_t *lh7a400_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t lh7a400_bus = { - "lh7a400", - N_("Sharp LH7A400 compatible bus driver via BSR (flash access only!)"), - lh7a400_bus_new, - lh7a400_bus_free, - lh7a400_bus_printinfo, - lh7a400_bus_prepare, - lh7a400_bus_area, - lh7a400_bus_read_start, - lh7a400_bus_read_next, - lh7a400_bus_read_end, - lh7a400_bus_read, - lh7a400_bus_write, - NULL -}; - static bus_t * lh7a400_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -286,12 +268,12 @@ lh7a400_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &lh7a400_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -355,3 +337,19 @@ lh7a400_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t lh7a400_bus = { + "lh7a400", + N_("Sharp LH7A400 compatible bus driver via BSR (flash access only!)"), + lh7a400_bus_new, + lh7a400_bus_free, + lh7a400_bus_printinfo, + lh7a400_bus_prepare, + lh7a400_bus_area, + lh7a400_bus_read_start, + lh7a400_bus_read_next, + lh7a400_bus_read_end, + lh7a400_bus_read, + lh7a400_bus_write, + NULL +}; diff --git a/jtag/src/bus/mpc5200.c b/jtag/src/bus/mpc5200.c index 8b97fce7..ee377d10 100644 --- a/jtag/src/bus/mpc5200.c +++ b/jtag/src/bus/mpc5200.c @@ -254,7 +254,7 @@ mpc5200_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; diff --git a/jtag/src/bus/mpc824x.c b/jtag/src/bus/mpc824x.c index 6cb04583..251293a0 100644 --- a/jtag/src/bus/mpc824x.c +++ b/jtag/src/bus/mpc824x.c @@ -432,7 +432,7 @@ mpc824x_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; diff --git a/jtag/src/bus/ppc405ep.c b/jtag/src/bus/ppc405ep.c index 92fd17c1..574d5fc3 100644 --- a/jtag/src/bus/ppc405ep.c +++ b/jtag/src/bus/ppc405ep.c @@ -216,23 +216,6 @@ ppc405ep_bus_free( bus_t *bus ) free( bus ); } -static bus_t *ppc405ep_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t ppc405ep_bus = { - "ppc405ep", - N_("IBM PowerPC 405EP compatible bus driver via BSR"), - ppc405ep_bus_new, - ppc405ep_bus_free, - ppc405ep_bus_printinfo, - ppc405ep_bus_prepare, - ppc405ep_bus_area, - ppc405ep_bus_read_start, - ppc405ep_bus_read_next, - ppc405ep_bus_read_end, - ppc405ep_bus_read, - ppc405ep_bus_write -}; - static bus_t * ppc405ep_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -244,12 +227,12 @@ ppc405ep_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || (chain->parts->len <= chain->active_part) || (chain->active_part < 0)) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &ppc405ep_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -301,3 +284,19 @@ ppc405ep_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t ppc405ep_bus = { + "ppc405ep", + N_("IBM PowerPC 405EP compatible bus driver via BSR"), + ppc405ep_bus_new, + ppc405ep_bus_free, + ppc405ep_bus_printinfo, + ppc405ep_bus_prepare, + ppc405ep_bus_area, + ppc405ep_bus_read_start, + ppc405ep_bus_read_next, + ppc405ep_bus_read_end, + ppc405ep_bus_read, + ppc405ep_bus_write, + NULL +}; diff --git a/jtag/src/bus/ppc440gx_ebc8.c b/jtag/src/bus/ppc440gx_ebc8.c index 953aaa21..8a0b50bd 100644 --- a/jtag/src/bus/ppc440gx_ebc8.c +++ b/jtag/src/bus/ppc440gx_ebc8.c @@ -214,24 +214,6 @@ ppc440gx_ebc8_bus_free( bus_t *bus ) free( bus ); } -static bus_t *ppc440gx_ebc8_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t ppc440gx_ebc8_bus = { - "ppc440gx_ebc8", - N_("IBM PowerPC 440GX 8-bit EBC compatible bus driver via BSR"), - ppc440gx_ebc8_bus_new, - ppc440gx_ebc8_bus_free, - ppc440gx_ebc8_bus_printinfo, - ppc440gx_ebc8_bus_prepare, - ppc440gx_ebc8_bus_area, - ppc440gx_ebc8_bus_read_start, - ppc440gx_ebc8_bus_read_next, - ppc440gx_ebc8_bus_read_end, - ppc440gx_ebc8_bus_read, - ppc440gx_ebc8_bus_write, - NULL -}; - static bus_t * ppc440gx_ebc8_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -243,12 +225,12 @@ ppc440gx_ebc8_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || (chain->parts->len <= chain->active_part) || (chain->active_part < 0)) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &ppc440gx_ebc8_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -300,3 +282,19 @@ ppc440gx_ebc8_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t ppc440gx_ebc8_bus = { + "ppc440gx_ebc8", + N_("IBM PowerPC 440GX 8-bit EBC compatible bus driver via BSR"), + ppc440gx_ebc8_bus_new, + ppc440gx_ebc8_bus_free, + ppc440gx_ebc8_bus_printinfo, + ppc440gx_ebc8_bus_prepare, + ppc440gx_ebc8_bus_area, + ppc440gx_ebc8_bus_read_start, + ppc440gx_ebc8_bus_read_next, + ppc440gx_ebc8_bus_read_end, + ppc440gx_ebc8_bus_read, + ppc440gx_ebc8_bus_write, + NULL +}; diff --git a/jtag/src/bus/prototype.c b/jtag/src/bus/prototype.c index cd391f16..d61ef217 100644 --- a/jtag/src/bus/prototype.c +++ b/jtag/src/bus/prototype.c @@ -265,12 +265,12 @@ prototype_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || (chain->parts->len <= chain->active_part) || (chain->active_part < 0)) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &prototype_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -450,6 +450,7 @@ const bus_driver_t prototype_bus = { prototype_bus_read_next, prototype_bus_read_end, prototype_bus_read, - prototype_bus_write + prototype_bus_write, + NULL }; diff --git a/jtag/src/bus/pxa2x0.c b/jtag/src/bus/pxa2x0.c index 95d50e76..eaa3dde4 100644 --- a/jtag/src/bus/pxa2x0.c +++ b/jtag/src/bus/pxa2x0.c @@ -607,41 +607,6 @@ pxa2xx_bus_free( bus_t *bus ) free( bus ); } -static bus_t *pxa2x0_bus_new( chain_t *chain, char *cmd_params[] ); -static bus_t *pxa27x_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t pxa2x0_bus = { - "pxa2x0", - N_("Intel PXA2x0 compatible bus driver via BSR"), - pxa2x0_bus_new, - pxa2xx_bus_free, - pxa2x0_bus_printinfo, - pxa2xx_bus_prepare, - pxa2xx_bus_area, - pxa2xx_bus_read_start, - pxa2xx_bus_read_next, - pxa2xx_bus_read_end, - pxa2xx_bus_read, - pxa2xx_bus_write, - NULL /* patch 909598 call pxax0_bus_init, but the patch fails and doesnt look compatible */ -}; - -const bus_driver_t pxa27x_bus = { - "pxa27x", - N_("Intel PXA27x compatible bus driver via BSR"), - pxa27x_bus_new, - pxa2xx_bus_free, - pxa27x_bus_printinfo, - pxa2xx_bus_prepare, - pxa27x_bus_area, - pxa2xx_bus_read_start, - pxa2xx_bus_read_next, - pxa2xx_bus_read_end, - pxa2xx_bus_read, - pxa2xx_bus_write, - pxa2xx_bus_init -}; - //static bus_t * //pxa2x0_bus_new( void ) static int @@ -657,7 +622,7 @@ pxa2xx_bus_new_common(bus_t * bus) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; @@ -762,7 +727,7 @@ pxa2x0_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; @@ -799,7 +764,7 @@ pxa27x_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; @@ -826,3 +791,35 @@ pxa27x_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t pxa2x0_bus = { + "pxa2x0", + N_("Intel PXA2x0 compatible bus driver via BSR"), + pxa2x0_bus_new, + pxa2xx_bus_free, + pxa2x0_bus_printinfo, + pxa2xx_bus_prepare, + pxa2xx_bus_area, + pxa2xx_bus_read_start, + pxa2xx_bus_read_next, + pxa2xx_bus_read_end, + pxa2xx_bus_read, + pxa2xx_bus_write, + NULL /* patch 909598 call pxax0_bus_init, but the patch fails and doesnt look compatible */ +}; + +const bus_driver_t pxa27x_bus = { + "pxa27x", + N_("Intel PXA27x compatible bus driver via BSR"), + pxa27x_bus_new, + pxa2xx_bus_free, + pxa27x_bus_printinfo, + pxa2xx_bus_prepare, + pxa27x_bus_area, + pxa2xx_bus_read_start, + pxa2xx_bus_read_next, + pxa2xx_bus_read_end, + pxa2xx_bus_read, + pxa2xx_bus_write, + pxa2xx_bus_init +}; diff --git a/jtag/src/bus/s3c4510x.c b/jtag/src/bus/s3c4510x.c index 27a0ab61..8849cd9f 100644 --- a/jtag/src/bus/s3c4510x.c +++ b/jtag/src/bus/s3c4510x.c @@ -325,24 +325,6 @@ s3c4510_bus_free( bus_t *bus ) free( bus ); } -static bus_t *s3c4510_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t s3c4510_bus = { - "s3c4510x", - N_("Samsung S3C4510B compatible bus driver via BSR"), - s3c4510_bus_new, - s3c4510_bus_free, - s3c4510_bus_printinfo, - s3c4510_bus_prepare, - s3c4510_bus_area, - s3c4510_bus_read_start, - s3c4510_bus_read_next, - s3c4510_bus_read_end, - s3c4510_bus_read, - s3c4510_bus_write, - NULL -}; - static bus_t * s3c4510_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -354,12 +336,12 @@ s3c4510_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &s3c4510_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -441,6 +423,22 @@ s3c4510_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } +const bus_driver_t s3c4510_bus = { + "s3c4510x", + N_("Samsung S3C4510B compatible bus driver via BSR"), + s3c4510_bus_new, + s3c4510_bus_free, + s3c4510_bus_printinfo, + s3c4510_bus_prepare, + s3c4510_bus_area, + s3c4510_bus_read_start, + s3c4510_bus_read_next, + s3c4510_bus_read_end, + s3c4510_bus_read, + s3c4510_bus_write, + NULL +}; + /*============================================================================= diff --git a/jtag/src/bus/sa1110.c b/jtag/src/bus/sa1110.c index 0f6f79e3..987d4e86 100644 --- a/jtag/src/bus/sa1110.c +++ b/jtag/src/bus/sa1110.c @@ -245,24 +245,6 @@ sa1110_bus_free( bus_t *bus ) free( bus ); } -static bus_t *sa1110_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t sa1110_bus = { - "sa1110", - N_("Intel SA-1110 compatible bus driver via BSR"), - sa1110_bus_new, - sa1110_bus_free, - sa1110_bus_printinfo, - sa1110_bus_prepare, - sa1110_bus_area, - sa1110_bus_read_start, - sa1110_bus_read_next, - sa1110_bus_read_end, - sa1110_bus_read, - sa1110_bus_write, - NULL -}; - static bus_t * sa1110_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -274,12 +256,12 @@ sa1110_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &sa1110_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -339,3 +321,19 @@ sa1110_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t sa1110_bus = { + "sa1110", + N_("Intel SA-1110 compatible bus driver via BSR"), + sa1110_bus_new, + sa1110_bus_free, + sa1110_bus_printinfo, + sa1110_bus_prepare, + sa1110_bus_area, + sa1110_bus_read_start, + sa1110_bus_read_next, + sa1110_bus_read_end, + sa1110_bus_read, + sa1110_bus_write, + NULL +}; diff --git a/jtag/src/bus/sh7727.c b/jtag/src/bus/sh7727.c index 7320dc1e..fbac787c 100644 --- a/jtag/src/bus/sh7727.c +++ b/jtag/src/bus/sh7727.c @@ -277,24 +277,6 @@ sh7727_bus_free( bus_t *bus ) free( bus ); } -static bus_t *sh7727_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t sh7727_bus = { - "sh7727", - N_("Hitachi SH7727 compatible bus driver via BSR"), - sh7727_bus_new, - sh7727_bus_free, - sh7727_bus_printinfo, - sh7727_bus_prepare, - sh7727_bus_area, - sh7727_bus_read_start, - sh7727_bus_read_next, - sh7727_bus_read_end, - sh7727_bus_read, - sh7727_bus_write, - NULL -}; - static bus_t * sh7727_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -306,7 +288,7 @@ sh7727_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; @@ -387,3 +369,19 @@ sh7727_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t sh7727_bus = { + "sh7727", + N_("Hitachi SH7727 compatible bus driver via BSR"), + sh7727_bus_new, + sh7727_bus_free, + sh7727_bus_printinfo, + sh7727_bus_prepare, + sh7727_bus_area, + sh7727_bus_read_start, + sh7727_bus_read_next, + sh7727_bus_read_end, + sh7727_bus_read, + sh7727_bus_write, + NULL +}; diff --git a/jtag/src/bus/sh7750r.c b/jtag/src/bus/sh7750r.c index d87f2b12..aba3aa24 100644 --- a/jtag/src/bus/sh7750r.c +++ b/jtag/src/bus/sh7750r.c @@ -259,24 +259,6 @@ sh7750r_bus_free( bus_t *bus ) free( bus ); } -static bus_t *sh7750r_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t sh7750r_bus = { - "sh7750r", - N_("Hitachi SH7750R compatible bus driver via BSR"), - sh7750r_bus_new, - sh7750r_bus_free, - sh7750r_bus_printinfo, - sh7750r_bus_prepare, - sh7750r_bus_area, - sh7750r_bus_read_start, - sh7750r_bus_read_next, - sh7750r_bus_read_end, - sh7750r_bus_read, - sh7750r_bus_write, - NULL -}; - static bus_t * sh7750r_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -288,7 +270,7 @@ sh7750r_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; @@ -367,3 +349,19 @@ sh7750r_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t sh7750r_bus = { + "sh7750r", + N_("Hitachi SH7750R compatible bus driver via BSR"), + sh7750r_bus_new, + sh7750r_bus_free, + sh7750r_bus_printinfo, + sh7750r_bus_prepare, + sh7750r_bus_area, + sh7750r_bus_read_start, + sh7750r_bus_read_next, + sh7750r_bus_read_end, + sh7750r_bus_read, + sh7750r_bus_write, + NULL +}; diff --git a/jtag/src/bus/sh7751r.c b/jtag/src/bus/sh7751r.c index 6cb46e32..47f98611 100644 --- a/jtag/src/bus/sh7751r.c +++ b/jtag/src/bus/sh7751r.c @@ -252,24 +252,6 @@ sh7751r_bus_free( bus_t *bus ) free( bus ); } -static bus_t *sh7751r_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t sh7751r_bus = { - "sh7751r", - N_("Hitachi SH7751R compatible bus driver via BSR"), - sh7751r_bus_new, - sh7751r_bus_free, - sh7751r_bus_printinfo, - sh7751r_bus_prepare, - sh7751r_bus_area, - sh7751r_bus_read_start, - sh7751r_bus_read_next, - sh7751r_bus_read_end, - sh7751r_bus_read, - sh7751r_bus_write, - NULL -}; - static bus_t * sh7751r_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -281,7 +263,7 @@ sh7751r_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; @@ -350,3 +332,19 @@ sh7751r_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t sh7751r_bus = { + "sh7751r", + N_("Hitachi SH7751R compatible bus driver via BSR"), + sh7751r_bus_new, + sh7751r_bus_free, + sh7751r_bus_printinfo, + sh7751r_bus_prepare, + sh7751r_bus_area, + sh7751r_bus_read_start, + sh7751r_bus_read_next, + sh7751r_bus_read_end, + sh7751r_bus_read, + sh7751r_bus_write, + NULL +}; diff --git a/jtag/src/bus/sharc21065l.c b/jtag/src/bus/sharc21065l.c index 65dc4d5c..3f346fd0 100644 --- a/jtag/src/bus/sharc21065l.c +++ b/jtag/src/bus/sharc21065l.c @@ -258,23 +258,6 @@ static void sharc_21065L_bus_free( bus_t *bus ) free( bus ); } -static bus_t *sharc_21065L_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t sharc_21065L_bus = { - "SHARC_21065L", - N_("SHARC_21065L compatible bus driver via BSR"), - sharc_21065L_bus_new, - sharc_21065L_bus_free, - sharc_21065L_bus_printinfo, - sharc_21065L_bus_prepare, - sharc_21065L_bus_area, - sharc_21065L_bus_read_start, - sharc_21065L_bus_read_next, - sharc_21065L_bus_read_end, - sharc_21065L_bus_read, - sharc_21065L_bus_write -}; - static bus_t *sharc_21065L_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -286,7 +269,7 @@ static bus_t *sharc_21065L_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; @@ -344,3 +327,19 @@ static bus_t *sharc_21065L_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t sharc_21065L_bus = { + "SHARC_21065L", + N_("SHARC_21065L compatible bus driver via BSR"), + sharc_21065L_bus_new, + sharc_21065L_bus_free, + sharc_21065L_bus_printinfo, + sharc_21065L_bus_prepare, + sharc_21065L_bus_area, + sharc_21065L_bus_read_start, + sharc_21065L_bus_read_next, + sharc_21065L_bus_read_end, + sharc_21065L_bus_read, + sharc_21065L_bus_write, + NULL +}; diff --git a/jtag/src/bus/slsup3.c b/jtag/src/bus/slsup3.c index cd3c0684..7b0a1440 100644 --- a/jtag/src/bus/slsup3.c +++ b/jtag/src/bus/slsup3.c @@ -367,7 +367,7 @@ slsup3_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; diff --git a/jtag/src/bus/tx4925.c b/jtag/src/bus/tx4925.c index 73b8ec72..1c4fc3af 100644 --- a/jtag/src/bus/tx4925.c +++ b/jtag/src/bus/tx4925.c @@ -249,25 +249,6 @@ tx4925_bus_free( bus_t *bus ) free( bus ); } -static bus_t *tx4925_bus_new( chain_t *chain, char *cmd_params[] ); - -const bus_driver_t tx4925_bus = { - "tx4925", - N_("Toshiba TX4925 compatible bus driver via BSR"), - tx4925_bus_new, - tx4925_bus_free, - tx4925_bus_printinfo, - tx4925_bus_prepare, - tx4925_bus_area, - tx4925_bus_read_start, - tx4925_bus_read_next, - tx4925_bus_read_end, - tx4925_bus_read, - tx4925_bus_write, - NULL -}; - - static bus_t * tx4925_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -279,12 +260,12 @@ tx4925_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &tx4925_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -353,3 +334,19 @@ tx4925_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } + +const bus_driver_t tx4925_bus = { + "tx4925", + N_("Toshiba TX4925 compatible bus driver via BSR"), + tx4925_bus_new, + tx4925_bus_free, + tx4925_bus_printinfo, + tx4925_bus_prepare, + tx4925_bus_area, + tx4925_bus_read_start, + tx4925_bus_read_next, + tx4925_bus_read_end, + tx4925_bus_read, + tx4925_bus_write, + NULL +}; diff --git a/jtag/src/bus/zefant-xs3.c b/jtag/src/bus/zefant-xs3.c index 52a2da28..25a0bc79 100644 --- a/jtag/src/bus/zefant-xs3.c +++ b/jtag/src/bus/zefant-xs3.c @@ -732,12 +732,12 @@ zefant_xs3_bus_new( chain_t *chain, char *cmd_params[] ) if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - bus = malloc( sizeof (bus_t) ); + bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; bus->driver = &zefant_xs3_bus; - bus->params = malloc( sizeof (bus_params_t) ); + bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; @@ -991,7 +991,8 @@ const bus_driver_t zefant_xs3_bus = { zefant_xs3_bus_read_next, zefant_xs3_bus_read_end, zefant_xs3_bus_read, - zefant_xs3_bus_write + zefant_xs3_bus_write, + NULL };