[修改] sslb 添加 configfs 下 functions目录新增 os_desc/interface.sslb

免驱正常
This commit is contained in:
gaoyang3513
2025-01-06 22:32:17 +08:00
parent 6062e38207
commit f55cb62690
3 changed files with 22 additions and 11 deletions

View File

@ -20,9 +20,6 @@
#include "u_os_desc.h" #include "u_os_desc.h"
//#if defined (CONFIG_GAOYANG)
// (struct usb_descriptor_header *) &WINUSB_WCIDDescriptor,
//#endif // defined (CONFIG_GAOYANG)
#if defined (CONFIG_GAOYANG) #if defined (CONFIG_GAOYANG)
#define WINUSB_IF0_WCID_PROPERTIES_SIZE (162) #define WINUSB_IF0_WCID_PROPERTIES_SIZE (162)
@ -1990,14 +1987,6 @@ unknown:
/* /*
* OS descriptors handling * OS descriptors handling
*/ */
#if defined (CONFIG_GAOYANG)
if (ctrl->bRequestType == 0xC0) {
value = min_t(int, w_length, sizeof(WINUSB20_WCIDDescriptorSet));
memcpy(req->buf, WINUSB20_WCIDDescriptorSet, value);
goto check_value;
}
#endif // defined (CONFIG_GAOYANG)
if (cdev->use_os_string && cdev->os_desc_config && if (cdev->use_os_string && cdev->os_desc_config &&
(ctrl->bRequestType & USB_TYPE_VENDOR) && (ctrl->bRequestType & USB_TYPE_VENDOR) &&
ctrl->bRequest == cdev->b_vendor_code) { ctrl->bRequest == cdev->b_vendor_code) {

View File

@ -14,6 +14,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/usb/composite.h> #include <linux/usb/composite.h>
#include <linux/err.h> #include <linux/err.h>
#include "configfs.h"
#include "g_zero.h" #include "g_zero.h"
#include "u_f.h" #include "u_f.h"
@ -1237,12 +1238,17 @@ static void source_sink_free_instance(struct usb_function_instance *fi)
struct f_ss_opts *ss_opts; struct f_ss_opts *ss_opts;
ss_opts = container_of(fi, struct f_ss_opts, func_inst); ss_opts = container_of(fi, struct f_ss_opts, func_inst);
kfree(ss_opts->sslb_interf_group); /* single VLA chunk */
kfree(ss_opts); kfree(ss_opts);
} }
static struct usb_function_instance *source_sink_alloc_inst(void) static struct usb_function_instance *source_sink_alloc_inst(void)
{ {
struct f_ss_opts *ss_opts; struct f_ss_opts *ss_opts;
struct usb_os_desc *descs[1];
struct config_group *sslb_interf_group;
char *names[1];
ss_opts = kzalloc(sizeof(*ss_opts), GFP_KERNEL); ss_opts = kzalloc(sizeof(*ss_opts), GFP_KERNEL);
if (!ss_opts) if (!ss_opts)
@ -1258,6 +1264,18 @@ static struct usb_function_instance *source_sink_alloc_inst(void)
config_group_init_type_name(&ss_opts->func_inst.group, "", config_group_init_type_name(&ss_opts->func_inst.group, "",
&ss_func_type); &ss_func_type);
INIT_LIST_HEAD(&ss_opts->sslb_os_desc.ext_prop);
ss_opts->sslb_os_desc.ext_compat_id = ss_opts->sslb_ext_compat_id;
names[0] = "sslb";
descs[0] = &ss_opts->sslb_os_desc;
sslb_interf_group = usb_os_desc_prepare_interf_dir(&ss_opts->func_inst.group, 1, descs, names, THIS_MODULE);
if (IS_ERR(sslb_interf_group)) {
source_sink_free_instance(&ss_opts->func_inst);
return ERR_CAST(sslb_interf_group);
}
ss_opts->sslb_interf_group = sslb_interf_group;
return &ss_opts->func_inst; return &ss_opts->func_inst;
} }
DECLARE_USB_FUNCTION(SourceSink, source_sink_alloc_inst, DECLARE_USB_FUNCTION(SourceSink, source_sink_alloc_inst,

View File

@ -45,6 +45,10 @@ struct f_ss_opts {
*/ */
struct mutex lock; struct mutex lock;
int refcnt; int refcnt;
struct config_group *sslb_interf_group;
struct usb_os_desc sslb_os_desc;
char sslb_ext_compat_id[16];
}; };
struct f_lb_opts { struct f_lb_opts {