All of lore.kernel.org
 help / color / mirror / Atom feed
From: olof@lixom.net (Olof Johansson)
To: Christoph Hellwig <hch@infradead.org>,
	linux-pcmcia@lists.infradead.org, akpm@osdl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] pcmcia: export pcmcia_bus_type
Date: Sun, 13 May 2007 18:51:28 -0500	[thread overview]
Message-ID: <20070513235128.GA25128@lixom.net> (raw)
In-Reply-To: <20070513231029.GC28855@flint.arm.linux.org.uk>

Hi,

On Mon, May 14, 2007 at 12:10:29AM +0100, Russell King wrote:
> Some random review comments on your driver, while I was passing.  Spotted
> a few things.

Thanks, I appreciate the feedback.

> On Sun, May 13, 2007 at 04:40:07PM -0500, Olof Johansson wrote:
> > +#include <linux/module.h>
> > +#include <linux/kernel.h>
> > +#include <linux/sched.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/platform_device.h>
> 
> Silly duplicate includes.

Silly indeed.

> > +#include <linux/errno.h>
> > +#include <linux/init.h>
> > +#include <linux/delay.h>
> > +#include <linux/interrupt.h>
> > +
> > +#include <pcmcia/ss.h>
> > +#include <asm/of_platform.h>
> > +
> > +static const char driver_name[] = "electra-cf";
> >...
> > +static int electra_cf_get_status(struct pcmcia_socket *s, u_int *sp)
> > +{
> > +	struct electra_cf_socket *cf;
> > +
> > +	if (!sp)
> > +		return -EINVAL;
> 
> Never called with a NULL argument, so useless check.

Ok. Carried over from omap_cf, but I'll definitely fix it here.

> > +
> > +	cf = container_of(s, struct electra_cf_socket, socket);
> > +
> > +	/* NOTE CF is always 3VCARD */
> > +	if (electra_cf_present(cf)) {
> > +		struct electra_cf_socket *cf;
> > +
> > +		*sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD;
> > +		cf = container_of(s, struct electra_cf_socket, socket);
> > +		s->pci_irq = cf->irq;
> > +	} else
> > +		*sp = 0;
> > +	return 0;
> > +}
> >...
> > +static int electra_cf_ss_suspend(struct pcmcia_socket *s)
> > +{
> > +	pr_debug("%s: %s\n", driver_name, __FUNCTION__);
> > +	return electra_cf_set_socket(s, &dead_socket);
> > +}
> 
> That's already done for you.  Remove this function entirely and set
> the ".suspend" method to NULL.

Thanks, will do.

> 
> > +static int electra_cf_set_io_map(struct pcmcia_socket *s,
> > +				 struct pccard_io_map *io)
> > +{
> > +	struct electra_cf_socket *cf;
> > +
> > +	cf = container_of(s, struct electra_cf_socket, socket);
> > +	io->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT;
> > +	io->start = (unsigned long)cf->io_base;
> > +	io->stop = (unsigned long)cf->io_base + 0x800 - 1;
> > +	return 0;
> > +}
> 
> PCMCIA code will ignore your writes to 'io'.  Therefore, does this
> do anything useful?  If not, an empty function will do.

Not sure if it does, it came over from omap_cf with some modifications
by me.  I'll take a closer look when I rework the rest of the I/O
mapping stuff.

> > +	cf->socket.owner = THIS_MODULE;
> > +	cf->socket.dev.parent = &ofdev->dev;
> > +	cf->socket.ops = &electra_cf_ops;
> > +	cf->socket.resource_ops = &pccard_static_ops;
> > +	cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP |
> > +				SS_CAP_MEM_ALIGN;
> > +	cf->socket.map_size = 0x800;
> > +	cf->socket.io[0].res = &cf->iomem;
> 
> Not a good idea - PCMCIA manages this resources itself and will free it
> when the card is removed.  Use ss_cap_static_map and socket.io_offset.

Right, I'm going to rework those parts alltogether.

> > +static int __devexit electra_cf_remove(struct of_device *ofdev)
> > +{
> > +	struct device *device = &ofdev->dev;
> > +	struct electra_cf_socket *cf;
> > +
> > +	cf = dev_get_drvdata(device);
> > +
> > +	cf->active = 0;
> > +	pcmcia_unregister_socket(&cf->socket);
> > +	del_timer_sync(&cf->timer);
> > +	free_irq(cf->irq, cf);
> 
> What if an IRQ occurs after the timer has been deleted?  Doesn't the
> interrupt handler re-add the timer back?

Ah, yes, good point.


Thanks,

-Olof

  reply	other threads:[~2007-05-13 23:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-12 15:33 [PATCH] pcmcia: export pcmcia_bus_type Olof Johansson
2007-05-12 18:06 ` [PATCH v2] " Olof Johansson
2007-05-13 21:20   ` Christoph Hellwig
2007-05-13 21:40     ` Olof Johansson
2007-05-13 23:10       ` Russell King
2007-05-13 23:51         ` Olof Johansson [this message]
2007-05-15  4:36   ` [PATCH v3] pcmcia: export pcmcia_bus_type (GPL-only) Olof Johansson

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=20070513235128.GA25128@lixom.net \
    --to=olof@lixom.net \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pcmcia@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.