summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2020-03-20 01:27:17 (GMT)
committerHyotaek Shim <hyotaek.shim@samsung.com>2020-03-20 01:51:04 (GMT)
commitcfaa165007a03dbe3df4b25ec629840878bf03fd (patch)
tree47dc6f6c444d46536bcccc4ec42a34dc3f228576
parent09e540970141dd6551c900b59e680f27e0b1ee41 (diff)
downloadlibdevice-node-cfaa165007a03dbe3df4b25ec629840878bf03fd.zip
libdevice-node-cfaa165007a03dbe3df4b25ec629840878bf03fd.tar.gz
libdevice-node-cfaa165007a03dbe3df4b25ec629840878bf03fd.tar.bz2
Since the _available_funcs global variable is used in many places, it should be prevented from changing to const. Change-Id: I53404030e16361a70254fe2780176ac1441b1e13 (cherry picked from commit 9065e52b99d5a10fa059c7337b7d693fa32584e5)
-rw-r--r--hw/usb_cfs_client_common.c14
-rw-r--r--hw/usb_client_common.c6
-rw-r--r--hw/usb_gadget.h8
-rw-r--r--hw/usb_gadget_common.c19
4 files changed, 23 insertions, 24 deletions
diff --git a/hw/usb_cfs_client_common.c b/hw/usb_cfs_client_common.c
index 029988b..d2ffe24 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 struct usb_function *cfs_find_usb_function(usbg_function *function)
+static const struct usb_function *cfs_find_usb_function(usbg_function *function)
{
char *sep;
char buf[MAX_INSTANCE_LEN];
@@ -95,7 +95,7 @@ static struct usb_function *cfs_find_usb_function(usbg_function *function)
}
static bool cfs_is_function_supported(struct usb_client *usb,
- struct usb_function *func)
+ const 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(struct usb_function *usb_func, usbg_function *function)
+static int cfs_prep_ffs_service(const 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];
- struct usb_function *usb_function;
+ const 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;
- struct usb_function *usb_function;
+ const 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;
- struct usb_function *usb_func;
+ const struct usb_function *usb_func;
if (!common)
return -EINVAL;
diff --git a/hw/usb_client_common.c b/hw/usb_client_common.c
index 963687a..260e80a 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,
- struct usb_function *func)
+ const 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];
- struct usb_function *func;
- struct usb_function *funcs[USB_FUNCTION_IDX_MAX];
+ const struct usb_function *func;
+ const 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 fd0e2fd..216c207 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;
- struct usb_function **funcs;
+ const 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;
- struct usb_function **funcs;
+ const 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);
-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);
+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);
#endif
diff --git a/hw/usb_gadget_common.c b/hw/usb_gadget_common.c
index 179bb4c..8a5e07b 100644
--- a/hw/usb_gadget_common.c
+++ b/hw/usb_gadget_common.c
@@ -45,7 +45,7 @@
#define EXPORT __attribute__ ((visibility("default")))
#endif
-static struct usb_function *_available_funcs[];
+static const struct usb_function *_available_funcs[];
static void simple_cleanup_config(struct usb_configuration *config)
{
@@ -191,7 +191,7 @@ out:
return -ENOMEM;
}
-static inline struct usb_function *find_func(struct usb_gadget *gadget,
+static inline const 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;
- struct usb_function **funcs;
+ const 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 struct usb_function _##_name##_function = { \
+ static const 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 struct usb_function *_available_funcs[] = {
+static const 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 struct usb_function *_available_funcs[] = {
[USB_FUNCTION_IDX_MAX] = NULL /* An indicator to end the array */
};
-struct usb_function *find_usb_function_by_name(const char *name)
+const struct usb_function *find_usb_function_by_name(const char *name)
{
int i;
@@ -413,7 +413,7 @@ struct usb_function *find_usb_function_by_name(const char *name)
return NULL;
}
-struct usb_function *find_usb_function_by_name_instance(const char *name, const char *instance)
+const struct usb_function *find_usb_function_by_name_instance(const char *name, const char *instance)
{
int i;
@@ -452,9 +452,8 @@ 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)) {
- _available_funcs[USB_FUNCTION_IDX_MTP]->service = "mtp-responder-dummy";
- }
+ if (access("/usr/lib/systemd/system/mtp-responder.socket", F_OK))
+ ((struct usb_function*)_available_funcs[USB_FUNCTION_IDX_MTP])->service = "mtp-responder-dummy";
*common = &simple_translator->common;
return 0;