]> git.proxmox.com Git - qemu.git/blobdiff - bt-host.c
guest agent: use QERR_UNSUPPORTED for disabled RPCs
[qemu.git] / bt-host.c
index 042a55e47e6a10079df838f5aa964be2a209633a..095254ddc6ef350e5f5e7f1f8b41ce0faa48b24f 100644 (file)
--- a/bt-host.c
+++ b/bt-host.c
  * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "qemu-common.h"
 #include "qemu-char.h"
-#include "sysemu.h"
 #include "net.h"
+#include "bt-host.h"
 
 #ifndef _WIN32
 # include <errno.h>
@@ -51,19 +49,19 @@ static void bt_host_send(struct HCIInfo *hci,
     struct bt_host_hci_s *s = (struct bt_host_hci_s *) hci;
     uint8_t pkt = type;
     struct iovec iv[2];
-    int ret;
 
-    iv[0].iov_base = &pkt;
+    iv[0].iov_base = (void *)&pkt;
     iv[0].iov_len  = 1;
     iv[1].iov_base = (void *) data;
     iv[1].iov_len  = len;
 
-    while ((ret = writev(s->fd, iv, 2)) < 0)
+    while (writev(s->fd, iv, 2) < 0) {
         if (errno != EAGAIN && errno != EINTR) {
             fprintf(stderr, "qemu: error %i writing bluetooth packet.\n",
                             errno);
             return;
         }
+    }
 }
 
 static void bt_host_cmd(struct HCIInfo *hci, const uint8_t *data, int len)
@@ -81,13 +79,6 @@ static void bt_host_sco(struct HCIInfo *hci, const uint8_t *data, int len)
     bt_host_send(hci, HCI_SCODATA_PKT, data, len);
 }
 
-static int bt_host_read_poll(void *opaque)
-{
-    struct bt_host_hci_s *s = (struct bt_host_hci_s *) opaque;
-
-    return !!s->hci.evt_recv;
-}
-
 static void bt_host_read(void *opaque)
 {
     struct bt_host_hci_s *s = (struct bt_host_hci_s *) opaque;
@@ -172,7 +163,7 @@ struct HCIInfo *bt_host_hci(const char *id)
     if (fd < 0) {
         fprintf(stderr, "qemu: Can't open `%s': %s (%i)\n",
                         id, strerror(errno), errno);
-        return 0;
+        return NULL;
     }
 
 # ifdef CONFIG_BLUEZ
@@ -193,14 +184,14 @@ struct HCIInfo *bt_host_hci(const char *id)
     s->hci.acl_send = bt_host_acl;
     s->hci.bdaddr_set = bt_host_bdaddr_set;
 
-    qemu_set_fd_handler2(s->fd, bt_host_read_poll, bt_host_read, 0, s);
+    qemu_set_fd_handler(s->fd, bt_host_read, NULL, s);
 
     return &s->hci;
 }
 #else
 struct HCIInfo *bt_host_hci(const char *id)
 {
-    fprintf(stderr, "qemu: bluetooth passthrough not supported (yet)\n", errno);
+    fprintf(stderr, "qemu: bluetooth passthrough not supported (yet)\n");
 
     return 0;
 }