public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@mandrakesoft.com>
To: Albert Cranford <ac9410@attbi.com>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	Kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: [patch 4/9]Four new i2c drivers and __init/__exit cleanup to i2c
Date: Sun, 15 Sep 2002 19:10:44 -0400	[thread overview]
Message-ID: <3D851374.8060402@mandrakesoft.com> (raw)
In-Reply-To: Pine.LNX.4.44.0209151837510.7637-200000@home1

Albert Cranford wrote:

> +static void pcf_epp_waitforpin(void) {
> +  int timeout = 10;
> +
> +  if (gpe.pe_irq > 0) {
> +    local_irq_disable();
> +    if (pcf_pending == 0) {
> +      interruptible_sleep_on_timeout(&pcf_wait, timeout*HZ);
> +      //udelay(100);
> +    } else {
> +      pcf_pending = 0;
> +    }
> +    local_irq_enable();
> +  } else {
> +    udelay(100);
> +  }
> +}

use a semaphore...  don't ever use local_irq_xxx() when you clearly 
don't need to


> +static void pcf_epp_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
> +  pcf_pending = 1;
> +  wake_up_interruptible(&pcf_wait);
> +  DEB3(printk(KERN_DEBUG "i2c-pcf-epp.o: in interrupt handler.\n"));
> +}
> +
> +
> +static int pcf_epp_init(void *data)
> +{
> +  if (check_region(gpe.pe_base, 5) < 0 ) {
> +    
> +    printk(KERN_WARNING "Could not request port region with base 0x%x\n", gpe.pe_base);
> +    return -ENODEV;
> +  } else {
> +    request_region(gpe.pe_base, 5, "i2c (EPP parallel port adapter)");
> +  }

race. never use check_region



> +  DEB3(printk(KERN_DEBUG "i2c-pcf-epp.o: init status port = 0x%x\n", inb(0x379)));
> +  
> +  if (gpe.pe_irq > 0) {
> +    if (request_irq(gpe.pe_irq, pcf_epp_handler, 0, "PCF8584", 0) < 0) {
> +      printk(KERN_NOTICE "i2c-pcf-epp.o: Request irq%d failed\n", gpe.pe_irq);
> +      gpe.pe_irq = 0;
> +    } else
> +      disable_irq(gpe.pe_irq);
> +    enable_irq(gpe.pe_irq);
> +  }

why do you disable then enable the irq here?



> +static void pcf_epp_inc_use(struct i2c_adapter *adap)
> +{
> +#ifdef MODULE
> +  MOD_INC_USE_COUNT;
> +#endif
> +}
> +
> +static void pcf_epp_dec_use(struct i2c_adapter *adap)
> +{
> +#ifdef MODULE
> +  MOD_DEC_USE_COUNT;
> +#endif
> +}

kill ifdefs, use ->owner if possible


> +#ifdef MODULE
> +MODULE_AUTHOR("Hans Berglund <hb@spacetec.no> \n modified by Ryosuke Tajima <rosk@jsk.t.u-tokyo.ac.jp>");
> +MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 EPP parallel port adapter");
> +
> +MODULE_PARM(base, "i");
> +MODULE_PARM(irq, "i");
> +MODULE_PARM(clock, "i");
> +MODULE_PARM(own, "i");
> +MODULE_PARM(i2c_debug, "i");
> +
> +int init_module(void) 
> +{
> +  return i2c_pcfepp_init();
> +}
> +
> +void cleanup_module(void) 
> +{
> +  i2c_pcf_del_bus(&pcf_epp_ops);
> +  pcf_epp_exit();
> +}
> +
> +#endif

kill ifdef, use module_init, module_exit



      reply	other threads:[~2002-09-15 23:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-15 22:39 [patch 4/9]Four new i2c drivers and __init/__exit cleanup to i2c Albert Cranford
2002-09-15 23:10 ` Jeff Garzik [this message]

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=3D851374.8060402@mandrakesoft.com \
    --to=jgarzik@mandrakesoft.com \
    --cc=ac9410@attbi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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