diff options
author | INSUN PYO <insun.pyo@samsung.com> | 2020-03-24 03:35:35 +0000 |
---|---|---|
committer | INSUN PYO <insun.pyo@samsung.com> | 2020-03-24 03:35:35 +0000 |
commit | 0eb9342b124760ee703d25bb4cd703338d58cdc1 (patch) | |
tree | 8cb44f5274969fbe3e978db907e23acbf44ba46e | |
parent | 9065e52b99d5a10fa059c7337b7d693fa32584e5 (diff) | |
download | libdevice-node-0eb9342b124760ee703d25bb4cd703338d58cdc1.tar.gz libdevice-node-0eb9342b124760ee703d25bb4cd703338d58cdc1.tar.bz2 libdevice-node-0eb9342b124760ee703d25bb4cd703338d58cdc1.zip |
Revert "Change global variable _available_funcs to const"
This reverts commit 9065e52b99d5a10fa059c7337b7d693fa32584e5.
The const variable is assigned to the read-only memory map area.
So, we can not modify it.
Change-Id: I8719eef3af23bd7c33e3419d94afdf4f5f19261c
-rw-r--r-- | hw/usb_cfs_client_common.c | 14 | ||||
-rw-r--r-- | hw/usb_client_common.c | 6 | ||||
-rw-r--r-- | hw/usb_gadget.h | 8 | ||||
-rw-r--r-- | hw/usb_gadget_common.c | 19 |
4 files changed, 24 insertions, 23 deletions
diff --git a/hw/usb_cfs_client_common.c b/hw/usb_cfs_client_common.c index d2ffe24..029988b 100644 --- a/hw/usb_cfs_client_common.c +++ b/hw/usb_cfs_client_common.c @@ -69,7 +69,7 @@ struct usbg_gadget_strs default_g_strs = { .serial = "01234TEST", }; -static const struct usb_function *cfs_find_usb_function(usbg_function *function) +static struct usb_function *cfs_find_usb_function(usbg_function *function) { char *sep; char buf[MAX_INSTANCE_LEN]; @@ -95,7 +95,7 @@ static const struct usb_function *cfs_find_usb_function(usbg_function *function) } static bool cfs_is_function_supported(struct usb_client *usb, - const struct usb_function *func) + struct usb_function *func) { bool res; int ret; @@ -197,7 +197,7 @@ static int cfs_ensure_dir(char *path) } -static int cfs_prep_ffs_service(const struct usb_function *usb_func, usbg_function *function) +static int cfs_prep_ffs_service(struct usb_function *usb_func, usbg_function *function) { int ret; const char *name; @@ -269,7 +269,7 @@ static int cfs_cleanup_ffs_service(usbg_function *function) { int ret; char buf[MAX_INSTANCE_LEN]; - const struct usb_function *usb_function; + struct usb_function *usb_function; if (!function) return -EINVAL; @@ -388,8 +388,8 @@ static int cfs_set_gadget_config(struct cfs_client *cfs_client, int config_id, s int function_type; usbg_config *config; usbg_function *function; + struct usb_function *usb_func; char instance[MAX_INSTANCE_LEN]; - const struct usb_function *usb_func; struct usbg_config_attrs cattrs = { .bmAttributes = usb_config->attrs.bmAttributs, .bMaxPower = usb_config->attrs.MaxPower/2, @@ -487,7 +487,7 @@ static int cfs_reconfigure_gadget(struct usb_client *usb, static void cfs_start_stop_service_and_handler(usbg_gadget *gadget, enum cfs_function_service_operation operation) { usbg_function *function; - const struct usb_function *usb_function; + struct usb_function *usb_function; usbg_for_each_function(function, gadget) { usb_function = cfs_find_usb_function(function); @@ -620,7 +620,7 @@ int hw_cfs_gadget_close(struct hw_common *common) { usbg_function *function; struct cfs_client *cfs_client; - const struct usb_function *usb_func; + struct usb_function *usb_func; if (!common) return -EINVAL; diff --git a/hw/usb_client_common.c b/hw/usb_client_common.c index 260e80a..963687a 100644 --- a/hw/usb_client_common.c +++ b/hw/usb_client_common.c @@ -59,7 +59,7 @@ #endif static bool legacy_is_function_supported(struct usb_client *usb, - const struct usb_function *func) + struct usb_function *func) { /* * TODO @@ -251,8 +251,8 @@ static void legacy_start_stop_service_and_handler(bool start) char *fname; char *sep = LEGACY_FUNC_SEP; char buf[MAX_GADGET_STR_LEN]; - const struct usb_function *func; - const struct usb_function *funcs[USB_FUNCTION_IDX_MAX]; + struct usb_function *func; + struct usb_function *funcs[USB_FUNCTION_IDX_MAX]; /* SLP gadget uses two USB configuration. * (/sys/class/usb_mode/usb0/funcs_fconf and /sys/class/usb_mode/usb0/funcs_sconf) diff --git a/hw/usb_gadget.h b/hw/usb_gadget.h index 216c207..fd0e2fd 100644 --- a/hw/usb_gadget.h +++ b/hw/usb_gadget.h @@ -95,7 +95,7 @@ struct usb_configuration_strings { struct usb_configuration { struct usb_configuration_attributes attrs; struct usb_configuration_strings *strs; - const struct usb_function **funcs; + struct usb_function **funcs; }; struct usb_gadget_attrs { @@ -117,7 +117,7 @@ struct usb_gadget_strings { struct usb_gadget { struct usb_gadget_attrs attrs; struct usb_gadget_strings *strs; - const struct usb_function **funcs; + struct usb_function **funcs; struct usb_configuration **configs; }; @@ -135,7 +135,7 @@ struct usb_gadget_translator { int simple_translator_open(struct hw_info *info, const char *id, struct hw_common **common); int simple_translator_close(struct hw_common *common); -const struct usb_function *find_usb_function_by_name(const char *name); -const struct usb_function *find_usb_function_by_name_instance(const char *name, const char *instance); +struct usb_function *find_usb_function_by_name(const char *name); +struct usb_function *find_usb_function_by_name_instance(const char *name, const char *instance); #endif diff --git a/hw/usb_gadget_common.c b/hw/usb_gadget_common.c index 8a5e07b..179bb4c 100644 --- a/hw/usb_gadget_common.c +++ b/hw/usb_gadget_common.c @@ -45,7 +45,7 @@ #define EXPORT __attribute__ ((visibility("default"))) #endif -static const struct usb_function *_available_funcs[]; +static struct usb_function *_available_funcs[]; static void simple_cleanup_config(struct usb_configuration *config) { @@ -191,7 +191,7 @@ out: return -ENOMEM; } -static inline const struct usb_function *find_func(struct usb_gadget *gadget, +static inline struct usb_function *find_func(struct usb_gadget *gadget, int func_id) { int i; @@ -209,7 +209,7 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, int n_functions; int n_configs = 0; struct usb_gadget *gadget; - const struct usb_function **funcs; + struct usb_function **funcs; int functions[2][sizeof(gadget_id->function_mask)*8]; /* zero terminates */ if (!gadget_id || !_gadget) @@ -366,7 +366,7 @@ void rndis_handler(int enable) } #define DEFINE_USB_FUNCTION(_id, _name, _is_functionfs, _service, _handler) \ - static const struct usb_function _##_name##_function = { \ + static struct usb_function _##_name##_function = { \ .id = _id, \ .name = #_name, \ .instance = "default", \ @@ -387,7 +387,7 @@ DEFINE_USB_FUNCTION(USB_FUNCTION_RMNET, rmnet, 0, NULL, N #undef DEFINE_USB_FUNCTION /* Caution: index order of arrary is important, because simple_id_to_gadget() uses it. */ -static const struct usb_function *_available_funcs[] = { +static struct usb_function *_available_funcs[] = { [USB_FUNCTION_IDX_MTP] = &_mtp_function, [USB_FUNCTION_IDX_ACM] = &_acm_function, [USB_FUNCTION_IDX_SDB] = &_sdb_function, @@ -399,7 +399,7 @@ static const struct usb_function *_available_funcs[] = { [USB_FUNCTION_IDX_MAX] = NULL /* An indicator to end the array */ }; -const struct usb_function *find_usb_function_by_name(const char *name) +struct usb_function *find_usb_function_by_name(const char *name) { int i; @@ -413,7 +413,7 @@ const struct usb_function *find_usb_function_by_name(const char *name) return NULL; } -const struct usb_function *find_usb_function_by_name_instance(const char *name, const char *instance) +struct usb_function *find_usb_function_by_name_instance(const char *name, const char *instance) { int i; @@ -452,8 +452,9 @@ int simple_translator_open(struct hw_info *info, * As a result, all usb operations do not work properly. * So in environments that mtp doesn't support, use dummy mtp. */ - if (access("/usr/lib/systemd/system/mtp-responder.socket", F_OK)) - ((struct usb_function*)_available_funcs[USB_FUNCTION_IDX_MTP])->service = "mtp-responder-dummy"; + if (access("/usr/lib/systemd/system/mtp-responder.socket", F_OK)) { + _available_funcs[USB_FUNCTION_IDX_MTP]->service = "mtp-responder-dummy"; + } *common = &simple_translator->common; return 0; |