Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / serial / serial_connection_posix.cc
index 18a2119..68b5f20 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include <linux/serial.h>
 #endif
 
-#if defined(OS_MACOSX)
-#include <IOKit/serial/ioss.h>
-#endif
-
 namespace extensions {
 
 namespace {
@@ -107,7 +103,9 @@ bool SetCustomBitrate(base::PlatformFile file,
   return ioctl(file, TIOCSSERIAL, &serial) >= 0;
 #elif defined(OS_MACOSX)
   speed_t speed = static_cast<speed_t>(bitrate);
-  return ioctl(file, IOSSIOSPEED, &speed) != -1;
+  cfsetispeed(config, speed);
+  cfsetospeed(config, speed);
+  return true;
 #else
   return false;
 #endif
@@ -254,6 +252,8 @@ bool SerialConnection::GetPortInfo(api::serial::ConnectionInfo* info) const {
     int bitrate = 0;
     if (SpeedConstantToBitrate(ispeed, &bitrate)) {
       info->bitrate.reset(new int(bitrate));
+    } else if (ispeed > 0) {
+      info->bitrate.reset(new int(static_cast<int>(ispeed)));
     }
   }
   if ((config.c_cflag & CSIZE) == CS7) {