The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: "Ha, Tristram" <Tristram.Ha@Micrel.Com>
Cc: "Dave Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2.6.33 1/3] net: Micrel KSZ8841/2 PCI Ethernet driver
Date: Sat, 16 Jan 2010 14:50:14 +0000	[thread overview]
Message-ID: <20100116145014.172ad340@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <14385191E87B904DBD836449AA30269D021A4A@MORGANITE.micrel.com>

> +/*
> + * PCI Configuration Space Registers
> + */

We have existing standard defines for most of these that should be used
instead where relevant. The code appears not use most of these defines
for generic PCI stuff anyway.


> +#define PORT_CTRL_ADDR(port, addr)		\
> +	(addr = KS8842_PORT_1_CTRL_1 + port *	\
> +		(KS8842_PORT_2_CTRL_1 - KS8842_PORT_1_CTRL_1))

Brackets around port so that things like PORT_CTRL_ADDR(x + 1) work
as expected


> +/*
> + * Hardware register access macros
> + */
> +
> +#define hw_dis_intr_sync(hw)	hw_dis_intr(hw)
> +
> +#define HW_R8(hw, addr, data)	(*(data) = readb((hw)->ioaddr + (addr)))
> +#define HW_W8(hw, addr, data)	writeb((data), (hw)->ioaddr + (addr))
> +
> +#define HW_R16(hw, addr, data)	(*(data) = readw((hw)->ioaddr + (addr)))
> +#define HW_W16(hw, addr, data)	writew((data), (hw)->ioaddr + (addr))
> +
> +#define HW_R32(hw, addr, data)	(*(data) = readl((hw)->ioaddr + (addr)))
> +#define HW_W32(hw, addr, data)	writel((data), (hw)->ioaddr + (addr))
> +
> +#define HW_PCI_READ_BYTE(hw, addr, data)				\
> +	pci_read_config_byte((struct pci_dev *) (hw)->pdev, addr, data)
> +
> +#define HW_PCI_READ_WORD(hw, addr, data)				\
> +	pci_read_config_word((struct pci_dev *) (hw)->pdev, addr, data)
> +
> +#define HW_PCI_READ_DWORD(hw, addr, data)				\
> +	pci_read_config_dword((struct pci_dev *) (hw)->pdev, addr, data)
> +
> +#define HW_PCI_WRITE_BYTE(hw, addr, data)				\
> +	pci_write_config_byte((struct pci_dev *) (hw)->pdev, addr, data)
> +
> +#define HW_PCI_WRITE_WORD(hw, addr, data)				\
> +	pci_write_config_word((struct pci_dev *) (hw)->pdev, addr, data)
> +
> +#define HW_PCI_WRITE_DWORD(hw, addr, data)				\
> +	pci_write_config_dword((struct pci_dev *) (hw)->pdev, addr, data)

This sort of stuff just obfuscates things so the defines ought to get
removed so the code is more readable to all (remember the Linux kernel
code needs to be generally readable not just readable by Micrel people)


> + * delay_milli - delay in millisecond
> + * @millisec:	Number of milliseconds to delay.
> + *
> + * This routine delays in milliseconds.
> + */
> +static void delay_milli(uint millisec)
> +{
> +	unsigned long ticks = millisec * HZ / 1000;
> +
> +	if (!ticks || in_interrupt())
> +		mdelay(millisec);
> +	else {
> +		set_current_state(TASK_INTERRUPTIBLE);
> +		schedule_timeout(ticks);

msleep() is probably what you want for this part ? Note that you really
don't want to be spinning for milliseconds in the IRQ paths if at all
possible.

The DEBUG ioctl is a bit odd - you define it and it does nothing - just a
left over ?



> +
> +#define PCI_VENDOR_ID_KS884X		0x16C6
> +#define PCI_DEVICE_ID_KS8841		0x8841
> +#define PCI_DEVICE_ID_KS8842		0x8842

Those belong in the pci device id header.


In your pci init function you do the following

> +	hw->pdev = pdev;


If you make a private copy of pdev in your struct you should refcount it
and use pci_dev_get/pci_dev_put when you take and release the reference.


The proc stuff probably belongs in sysfs nowdays



  parent reply	other threads:[~2010-01-16 14:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-16  2:57 [PATCH 2.6.33 1/3] net: Micrel KSZ8841/2 PCI Ethernet driver Ha, Tristram
2010-01-16  9:20 ` David Miller
2010-01-19 20:03   ` Ha, Tristram
2010-01-19 21:40     ` Stephen Hemminger
2010-01-19 23:48       ` Ha, Tristram
2010-01-20  0:11         ` Stephen Hemminger
2010-01-20  0:34           ` Ha, Tristram
2010-01-20  0:50             ` Stephen Hemminger
2010-01-16 14:50 ` Alan Cox [this message]
2010-01-19 21:22   ` Ha, Tristram
2010-01-19 21:32     ` Alan Cox
2010-01-20  0:12       ` Ha, Tristram
2010-01-16 16:00 ` Michał Mirosław
2010-01-16 16:16   ` Felix Fietkau
2010-01-19 21:51     ` Ha, Tristram
2010-01-19 22:11       ` Felix Fietkau
  -- strict thread matches above, loose matches on Subject: below --
2010-02-08 21:36 Ha, Tristram

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=20100116145014.172ad340@lxorguk.ukuu.org.uk \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=Tristram.Ha@Micrel.Com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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