ndlc.c (e67e7e596f3ff19fb90520be9f2130aa54914181) ndlc.c (3648dc6d27f648b8e3ce9b48874627a833d53c3a)
1/*
2 * Low Level Transport (NDLC) Driver for STMicroelectronics NFC Chip
3 *
4 * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.

--- 6 unchanged lines hidden (view full) ---

15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/sched.h>
20#include <net/nfc/nci_core.h>
21
22#include "st-nci.h"
1/*
2 * Low Level Transport (NDLC) Driver for STMicroelectronics NFC Chip
3 *
4 * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.

--- 6 unchanged lines hidden (view full) ---

15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/sched.h>
20#include <net/nfc/nci_core.h>
21
22#include "st-nci.h"
23#include "ndlc.h"
23
24#define NDLC_TIMER_T1 100
25#define NDLC_TIMER_T1_WAIT 400
26#define NDLC_TIMER_T2 1200
27
28#define PCB_TYPE_DATAFRAME 0x80
29#define PCB_TYPE_SUPERVISOR 0xc0
30#define PCB_TYPE_MASK PCB_TYPE_SUPERVISOR

--- 229 unchanged lines hidden (view full) ---

260 struct llt_ndlc *ndlc = (struct llt_ndlc *)data;
261
262 pr_debug("\n");
263
264 schedule_work(&ndlc->sm_work);
265}
266
267int ndlc_probe(void *phy_id, struct nfc_phy_ops *phy_ops, struct device *dev,
24
25#define NDLC_TIMER_T1 100
26#define NDLC_TIMER_T1_WAIT 400
27#define NDLC_TIMER_T2 1200
28
29#define PCB_TYPE_DATAFRAME 0x80
30#define PCB_TYPE_SUPERVISOR 0xc0
31#define PCB_TYPE_MASK PCB_TYPE_SUPERVISOR

--- 229 unchanged lines hidden (view full) ---

261 struct llt_ndlc *ndlc = (struct llt_ndlc *)data;
262
263 pr_debug("\n");
264
265 schedule_work(&ndlc->sm_work);
266}
267
268int ndlc_probe(void *phy_id, struct nfc_phy_ops *phy_ops, struct device *dev,
268 int phy_headroom, int phy_tailroom, struct llt_ndlc **ndlc_id)
269 int phy_headroom, int phy_tailroom, struct llt_ndlc **ndlc_id,
270 struct st_nci_se_status *se_status)
269{
270 struct llt_ndlc *ndlc;
271
272 ndlc = devm_kzalloc(dev, sizeof(struct llt_ndlc), GFP_KERNEL);
273 if (!ndlc)
274 return -ENOMEM;
275
276 ndlc->ops = phy_ops;

--- 13 unchanged lines hidden (view full) ---

290 ndlc->t2_timer.function = ndlc_t2_timeout;
291
292 skb_queue_head_init(&ndlc->rcv_q);
293 skb_queue_head_init(&ndlc->send_q);
294 skb_queue_head_init(&ndlc->ack_pending_q);
295
296 INIT_WORK(&ndlc->sm_work, llt_ndlc_sm_work);
297
271{
272 struct llt_ndlc *ndlc;
273
274 ndlc = devm_kzalloc(dev, sizeof(struct llt_ndlc), GFP_KERNEL);
275 if (!ndlc)
276 return -ENOMEM;
277
278 ndlc->ops = phy_ops;

--- 13 unchanged lines hidden (view full) ---

292 ndlc->t2_timer.function = ndlc_t2_timeout;
293
294 skb_queue_head_init(&ndlc->rcv_q);
295 skb_queue_head_init(&ndlc->send_q);
296 skb_queue_head_init(&ndlc->ack_pending_q);
297
298 INIT_WORK(&ndlc->sm_work, llt_ndlc_sm_work);
299
298 return st_nci_probe(ndlc, phy_headroom, phy_tailroom);
300 return st_nci_probe(ndlc, phy_headroom, phy_tailroom, se_status);
299}
300EXPORT_SYMBOL(ndlc_probe);
301
302void ndlc_remove(struct llt_ndlc *ndlc)
303{
304 st_nci_remove(ndlc->ndev);
305
306 /* cancel timers */
307 del_timer_sync(&ndlc->t1_timer);
308 del_timer_sync(&ndlc->t2_timer);
309 ndlc->t2_active = false;
310 ndlc->t1_active = false;
311
312 skb_queue_purge(&ndlc->rcv_q);
313 skb_queue_purge(&ndlc->send_q);
314}
315EXPORT_SYMBOL(ndlc_remove);
301}
302EXPORT_SYMBOL(ndlc_probe);
303
304void ndlc_remove(struct llt_ndlc *ndlc)
305{
306 st_nci_remove(ndlc->ndev);
307
308 /* cancel timers */
309 del_timer_sync(&ndlc->t1_timer);
310 del_timer_sync(&ndlc->t2_timer);
311 ndlc->t2_active = false;
312 ndlc->t1_active = false;
313
314 skb_queue_purge(&ndlc->rcv_q);
315 skb_queue_purge(&ndlc->send_q);
316}
317EXPORT_SYMBOL(ndlc_remove);