diff options
Diffstat (limited to 'drivers/hsi/clients/ssi_protocol.c')
| -rw-r--r-- | drivers/hsi/clients/ssi_protocol.c | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/drivers/hsi/clients/ssi_protocol.c b/drivers/hsi/clients/ssi_protocol.c index 561abf7bdf1f..d10a01f3eb9e 100644 --- a/drivers/hsi/clients/ssi_protocol.c +++ b/drivers/hsi/clients/ssi_protocol.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * ssi_protocol.c * @@ -7,27 +8,12 @@ * Copyright (C) 2013 Sebastian Reichel <sre@kernel.org> * * Contact: Carlos Chinea <carlos.chinea@nokia.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA */ #include <linux/atomic.h> #include <linux/clk.h> #include <linux/device.h> #include <linux/err.h> -#include <linux/gpio.h> #include <linux/if_ether.h> #include <linux/if_arp.h> #include <linux/if_phonet.h> @@ -45,8 +31,6 @@ #include <linux/hsi/hsi.h> #include <linux/hsi/ssi_protocol.h> -void ssi_waketest(struct hsi_client *cl, unsigned int enable); - #define SSIP_TXQUEUE_LEN 100 #define SSIP_MAX_MTU 65535 #define SSIP_DEFAULT_MTU 4000 @@ -129,9 +113,10 @@ enum { * @netdev: Phonet network device * @txqueue: TX data queue * @cmdqueue: Queue of free commands + * @work: &struct work_struct for scheduled work * @cl: HSI client own reference * @link: Link for ssip_list - * @tx_usecount: Refcount to keep track the slaves that use the wake line + * @tx_usecnt: Refcount to keep track the slaves that use the wake line * @channel_id_cmd: HSI channel id for command stream * @channel_id_data: HSI channel id for data stream */ @@ -194,7 +179,8 @@ static void ssip_skb_to_msg(struct sk_buff *skb, struct hsi_msg *msg) sg = sg_next(sg); BUG_ON(!sg); frag = &skb_shinfo(skb)->frags[i]; - sg_set_page(sg, frag->page.p, frag->size, frag->page_offset); + sg_set_page(sg, skb_frag_page(frag), skb_frag_size(frag), + skb_frag_off(frag)); } } @@ -295,15 +281,15 @@ static void ssip_set_rxstate(struct ssi_protocol *ssi, unsigned int state) ssi->recv_state = state; switch (state) { case RECV_IDLE: - del_timer(&ssi->rx_wd); + timer_delete(&ssi->rx_wd); if (ssi->send_state == SEND_IDLE) - del_timer(&ssi->keep_alive); + timer_delete(&ssi->keep_alive); break; case RECV_READY: /* CMT speech workaround */ if (atomic_read(&ssi->tx_usecnt)) break; - /* Otherwise fall through */ + fallthrough; case RECEIVING: mod_timer(&ssi->keep_alive, jiffies + msecs_to_jiffies(SSIP_KATOUT)); @@ -320,9 +306,9 @@ static void ssip_set_txstate(struct ssi_protocol *ssi, unsigned int state) switch (state) { case SEND_IDLE: case SEND_READY: - del_timer(&ssi->tx_wd); + timer_delete(&ssi->tx_wd); if (ssi->recv_state == RECV_IDLE) - del_timer(&ssi->keep_alive); + timer_delete(&ssi->keep_alive); break; case WAIT4READY: case SENDING: @@ -412,9 +398,10 @@ static void ssip_reset(struct hsi_client *cl) if (test_and_clear_bit(SSIP_WAKETEST_FLAG, &ssi->flags)) ssi_waketest(cl, 0); /* FIXME: To be removed */ spin_lock_bh(&ssi->lock); - del_timer(&ssi->rx_wd); - del_timer(&ssi->tx_wd); - del_timer(&ssi->keep_alive); + timer_delete(&ssi->rx_wd); + timer_delete(&ssi->tx_wd); + timer_delete(&ssi->keep_alive); + cancel_work_sync(&ssi->work); ssi->main_state = 0; ssi->send_state = 0; ssi->recv_state = 0; @@ -466,7 +453,7 @@ static void ssip_error(struct hsi_client *cl) static void ssip_keep_alive(struct timer_list *t) { - struct ssi_protocol *ssi = from_timer(ssi, t, keep_alive); + struct ssi_protocol *ssi = timer_container_of(ssi, t, keep_alive); struct hsi_client *cl = ssi->cl; dev_dbg(&cl->device, "Keep alive kick in: m(%d) r(%d) s(%d)\n", @@ -478,9 +465,10 @@ static void ssip_keep_alive(struct timer_list *t) case SEND_READY: if (atomic_read(&ssi->tx_usecnt) == 0) break; + fallthrough; /* - * Fall through. Workaround for cmt-speech - * in that case we relay on audio timers. + * Workaround for cmt-speech in that case + * we relay on audio timers. */ case SEND_IDLE: spin_unlock(&ssi->lock); @@ -492,7 +480,7 @@ static void ssip_keep_alive(struct timer_list *t) static void ssip_rx_wd(struct timer_list *t) { - struct ssi_protocol *ssi = from_timer(ssi, t, rx_wd); + struct ssi_protocol *ssi = timer_container_of(ssi, t, rx_wd); struct hsi_client *cl = ssi->cl; dev_err(&cl->device, "Watchdog triggered\n"); @@ -501,7 +489,7 @@ static void ssip_rx_wd(struct timer_list *t) static void ssip_tx_wd(struct timer_list *t) { - struct ssi_protocol *ssi = from_timer(ssi, t, tx_wd); + struct ssi_protocol *ssi = timer_container_of(ssi, t, tx_wd); struct hsi_client *cl = ssi->cl; dev_err(&cl->device, "Watchdog triggered\n"); @@ -660,7 +648,7 @@ static void ssip_rx_data_complete(struct hsi_msg *msg) ssip_error(cl); return; } - del_timer(&ssi->rx_wd); /* FIXME: Revisit */ + timer_delete(&ssi->rx_wd); /* FIXME: Revisit */ skb = msg->context; ssip_pn_rx(skb); hsi_free_msg(msg); @@ -679,7 +667,7 @@ static void ssip_rx_bootinforeq(struct hsi_client *cl, u32 cmd) case ACTIVE: dev_err(&cl->device, "Boot info req on active state\n"); ssip_error(cl); - /* Fall through */ + fallthrough; case INIT: case HANDSHAKE: spin_lock_bh(&ssi->lock); @@ -743,7 +731,7 @@ static void ssip_rx_waketest(struct hsi_client *cl, u32 cmd) spin_lock_bh(&ssi->lock); ssi->main_state = ACTIVE; - del_timer(&ssi->tx_wd); /* Stop boot handshake timer */ + timer_delete(&ssi->tx_wd); /* Stop boot handshake timer */ spin_unlock_bh(&ssi->lock); dev_notice(&cl->device, "WAKELINES TEST %s\n", @@ -807,7 +795,6 @@ static void ssip_rx_strans(struct hsi_client *cl, u32 cmd) dev_err(&cl->device, "No memory for rx skb\n"); goto out1; } - skb->dev = ssi->netdev; skb_put(skb, len * 4); msg = ssip_alloc_data(ssi, skb, GFP_ATOMIC); if (unlikely(!msg)) { @@ -942,6 +929,7 @@ static int ssip_pn_open(struct net_device *dev) if (err < 0) { dev_err(&cl->device, "Register HSI port event failed (%d)\n", err); + hsi_release_port(cl); return err; } dev_dbg(&cl->device, "Configuring SSI port\n"); @@ -979,7 +967,7 @@ static void ssip_xmit_work(struct work_struct *work) ssip_xmit(cl); } -static int ssip_pn_xmit(struct sk_buff *skb, struct net_device *dev) +static netdev_tx_t ssip_pn_xmit(struct sk_buff *skb, struct net_device *dev) { struct hsi_client *cl = to_hsi_client(dev->dev.parent); struct ssi_protocol *ssi = hsi_client_drvdata(cl); @@ -1038,7 +1026,7 @@ static int ssip_pn_xmit(struct sk_buff *skb, struct net_device *dev) dev->stats.tx_packets++; dev->stats.tx_bytes += skb->len; - return 0; + return NETDEV_TX_OK; drop2: hsi_free_msg(msg); drop: @@ -1046,7 +1034,7 @@ drop: inc_dropped: dev->stats.tx_dropped++; - return 0; + return NETDEV_TX_OK; } /* CMT reset event handler */ @@ -1066,14 +1054,16 @@ static const struct net_device_ops ssip_pn_ops = { static void ssip_pn_setup(struct net_device *dev) { + static const u8 addr = PN_MEDIA_SOS; + dev->features = 0; dev->netdev_ops = &ssip_pn_ops; dev->type = ARPHRD_PHONET; dev->flags = IFF_POINTOPOINT | IFF_NOARP; dev->mtu = SSIP_DEFAULT_MTU; dev->hard_header_len = 1; - dev->dev_addr[0] = PN_MEDIA_SOS; dev->addr_len = 1; + dev_addr_set(dev, &addr); dev->tx_queue_len = SSIP_TXQUEUE_LEN; dev->needs_free_netdev = true; |
