AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
afhba_devman.c
Go to the documentation of this file.
1 /* ------------------------------------------------------------------------- *
2  * afhba_devman.c
3  * ------------------------------------------------------------------------- *
4  * Copyright (C) 2014 Peter Milne, D-TACQ Solutions Ltd
5  * <peter dot milne at D hyphen TACQ dot com>
6  * www.d-tacq.com
7  * Created on: 10 Aug 2014
8  * Author: pgm
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of Version 2 of the GNU General Public License *
12  * as published by the Free Software Foundation; *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the Free Software *
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* ------------------------------------------------------------------------- */
23 
24 
25 #include "acq-fiber-hba.h"
26 
28 {
29  dev_dbg(pdev(adev), "name %s", adev->name);
30  list_add_tail(&adev->list, &afhba_devices);
31  return 0;
32 }
33 
34 void afhba_deleteDevice(struct AFHBA_DEV *adev)
35 {
36  list_del(&adev->list);
37  kfree(adev);
38 }
40 {
41  struct AFHBA_DEV *pos;
42 
43  list_for_each_entry(pos, &afhba_devices, list){
44  if (pos->major == major){
45  return pos;
46  }
47  }
48  BUG();
49  return 0;
50 }
51 
52 struct AFHBA_DEV *afhba_lookupDeviceFromClass(struct device *dev)
53 {
54  struct AFHBA_DEV *pos;
55 
56  list_for_each_entry(pos, &afhba_devices, list){
57  if (pos->class_dev == dev){
58  return pos;
59  }
60  }
61  BUG();
62  return 0;
63 }
64 
66 {
67  struct AFHBA_DEV *pos;
68 
69  list_for_each_entry(pos, &afhba_devices, list){
70  if (pos->pci_dev == pci_dev){
71  return pos;
72  }
73  }
74  BUG();
75  return 0;
76 }
77 
78 struct AFHBA_DEV* afhba_lookupDev(struct device *dev)
79 {
80  struct AFHBA_DEV *pos;
81 
82  list_for_each_entry(pos, &afhba_devices, list){
83  if (&pos->pci_dev->dev == dev){
84  return pos;
85  }
86  }
87  BUG();
88  return 0;
89 }
afhba_lookupDeviceFromClass
struct AFHBA_DEV * afhba_lookupDeviceFromClass(struct device *dev)
Definition: afhba_devman.c:52
pdev
#define pdev(adev)
Definition: acq-fiber-hba.h:176
AFHBA_DEV::major
int major
Definition: acq-fiber-hba.h:118
afhba_registerDevice
int afhba_registerDevice(struct AFHBA_DEV *adev)
Definition: afhba_devman.c:27
afhba_lookupDevice
struct AFHBA_DEV * afhba_lookupDevice(int major)
Definition: afhba_devman.c:39
afhba_deleteDevice
void afhba_deleteDevice(struct AFHBA_DEV *adev)
Definition: afhba_devman.c:34
afhba_lookupDevicePci
struct AFHBA_DEV * afhba_lookupDevicePci(struct pci_dev *pci_dev)
Definition: afhba_devman.c:65
afhba_devices
struct list_head afhba_devices
AFHBA_DEV::list
struct list_head list
Definition: acq-fiber-hba.h:119
AFHBA_DEV::class_dev
struct device * class_dev
Definition: acq-fiber-hba.h:116
AFHBA_DEV
Definition: acq-fiber-hba.h:111
AFHBA_DEV::name
char name[16]
Definition: acq-fiber-hba.h:112
afhba_lookupDev
struct AFHBA_DEV * afhba_lookupDev(struct device *dev)
Definition: afhba_devman.c:78
acq-fiber-hba.h
AFHBA_DEV::pci_dev
struct pci_dev * pci_dev
Definition: acq-fiber-hba.h:115