Commit 32522a51 authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Felipe Balbi

usb: gadget: midi: convert to new interface of f_midi

Use the new f_midi interface so that the old can be removed.
Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent b85e9de9
...@@ -287,6 +287,7 @@ config USB_MIDI_GADGET ...@@ -287,6 +287,7 @@ config USB_MIDI_GADGET
depends on SND depends on SND
select USB_LIBCOMPOSITE select USB_LIBCOMPOSITE
select SND_RAWMIDI select SND_RAWMIDI
select USB_F_MIDI
help help
The MIDI Gadget acts as a USB Audio device, with one MIDI The MIDI Gadget acts as a USB Audio device, with one MIDI
input and one MIDI output. These MIDI jacks appear as input and one MIDI output. These MIDI jacks appear as
......
...@@ -37,8 +37,7 @@ ...@@ -37,8 +37,7 @@
#include "gadget_chips.h" #include "gadget_chips.h"
#define USBF_MIDI_INCLUDED #include "u_midi.h"
#include "f_midi.c"
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -116,8 +115,13 @@ static struct usb_gadget_strings *dev_strings[] = { ...@@ -116,8 +115,13 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL, NULL,
}; };
struct usb_function_instance *fi_midi;
struct usb_function *f_midi;
static int __exit midi_unbind(struct usb_composite_dev *dev) static int __exit midi_unbind(struct usb_composite_dev *dev)
{ {
usb_put_function(f_midi);
usb_put_function_instance(fi_midi);
return 0; return 0;
} }
...@@ -131,28 +135,54 @@ static struct usb_configuration midi_config = { ...@@ -131,28 +135,54 @@ static struct usb_configuration midi_config = {
static int __init midi_bind_config(struct usb_configuration *c) static int __init midi_bind_config(struct usb_configuration *c)
{ {
return f_midi_bind_config(c, index, id, int status;
in_ports, out_ports,
buflen, qlen); f_midi = usb_get_function(fi_midi);
if (IS_ERR(f_midi))
return PTR_ERR(f_midi);
status = usb_add_function(c, f_midi);
if (status < 0) {
usb_put_function(f_midi);
return status;
}
return 0;
} }
static int __init midi_bind(struct usb_composite_dev *cdev) static int __init midi_bind(struct usb_composite_dev *cdev)
{ {
struct f_midi_opts *midi_opts;
int status; int status;
fi_midi = usb_get_function_instance("midi");
if (IS_ERR(fi_midi))
return PTR_ERR(fi_midi);
midi_opts = container_of(fi_midi, struct f_midi_opts, func_inst);
midi_opts->index = index;
midi_opts->id = id;
midi_opts->in_ports = in_ports;
midi_opts->out_ports = out_ports;
midi_opts->buflen = buflen;
midi_opts->qlen = qlen;
status = usb_string_ids_tab(cdev, strings_dev); status = usb_string_ids_tab(cdev, strings_dev);
if (status < 0) if (status < 0)
return status; goto put;
device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id; midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id;
status = usb_add_config(cdev, &midi_config, midi_bind_config); status = usb_add_config(cdev, &midi_config, midi_bind_config);
if (status < 0) if (status < 0)
return status; goto put;
usb_composite_overwrite_options(cdev, &coverwrite); usb_composite_overwrite_options(cdev, &coverwrite);
pr_info("%s\n", longname); pr_info("%s\n", longname);
return 0; return 0;
put:
usb_put_function_instance(fi_midi);
return status;
} }
static __refdata struct usb_composite_driver midi_driver = { static __refdata struct usb_composite_driver midi_driver = {
......
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