From 290427f21ea089c37184886c6569e8a01b990cca Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 23 Dec 2008 05:39:54 +0100 Subject: Fix broken forward declarations --- tools/Makefile.am | 3 ++- tools/hciattach.c | 35 +++++------------------------------ tools/hciattach.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ tools/hciattach_st.c | 2 ++ tools/hciattach_ti.c | 5 ++--- tools/hciattach_tialt.c | 4 ++-- 6 files changed, 60 insertions(+), 36 deletions(-) create mode 100644 tools/hciattach.h diff --git a/tools/Makefile.am b/tools/Makefile.am index eb4dcc74..648ebc0f 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -43,7 +43,8 @@ bin_PROGRAMS = $(tools_programs) $(dfutool_programs) $(dfubabel_programs) noinst_PROGRAMS = hcisecfilter ppporc avinfo $(usb_programs) -hciattach_SOURCES = hciattach.c hciattach_st.c hciattach_ti.c hciattach_tialt.c +hciattach_SOURCES = hciattach.c hciattach.h \ + hciattach_st.c hciattach_ti.c hciattach_tialt.c hciattach_LDADD = @BLUEZ_LIBS@ hciconfig_SOURCES = hciconfig.c csr.h csr.c diff --git a/tools/hciattach.c b/tools/hciattach.c index 439b6658..4d6604ab 100644 --- a/tools/hciattach.c +++ b/tools/hciattach.c @@ -48,19 +48,7 @@ #include #include -#ifndef N_HCI -#define N_HCI 15 -#endif - -#define HCIUARTSETPROTO _IOW('U', 200, int) -#define HCIUARTGETPROTO _IOR('U', 201, int) -#define HCIUARTGETDEVICE _IOR('U', 202, int) - -#define HCI_UART_H4 0 -#define HCI_UART_BCSP 1 -#define HCI_UART_3WIRE 2 -#define HCI_UART_H4DS 3 -#define HCI_UART_LL 4 +#include "hciattach.h" struct uart_t { char *type; @@ -291,9 +279,6 @@ static int digi(int fd, struct uart_t *u, struct termios *ti) return 0; } -extern int texas_init(int fd, struct termios *ti); -extern int texas_post(int fd, struct termios *ti); - static int texas(int fd, struct uart_t *u, struct termios *ti) { return texas_init(fd, ti); @@ -304,11 +289,9 @@ static int texas2(int fd, struct uart_t *u, struct termios *ti) return texas_post(fd, ti); } -extern int texasalt_init(int fd, int speed); - static int texasalt(int fd, struct uart_t *u, struct termios *ti) { - return texasalt_init(fd, u->speed); + return texasalt_init(fd, u->speed, ti); } static int read_check(int fd, void *buf, int count) @@ -826,8 +809,6 @@ static int st(int fd, struct uart_t *u, struct termios *ti) return 0; } -extern int stlc2500_init(int fd, bdaddr_t *bdaddr); - static int stlc2500(int fd, struct uart_t *u, struct termios *ti) { bdaddr_t bdaddr; @@ -868,12 +849,6 @@ static int stlc2500(int fd, struct uart_t *u, struct termios *ti) return stlc2500_init(fd, &bdaddr); } -static int bgb2xx_init(int fd, bdaddr_t *bdaddr) -{ - /* This is broken and the routine got lost somewhere */ - return -EIO; -} - static int bgb2xx(int fd, struct uart_t *u, struct termios *ti) { bdaddr_t bdaddr; @@ -1095,7 +1070,7 @@ struct uart_t uart[] = { { NULL, 0 } }; -struct uart_t * get_by_id(int m_id, int p_id) +static struct uart_t * get_by_id(int m_id, int p_id) { int i; for (i = 0; uart[i].type; i++) { @@ -1105,7 +1080,7 @@ struct uart_t * get_by_id(int m_id, int p_id) return NULL; } -struct uart_t * get_by_type(char *type) +static struct uart_t * get_by_type(char *type) { int i; for (i = 0; uart[i].type; i++) { @@ -1116,7 +1091,7 @@ struct uart_t * get_by_type(char *type) } /* Initialize UART driver */ -int init_uart(char *dev, struct uart_t *u, int send_break) +static int init_uart(char *dev, struct uart_t *u, int send_break) { struct termios ti; int fd, i; diff --git a/tools/hciattach.h b/tools/hciattach.h new file mode 100644 index 00000000..3d2e0776 --- /dev/null +++ b/tools/hciattach.h @@ -0,0 +1,47 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2003-2008 Marcel Holtmann + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include + +#ifndef N_HCI +#define N_HCI 15 +#endif + +#define HCIUARTSETPROTO _IOW('U', 200, int) +#define HCIUARTGETPROTO _IOR('U', 201, int) +#define HCIUARTGETDEVICE _IOR('U', 202, int) + +#define HCI_UART_H4 0 +#define HCI_UART_BCSP 1 +#define HCI_UART_3WIRE 2 +#define HCI_UART_H4DS 3 +#define HCI_UART_LL 4 + +int read_hci_event(int fd, unsigned char* buf, int size); +int set_speed(int fd, struct termios *ti, int speed); + +int texas_init(int fd, struct termios *ti); +int texas_post(int fd, struct termios *ti); +int texasalt_init(int fd, int speed, struct termios *ti); +int stlc2500_init(int fd, bdaddr_t *bdaddr); +int bgb2xx_init(int dd, bdaddr_t *bdaddr); diff --git a/tools/hciattach_st.c b/tools/hciattach_st.c index 2c7d7438..6f18c969 100644 --- a/tools/hciattach_st.c +++ b/tools/hciattach_st.c @@ -37,6 +37,8 @@ #include +#include "hciattach.h" + static int debug = 0; static int do_command(int fd, uint8_t ogf, uint16_t ocf, diff --git a/tools/hciattach_ti.c b/tools/hciattach_ti.c index 7c1d58f9..1d6e273f 100644 --- a/tools/hciattach_ti.c +++ b/tools/hciattach_ti.c @@ -43,6 +43,8 @@ #include #include +#include "hciattach.h" + #ifdef HCIATTACH_DEBUG #define DPRINTF(x...) printf(x) #else @@ -109,9 +111,6 @@ struct bts_action_serial { uint32_t flow_control; }__attribute__ ((packed)); -extern int set_speed(int fd, struct termios *ti, int speed); -extern int read_hci_event(int fd, unsigned char* buf, int size); - static FILE *bts_load_script(const char* file_name, uint32_t* version) { struct bts_header header; diff --git a/tools/hciattach_tialt.c b/tools/hciattach_tialt.c index efeae3da..b3dee87e 100644 --- a/tools/hciattach_tialt.c +++ b/tools/hciattach_tialt.c @@ -46,6 +46,8 @@ #include #include +#include "hciattach.h" + #define FAILIF(x, args...) do { \ if (x) { \ fprintf(stderr, ##args); \ @@ -61,8 +63,6 @@ typedef struct { uint8_t data[16]; } __attribute__((packed)) command_complete_t; -extern int read_hci_event(int fd, unsigned char* buf, int size); - static int read_command_complete(int fd, unsigned short opcode, unsigned char len) { command_complete_t resp; /* Read reply. */ -- cgit