Change global variable _available_funcs to const
[platform/core/system/libdevice-node.git] / hw / usb_gadget_common.c
index 179bb4c..8a5e07b 100644 (file)
@@ -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;