public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Michael Buesch <mb@bu3sch.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	mchehab@infradead.org,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	David Brownell <david-b@pacbell.net>
Subject: Re: [PATCH v3] Add bt8xxgpio driver
Date: Thu, 10 Jul 2008 20:15:38 +0200	[thread overview]
Message-ID: <487651CA.6030405@gmail.com> (raw)
In-Reply-To: <200807101914.10174.mb@bu3sch.de>

<Moved from the bottom>
+A·generic·digital·24-port·PCI·GPIO·card·can·be·built·out·of·an·ordinary
+Brooktree·bt848,·bt849,·bt878·or·bt879·based·analog·TV·tuner·card.·The
+Brooktree·chip·is·used·in·old·analog·Hauppauge·WinTV·PCI·cards.·You·can·easily
+find·them·used·for·low·prices·on·the·net.

Thanks for that!

On 07/10/2008 07:14 PM, Michael Buesch wrote:
> Index: linux-next/drivers/gpio/bt8xxgpio.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ linux-next/drivers/gpio/bt8xxgpio.c	2008-07-10 19:05:56.000000000 +0200
> @@ -0,0 +1,348 @@
[...]
> +static int bt8xxgpio_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
> +{
> +	struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio);
> +	unsigned long flags;
> +	u32 outen, data;
> +
> +	spin_lock_irqsave(&bg->lock, flags);

Why all those irq variants? I can't see interrupts anywhere. May gpio call this 
from irq?

> +
> +	data = bgread(BT848_GPIO_DATA);
> +	data &= ~(1 << nr);
> +	bgwrite(data, BT848_GPIO_DATA);
> +
> +	outen = bgread(BT848_GPIO_OUT_EN);
> +	outen &= ~(1 << nr);
> +	bgwrite(outen, BT848_GPIO_OUT_EN);

some flushing of posted values here?

> +	spin_unlock_irqrestore(&bg->lock, flags);
> +
> +	return 0;
> +}
[...]
> +static int bt8xxgpio_gpio_direction_output(struct gpio_chip *gpio,
> +					unsigned nr, int val)
> +{
> +	struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio);
> +	unsigned long flags;
> +	u32 outen, data;
> +
> +	spin_lock_irqsave(&bg->lock, flags);
> +
> +	outen = bgread(BT848_GPIO_OUT_EN);
> +	outen |= (1 << nr);
> +	bgwrite(outen, BT848_GPIO_OUT_EN);
> +
> +	data = bgread(BT848_GPIO_DATA);
> +	if (val)
> +		data |= (1 << nr);
> +	else
> +		data &= ~(1 << nr);
> +	bgwrite(data, BT848_GPIO_DATA);

and here

> +
> +	spin_unlock_irqrestore(&bg->lock, flags);
> +
> +	return 0;
> +}
> +
> +static void bt8xxgpio_gpio_set(struct gpio_chip *gpio,
> +			    unsigned nr, int val)
> +{
> +	struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio);
> +	unsigned long flags;
> +	u32 data;
> +
> +	spin_lock_irqsave(&bg->lock, flags);
> +
> +	data = bgread(BT848_GPIO_DATA);
> +	if (val)
> +		data |= (1 << nr);
> +	else
> +		data &= ~(1 << nr);
> +	bgwrite(data, BT848_GPIO_DATA);

and here and further in the code

> +	spin_unlock_irqrestore(&bg->lock, flags);
> +}
[...]
> +static int bt8xxgpio_probe(struct pci_dev *dev,
> +			const struct pci_device_id *pci_id)
> +{
> +	struct bt8xxgpio *bg;
> +	int err;
> +
> +	bg = kzalloc(sizeof(*bg), GFP_KERNEL);
> +	if (!bg)
> +		return -ENOMEM;
> +
> +	bg->pdev = dev;
> +	spin_lock_init(&bg->lock);
> +
> +	err = pci_enable_device(dev);
> +	if (err) {
> +		printk(KERN_ERR "bt8xxgpio: Can't enable device.\n");

dev_err() et al. all over here.

> +		goto err_freebg;
> +	}
> +	if (!request_mem_region(pci_resource_start(dev, 0),
> +				pci_resource_len(dev, 0),
> +				"bt8xxgpio")) {

pci_request_region();?

> +		printk(KERN_WARNING
> +		       "bt8xxgpio: Can't request iomem (0x%llx).\n",
> +		       (unsigned long long)pci_resource_start(dev, 0));

You don't need to print the value out, we can see it in lspci.

> +		err = -EBUSY;
> +		goto err_disable;
> +	}
> +	pci_set_master(dev);
> +	pci_set_drvdata(dev, bg);
> +
> +	bg->mmio = ioremap(pci_resource_start(dev, 0), 0x1000);
> +	if (!bg->mmio) {
> +		printk(KERN_ERR "bt8xxgpio: ioremap() failed\n");
> +		err = -EIO;
> +		goto err_release_mem;
> +	}
[...]
> +static int bt8xxgpio_resume(struct pci_dev *pdev)
> +{
> +	struct bt8xxgpio *bg = pci_get_drvdata(pdev);
> +	unsigned long flags;
> +	int err;
> +
> +	pci_set_power_state(pdev, 0);

No need to set that state again (PCI layer cares).

> +	err = pci_enable_device(pdev);
> +	if (err)
> +		return err;
> +	pci_restore_state(pdev);
> +
> +	spin_lock_irqsave(&bg->lock, flags);
[...]
> +static int bt8xxgpio_init(void)

__init

> +{
> +	return pci_register_driver(&bt8xxgpio_pci_driver);
> +}
> +module_init(bt8xxgpio_init)
> +
> +static void bt8xxgpio_exit(void)

__exit

> +{
> +	pci_unregister_driver(&bt8xxgpio_pci_driver);
> +}
> +module_exit(bt8xxgpio_exit)


  reply	other threads:[~2008-07-10 18:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-10 17:14 [PATCH v3] Add bt8xxgpio driver Michael Buesch
2008-07-10 18:15 ` Jiri Slaby [this message]
2008-07-10 18:44   ` Michael Buesch
2008-07-10 20:02   ` David Brownell
2008-07-11 12:53     ` Michael Buesch
2008-07-10 19:02 ` Mauro Carvalho Chehab
2008-07-10 19:12   ` Michael Buesch
2008-07-10 19:33     ` Mauro Carvalho Chehab
2008-07-11 13:00       ` Michael Buesch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=487651CA.6030405@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david-b@pacbell.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mb@bu3sch.de \
    --cc=mchehab@infradead.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox