From 4c0892b468a85bee0dfd7b6cb114e68f5cca0bb2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Tue, 27 Feb 2018 17:16:29 +0100 Subject: [PATCH] usb: Remove usb-operation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Starting and stopping usb operation is specific to the implementation. This responsibility is moved to USB HAL. Change-Id: I8a729a1343d27dc04e5a5611c9fd6ccdf394d4a4 Signed-off-by: Paweł Szewczyk --- CMakeLists.txt | 2 - conf/usb-operation.conf | 14 ------ packaging/deviced.spec | 1 - src/usb/usb-operation.c | 114 ------------------------------------------------ src/usb/usb.c | 8 ---- src/usb/usb.h | 3 -- 6 files changed, 142 deletions(-) delete mode 100644 conf/usb-operation.conf delete mode 100644 src/usb/usb-operation.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7000c7d..4632a10 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,8 +244,6 @@ ENDIF() # USB connection IF(USB_MODULE STREQUAL on) - INSTALL_CONF(conf usb-operation) - # USB (Manual setting) INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/direct_set_debug.sh DESTINATION bin) IF(${SDB_PRESTART} STREQUAL on) diff --git a/conf/usb-operation.conf b/conf/usb-operation.conf deleted file mode 100644 index da6c71c..0000000 --- a/conf/usb-operation.conf +++ /dev/null @@ -1,14 +0,0 @@ -[sdb] -StartService=sdbd.service -StopService=sdbd.service - -[mtp] -StartService=mtp-responder.service -StopService=mtp-responder.service - -[rndis] -Start=/sbin/ifconfig usb0 192.168.129.3 up -Start=/sbin/route add -net 192.168.129.0 netmask 255.255.255.0 dev usb0 -StartService=sshd.service -StopService=sshd.service -Stop=/sbin/ifconfig usb0 down diff --git a/packaging/deviced.spec b/packaging/deviced.spec index a908a6d..17848f2 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -217,7 +217,6 @@ mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so %config %{_sysconfdir}/deviced/power.conf %config %{_sysconfdir}/deviced/battery.conf %config %{_sysconfdir}/deviced/display.conf -%config %{_sysconfdir}/deviced/usb-operation.conf # usbhost_test %{_sysconfdir}/deviced/usb-host-test/test_gadget.gs %{_bindir}/usb-host-ffs-test-daemon diff --git a/src/usb/usb-operation.c b/src/usb/usb-operation.c deleted file mode 100644 index 1bc8efc..0000000 --- a/src/usb/usb-operation.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include - -#include "core/log.h" -#include "core/common.h" -#include "core/config-parser.h" -#include "core/launch.h" -#include "shared/deviced-systemd.h" -#include "usb.h" - -#define USB_OPERATION "/etc/deviced/usb-operation.conf" - -#define KEY_START_STR "Start" -#define KEY_STOP_STR "Stop" - -#define BUF_MAX 128 - -typedef enum { - OPERATION_STOP, - OPERATION_START, -} operation_e; - -struct oper_data { - char mode_str[BUF_MAX]; - operation_e type; -}; - -static int load_operation_config(struct parse_result *result, void *user_data) -{ - struct oper_data *data = user_data; - int ret; - operation_e type; - - if (!data || !result) - return -EINVAL; - - if (!strstr(data->mode_str, result->section)) - return 0; - - if (!strncmp(result->name, KEY_START_STR, strlen(KEY_START_STR))) - type = OPERATION_START; - else if (!strncmp(result->name, KEY_STOP_STR, strlen(KEY_STOP_STR))) - type = OPERATION_STOP; - else { - _E("Invalid name (%s)", result->name); - return -EINVAL; - } - - if (type != data->type) - return 0; - - if (strstr(result->name, "Service")) { - if (type == OPERATION_START) - ret = deviced_systemd_start_unit(result->value); - if (type == OPERATION_STOP) - ret = deviced_systemd_stop_unit(result->value); - } else - ret = launch_app_cmd(result->value); - - _I("Execute(%s %s: %d)", result->name, result->value, ret); - - return 0; -} - -static int usb_execute_operation(unsigned int mode, operation_e type) -{ - int ret; - struct oper_data data; - - usb_state_get_mode_str(mode, data.mode_str, sizeof(data.mode_str)); - - data.type = type; - - ret = config_parse(USB_OPERATION, - load_operation_config, &data); - if (ret < 0) - _E("Failed to load usb operation (%d)", ret); - - return ret; -} - -int usb_operation_start(unsigned int mode) -{ - if (is_emulator()) - return 0; - return usb_execute_operation(mode, OPERATION_START); -} - -int usb_operation_stop(unsigned int mode) -{ - if (is_emulator()) - return 0; - return usb_execute_operation(mode, OPERATION_STOP); -} diff --git a/src/usb/usb.c b/src/usb/usb.c index 66ac8b1..db380f5 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -315,8 +315,6 @@ int usb_change_mode(unsigned mode) unsigned int curr = usb_state_get_current_mode(); if (curr != USB_FUNCTION_NONE) { - usb_operation_stop(curr); - ret = usb_disable(); if (ret < 0) { _E("Failed to disable current usb mode"); @@ -339,8 +337,6 @@ int usb_change_mode(unsigned mode) _E("Failed to enable usb mode (%d)"); return ret; } - - usb_operation_start(mode); } return 0; @@ -359,15 +355,11 @@ static int usb_connected(void) return ret; } - usb_operation_start(mode); - return 0; } static int usb_disconnected(void) { - usb_operation_stop(usb_state_get_current_mode()); - usb_state_update_state(USB_DISCONNECTED, USB_FUNCTION_NONE); return usb_disable(); diff --git a/src/usb/usb.h b/src/usb/usb.h index ae26162..0e6165b 100644 --- a/src/usb/usb.h +++ b/src/usb/usb.h @@ -67,9 +67,6 @@ void usb_state_set_selected_mode(unsigned int mode); unsigned int usb_state_get_current_mode(void); usb_connection_state_e usb_state_get_connection(void); -int usb_operation_start(unsigned int mode); -int usb_operation_stop(unsigned int mode); - /* dbus methods/signals (usb-dbus.c) */ enum { DISABLED, -- 2.7.4