xhci: dbc: remove tty specific port structure from struct xhci_dbc
Use a void pointer that any function driver can use instead. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200723144530.9992-28-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
688915b11a
commit
9a360a7cae
@ -137,8 +137,8 @@ struct xhci_dbc {
|
|||||||
unsigned resume_required:1;
|
unsigned resume_required:1;
|
||||||
struct dbc_ep eps[2];
|
struct dbc_ep eps[2];
|
||||||
|
|
||||||
struct dbc_port port;
|
|
||||||
const struct dbc_driver *driver;
|
const struct dbc_driver *driver;
|
||||||
|
void *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dbc_request {
|
struct dbc_request {
|
||||||
|
@ -19,6 +19,11 @@ static void dbc_tty_exit(void);
|
|||||||
|
|
||||||
static struct tty_driver *dbc_tty_driver;
|
static struct tty_driver *dbc_tty_driver;
|
||||||
|
|
||||||
|
static inline struct dbc_port *dbc_to_port(struct xhci_dbc *dbc)
|
||||||
|
{
|
||||||
|
return dbc->priv;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
dbc_send_packet(struct dbc_port *port, char *packet, unsigned int size)
|
dbc_send_packet(struct dbc_port *port, char *packet, unsigned int size)
|
||||||
{
|
{
|
||||||
@ -99,7 +104,7 @@ static void
|
|||||||
dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request *req)
|
dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request *req)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct dbc_port *port = &dbc->port;
|
struct dbc_port *port = dbc_to_port(dbc);
|
||||||
|
|
||||||
spin_lock_irqsave(&port->port_lock, flags);
|
spin_lock_irqsave(&port->port_lock, flags);
|
||||||
list_add_tail(&req->list_pool, &port->read_queue);
|
list_add_tail(&req->list_pool, &port->read_queue);
|
||||||
@ -110,7 +115,7 @@ dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request *req)
|
|||||||
static void dbc_write_complete(struct xhci_dbc *dbc, struct dbc_request *req)
|
static void dbc_write_complete(struct xhci_dbc *dbc, struct dbc_request *req)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct dbc_port *port = &dbc->port;
|
struct dbc_port *port = dbc_to_port(dbc);
|
||||||
|
|
||||||
spin_lock_irqsave(&port->port_lock, flags);
|
spin_lock_irqsave(&port->port_lock, flags);
|
||||||
list_add(&req->list_pool, &port->write_pool);
|
list_add(&req->list_pool, &port->write_pool);
|
||||||
@ -397,7 +402,7 @@ int xhci_dbc_tty_register_device(struct xhci_dbc *dbc)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct device *tty_dev;
|
struct device *tty_dev;
|
||||||
struct dbc_port *port = &dbc->port;
|
struct dbc_port *port = dbc_to_port(dbc);
|
||||||
|
|
||||||
if (port->registered)
|
if (port->registered)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
@ -446,7 +451,7 @@ register_fail:
|
|||||||
|
|
||||||
void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc)
|
void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc)
|
||||||
{
|
{
|
||||||
struct dbc_port *port = &dbc->port;
|
struct dbc_port *port = dbc_to_port(dbc);
|
||||||
|
|
||||||
if (!port->registered)
|
if (!port->registered)
|
||||||
return;
|
return;
|
||||||
@ -468,6 +473,7 @@ static const struct dbc_driver dbc_driver = {
|
|||||||
int xhci_dbc_tty_probe(struct xhci_hcd *xhci)
|
int xhci_dbc_tty_probe(struct xhci_hcd *xhci)
|
||||||
{
|
{
|
||||||
struct xhci_dbc *dbc = xhci->dbc;
|
struct xhci_dbc *dbc = xhci->dbc;
|
||||||
|
struct dbc_port *port;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
/* dbc_tty_init will be called by module init() in the future */
|
/* dbc_tty_init will be called by module init() in the future */
|
||||||
@ -475,13 +481,20 @@ int xhci_dbc_tty_probe(struct xhci_hcd *xhci)
|
|||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
dbc->driver = &dbc_driver;
|
port = kzalloc(sizeof(*port), GFP_KERNEL);
|
||||||
|
if (!port) {
|
||||||
|
status = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
dbc_tty_driver->driver_state = &dbc->port;
|
dbc->driver = &dbc_driver;
|
||||||
|
dbc->priv = port;
|
||||||
|
|
||||||
|
|
||||||
|
dbc_tty_driver->driver_state = port;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
out:
|
out:
|
||||||
|
|
||||||
/* dbc_tty_exit will be called by module_exit() in the future */
|
/* dbc_tty_exit will be called by module_exit() in the future */
|
||||||
dbc_tty_exit();
|
dbc_tty_exit();
|
||||||
return status;
|
return status;
|
||||||
@ -493,7 +506,11 @@ out:
|
|||||||
*/
|
*/
|
||||||
void xhci_dbc_tty_remove(struct xhci_dbc *dbc)
|
void xhci_dbc_tty_remove(struct xhci_dbc *dbc)
|
||||||
{
|
{
|
||||||
|
struct dbc_port *port = dbc_to_port(dbc);
|
||||||
|
|
||||||
dbc->driver = NULL;
|
dbc->driver = NULL;
|
||||||
|
dbc->priv = NULL;
|
||||||
|
kfree(port);
|
||||||
|
|
||||||
/* dbc_tty_exit will be called by module_exit() in the future */
|
/* dbc_tty_exit will be called by module_exit() in the future */
|
||||||
dbc_tty_exit();
|
dbc_tty_exit();
|
||||||
|
Reference in New Issue
Block a user