Commit 260d88b7 authored by Linyu Yuan's avatar Linyu Yuan Committed by Greg Kroah-Hartman

usb: gadget: configfs: add cfg_to_gadget_info() helper

add this helper function can simplify code of
config_usb_cfg_link() and config_usb_cfg_unlink().
Signed-off-by: default avatarLinyu Yuan <quic_linyyuan@quicinc.com>
Link: https://lore.kernel.org/r/1634649997-28745-2-git-send-email-quic_linyyuan@quicinc.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d1a46837
...@@ -73,6 +73,11 @@ static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item) ...@@ -73,6 +73,11 @@ static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item)
group); group);
} }
static inline struct gadget_info *cfg_to_gadget_info(struct config_usb_cfg *cfg)
{
return container_of(cfg->c.cdev, struct gadget_info, cdev);
}
struct gadget_strings { struct gadget_strings {
struct usb_gadget_strings stringtab_dev; struct usb_gadget_strings stringtab_dev;
struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX]; struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX];
...@@ -413,8 +418,7 @@ static int config_usb_cfg_link( ...@@ -413,8 +418,7 @@ static int config_usb_cfg_link(
struct config_item *usb_func_ci) struct config_item *usb_func_ci)
{ {
struct config_usb_cfg *cfg = to_config_usb_cfg(usb_cfg_ci); struct config_usb_cfg *cfg = to_config_usb_cfg(usb_cfg_ci);
struct usb_composite_dev *cdev = cfg->c.cdev; struct gadget_info *gi = cfg_to_gadget_info(cfg);
struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev);
struct config_group *group = to_config_group(usb_func_ci); struct config_group *group = to_config_group(usb_func_ci);
struct usb_function_instance *fi = container_of(group, struct usb_function_instance *fi = container_of(group,
...@@ -464,8 +468,7 @@ static void config_usb_cfg_unlink( ...@@ -464,8 +468,7 @@ static void config_usb_cfg_unlink(
struct config_item *usb_func_ci) struct config_item *usb_func_ci)
{ {
struct config_usb_cfg *cfg = to_config_usb_cfg(usb_cfg_ci); struct config_usb_cfg *cfg = to_config_usb_cfg(usb_cfg_ci);
struct usb_composite_dev *cdev = cfg->c.cdev; struct gadget_info *gi = cfg_to_gadget_info(cfg);
struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev);
struct config_group *group = to_config_group(usb_func_ci); struct config_group *group = to_config_group(usb_func_ci);
struct usb_function_instance *fi = container_of(group, struct usb_function_instance *fi = container_of(group,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment