diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2022-02-07 16:26:03 +0100 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2022-02-08 09:49:55 +0100 |
commit | 12a435ec8234fa05eef3a85a12a916c047801433 (patch) | |
tree | 98449325849958dfe54390c75a924e52e288e8c7 /drivers/net | |
parent | 2346d34b505423c155fec1a28824606e9e32d6bc (diff) | |
download | kernel_replicant_linux-12a435ec8234fa05eef3a85a12a916c047801433.tar.gz kernel_replicant_linux-12a435ec8234fa05eef3a85a12a916c047801433.tar.bz2 kernel_replicant_linux-12a435ec8234fa05eef3a85a12a916c047801433.zip |
net: usb: sipc_hsic: style cleanup
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/usb/sipc_hsic.c | 77 |
1 files changed, 48 insertions, 29 deletions
diff --git a/drivers/net/usb/sipc_hsic.c b/drivers/net/usb/sipc_hsic.c index f9886971cecc..1809480cd5dd 100644 --- a/drivers/net/usb/sipc_hsic.c +++ b/drivers/net/usb/sipc_hsic.c @@ -1,16 +1,16 @@ // SPDX-License-Identifier: GPL-2.0+ -// -// HSIC interface for modems speaking -// Samsung's IPC v4.x protocol -// -// Copyright (C) 2018 Simon Shields <simon@lineageos.org> -// +/* HSIC interface for modems speaking + * Samsung's IPC v4.x protocol + * + * Copyright (C) 2018 Simon Shields <simon@lineageos.org> + */ + +#include <linux/sipc.h> #include <linux/module.h> #include <linux/netdevice.h> +#include <linux/skbuff.h> #include <linux/usb.h> #include <linux/usb/cdc.h> -#include <linux/sipc.h> -#include <linux/skbuff.h> #define USB_EP_FMT 0 #define USB_EP_RAW 1 @@ -33,12 +33,14 @@ struct sipc_usb_ep { struct usb_device *udev; struct usb_interface *data_intf; }; + #define linkops_to_ep(ops) container_of(ops, struct sipc_usb_ep, link_ops) static int sipc_start_rx(struct sipc_usb_ep *ep); static int sipc_link_transmit(struct sipc_link *link, struct sk_buff *skb); -static unsigned int usb_to_sipc_format(int ep) { +static unsigned int usb_to_sipc_format(int ep) +{ switch (ep) { case USB_EP_FMT: return SAMSUNG_IPC_FORMAT_FMT; @@ -57,6 +59,7 @@ static void sipc_rx_complete(struct urb *urb) { struct sipc_usb_ep *ep = urb->context; int format = usb_to_sipc_format(ep->ep); + if (format == SAMSUNG_IPC_FORMAT_RAW) format = SAMSUNG_IPC_FORMAT_MULTI_RAW; @@ -74,9 +77,10 @@ static int sipc_start_rx(struct sipc_usb_ep *ep) urb = ep->in_urb; urb->transfer_flags = 0; - usb_fill_bulk_urb(urb, ep->udev, usb_rcvbulkpipe(ep->udev, ep->bulk_in_addr), - ep->in_buf, ep->in_buf_size, sipc_rx_complete, - ep); + usb_fill_bulk_urb(urb, ep->udev, + usb_rcvbulkpipe(ep->udev, ep->bulk_in_addr), + ep->in_buf, ep->in_buf_size, sipc_rx_complete, + ep); ret = usb_submit_urb(urb, GFP_ATOMIC); if (ret) @@ -88,6 +92,7 @@ static int sipc_start_rx(struct sipc_usb_ep *ep) static void sipc_tx_complete(struct urb *urb) { struct sk_buff *skb = urb->context; + dev_kfree_skb_any(skb); usb_free_urb(urb); } @@ -103,8 +108,9 @@ static int sipc_link_transmit(struct sipc_link *link, struct sk_buff *skb) return -ENOMEM; urb->transfer_flags = URB_ZERO_PACKET; - usb_fill_bulk_urb(urb, ep->udev, usb_sndbulkpipe(ep->udev, ep->bulk_out_addr), - skb->data, skb->len, sipc_tx_complete, skb); + usb_fill_bulk_urb(urb, ep->udev, + usb_sndbulkpipe(ep->udev, ep->bulk_out_addr), + skb->data, skb->len, sipc_tx_complete, skb); ret = usb_submit_urb(urb, GFP_KERNEL); if (ret < 0) { @@ -125,7 +131,6 @@ static int sipc_link_open(struct sipc_link *link, int channel, int format) /* TODO: runtime PM support */ if (channel == 0x1) { - skb = alloc_skb(16, GFP_KERNEL); if (unlikely(!skb)) return -ENOMEM; @@ -133,21 +138,22 @@ static int sipc_link_open(struct sipc_link *link, int channel, int format) memcpy(skb_put(skb, sizeof(data)), &data, sizeof(data)); ret = sipc_link_transmit(&ep->link_ops, skb); - if (ret < 0) { + if (ret < 0) dev_kfree_skb_any(skb); - } } return ret; } static void sipc_set_callbacks(struct sipc_link *link, - struct sipc_link_callback *cb) + struct sipc_link_callback *cb) { struct sipc_usb_ep *ep = linkops_to_ep(link); + ep->cb = cb; } -static int sipc_probe(struct usb_interface *intf, const struct usb_device_id *id) +static int sipc_probe(struct usb_interface *intf, + const struct usb_device_id *id) { int ret, buflen; struct sipc_usb_ep *ep; @@ -195,9 +201,11 @@ static int sipc_probe(struct usb_interface *intf, const struct usb_device_id *id } ret = usb_find_common_endpoints(data_intf->altsetting, - &bulk_in, &bulk_out, NULL, NULL); + &bulk_in, &bulk_out, NULL, NULL); if (ret) { - dev_err(&intf->dev, "Couldn't find bulk-in and bulk-out endpoints: %d\n", ret); + dev_err(&intf->dev, + "Couldn't find bulk-in and bulk-out endpoints: %d\n", + ret); return ret; } @@ -235,20 +243,26 @@ static int sipc_probe(struct usb_interface *intf, const struct usb_device_id *id ret = sipc_set_link(&ep->link_ops, fmt); if (ret < 0) { - dev_err(&intf->dev, "Failed to set SIPC link for fmt %u: %d\n", fmt, ret); + dev_err(&intf->dev, + "Failed to set SIPC link for fmt %u: %d\n", fmt, ret); return ret; } if (fmt == SAMSUNG_IPC_FORMAT_RAW) { - ret = sipc_set_link(&ep->link_ops, SAMSUNG_IPC_FORMAT_MULTI_RAW); + ret = sipc_set_link(&ep->link_ops, + SAMSUNG_IPC_FORMAT_MULTI_RAW); if (ret < 0) { - dev_err(&intf->dev, "Failed to set SIPC link for MULTI_RAW: %d\n", ret); + dev_err(&intf->dev, + "Failed to set SIPC link for MULTI_RAW: %d\n", + ret); return ret; } } sipc_start_rx(ep); + return 0; + urb_free: usb_free_urb(ep->in_urb); return ret; @@ -257,7 +271,6 @@ urb_free: static void sipc_disconnect(struct usb_interface *intf) { struct sipc_usb_ep *ep = usb_get_intfdata(intf); - struct usb_driver *usbdrv = to_usb_driver(intf->dev.driver); int fmt; fmt = usb_to_sipc_format(ep->ep); @@ -274,10 +287,16 @@ invalid_format: } static struct usb_device_id sipc_idtable[] = { - /* Infineon XMM626x */ - {USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0020, - USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, USB_CDC_ACM_PROTO_AT_V25TER)}, - {}, + { + /* Infineon XMM626x */ + USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0020, + USB_CLASS_COMM, + USB_CDC_SUBCLASS_ACM, + USB_CDC_ACM_PROTO_AT_V25TER) + }, + { + /* Sentinel */ + }, }; static struct usb_driver sipc_hsic_driver = { |