All of lore.kernel.org
 help / color / mirror / Atom feed
From: marc@cpdesign.com.au (Marc Reilly)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] Added i2c support for mc13xxx-core
Date: Wed, 8 Dec 2010 19:07:55 +1100	[thread overview]
Message-ID: <201012081907.55980.marc@cpdesign.com.au> (raw)
In-Reply-To: <AANLkTikuhKAsgY-9X+FUzeL5piv5S6Cy4_RXdiAD0efP@mail.gmail.com>

Hi Yong,

> It's better to use git format-patch to gernerate patch for review, by
> which you can add some commit information and s-o-b stuff.

I've submitted a (slightly) better patch earlier today. (although this was 
generated via format-patch, I forgot the sob.). 

My main hope was to get some indication that I was progressing along the right 
path.

> Please see inline comments.
Thanks, replies also in-line.

snip...

> > +               if (usespi) {
> > +                       const struct spi_device_id *devid =
> > +                               spi_get_device_id(mc13xxx->spidev);
> > +                       if (!devid || devid->driver_data !=
> > mc13xxx->icid) +                               dev_warn(mc13xxx->pdev,
> > "device id doesn't " +                                              
> > "match auto detection!\n"); +               } else {
> > +                       /* TODO */
> 
> todo what? remove this or add real code here.
> 

I wasn't immediately sure of what the equivalent way to do this via the i2c 
subsystem is. I'm not sure how useful it would be anyway, so I'll leave it out 
in future.

snip ...

> > +       mutex_init(&mc13xxx->lock);
> > +       mc13xxx_lock(mc13xxx);
> > +
> > +       ret = mc13xxx_identify(mc13xxx, 0);
> > +       if (ret || (mc13xxx->icid == MC13XXX_ID_INVALID))
> > +               goto err_revision;
> > +
> > +       /* mask all irqs */
> > +       ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK0, 0x00ffffff);
> > +       if (ret)
> > +               goto err_mask;
> > +
> > +       ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK1, 0x00ffffff);
> > +       if (ret)
> > +               goto err_mask;
> > +
> > +       ret = request_threaded_irq(mc13xxx->irq, NULL,
> > mc13xxx_irq_thread, +                       IRQF_ONESHOT |
> > IRQF_TRIGGER_HIGH, "mc13xxx", mc13xxx); +
> > +       if (ret) {
> > +err_mask:
> 
> > +err_revision:
> Why two labels here?

Copied from existing code. 

> Also, if ret == 0, the lock will not be released.

The lock is released in mc13xxx_common_probe. 
Yes, it would be better in this function, before common_probe is called.

> 
> > +               mutex_unlock(&mc13xxx->lock);
> > +               kfree(mc13xxx);
> > +               return ret;
> > +       }
> > +
> > +       return mc13xxx_common_probe(mc13xxx,pdata);
> > +}
> > +
> > +static int __devexit mc13xxx_i2c_remove(struct i2c_client *client)
> > +{
> > +       struct mc13xxx *mc13xxx = dev_get_drvdata(&client->dev);
> > +
> > +       free_irq(mc13xxx->irq, mc13xxx);
> > +
> > +       mfd_remove_devices(&client->dev);
> > +
> > +       kfree(mc13xxx);
> > +
> > +       return 0;
> > +}
> > +
> > +static const struct i2c_device_id mc13xxx_i2c_idtable[] = {
> > +       { "mc13892", MC13XXX_ID_MC13892},
> > +       { }
> 
> you may want to remove empty '{}'

Again, mimicking the existing spi device table.

> 
> > +};
> > +
> > +static struct i2c_driver mc13xxx_i2c_driver = {
> > +       .driver = {
> > +               .owner = THIS_MODULE,
> > +               .name = "mc13xxx-i2c"
> > +       },
> > +       .id_table = mc13xxx_i2c_idtable,
> > +       .probe = mc13xxx_i2c_probe,
> > +       .remove = __devexit_p(mc13xxx_i2c_remove),
> >  };
> > 
> >  static int __init mc13xxx_init(void)
> >  {
> > -       return spi_register_driver(&mc13xxx_driver);
> > +       int i2cret;
> > +       int spiret;
> > +       i2cret = i2c_add_driver(&mc13xxx_i2c_driver);
> > +       spiret = spi_register_driver(&mc13xxx_driver);
> > +
> > +       return (i2cret == 0) && (spiret == 0);

For the record, I missed this, its fixed in my later patch. Return should be 0 
if both are successful.

Cheers,
Marc

  reply	other threads:[~2010-12-08  8:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-06  6:25 [PATCH] support PMIC mc13892 yong.shen at freescale.com
2010-12-06  7:22 ` Uwe Kleine-König
2010-12-07  2:41   ` Yong Shen
2010-12-07  7:57   ` Yong Shen
2010-12-07  8:02     ` Uwe Kleine-König
2010-12-06 10:40 ` David Jander
2010-12-07  2:50   ` Yong Shen
2010-12-06 10:55 ` Arnaud Patard (Rtp)
2010-12-06 11:42   ` Alberto Panizzo
2010-12-06 11:55     ` Arnaud Patard (Rtp)
2010-12-06 13:12       ` Alberto Panizzo
2010-12-07  2:52   ` Yong Shen
2010-12-06 21:54 ` Marc Reilly
2010-12-07  7:14   ` [PATCH] Added i2c support for mc13xxx-core Marc Reilly
2010-12-07  8:32     ` Yong Shen
2010-12-07 10:09       ` Marc Reilly
2010-12-08  6:24     ` Yong Shen
2010-12-08  8:07       ` Marc Reilly [this message]
2010-12-08 10:42         ` Uwe Kleine-König
2010-12-07  7:23   ` Marc Reilly
2010-12-07  7:23   ` Marc Reilly
     [not found] <1291761693-29689-2-git-send-email-marc@cpdesign.com.au>
2010-12-07 22:52 ` Marc Reilly
2010-12-08  8:38   ` Uwe Kleine-König

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=201012081907.55980.marc@cpdesign.com.au \
    --to=marc@cpdesign.com.au \
    --cc=linux-arm-kernel@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.