Since the _available_funcs global variable is used in many places, it should be prevented from changing to const.
Change-Id: I53404030e16361a70254fe2780176ac1441b1e13
.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];
}
static bool cfs_is_function_supported(struct usb_client *usb,
- struct usb_function *func)
+ const struct usb_function *func)
{
bool res;
int ret;
}
-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;
{
int ret;
char buf[MAX_INSTANCE_LEN];
- struct usb_function *usb_function;
+ const struct usb_function *usb_function;
if (!function)
return -EINVAL;
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,
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);
{
usbg_function *function;
struct cfs_client *cfs_client;
- struct usb_function *usb_func;
+ const struct usb_function *usb_func;
if (!common)
return -EINVAL;
#endif
static bool legacy_is_function_supported(struct usb_client *usb,
- struct usb_function *func)
+ const struct usb_function *func)
{
/*
* TODO
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)
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 {
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;
};
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
#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)
{
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;
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)
}
#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", \
#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,
[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;
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;
* 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;