public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Pavel Machek <pavel@ucw.cz>
Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	jkosina@suse.cz, benm@symmetric.co.nz, stephen@symmetric.co.nz
Subject: Re: [PATCH] ipwireless: driver for 3G PC Card
Date: Fri, 1 Feb 2008 16:21:26 +0100	[thread overview]
Message-ID: <200802011621.27239.dsterba@suse.cz> (raw)
In-Reply-To: <20080130134046.GB5139@elf.ucw.cz>

Hi,

> > +/* DCR bits */
> > +#define DCR_RXDONE      ((unsigned short) 0x1)
> > +#define DCR_TXDONE      ((unsigned short) 0x2)
> > +#define DCR_RXRESET     ((unsigned short) 0x4)
> > +#define DCR_TXRESET     ((unsigned short) 0x8)
>
> Are those casts neccessary?

No, removed.

> > +/* I/O ports and bit definitions for version 2 of the hardware */
> > +
> > +struct MEMCCR {
> > +	unsigned short PCCOR;		/* Configuration Option Register */
> > +	unsigned short PCCSR;		/* Configuration and Status Register */
> > +	unsigned short PCPRR;		/* Pin Replacemant Register */
> > +	unsigned short PCSCR;		/* Socket and Copy Register */
> > +	unsigned short PCESR;		/* Extendend Status Register */
> > +	unsigned short PCIOB;		/* I/O Base Register */
> > +};
>
> Could we get better names? PCIOB is cryptic, pci_io_base is pretty
> good.

Ok, changed to eg. reg_config_and_status.

> > +/* Signals from DTE */
> > +enum ComCtrl_DTESignal {
> > +	ComCtrl_RTS = 0,
> > +	ComCtrl_DTR = 1
> > +};
>
> CamelCaseIsEvil.

Converted to underscores.

>
> > +static irqreturn_t ipwireless_handle_v1_interrupt(int irq,
> > +						  struct ipw_hardware *hw)
> > +{
> > +	unsigned short irqn;
> > +	unsigned short ack;
> > +
> > +	irqn = inw(hw->base_port + IOIR);
> > +
> > +	/* Check if card is present */
> > +	if (irqn == (unsigned short) 0xFFFF) {
> > +		if (++hw->bad_interrupt_count >= 100) {
> > +			/*
> > +			 * It is necessary to disable the interrupt at this
> > +			 * point, or the kernel hangs, interrupting repeatedly
> > +			 * forever.
> > +			 */
> > +			hw->irq = irq;
> > +			hw->removed = 1;
> > +			disable_irq_nosync(irq);
> > +			printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME
> > +					": Mr. Fluffy is not happy!\n");
> > +		}
> > +		return IRQ_HANDLED;
>
> Not sure how this is supposed to work. If you assume unshared
> interrupts, it should be possible to return something and make core
> care.
>
> If you are assuming shared interrupts, either you should disable on
> first 0xFFFF (are you sure cast is needed, btw?), or not at all,
> because it could be the other device sedning you 100 of those...
>
> ...so which one is it?

Shared. It'll check if device has interrupt pending, else exit.

> Is some locking needed around *hw?

Some items are set during initial phase and read only afterwards. This don't 
need to be protected. Nevetheless, I've found some missing locking around 
tx_ready and rx_ready which might cause bugs (eg. hangs).

>
> > +int ipwireless_send_packet(struct ipw_hardware *hw, unsigned int
> > channel_idx, +			    unsigned char *data, unsigned int length,
> > +			    void (*callback) (void *cb, unsigned int length),
> > +			    void *callback_data)
> > +{
> > +	struct ipw_tx_packet *packet;
> > +
> > +	packet = alloc_data_packet(length,
> > +			       (unsigned char) (channel_idx + 1),
> > +			       TL_PROTOCOLID_COM_DATA);
> > +	if (!packet)
> > +		return -1;
>
> -ENOMEM would be more usual calling convention.

Done.

>
> > +struct ipw_setup_get_version_query_packet {
> > +	struct ipw_tx_packet header;
> > +	struct TlSetupGetVersionQry body;
> > +};
>
> MoreEvilCamelCase.

Converted.

> > +static int config_ipwireless(struct ipw_dev *ipw)
> > +{
> > +	struct pcmcia_device *link = ipw->link;
> > +	int ret;
> > +	config_info_t conf;
> > +	tuple_t tuple;
> > +	unsigned short buf[64];
> > +	cisparse_t parse;
> > +	unsigned short cor_value;
> > +	win_req_t reqAM;
> > +	win_req_t reqCM;
>
> Hiding structs BehindTypedefsIsEvil.

Unfortunatelly PCMCIA subsystem is full of these and all drivers use them. 
I'll stay consistent for now.

Updated patch v4 will follow.

dave

  parent reply	other threads:[~2008-02-01 15:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-28 17:19 [PATCH] ipwireless: driver for 3G PC Card David Sterba
2008-01-28 17:53 ` Alexey Dobriyan
2008-01-30 13:28   ` Pavel Machek
2008-01-28 18:08 ` Randy Dunlap
2008-01-28 23:18   ` Jiri Slaby
2008-01-28 23:28     ` Randy Dunlap
2008-01-28 23:29       ` Jiri Slaby
2008-01-28 23:33         ` Randy Dunlap
2008-01-29  6:22           ` Pekka Enberg
2008-01-29 13:42     ` David Sterba
2008-01-29 13:40   ` David Sterba
2008-01-30 13:40 ` Pavel Machek
2008-01-30 21:29   ` Stephen Blackheath [to Foxconn]
2008-01-30 23:15     ` Pavel Machek
2008-02-01 15:21   ` David Sterba [this message]
2008-02-01 23:43     ` Pavel Machek

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=200802011621.27239.dsterba@suse.cz \
    --to=dsterba@suse.cz \
    --cc=benm@symmetric.co.nz \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=stephen@symmetric.co.nz \
    --cc=torvalds@linux-foundation.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