treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / media / pci / bt8xx / bttv-if.c
blob363c84bac590a4cdafc3f3dc8ceea01ee8b3f6f4
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
4 bttv-if.c -- old gpio interface to other kernel modules
5 don't use in new code, will go away in 2.7
6 have a look at bttv-gpio.c instead.
8 bttv - Bt848 frame grabber driver
10 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
11 & Marcus Metzler (mocm@thp.uni-koeln.de)
12 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/delay.h>
20 #include <asm/io.h>
22 #include "bttvp.h"
24 EXPORT_SYMBOL(bttv_get_pcidev);
25 EXPORT_SYMBOL(bttv_gpio_enable);
26 EXPORT_SYMBOL(bttv_read_gpio);
27 EXPORT_SYMBOL(bttv_write_gpio);
29 /* ----------------------------------------------------------------------- */
30 /* Exported functions - for other modules which want to access the */
31 /* gpio ports (IR for example) */
32 /* see bttv.h for comments */
34 struct pci_dev* bttv_get_pcidev(unsigned int card)
36 if (card >= bttv_num)
37 return NULL;
38 if (!bttvs[card])
39 return NULL;
41 return bttvs[card]->c.pci;
45 int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data)
47 struct bttv *btv;
49 if (card >= bttv_num) {
50 return -EINVAL;
53 btv = bttvs[card];
54 if (!btv)
55 return -ENODEV;
57 gpio_inout(mask,data);
58 if (bttv_gpio)
59 bttv_gpio_tracking(btv,"extern enable");
60 return 0;
63 int bttv_read_gpio(unsigned int card, unsigned long *data)
65 struct bttv *btv;
67 if (card >= bttv_num) {
68 return -EINVAL;
71 btv = bttvs[card];
72 if (!btv)
73 return -ENODEV;
75 if(btv->shutdown) {
76 return -ENODEV;
79 /* prior setting BT848_GPIO_REG_INP is (probably) not needed
80 because we set direct input on init */
81 *data = gpio_read();
82 return 0;
85 int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data)
87 struct bttv *btv;
89 if (card >= bttv_num) {
90 return -EINVAL;
93 btv = bttvs[card];
94 if (!btv)
95 return -ENODEV;
97 /* prior setting BT848_GPIO_REG_INP is (probably) not needed
98 because direct input is set on init */
99 gpio_bits(mask,data);
100 if (bttv_gpio)
101 bttv_gpio_tracking(btv,"extern write");
102 return 0;