Re: [PATCHv4 2.6.25] i2c: adds support for i2c bus on Freescale CPM1/CPM2 controllers

2008-02-24 Thread Jon Smirl
On 2/22/08, Jochen Friedrich <[EMAIL PROTECTED]> wrote:
> Hi Jean,
>
>
>  >> +/*
>  >> + * Wait for patch from Jon Smirl
>  >> + * #include "powerpc-common.h"
>  >> + */
>  >
>  > It doesn't make sense to merge this comment upstream.
>
>
> I know you don't like the patch from Jon Smirl and you also explained your 
> reasons.
>  Fortunately, I2c no longer uses numeric device IDs but names. So what are 
> the alternatives?
>
>  1. modify the I2c subsystem to accept OF names additionally to I2c names 
> (proposed by Jon smirl).

The correct statement is: modify the i2c subsystem to support the
standard kernel driver aliasing mechanism. Leaving powerpc and OF out
of the argument for the moment, i2c has a custom aliasing scheme on
the x86 too.

So as a first step, can we remove the custom i2c aliasing scheme and
change i2c to use standard module aliases on the x86? Patches for this
already exist.

On 2/23/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> The problem I have with this is that it breaks compatibility. The chip
>  name is not only used for device/driver matching, it is also exported
>  to userspace as a sysfs attribute ("name"). Applications might rely on
>  it. At least libsensors does.

I think there is some confusion here. The OF aliases are only used by
the kernel to load the correct driver. Would doing something like this
help?

static struct i2c_device_id pcf8563_id[] = {
{"pcf8563", 0, "sysfs_legacy_name"},
{"rtc8564", 0, "sysfs_legacy_name"},
OF_ID("phillips,pcf8563", _id[0], 0)
OF_ID("epson,rtc8564", _id[1], 0)
{},
};
MODULE_DEVICE_TABLE(i2c, pcf8563_id);

Then in the probe function you can use the pointer to find the base id
entry and i2c never has to be aware that the OF alias exists.

>  2. record the I2c name in the dts tree, either as separate tag (like 
> linux,i2c-name="")

Not really practical for the millions of machines (all PowerPC Macs)
already shipped.

>or as additional compatible entry (like compatible="...", 
> "linux,").
>  3. use a glue layer with a translation map.

Audio codecs have exactly the same problem. There are probably other
devices that also need mapping.

This mapping table will need to contain a map from the OF names to the
kernel driver names.  It will need to stored permanently in RAM and
contain all possible mappings. This table will only grow in size.

The kernel has a widely used mechanism for mapping -- aliases in the
device drivers. Why do we want to build a new, parallel one?

What we are doing now is option 4.

4. Use kconfig to build custom kernels for each target system. Don't
load drivers automatically based on what the BIOS tells us.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv4 2.6.25] i2c: adds support for i2c bus on Freescale CPM1/CPM2 controllers

2008-02-24 Thread Jon Smirl
On 2/22/08, Jochen Friedrich [EMAIL PROTECTED] wrote:
 Hi Jean,


   +/*
   + * Wait for patch from Jon Smirl
   + * #include powerpc-common.h
   + */
  
   It doesn't make sense to merge this comment upstream.


 I know you don't like the patch from Jon Smirl and you also explained your 
 reasons.
  Fortunately, I2c no longer uses numeric device IDs but names. So what are 
 the alternatives?

  1. modify the I2c subsystem to accept OF names additionally to I2c names 
 (proposed by Jon smirl).

The correct statement is: modify the i2c subsystem to support the
standard kernel driver aliasing mechanism. Leaving powerpc and OF out
of the argument for the moment, i2c has a custom aliasing scheme on
the x86 too.

So as a first step, can we remove the custom i2c aliasing scheme and
change i2c to use standard module aliases on the x86? Patches for this
already exist.

On 2/23/08, Jean Delvare [EMAIL PROTECTED] wrote:
 The problem I have with this is that it breaks compatibility. The chip
  name is not only used for device/driver matching, it is also exported
  to userspace as a sysfs attribute (name). Applications might rely on
  it. At least libsensors does.

I think there is some confusion here. The OF aliases are only used by
the kernel to load the correct driver. Would doing something like this
help?

static struct i2c_device_id pcf8563_id[] = {
{pcf8563, 0, sysfs_legacy_name},
{rtc8564, 0, sysfs_legacy_name},
OF_ID(phillips,pcf8563, pcf8563_id[0], 0)
OF_ID(epson,rtc8564, pcf8563_id[1], 0)
{},
};
MODULE_DEVICE_TABLE(i2c, pcf8563_id);

Then in the probe function you can use the pointer to find the base id
entry and i2c never has to be aware that the OF alias exists.

  2. record the I2c name in the dts tree, either as separate tag (like 
 linux,i2c-name=i2c-name)

Not really practical for the millions of machines (all PowerPC Macs)
already shipped.

or as additional compatible entry (like compatible=..., 
 linux,i2c-name).
  3. use a glue layer with a translation map.

Audio codecs have exactly the same problem. There are probably other
devices that also need mapping.

This mapping table will need to contain a map from the OF names to the
kernel driver names.  It will need to stored permanently in RAM and
contain all possible mappings. This table will only grow in size.

The kernel has a widely used mechanism for mapping -- aliases in the
device drivers. Why do we want to build a new, parallel one?

What we are doing now is option 4.

4. Use kconfig to build custom kernels for each target system. Don't
load drivers automatically based on what the BIOS tells us.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] USB: mark USB drivers as being GPL only

2008-02-06 Thread Jon Smirl
There a company that is providing a common API for writting Windows
and Linux drivers. Last time I was using a Macraigor JTAG it was based
on this proprietary dual platform driver.

http://www.macraigor.com/cgi_bin/counters/unicounter.pl?name=counters/ocd_cmdr_linux=http://www.macraigor.biz/gnu/mcgr-hwsupport-4.8-0.i386.rpm

The dual platform driver was from Jungo.
http://www.jungo.com/

WinDriver™ USB for Linux automates and simplifies the development of
user-mode Linux device drivers and hardware control applications for
USB peripheral devices. No Linux kernel knowledge or kernel level
programming required.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] USB: mark USB drivers as being GPL only

2008-02-06 Thread Jon Smirl
There a company that is providing a common API for writting Windows
and Linux drivers. Last time I was using a Macraigor JTAG it was based
on this proprietary dual platform driver.

http://www.macraigor.com/cgi_bin/counters/unicounter.pl?name=counters/ocd_cmdr_linuxdeliver=http://www.macraigor.biz/gnu/mcgr-hwsupport-4.8-0.i386.rpm

The dual platform driver was from Jungo.
http://www.jungo.com/

WinDriver™ USB for Linux automates and simplifies the development of
user-mode Linux device drivers and hardware control applications for
USB peripheral devices. No Linux kernel knowledge or kernel level
programming required.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL] i2c updates for 2.6.25

2008-01-28 Thread Jon Smirl
On 1/28/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Hi Jon,
>
> On Sun, 27 Jan 2008 12:36:03 -0500, Jon Smirl wrote:
> > On 1/27/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > > Linus,
> > >
> > > Please pull the i2c subsystem updates for Linux 2.6.25 from:
> > >
> > > git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus
> >
> > The support for modalias loading of i2c modules isn't in here, what's
> > the status?
>
> The status is that I want to give people some time to comment on my
> modalias patches before I merge them. I also didn't have the time to
> look into the latest patches you sent yet, and I'd rather merge
> everything at once. So the merge window for this is rather 2.6.26.

Delaying these until 2.6.26 which won't be final until 2009 forces us
to ship boxes using a private kernel. These patches have been around
since November. Does it really take over a year to get these changes
in?

>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL] i2c updates for 2.6.25

2008-01-28 Thread Jon Smirl
On 1/28/08, Jean Delvare [EMAIL PROTECTED] wrote:
 Hi Jon,

 On Sun, 27 Jan 2008 12:36:03 -0500, Jon Smirl wrote:
  On 1/27/08, Jean Delvare [EMAIL PROTECTED] wrote:
   Linus,
  
   Please pull the i2c subsystem updates for Linux 2.6.25 from:
  
   git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus
 
  The support for modalias loading of i2c modules isn't in here, what's
  the status?

 The status is that I want to give people some time to comment on my
 modalias patches before I merge them. I also didn't have the time to
 look into the latest patches you sent yet, and I'd rather merge
 everything at once. So the merge window for this is rather 2.6.26.

Delaying these until 2.6.26 which won't be final until 2009 forces us
to ship boxes using a private kernel. These patches have been around
since November. Does it really take over a year to get these changes
in?


 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL] i2c updates for 2.6.25

2008-01-27 Thread Jon Smirl
On 1/27/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Linus,
>
> Please pull the i2c subsystem updates for Linux 2.6.25 from:
>
> git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus

The support for modalias loading of i2c modules isn't in here, what's
the status?

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL] i2c updates for 2.6.25

2008-01-27 Thread Jon Smirl
On 1/27/08, Jean Delvare [EMAIL PROTECTED] wrote:
 Linus,

 Please pull the i2c subsystem updates for Linux 2.6.25 from:

 git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus

The support for modalias loading of i2c modules isn't in here, what's
the status?

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2] i2c: adds support for i2c bus on Frescale CPM1/CPM2 controllers

2008-01-23 Thread Jon Smirl
On 1/23/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Hallo Jochen,
>
> On Wed, 23 Jan 2008 12:23:58 +0100, Jochen Friedrich wrote:
> > Hi Jean,
> >
> > > Do you have an updated patch addressing Stephen's comment?
> > >
> > > Note: you'd rather send updates of this patch to the i2c list rather
> > > than LKML.
> >
> > I'm currently looking at that last patches from Jon and try to make this
> > driver fit in there (+ the class override stuff).
>
> I'm not sure what patches exactly you're talking about, but the
> aliasing stuff Jon and myself have been working on are still under
> debate. Your patch shouldn't assume that any of these patches will go
> upstream immediately, so your patch adding the i2c-cpm driver can
> ignore them. I'll update the patches before merging them as needed, do
> not worry too much about that.

He wants the module name translation support I split out into powerpc-common.c.

>
> > Note: will do. I just subscribed to this list.
>
> Note hat you do not need to be subscribed to post to the i2c list (but
> of course, if you have some interest in Linux i2c development,
> subscribing was a good idea anyway.)
>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2] i2c: adds support for i2c bus on Frescale CPM1/CPM2 controllers

2008-01-23 Thread Jon Smirl
On 1/23/08, Jean Delvare [EMAIL PROTECTED] wrote:
 Hallo Jochen,

 On Wed, 23 Jan 2008 12:23:58 +0100, Jochen Friedrich wrote:
  Hi Jean,
 
   Do you have an updated patch addressing Stephen's comment?
  
   Note: you'd rather send updates of this patch to the i2c list rather
   than LKML.
 
  I'm currently looking at that last patches from Jon and try to make this
  driver fit in there (+ the class override stuff).

 I'm not sure what patches exactly you're talking about, but the
 aliasing stuff Jon and myself have been working on are still under
 debate. Your patch shouldn't assume that any of these patches will go
 upstream immediately, so your patch adding the i2c-cpm driver can
 ignore them. I'll update the patches before merging them as needed, do
 not worry too much about that.

He wants the module name translation support I split out into powerpc-common.c.


  Note: will do. I just subscribed to this list.

 Note hat you do not need to be subscribed to post to the i2c list (but
 of course, if you have some interest in Linux i2c development,
 subscribing was a good idea anyway.)

 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 19 3/5] Clean up error returns

2008-01-20 Thread Jon Smirl
Here' s a version with the compares to zero switched to NO_IRQ. If I
understand how NO_IRQ works it is the correct change. My understanding
is that under ppc IRQ zero was legal and NO_IRQ was -1. But then the
whole kernel switched to NO_IRQ = zero. Powerpc updated to NO_IRQ=0
and used virtual IRQs to move a physical IRQ 0 to another IRQ number.
ppc was not changed. This driver does not appear to have been updated
to track this global change since it didn't initially use the NO_IRQ
define everywhere.

-- 
Jon Smirl
[EMAIL PROTECTED]


jds-fix-err-returns
Description: Binary data


Re: [i2c] [PATCH 19 3/5] Clean up error returns

2008-01-20 Thread Jon Smirl
On 1/20/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > @@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
> >   i2c_del_adapter(>adap);
> >   platform_set_drvdata(pdev, NULL);
> >
> > - if (i2c->irq != 0)
> > + if (i2c->irq != NO_IRQ)
> >   free_irq(i2c->irq, i2c);
> >
> >   iounmap(i2c->base);
> >
> >
>
> Is this last chunk a cleanup or a bugfix? It seems that NO_IRQ can have
> value 0 or -1 depending on the architecture, so your change is real on
> some architectures.

I was confused by this too. Search the ppc list archives and there is
a thread about it where BenH tries to explain the correct way of
fixing it to me.

This is part of the ppc to powerpc conversion that has not been
completely cleaned up in this driver. NO_IRQ = -1 is ppc and NO_IRQ =
0 is powerpc. Since this driver didn't originally use the NO_IRQ
define it didn't get automatically converted. We need to identify the
right places where NO_IRQ should have been used.

>
> I have to admit that I'm a bit confused by the way IRQs are handled by
> this driver. On the one hand, there is code to handle polled-mode:
>
> static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
> {
> (...)
> if (i2c->irq == 0)

I missed this one, it should have been NO_IRQ.

> {
> (...)
> } else {
> /* Interrupt mode */
>
> But on the other hand the initialization code bails out if the platform
> device doesn't provide an IRQ:

>
> static int fsl_i2c_probe(struct platform_device *pdev)
> {
> (...)
> i2c->irq = platform_get_irq(pdev, 0);
> if (i2c->irq < 0) {
> result = -ENXIO;
> goto fail_get_irq;

It is only bailing out on an error, not the NO_IRQ case. But maybe the
comparison needs to be with NO_IRQ instead of zero.



> }
>
> So it seems to me like the polling mode code is never actually used?
> Unless some platforms include an "empty" IRQ in their device
> definition. Which indeed seems to be the case... but then they set the
> IRQ to 0, NOT to NO_IRQ, so I'm wondering if the change you propose is
> really correct.

All of this is very confusing to me, There are physical IRQs and
virtual IRQs. Apparently zero is a legal physical IRQ but it is not a
legal virtual IRQ. We only get virtual IRQs in this code. We need to
get BenH to give us the right answer on these two cases.


>
> Either way, there are more places in the driver where the IRQ is
> compared to 0, so if your change is correct, it should be applied
> consistently. Thus I will revert this part for the time being, if any
> change is really needed with regards to interrupts in this driver,
> please send a separate patch. But please double-check first, as I said
> above it's trickier than it looks.
>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 19 3/5] Clean up error returns

2008-01-20 Thread Jon Smirl
On 1/20/08, Jean Delvare [EMAIL PROTECTED] wrote:
  @@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(i2c-adap);
platform_set_drvdata(pdev, NULL);
 
  - if (i2c-irq != 0)
  + if (i2c-irq != NO_IRQ)
free_irq(i2c-irq, i2c);
 
iounmap(i2c-base);
 
 

 Is this last chunk a cleanup or a bugfix? It seems that NO_IRQ can have
 value 0 or -1 depending on the architecture, so your change is real on
 some architectures.

I was confused by this too. Search the ppc list archives and there is
a thread about it where BenH tries to explain the correct way of
fixing it to me.

This is part of the ppc to powerpc conversion that has not been
completely cleaned up in this driver. NO_IRQ = -1 is ppc and NO_IRQ =
0 is powerpc. Since this driver didn't originally use the NO_IRQ
define it didn't get automatically converted. We need to identify the
right places where NO_IRQ should have been used.


 I have to admit that I'm a bit confused by the way IRQs are handled by
 this driver. On the one hand, there is code to handle polled-mode:

 static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 {
 (...)
 if (i2c-irq == 0)

I missed this one, it should have been NO_IRQ.

 {
 (...)
 } else {
 /* Interrupt mode */

 But on the other hand the initialization code bails out if the platform
 device doesn't provide an IRQ:


 static int fsl_i2c_probe(struct platform_device *pdev)
 {
 (...)
 i2c-irq = platform_get_irq(pdev, 0);
 if (i2c-irq  0) {
 result = -ENXIO;
 goto fail_get_irq;

It is only bailing out on an error, not the NO_IRQ case. But maybe the
comparison needs to be with NO_IRQ instead of zero.



 }

 So it seems to me like the polling mode code is never actually used?
 Unless some platforms include an empty IRQ in their device
 definition. Which indeed seems to be the case... but then they set the
 IRQ to 0, NOT to NO_IRQ, so I'm wondering if the change you propose is
 really correct.

All of this is very confusing to me, There are physical IRQs and
virtual IRQs. Apparently zero is a legal physical IRQ but it is not a
legal virtual IRQ. We only get virtual IRQs in this code. We need to
get BenH to give us the right answer on these two cases.



 Either way, there are more places in the driver where the IRQ is
 compared to 0, so if your change is correct, it should be applied
 consistently. Thus I will revert this part for the time being, if any
 change is really needed with regards to interrupts in this driver,
 please send a separate patch. But please double-check first, as I said
 above it's trickier than it looks.

 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 19 3/5] Clean up error returns

2008-01-20 Thread Jon Smirl
Here' s a version with the compares to zero switched to NO_IRQ. If I
understand how NO_IRQ works it is the correct change. My understanding
is that under ppc IRQ zero was legal and NO_IRQ was -1. But then the
whole kernel switched to NO_IRQ = zero. Powerpc updated to NO_IRQ=0
and used virtual IRQs to move a physical IRQ 0 to another IRQ number.
ppc was not changed. This driver does not appear to have been updated
to track this global change since it didn't initially use the NO_IRQ
define everywhere.

-- 
Jon Smirl
[EMAIL PROTECTED]


jds-fix-err-returns
Description: Binary data


Re: Why not creating a GIT RT tree ?

2008-01-19 Thread Jon Smirl
On 1/18/08, Steven Rostedt <[EMAIL PROTECTED]> wrote:
>
> On Fri, 18 Jan 2008, Francis Moreau wrote:
>
> > Maybe I missed it but I'm wondering why GIT is not used for
> > the RT development ? I can't find a rt tree anywhere and all
> > new rt release spoke about a patchset to apply on mainline
> > kernels.
>
> The answer to this is pretty much the same as why the -mm tree isn't in
> git either.
>
> The RT tree is made up of lots of patches (over 300). Our goal is to get
> RT into mainline Linux. RT isn't just one type of system, it extends all
> over the kernel, and the patches may be rewriten over and over. Managing
> this in quilt is a lot easier than managing it in git.
>
> That said, there's been talk about making a git tree for others based on
> the quilt queue. The thing is that a new git tree will need to be created
> for every release. Which means that it will be difficult for others to
> simply update their local repo since you will get a bunch of errors with
> not being from the same head.

stgit is worth checking out. It's basically quilt for git. I'm using
to juggle about 30 patches.

I believe there is a way to set up the git config file on the server
to force updating clients onto the new head without triggering an
error messages.

Ask on the git list and you'll get at least a dozen different
suggestions on how to make your repo available on git.

>
>
> >
> > Another question, is there a TODO list somewhere which would
> > help to port the RT patch to a new architecture ?
>
> Which arch? We are already on PowerPC, ARM and MIPS. Thinking about sh?
>
> The best would be to read the code and look at my paper:
>
> http://ols.108.redhat.com/2007/Reprints/rostedt-Reprint.pdf
> (Internals of the RT Patch)
>
> This will give you an idea of what is needed to port to another arch.
>
> >
> > Sorry if the questions are dumbed but I'm just new to this
> > project.
>
> No, in fact, I think it's about time to add these to our FAQ:
>
> http://rt.wiki.kernel.org/index.php/Frequently_Asked_Questions
>
> Thanks,
>
> -- Steve
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Why not creating a GIT RT tree ?

2008-01-19 Thread Jon Smirl
On 1/18/08, Steven Rostedt [EMAIL PROTECTED] wrote:

 On Fri, 18 Jan 2008, Francis Moreau wrote:

  Maybe I missed it but I'm wondering why GIT is not used for
  the RT development ? I can't find a rt tree anywhere and all
  new rt release spoke about a patchset to apply on mainline
  kernels.

 The answer to this is pretty much the same as why the -mm tree isn't in
 git either.

 The RT tree is made up of lots of patches (over 300). Our goal is to get
 RT into mainline Linux. RT isn't just one type of system, it extends all
 over the kernel, and the patches may be rewriten over and over. Managing
 this in quilt is a lot easier than managing it in git.

 That said, there's been talk about making a git tree for others based on
 the quilt queue. The thing is that a new git tree will need to be created
 for every release. Which means that it will be difficult for others to
 simply update their local repo since you will get a bunch of errors with
 not being from the same head.

stgit is worth checking out. It's basically quilt for git. I'm using
to juggle about 30 patches.

I believe there is a way to set up the git config file on the server
to force updating clients onto the new head without triggering an
error messages.

Ask on the git list and you'll get at least a dozen different
suggestions on how to make your repo available on git.



 
  Another question, is there a TODO list somewhere which would
  help to port the RT patch to a new architecture ?

 Which arch? We are already on PowerPC, ARM and MIPS. Thinking about sh?

 The best would be to read the code and look at my paper:

 http://ols.108.redhat.com/2007/Reprints/rostedt-Reprint.pdf
 (Internals of the RT Patch)

 This will give you an idea of what is needed to port to another arch.

 
  Sorry if the questions are dumbed but I'm just new to this
  project.

 No, in fact, I think it's about time to add these to our FAQ:

 http://rt.wiki.kernel.org/index.php/Frequently_Asked_Questions

 Thanks,

 -- Steve

 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to [EMAIL PROTECTED]
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] update module-init-tools to support the i2c subsystem

2008-01-14 Thread Jon Smirl
On 1/14/08, Geert Uytterhoeven <[EMAIL PROTECTED]> wrote:
> On Sun, 13 Jan 2008, Jon Smirl wrote:
> > On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > > On Sun, 13 Jan 2008 11:26:07 -0500, Jon Smirl wrote:
> > > > On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > > > > On Sun, 13 Jan 2008 10:14:14 -0500, Jon Smirl wrote:
> > > > > > On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > > > > > > On Mon, 17 Dec 2007 21:39:37 -0500, Jon Smirl wrote:
> > > > > > > > Follow on to: "Series to add device tree naming to i2c"
> > > > > > > > Teach module-init-tools about the i2c subsystem.
> > > > > > >
> > > > > > > Can you please explain what this patch does and why it is needed?
> > > > > >
> > > > > > It generates the entries needed for the user space module tools to
> > > > > > work with the aliases. For example modprobe/depmod. It is a standard
> > > > > > part of the kernel module system.
> > > > >
> > > > > What entries, where? What can you do after applying your patch that 
> > > > > you
> > > > > couldn't do before?
> > > >
> > > > The drivers you are testing with don't depend on other drivers.
> > >
> > > They do. I'm testing with the lm90 driver, which depends on the hwmon
> > > driver. Both load automatically when the underlying i2c-parport driver
> > > instantiate an "adm1032" i2c device.
> >
> > I don't know exactly what those modules tables are used for. I just
> > copied what the other subsystems do. Maybe they are used when you make
> > an initrd to know which drivers to copy into the image.
>
> Module-init-tools needs those table to create module aliases in the *.ko
> files from the MODULE_DEVICE_TABLE(), so udev can load the modules based
> on the device IDs when the devices appear in sysfs.
>
> That's the generic part. How this applies to i2c devices on platforms
> without Open Firmware device trees is another question. I guess that's
> where Jean gets confused (i2c_device_id got _removed_ last year,
> because it didn't make sense (at the time?)).

Last year i2c modules weren't dynamically loadable so it wasn't needed.

>
> With kind regards,
>
> Geert Uytterhoeven
> Software Architect
>
> Sony Network and Software Technology Center Europe
> The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
>
> Phone:+32 (0)2 700 8453
> Fax:  +32 (0)2 700 8622
> E-mail:   [EMAIL PROTECTED]
> Internet: http://www.sony-europe.com/
>
> Sony Network and Software Technology Center Europe
> A division of Sony Service Centre (Europe) N.V.
> Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium
> VAT BE 0413.825.160 · RPR Brussels
> Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] update module-init-tools to support the i2c subsystem

2008-01-14 Thread Jon Smirl
On 1/14/08, Geert Uytterhoeven [EMAIL PROTECTED] wrote:
 On Sun, 13 Jan 2008, Jon Smirl wrote:
  On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
   On Sun, 13 Jan 2008 11:26:07 -0500, Jon Smirl wrote:
On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
 On Sun, 13 Jan 2008 10:14:14 -0500, Jon Smirl wrote:
  On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
   On Mon, 17 Dec 2007 21:39:37 -0500, Jon Smirl wrote:
Follow on to: Series to add device tree naming to i2c
Teach module-init-tools about the i2c subsystem.
  
   Can you please explain what this patch does and why it is needed?
 
  It generates the entries needed for the user space module tools to
  work with the aliases. For example modprobe/depmod. It is a standard
  part of the kernel module system.

 What entries, where? What can you do after applying your patch that 
 you
 couldn't do before?
   
The drivers you are testing with don't depend on other drivers.
  
   They do. I'm testing with the lm90 driver, which depends on the hwmon
   driver. Both load automatically when the underlying i2c-parport driver
   instantiate an adm1032 i2c device.
 
  I don't know exactly what those modules tables are used for. I just
  copied what the other subsystems do. Maybe they are used when you make
  an initrd to know which drivers to copy into the image.

 Module-init-tools needs those table to create module aliases in the *.ko
 files from the MODULE_DEVICE_TABLE(), so udev can load the modules based
 on the device IDs when the devices appear in sysfs.

 That's the generic part. How this applies to i2c devices on platforms
 without Open Firmware device trees is another question. I guess that's
 where Jean gets confused (i2c_device_id got _removed_ last year,
 because it didn't make sense (at the time?)).

Last year i2c modules weren't dynamically loadable so it wasn't needed.


 With kind regards,

 Geert Uytterhoeven
 Software Architect

 Sony Network and Software Technology Center Europe
 The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

 Phone:+32 (0)2 700 8453
 Fax:  +32 (0)2 700 8622
 E-mail:   [EMAIL PROTECTED]
 Internet: http://www.sony-europe.com/

 Sony Network and Software Technology Center Europe
 A division of Sony Service Centre (Europe) N.V.
 Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium
 VAT BE 0413.825.160 · RPR Brussels
 Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Hi Jon,
>
> On Sun, 13 Jan 2008 13:01:06 -0500, Jon Smirl wrote:
> > On 1/13/08, Jean Delvare wrote:
> > > On Sun, 13 Jan 2008 11:24:29 -0500, Jon Smirl wrote:
> > > > The kernel automatically exposes modalias as a sysfs attribute so the
> > > > string must be recorded further down in the driver support layers. No
> > > > need to keep a copy in the i2c structure.
> > >
> > > Really? I didn't know that. So that's another thing that the i2c
> > > subsystem is not doing like the rest of the kernel? Can you please
> > > point me to the code that does this?
> >
> > I never noticed it before either. Just do find | grep modalias in /sys
> > and see that every driver has a modalias attribute. It is probably
> > implement in drivers/base.
>
> This doesn't mean that the kernel does this automatically! It could
> also be that each subsystem does it on its own. Given that the format of
> the modalias depends on the bus type, it wouldn't be all that
> surprising. Anyway, I'll go look at how the other subsystems handle it
> before going on.
>
> > > > Standard devices don't export a 'name' attribute. To see the driver
> > > > name for a device in sysfs look at the 'driver' link.
> > >
> > > The driver name and the device name are different things! The "name"
> > > attribute that i2c devices have tells user-space the device name, not
> > > the driver name.
> >
> > For this system my i2c device names are:
> > 0-0050  0-0051  0-0052  0-0053
>
> These are not device names, these are device bus IDs. They tell you how
> to access the devices, but they do not tell you what these devices are.
>
> > How does the name=eeprom attribute interact with this? All four of my
> > devices have name=eeprom. What is the name field used for in user
> > space?
>
> The eeprom case might be a bit confusing because that i2c driver
> supports a single device type, so the driver name is the same as the
> device name. Take a look at the hwmon/lm90 driver for a better example:
> this device supports 7 different devices. The devices are mostly
> compatible so it made sense to have a single driver for them, but they
> all differ in some way. For example, the LM90 doesn't support PEC,
> while the ADM1032 does. User-space needs to be able to distinguish
> between the various types. That's the reason why we export the device
> name through sysfs.
>
> Most i2c sensor drivers support several chip types, and libsensors has
> been relying heavily on the name attribute. Less so with the lm-sensors
> 3.0.0 rewrite, where most things are automatically detected, but if
> nothing else, giving humans a way to distinguish between the different
> sensor chip types is very useful. Also, not everyone will upgrade to
> lm-sensors 3.0.0 so we need to keep supporting the previous versions.

Another way to handle this is to have the drivers register multiple
times using different names. So LM90 would register as both LM90 and
ADM1032. All the code is shared, you just register it multiple times
under different names.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] update module-init-tools to support the i2c subsystem

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> On Sun, 13 Jan 2008 11:26:07 -0500, Jon Smirl wrote:
> > On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > > On Sun, 13 Jan 2008 10:14:14 -0500, Jon Smirl wrote:
> > > > On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > > > > On Mon, 17 Dec 2007 21:39:37 -0500, Jon Smirl wrote:
> > > > > > Follow on to: "Series to add device tree naming to i2c"
> > > > > > Teach module-init-tools about the i2c subsystem.
> > > > >
> > > > > Can you please explain what this patch does and why it is needed?
> > > >
> > > > It generates the entries needed for the user space module tools to
> > > > work with the aliases. For example modprobe/depmod. It is a standard
> > > > part of the kernel module system.
> > >
> > > What entries, where? What can you do after applying your patch that you
> > > couldn't do before?
> >
> > The drivers you are testing with don't depend on other drivers.
>
> They do. I'm testing with the lm90 driver, which depends on the hwmon
> driver. Both load automatically when the underlying i2c-parport driver
> instantiate an "adm1032" i2c device.

I don't know exactly what those modules tables are used for. I just
copied what the other subsystems do. Maybe they are used when you make
an initrd to know which drivers to copy into the image.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> On Sun, 13 Jan 2008 11:24:29 -0500, Jon Smirl wrote:
> > On 1/13/08, Jean Delvare wrote:
> > > On Sat, 12 Jan 2008 11:26:34 -0500, Jon Smirl wrote:
> > > > IMHO, driver_name/type should be removed in new style drivers and
> > > > replaced with aliases on all platforms since aliases are the standard
> > > > kernel mechanism.
> > >
> > > I agree. But we can take your aliasing code now (once you have
> > > addressed the issues I raised) and convert the users of driver_name
> > > later; it doesn't have to be done all at once.
> >
> > GregKH, adding a new dynamically loadable subsystem is not something
> > that happens every day, can you check to make sure all of the standard
> > kernels mechanisms are being used? I'm not totally sure how the
> > modalias naming code is supposed to be done. The subsystem core code
> > in these patches needs review.
> >
> > Jean, could you take over the i2c core portion of the patch? That will
> > let you decide exactly how you want the driver_name/name fields to be
> > dealt with. After you get standard naming support into i2c core I'll
> > rework the rest of the patch to use your new code.
>
> Yes, that could be done, and I agree that it will probably be faster
> than iterative review/rework cycles between you and me. I'll free some
> cycles next week for that.
>
> > I don't think driver_name/name fields should be stored in an i2c
> > structure at all. They are redundant with the standard mechanism.
> >
> > The kernel automatically exposes modalias as a sysfs attribute so the
> > string must be recorded further down in the driver support layers. No
> > need to keep a copy in the i2c structure.
>
> Really? I didn't know that. So that's another thing that the i2c
> subsystem is not doing like the rest of the kernel? Can you please
> point me to the code that does this?

I never noticed it before either. Just do find | grep modalias in /sys
and see that every driver has a modalias attribute. It is probably
implement in drivers/base.

>
> > Standard devices don't export a 'name' attribute. To see the driver
> > name for a device in sysfs look at the 'driver' link.
>
> The driver name and the device name are different things! The "name"
> attribute that i2c devices have tells user-space the device name, not
> the driver name.

For this system my i2c device names are:
0-0050  0-0051  0-0052  0-0053
How does the name=eeprom attribute interact with this? All four of my
devices have name=eeprom. What is the name field used for in user
space?

[EMAIL PROTECTED]:/sys/bus/i2c/devices/0-0052$ ls
driver  eeprom  modalias  name  power  subsystem  uevent
[EMAIL PROTECTED]:/sys/bus/i2c/devices/0-0052$ cat name
eeprom
[EMAIL PROTECTED]:/sys/bus/i2c/devices/0-0052$ ls driver -l
lrwxrwxrwx 1 root root 0 2008-01-13 12:46 driver ->
../../../../../../bus/i2c/drivers/eeprom
[EMAIL PROTECTED]:/sys/bus/i2c/devices/0-0052$

[EMAIL PROTECTED]:/sys/bus/i2c/drivers$ ls
eeprom
[EMAIL PROTECTED]:/sys/bus/i2c/drivers$ ls eeprom
0-0050  0-0051  0-0052  0-0053  bind  module  uevent  unbind

>
> You may not like what the i2c subsystem does but you can't ignore its
> history. The name attribute of i2c devices has been there pretty much
> forever and user-space relies on it, thus we can't remove it.
>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] update module-init-tools to support the i2c subsystem

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> On Sun, 13 Jan 2008 10:14:14 -0500, Jon Smirl wrote:
> > On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > > On Mon, 17 Dec 2007 21:39:37 -0500, Jon Smirl wrote:
> > > > Follow on to: "Series to add device tree naming to i2c"
> > > > Teach module-init-tools about the i2c subsystem.
> > >
> > > Can you please explain what this patch does and why it is needed?
> >
> > It generates the entries needed for the user space module tools to
> > work with the aliases. For example modprobe/depmod. It is a standard
> > part of the kernel module system.
>
> What entries, where? What can you do after applying your patch that you
> couldn't do before?

The drivers you are testing with don't depend on other drivers.

> I'm asking because automatic i2c driver loading works just fine for me
> without patching user-space. So I don't get why your want to change
> anything.
>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Hi Jon,
>
> On Sat, 12 Jan 2008 11:26:34 -0500, Jon Smirl wrote:
> > The common scheme used elsewhere in the kernel for handling more than
> > one device in a single driver is aliases. The i2c code's existing
> > driver_name/type combination is a different way of implementing the
> > same feature. But there is no real need for driver_name/type on any
> > platform if aliases are used. Back in version 10 or 11 I had code in
> > there which replaced the two fields with aliases on all platforms but
> > too many people objected so I removed it..
>
> While I agree that aliases make i2c_client.driver_name obsolete,
> i2c_client.type is still needed. Not for device/driver matching in the
> kernel, granted, but for device identification from userspace. This is
> a first problem your patch has: when using your aliasing mechanism, the
> type string is left empty. i2c-core exports this value to user-space
> via the "name" sysfs attribute, and some libraries and applications
> make use of it. I know of libsensors at least, but I guess there are
> more. I can't apply your patch until this problem is solved, otherwise
> we would break some user-space applications.
>
> > IMHO, driver_name/type should be removed in new style drivers and
> > replaced with aliases on all platforms since aliases are the standard
> > kernel mechanism.
>
> I agree. But we can take your aliasing code now (once you have
> addressed the issues I raised) and convert the users of driver_name
> later; it doesn't have to be done all at once.

GregKH, adding a new dynamically loadable subsystem is not something
that happens every day, can you check to make sure all of the standard
kernels mechanisms are being used? I'm not totally sure how the
modalias naming code is supposed to be done. The subsystem core code
in these patches needs review.

Jean, could you take over the i2c core portion of the patch? That will
let you decide exactly how you want the driver_name/name fields to be
dealt with. After you get standard naming support into i2c core I'll
rework the rest of the patch to use your new code.

I don't think driver_name/name fields should be stored in an i2c
structure at all. They are redundant with the standard mechanism.

The kernel automatically exposes modalias as a sysfs attribute so the
string must be recorded further down in the driver support layers. No
need to keep a copy in the i2c structure.

Standard devices don't export a 'name' attribute. To see the driver
name for a device in sysfs look at the 'driver' link.

> The second problem I have with your patch is that you make use of the
> driver_name field, while I ultimately want to get rid of it. I'd rather
> see you use a different field for aliases, so that the later removal of
> the driver_name field and the associated mechanism is easier.
>
> A third, related problem, is the contents of the modalias file when
> using your patch. When I tested on my ADM1032 evaluation board, the
> modalias contained "adm1032". This isn't a valid module alias string:
> "modprobe adm1032" doesn't work. What works is "modprobe i2c:Nadm1032"
> so the modalias file should contain "i2c:Nadm1032". Just take a look at
> all modalias files in /sys, they all include the subsystem prefix and a
> simple modprobe `cat modalias` loads the required driver. I fail to see
> why the i2c subsystem would be different.
>
> I said this is related to the second problem because right now,
> i2c-core can't easily differentiate between driver names and aliases,
> as both are stored in i2c_client.driver_name. Having separate fields
> would make it possible (and relatively easy) to add the required prefix
> before aliases but not before driver names. The only drawback is that
> it will increase the size of the i2c_client structure, but I do not
> care that much given that it is only temporary.
>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] update module-init-tools to support the i2c subsystem

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> On Mon, 17 Dec 2007 21:39:37 -0500, Jon Smirl wrote:
> > Follow on to: "Series to add device tree naming to i2c"
> > Teach module-init-tools about the i2c subsystem.
>
> Can you please explain what this patch does and why it is needed?

It generates the entries needed for the user space module tools to
work with the aliases. For example modprobe/depmod. It is a standard
part of the kernel module system.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] update module-init-tools to support the i2c subsystem

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
 On Mon, 17 Dec 2007 21:39:37 -0500, Jon Smirl wrote:
  Follow on to: Series to add device tree naming to i2c
  Teach module-init-tools about the i2c subsystem.

 Can you please explain what this patch does and why it is needed?

It generates the entries needed for the user space module tools to
work with the aliases. For example modprobe/depmod. It is a standard
part of the kernel module system.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
 Hi Jon,

 On Sat, 12 Jan 2008 11:26:34 -0500, Jon Smirl wrote:
  The common scheme used elsewhere in the kernel for handling more than
  one device in a single driver is aliases. The i2c code's existing
  driver_name/type combination is a different way of implementing the
  same feature. But there is no real need for driver_name/type on any
  platform if aliases are used. Back in version 10 or 11 I had code in
  there which replaced the two fields with aliases on all platforms but
  too many people objected so I removed it..

 While I agree that aliases make i2c_client.driver_name obsolete,
 i2c_client.type is still needed. Not for device/driver matching in the
 kernel, granted, but for device identification from userspace. This is
 a first problem your patch has: when using your aliasing mechanism, the
 type string is left empty. i2c-core exports this value to user-space
 via the name sysfs attribute, and some libraries and applications
 make use of it. I know of libsensors at least, but I guess there are
 more. I can't apply your patch until this problem is solved, otherwise
 we would break some user-space applications.

  IMHO, driver_name/type should be removed in new style drivers and
  replaced with aliases on all platforms since aliases are the standard
  kernel mechanism.

 I agree. But we can take your aliasing code now (once you have
 addressed the issues I raised) and convert the users of driver_name
 later; it doesn't have to be done all at once.

GregKH, adding a new dynamically loadable subsystem is not something
that happens every day, can you check to make sure all of the standard
kernels mechanisms are being used? I'm not totally sure how the
modalias naming code is supposed to be done. The subsystem core code
in these patches needs review.

Jean, could you take over the i2c core portion of the patch? That will
let you decide exactly how you want the driver_name/name fields to be
dealt with. After you get standard naming support into i2c core I'll
rework the rest of the patch to use your new code.

I don't think driver_name/name fields should be stored in an i2c
structure at all. They are redundant with the standard mechanism.

The kernel automatically exposes modalias as a sysfs attribute so the
string must be recorded further down in the driver support layers. No
need to keep a copy in the i2c structure.

Standard devices don't export a 'name' attribute. To see the driver
name for a device in sysfs look at the 'driver' link.

 The second problem I have with your patch is that you make use of the
 driver_name field, while I ultimately want to get rid of it. I'd rather
 see you use a different field for aliases, so that the later removal of
 the driver_name field and the associated mechanism is easier.

 A third, related problem, is the contents of the modalias file when
 using your patch. When I tested on my ADM1032 evaluation board, the
 modalias contained adm1032. This isn't a valid module alias string:
 modprobe adm1032 doesn't work. What works is modprobe i2c:Nadm1032
 so the modalias file should contain i2c:Nadm1032. Just take a look at
 all modalias files in /sys, they all include the subsystem prefix and a
 simple modprobe `cat modalias` loads the required driver. I fail to see
 why the i2c subsystem would be different.

 I said this is related to the second problem because right now,
 i2c-core can't easily differentiate between driver names and aliases,
 as both are stored in i2c_client.driver_name. Having separate fields
 would make it possible (and relatively easy) to add the required prefix
 before aliases but not before driver names. The only drawback is that
 it will increase the size of the i2c_client structure, but I do not
 care that much given that it is only temporary.

 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] update module-init-tools to support the i2c subsystem

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
 On Sun, 13 Jan 2008 10:14:14 -0500, Jon Smirl wrote:
  On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
   On Mon, 17 Dec 2007 21:39:37 -0500, Jon Smirl wrote:
Follow on to: Series to add device tree naming to i2c
Teach module-init-tools about the i2c subsystem.
  
   Can you please explain what this patch does and why it is needed?
 
  It generates the entries needed for the user space module tools to
  work with the aliases. For example modprobe/depmod. It is a standard
  part of the kernel module system.

 What entries, where? What can you do after applying your patch that you
 couldn't do before?

The drivers you are testing with don't depend on other drivers.

 I'm asking because automatic i2c driver loading works just fine for me
 without patching user-space. So I don't get why your want to change
 anything.

 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
 On Sun, 13 Jan 2008 11:24:29 -0500, Jon Smirl wrote:
  On 1/13/08, Jean Delvare wrote:
   On Sat, 12 Jan 2008 11:26:34 -0500, Jon Smirl wrote:
IMHO, driver_name/type should be removed in new style drivers and
replaced with aliases on all platforms since aliases are the standard
kernel mechanism.
  
   I agree. But we can take your aliasing code now (once you have
   addressed the issues I raised) and convert the users of driver_name
   later; it doesn't have to be done all at once.
 
  GregKH, adding a new dynamically loadable subsystem is not something
  that happens every day, can you check to make sure all of the standard
  kernels mechanisms are being used? I'm not totally sure how the
  modalias naming code is supposed to be done. The subsystem core code
  in these patches needs review.
 
  Jean, could you take over the i2c core portion of the patch? That will
  let you decide exactly how you want the driver_name/name fields to be
  dealt with. After you get standard naming support into i2c core I'll
  rework the rest of the patch to use your new code.

 Yes, that could be done, and I agree that it will probably be faster
 than iterative review/rework cycles between you and me. I'll free some
 cycles next week for that.

  I don't think driver_name/name fields should be stored in an i2c
  structure at all. They are redundant with the standard mechanism.
 
  The kernel automatically exposes modalias as a sysfs attribute so the
  string must be recorded further down in the driver support layers. No
  need to keep a copy in the i2c structure.

 Really? I didn't know that. So that's another thing that the i2c
 subsystem is not doing like the rest of the kernel? Can you please
 point me to the code that does this?

I never noticed it before either. Just do find | grep modalias in /sys
and see that every driver has a modalias attribute. It is probably
implement in drivers/base.


  Standard devices don't export a 'name' attribute. To see the driver
  name for a device in sysfs look at the 'driver' link.

 The driver name and the device name are different things! The name
 attribute that i2c devices have tells user-space the device name, not
 the driver name.

For this system my i2c device names are:
0-0050  0-0051  0-0052  0-0053
How does the name=eeprom attribute interact with this? All four of my
devices have name=eeprom. What is the name field used for in user
space?

[EMAIL PROTECTED]:/sys/bus/i2c/devices/0-0052$ ls
driver  eeprom  modalias  name  power  subsystem  uevent
[EMAIL PROTECTED]:/sys/bus/i2c/devices/0-0052$ cat name
eeprom
[EMAIL PROTECTED]:/sys/bus/i2c/devices/0-0052$ ls driver -l
lrwxrwxrwx 1 root root 0 2008-01-13 12:46 driver -
../../../../../../bus/i2c/drivers/eeprom
[EMAIL PROTECTED]:/sys/bus/i2c/devices/0-0052$

[EMAIL PROTECTED]:/sys/bus/i2c/drivers$ ls
eeprom
[EMAIL PROTECTED]:/sys/bus/i2c/drivers$ ls eeprom
0-0050  0-0051  0-0052  0-0053  bind  module  uevent  unbind


 You may not like what the i2c subsystem does but you can't ignore its
 history. The name attribute of i2c devices has been there pretty much
 forever and user-space relies on it, thus we can't remove it.

 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] update module-init-tools to support the i2c subsystem

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
 On Sun, 13 Jan 2008 11:26:07 -0500, Jon Smirl wrote:
  On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
   On Sun, 13 Jan 2008 10:14:14 -0500, Jon Smirl wrote:
On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
 On Mon, 17 Dec 2007 21:39:37 -0500, Jon Smirl wrote:
  Follow on to: Series to add device tree naming to i2c
  Teach module-init-tools about the i2c subsystem.

 Can you please explain what this patch does and why it is needed?
   
It generates the entries needed for the user space module tools to
work with the aliases. For example modprobe/depmod. It is a standard
part of the kernel module system.
  
   What entries, where? What can you do after applying your patch that you
   couldn't do before?
 
  The drivers you are testing with don't depend on other drivers.

 They do. I'm testing with the lm90 driver, which depends on the hwmon
 driver. Both load automatically when the underlying i2c-parport driver
 instantiate an adm1032 i2c device.

I don't know exactly what those modules tables are used for. I just
copied what the other subsystems do. Maybe they are used when you make
an initrd to know which drivers to copy into the image.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-13 Thread Jon Smirl
On 1/13/08, Jean Delvare [EMAIL PROTECTED] wrote:
 Hi Jon,

 On Sun, 13 Jan 2008 13:01:06 -0500, Jon Smirl wrote:
  On 1/13/08, Jean Delvare wrote:
   On Sun, 13 Jan 2008 11:24:29 -0500, Jon Smirl wrote:
The kernel automatically exposes modalias as a sysfs attribute so the
string must be recorded further down in the driver support layers. No
need to keep a copy in the i2c structure.
  
   Really? I didn't know that. So that's another thing that the i2c
   subsystem is not doing like the rest of the kernel? Can you please
   point me to the code that does this?
 
  I never noticed it before either. Just do find | grep modalias in /sys
  and see that every driver has a modalias attribute. It is probably
  implement in drivers/base.

 This doesn't mean that the kernel does this automatically! It could
 also be that each subsystem does it on its own. Given that the format of
 the modalias depends on the bus type, it wouldn't be all that
 surprising. Anyway, I'll go look at how the other subsystems handle it
 before going on.

Standard devices don't export a 'name' attribute. To see the driver
name for a device in sysfs look at the 'driver' link.
  
   The driver name and the device name are different things! The name
   attribute that i2c devices have tells user-space the device name, not
   the driver name.
 
  For this system my i2c device names are:
  0-0050  0-0051  0-0052  0-0053

 These are not device names, these are device bus IDs. They tell you how
 to access the devices, but they do not tell you what these devices are.

  How does the name=eeprom attribute interact with this? All four of my
  devices have name=eeprom. What is the name field used for in user
  space?

 The eeprom case might be a bit confusing because that i2c driver
 supports a single device type, so the driver name is the same as the
 device name. Take a look at the hwmon/lm90 driver for a better example:
 this device supports 7 different devices. The devices are mostly
 compatible so it made sense to have a single driver for them, but they
 all differ in some way. For example, the LM90 doesn't support PEC,
 while the ADM1032 does. User-space needs to be able to distinguish
 between the various types. That's the reason why we export the device
 name through sysfs.

 Most i2c sensor drivers support several chip types, and libsensors has
 been relying heavily on the name attribute. Less so with the lm-sensors
 3.0.0 rewrite, where most things are automatically detected, but if
 nothing else, giving humans a way to distinguish between the different
 sensor chip types is very useful. Also, not everyone will upgrade to
 lm-sensors 3.0.0 so we need to keep supporting the previous versions.

Another way to handle this is to have the drivers register multiple
times using different names. So LM90 would register as both LM90 and
ADM1032. All the code is shared, you just register it multiple times
under different names.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-12 Thread Jon Smirl
On 1/12/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Hi Jon,
>
> On Fri, 11 Jan 2008 20:20:15 +0100, Jean Delvare wrote:
> > > +{
> > > +   /* only powerpc drivers implement the id_table,
> > > +* it is empty on other platforms */
> > > +   if (id) {
> > > +   while (id->name[0]) {
> > > +   if (strcmp(client->driver_name, id->name) == 0)
> >
> > This doesn't look right to me. You should be comparing client->name,
> > not client->driver_name, with id->name. Where id_table is implemented,
> > client->driver_name might not even be set. I see that the next patch in
> > the series makes use of client->driver_name as well, so your code
> > "works"... but this ain't correct still.
>
> Err, scratch this (and related comments), I just realized what you were
> trying to do. That's different from what I had in mind and so I read
> your code wrong. I'll read it (and test it) again not making this
> incorrect assumption and my comments will likely be different after
> that. Well, I still think that it needs to be changed a bit, but
> probably not in the direction I suggested at first (which, I realize
> now, has its own share of issues - so it's not fair to me to point you
> there.)

The common scheme used elsewhere in the kernel for handling more than
one device in a single driver is aliases. The i2c code's existing
driver_name/type combination is a different way of implementing the
same feature. But there is no real need for driver_name/type on any
platform if aliases are used. Back in version 10 or 11 I had code in
there which replaced the two fields with aliases on all platforms but
too many people objected so I removed it..

IMHO, driver_name/type should be removed in new style drivers and
replaced with aliases on all platforms since aliases are the standard
kernel mechanism.



>
> Sorry for the trouble. I'll post updated comments later today, but I'm
> also pretty busy with other issues, some of which need to be solved
> before 2.6.24 is released so I can't really delay them.
>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 0/5] Version 17, series to add device tree naming to i2c

2008-01-12 Thread Jon Smirl
On 1/12/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> On Fri, 11 Jan 2008 15:16:57 -0500, Jon Smirl wrote:
> > On 1/11/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> > > Secondly, it promotes OF device names as acceptable aliases. This I
> > > don't think I agree with. While I see some value in moving the OF name
> > > -> Linux name translation to the drivers themselves (even though I
> > > don't see this as a mandatory move either), this doesn't imply that OF
> > > names should be used as aliases. I don't like the idea that different
> > > architectures will name the same device differently in a visible way.
> > > This could easily break user-space code that makes assumptions on the
> > > device names (libsensors comes to mind.) So, I think that this part
> > > will need some more discussion.
> >
> > They're aliases.  On the x86 my e1000 Ethernet driver loads using this
> > alias name:
> > "pci:v8086d1010sv*sd*bc*sc*i*"
> > In fact, the e1000 driver has 63 alias names in addition to "e1000"
> >
> > But it's still the e1000 driver after it is loaded.
> > [EMAIL PROTECTED]:/home/linux/drivers/net/e1000$ lsmod | grep e1000
> > e1000 115968  0
> >
> > Loading a I2C driver with an OF alias name is not going to change the
> > module name after it is loaded. In fact, once the module is in memory
> > there's no way to tell what name was used to load it.
>
> Of course. That's not what I was worried about... what I was worried
> about is something your patch set doesn't do but I misread the code and
> I thought it was doing. I'll read it again before I make more comments
> on this.
>
> > OF device names are set by the Open Firmware committee. It is not
> > reasonable to force the Linux names back into Open Firmware since this
> > would force the other operating systems using Open Firmware to adopt
> > the Linux names.
>
> I never meant to force the Linux names into Open Firmware. It wouldn't
> make sense especially when the Linux names are invented by random
> contributors with no specific rules, and can even change over time.
>
> What I meant is that the translation from Open Firmware device name to
> Linux device name could happen in different ways. Making module aliases
> out of the is one possibility but this is not the only one.
>
> I am curious why the translation could not happen "offline". As I
> understand it, you're getting the device names from these .dts files.
> However you're not parsing them in the kernel directly, are you? I
> presume that you have some tool that converts these files into C code
> that the kernel can use? This conversion tool could translate the names.

Those dts files are for embedded devices that were specifically
developed for Linux. All of the PowerPC Macs in the world have a
device tree in ROM that was developed by Apple following the Open
Firmware standard. Same thing for Sun boxes, but I'm not working on
those.

The kernel has an existing mechanism for handling translations like
these, the alias scheme.


> > This issue hasn't been visible before since there was a global table
> > in the PowerPC code mapping all known Open Firmware names into linux
> > names. Keeping this as a global table doesn't scale. The mapping needs
> > to be done by each device individually.
>
> Looking at your patch set, I see only 11 entries in the table (in
> arch/powerpc/sysdev/fsl_soc.c) that patch #2 deletes. Are there more in
> other files? I'm asking because 11 entries hardly qualifies as "doesn't
> scale". I sure hope that you're not doing all this for the sole purpose
> of getting rid of this 11-element table.

Currently developers add entries to the table in their private builds
for the i2c devices they are using. Another way to avoid adding a
table entry is to create a platform device in the platform code. But
this support is being extended to audio codecs too. There are hundreds
of audio codecs.

The whole purpose of this code is to dynamically load the correct i2c
and audio drivers by reading the device tree instead of having static
i2s/codec devices for every possible platform combination.


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 0/5] Version 17, series to add device tree naming to i2c

2008-01-12 Thread Jon Smirl
On 1/12/08, Jean Delvare [EMAIL PROTECTED] wrote:
 On Fri, 11 Jan 2008 15:16:57 -0500, Jon Smirl wrote:
  On 1/11/08, Jean Delvare [EMAIL PROTECTED] wrote:
   Secondly, it promotes OF device names as acceptable aliases. This I
   don't think I agree with. While I see some value in moving the OF name
   - Linux name translation to the drivers themselves (even though I
   don't see this as a mandatory move either), this doesn't imply that OF
   names should be used as aliases. I don't like the idea that different
   architectures will name the same device differently in a visible way.
   This could easily break user-space code that makes assumptions on the
   device names (libsensors comes to mind.) So, I think that this part
   will need some more discussion.
 
  They're aliases.  On the x86 my e1000 Ethernet driver loads using this
  alias name:
  pci:v8086d1010sv*sd*bc*sc*i*
  In fact, the e1000 driver has 63 alias names in addition to e1000
 
  But it's still the e1000 driver after it is loaded.
  [EMAIL PROTECTED]:/home/linux/drivers/net/e1000$ lsmod | grep e1000
  e1000 115968  0
 
  Loading a I2C driver with an OF alias name is not going to change the
  module name after it is loaded. In fact, once the module is in memory
  there's no way to tell what name was used to load it.

 Of course. That's not what I was worried about... what I was worried
 about is something your patch set doesn't do but I misread the code and
 I thought it was doing. I'll read it again before I make more comments
 on this.

  OF device names are set by the Open Firmware committee. It is not
  reasonable to force the Linux names back into Open Firmware since this
  would force the other operating systems using Open Firmware to adopt
  the Linux names.

 I never meant to force the Linux names into Open Firmware. It wouldn't
 make sense especially when the Linux names are invented by random
 contributors with no specific rules, and can even change over time.

 What I meant is that the translation from Open Firmware device name to
 Linux device name could happen in different ways. Making module aliases
 out of the is one possibility but this is not the only one.

 I am curious why the translation could not happen offline. As I
 understand it, you're getting the device names from these .dts files.
 However you're not parsing them in the kernel directly, are you? I
 presume that you have some tool that converts these files into C code
 that the kernel can use? This conversion tool could translate the names.

Those dts files are for embedded devices that were specifically
developed for Linux. All of the PowerPC Macs in the world have a
device tree in ROM that was developed by Apple following the Open
Firmware standard. Same thing for Sun boxes, but I'm not working on
those.

The kernel has an existing mechanism for handling translations like
these, the alias scheme.


  This issue hasn't been visible before since there was a global table
  in the PowerPC code mapping all known Open Firmware names into linux
  names. Keeping this as a global table doesn't scale. The mapping needs
  to be done by each device individually.

 Looking at your patch set, I see only 11 entries in the table (in
 arch/powerpc/sysdev/fsl_soc.c) that patch #2 deletes. Are there more in
 other files? I'm asking because 11 entries hardly qualifies as doesn't
 scale. I sure hope that you're not doing all this for the sole purpose
 of getting rid of this 11-element table.

Currently developers add entries to the table in their private builds
for the i2c devices they are using. Another way to avoid adding a
table entry is to create a platform device in the platform code. But
this support is being extended to audio codecs too. There are hundreds
of audio codecs.

The whole purpose of this code is to dynamically load the correct i2c
and audio drivers by reading the device tree instead of having static
i2s/codec devices for every possible platform combination.


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-12 Thread Jon Smirl
On 1/12/08, Jean Delvare [EMAIL PROTECTED] wrote:
 Hi Jon,

 On Fri, 11 Jan 2008 20:20:15 +0100, Jean Delvare wrote:
   +{
   +   /* only powerpc drivers implement the id_table,
   +* it is empty on other platforms */
   +   if (id) {
   +   while (id-name[0]) {
   +   if (strcmp(client-driver_name, id-name) == 0)
 
  This doesn't look right to me. You should be comparing client-name,
  not client-driver_name, with id-name. Where id_table is implemented,
  client-driver_name might not even be set. I see that the next patch in
  the series makes use of client-driver_name as well, so your code
  works... but this ain't correct still.

 Err, scratch this (and related comments), I just realized what you were
 trying to do. That's different from what I had in mind and so I read
 your code wrong. I'll read it (and test it) again not making this
 incorrect assumption and my comments will likely be different after
 that. Well, I still think that it needs to be changed a bit, but
 probably not in the direction I suggested at first (which, I realize
 now, has its own share of issues - so it's not fair to me to point you
 there.)

The common scheme used elsewhere in the kernel for handling more than
one device in a single driver is aliases. The i2c code's existing
driver_name/type combination is a different way of implementing the
same feature. But there is no real need for driver_name/type on any
platform if aliases are used. Back in version 10 or 11 I had code in
there which replaced the two fields with aliases on all platforms but
too many people objected so I removed it..

IMHO, driver_name/type should be removed in new style drivers and
replaced with aliases on all platforms since aliases are the standard
kernel mechanism.




 Sorry for the trouble. I'll post updated comments later today, but I'm
 also pretty busy with other issues, some of which need to be solved
 before 2.6.24 is released so I can't really delay them.

 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 19 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-11 Thread Jon Smirl
Comment was wrong, I2C_OF_MODULE_PREFIX was needed. Add it back.

Implement module aliasing for i2c to translate from device tree names

This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/hwmon/f75375s.c |4 ++--
 drivers/i2c/chips/ds1682.c  |2 +-
 drivers/i2c/chips/menelaus.c|2 +-
 drivers/i2c/chips/tps65010.c|2 +-
 drivers/i2c/chips/tsl2550.c |2 +-
 drivers/i2c/i2c-core.c  |   24 +++-
 drivers/rtc/rtc-ds1307.c|2 +-
 drivers/rtc/rtc-ds1374.c|2 +-
 drivers/rtc/rtc-m41t80.c|2 +-
 drivers/rtc/rtc-rs5c372.c   |2 +-
 include/linux/i2c.h |5 ++---
 include/linux/mod_devicetable.h |   20 
 scripts/mod/file2alias.c|   12 
 13 files changed, 67 insertions(+), 14 deletions(-)


diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 6892f76..2247de6 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -117,7 +117,7 @@ struct f75375_data {
 static int f75375_attach_adapter(struct i2c_adapter *adapter);
 static int f75375_detect(struct i2c_adapter *adapter, int address, int kind);
 static int f75375_detach_client(struct i2c_client *client);
-static int f75375_probe(struct i2c_client *client);
+static int f75375_probe(struct i2c_client *client, const struct
i2c_device_id *id);
 static int f75375_remove(struct i2c_client *client);

 static struct i2c_driver f75375_legacy_driver = {
@@ -628,7 +628,7 @@ static void f75375_init(struct i2c_client *client,
struct f75375_data *data,

 }

-static int f75375_probe(struct i2c_client *client)
+static int f75375_probe(struct i2c_client *client, const struct
i2c_device_id *id)
 {
struct f75375_data *data = i2c_get_clientdata(client);
struct f75375s_platform_data *f75375s_pdata = client->dev.platform_data;
diff --git a/drivers/i2c/chips/ds1682.c b/drivers/i2c/chips/ds1682.c
index 9e94542..93c0441 100644
--- a/drivers/i2c/chips/ds1682.c
+++ b/drivers/i2c/chips/ds1682.c
@@ -200,7 +200,7 @@ static struct bin_attribute ds1682_eeprom_attr = {
 /*
  * Called when a ds1682 device is matched with this driver
  */
-static int ds1682_probe(struct i2c_client *client)
+static int ds1682_probe(struct i2c_client *client, const struct
i2c_device_id *id)
 {
int rc;

diff --git a/drivers/i2c/chips/menelaus.c b/drivers/i2c/chips/menelaus.c
index 2dea012..89ef9b6 100644
--- a/drivers/i2c/chips/menelaus.c
+++ b/drivers/i2c/chips/menelaus.c
@@ -1149,7 +1149,7 @@ static inline void menelaus_rtc_init(struct
menelaus_chip *m)

 static struct i2c_driver menelaus_i2c_driver;

-static int menelaus_probe(struct i2c_client *client)
+static int menelaus_probe(struct i2c_client *client, const struct
i2c_device_id *id)
 {
struct menelaus_chip*menelaus;
int rev = 0, val;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index e320994..6b13642 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -465,7 +465,7 @@ static int __exit tps65010_remove(struct i2c_client *client)
return 0;
 }

-static int tps65010_probe(struct i2c_client *client)
+static int tps65010_probe(struct i2c_client *client, const struct
i2c_device_id *id)
 {
struct tps65010 *tps;
int status;
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c
index 3de4b19..27c553d 100644
--- a/drivers/i2c/chips/tsl2550.c
+++ b/drivers/i2c/chips/tsl2550.c
@@ -364,7 +364,7 @@ static int tsl2550_init_client(struct i2c_client *client)
  */

 static struct i2c_driver tsl2550_driver;
-static int __devinit tsl2550_probe(struct i2c_client *client)
+static int __devinit tsl2550_probe(struct i2c_client *client, const
struct i2c_device_id *id)
 {
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct tsl2550_data *data;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..5f62230 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,6 +47,19 @@ static DEFINE_IDR(i2c_adapter_idr);

 /* - */

+static const struct i2c_device_id *i2c_match_id(
+   const struct i2c_device_id *id, struct i2c_client *client)
+{
+   /* only powerpc drivers implement the id_table,
+* it is empty on other platforms */
+   while (id->name[0]) {
+   if (strcmp(client->name, id->name) == 0)
+   return id;
+   id++;
+   }
+   return NULL;
+}
+
 static int i2c_device_match(struct device *dev, struct device_driver *drv)
 {
struct i2c

[PATCH 19 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-11 Thread Jon Smirl
This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/hwmon/f75375s.c |4 ++--
 drivers/i2c/chips/ds1682.c  |2 +-
 drivers/i2c/chips/menelaus.c|2 +-
 drivers/i2c/chips/tps65010.c|2 +-
 drivers/i2c/chips/tsl2550.c |2 +-
 drivers/i2c/i2c-core.c  |   24 +++-
 drivers/rtc/rtc-ds1307.c|2 +-
 drivers/rtc/rtc-ds1374.c|2 +-
 drivers/rtc/rtc-m41t80.c|2 +-
 drivers/rtc/rtc-rs5c372.c   |2 +-
 include/linux/i2c.h |5 ++---
 include/linux/mod_devicetable.h |   19 +++
 scripts/mod/file2alias.c|   14 ++
 13 files changed, 68 insertions(+), 14 deletions(-)


diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 6892f76..2247de6 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -117,7 +117,7 @@ struct f75375_data {
 static int f75375_attach_adapter(struct i2c_adapter *adapter);
 static int f75375_detect(struct i2c_adapter *adapter, int address, int kind);
 static int f75375_detach_client(struct i2c_client *client);
-static int f75375_probe(struct i2c_client *client);
+static int f75375_probe(struct i2c_client *client, const struct i2c_device_id 
*id);
 static int f75375_remove(struct i2c_client *client);
 
 static struct i2c_driver f75375_legacy_driver = {
@@ -628,7 +628,7 @@ static void f75375_init(struct i2c_client *client, struct 
f75375_data *data,
 
 }
 
-static int f75375_probe(struct i2c_client *client)
+static int f75375_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
struct f75375_data *data = i2c_get_clientdata(client);
struct f75375s_platform_data *f75375s_pdata = client->dev.platform_data;
diff --git a/drivers/i2c/chips/ds1682.c b/drivers/i2c/chips/ds1682.c
index 9e94542..93c0441 100644
--- a/drivers/i2c/chips/ds1682.c
+++ b/drivers/i2c/chips/ds1682.c
@@ -200,7 +200,7 @@ static struct bin_attribute ds1682_eeprom_attr = {
 /*
  * Called when a ds1682 device is matched with this driver
  */
-static int ds1682_probe(struct i2c_client *client)
+static int ds1682_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
int rc;
 
diff --git a/drivers/i2c/chips/menelaus.c b/drivers/i2c/chips/menelaus.c
index 2dea012..89ef9b6 100644
--- a/drivers/i2c/chips/menelaus.c
+++ b/drivers/i2c/chips/menelaus.c
@@ -1149,7 +1149,7 @@ static inline void menelaus_rtc_init(struct menelaus_chip 
*m)
 
 static struct i2c_driver menelaus_i2c_driver;
 
-static int menelaus_probe(struct i2c_client *client)
+static int menelaus_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct menelaus_chip*menelaus;
int rev = 0, val;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index e320994..6b13642 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -465,7 +465,7 @@ static int __exit tps65010_remove(struct i2c_client *client)
return 0;
 }
 
-static int tps65010_probe(struct i2c_client *client)
+static int tps65010_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct tps65010 *tps;
int status;
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c
index 3de4b19..27c553d 100644
--- a/drivers/i2c/chips/tsl2550.c
+++ b/drivers/i2c/chips/tsl2550.c
@@ -364,7 +364,7 @@ static int tsl2550_init_client(struct i2c_client *client)
  */
 
 static struct i2c_driver tsl2550_driver;
-static int __devinit tsl2550_probe(struct i2c_client *client)
+static int __devinit tsl2550_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct tsl2550_data *data;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..5f62230 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,6 +47,19 @@ static DEFINE_IDR(i2c_adapter_idr);
 
 /* - */
 
+static const struct i2c_device_id *i2c_match_id(
+   const struct i2c_device_id *id, struct i2c_client *client)
+{
+   /* only powerpc drivers implement the id_table,
+* it is empty on other platforms */
+   while (id->name[0]) {
+   if (strcmp(client->name, id->name) == 0)
+   return id;
+   id++;
+   }
+   return NULL;
+}
+
 static int i2c_device_match(struct device *dev, struct device_driver *drv)
 {
struct i2c_client   *client = to_i2c_client(dev);
@@ -58,6 +71,10 @@ static int i2c_device_match(struct device *dev, struc

[PATCH 19 0/5] Version 18, series to add device tree naming to i2c

2008-01-11 Thread Jon Smirl
Updated to reflect comments in:
http://lkml.org/lkml/2008/1/11/272

Since copying i2c-mpc.c to maintain support for the ppc architecture seems to 
be an issue; instead rework i2c-mpc.c to use CONFIG_PPC_MERGE #ifdefs to 
support both the ppc and powerpc architecture. When ppc is deleted in six 
months these #ifdefs will need to be removed.

Another rework of the i2c for powerpc device tree patch. This version 
implements standard alias naming only on the powerpc platform and only for the 
device tree names. The old naming mechanism of i2c_client.name,driver_name is 
left in place and not changed for non-powerpc platforms. This patch is fully 
capable of dynamically loading the i2c modules. You can modprobe in the i2c-mpc 
driver and the i2c modules described in the device tree will be automatically 
loaded. Modules also work if compiled in.

The follow on patch to module-init-tools is also needed since the i2c subsystem 
has never implemented dynamic loading.
http://lkml.org/lkml/2007/12/17/493

The following series implements standard linux module aliasing for i2c modules 
on arch=powerpc. It then converts the mpc i2c driver from being a platform 
driver to an open firmware one. I2C device names are picked up from the device 
tree. Module aliasing is used to translate from device tree names into to linux 
kernel names. Several i2c drivers are updated to use the new aliasing. 

--
Jon Smirl
[EMAIL PROTECTED] 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19 5/5] Convert pfc8563 i2c driver from old style to new style

2008-01-11 Thread Jon Smirl
Convert pfc8563 i2c driver from old style to new style. The
driver is also modified to support device tree names via the
i2c mod alias mechanism.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/rtc/rtc-pcf8563.c |  107 +++--
 1 files changed, 27 insertions(+), 80 deletions(-)


diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 0242d80..e1ea2a0 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -25,10 +25,6 @@
  * located at 0x51 will pass the validation routine due to
  * the way the registers are implemented.
  */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Module parameters */
-I2C_CLIENT_INSMOD;
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -72,9 +68,6 @@ struct pcf8563 {
int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
-static int pcf8563_detach(struct i2c_client *client);
-
 /*
  * In the routines that deal directly with the pcf8563 hardware, we use
  * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
@@ -257,98 +250,52 @@ static const struct rtc_class_ops pcf8563_rtc_ops = {
.set_time   = pcf8563_rtc_set_time,
 };
 
-static int pcf8563_attach(struct i2c_adapter *adapter)
+static int pcf8563_remove(struct i2c_client *client)
 {
-   return i2c_probe(adapter, _data, pcf8563_probe);
+   struct rtc_device *rtc = i2c_get_clientdata(client);
+
+   if (rtc)
+   rtc_device_unregister(rtc);
+
+   return 0;
 }
 
+static struct i2c_device_id pcf8563_id[] = {
+   OF_I2C_ID("philips,pcf8563", 0)
+   OF_I2C_ID("epson,rtc8564", 0)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, pcf8563_id);
+
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id);
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
-   .name   = "pcf8563",
+   .name   = "rtc-pcf8563",
},
.id = I2C_DRIVERID_PCF8563,
-   .attach_adapter = _attach,
-   .detach_client  = _detach,
+   .probe = _probe,
+   .remove = _remove,
+   .id_table   = pcf8563_id,
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
-   struct pcf8563 *pcf8563;
-   struct i2c_client *client;
+   int result;
struct rtc_device *rtc;
 
-   int err = 0;
-
-   dev_dbg(>dev, "%s\n", __FUNCTION__);
-
-   if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
-   err = -ENODEV;
-   goto exit;
-   }
-
-   if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
-   err = -ENOMEM;
-   goto exit;
-   }
-
-   client = >client;
-   client->addr = address;
-   client->driver = _driver;
-   client->adapter = adapter;
-
-   strlcpy(client->name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
-
-   /* Verify the chip is really an PCF8563 */
-   if (kind < 0) {
-   if (pcf8563_validate_client(client) < 0) {
-   err = -ENODEV;
-   goto exit_kfree;
-   }
-   }
-
-   /* Inform the i2c layer */
-   if ((err = i2c_attach_client(client)))
-   goto exit_kfree;
-
-   dev_info(>dev, "chip found, driver version " DRV_VERSION "\n");
+   result = pcf8563_validate_client(client);
+   if (result)
+   return result;
 
rtc = rtc_device_register(pcf8563_driver.driver.name, >dev,
_rtc_ops, THIS_MODULE);
-
-   if (IS_ERR(rtc)) {
-   err = PTR_ERR(rtc);
-   goto exit_detach;
-   }
+   if (IS_ERR(rtc))
+   return PTR_ERR(rtc);
 
i2c_set_clientdata(client, rtc);
 
return 0;
-
-exit_detach:
-   i2c_detach_client(client);
-
-exit_kfree:
-   kfree(pcf8563);
-
-exit:
-   return err;
-}
-
-static int pcf8563_detach(struct i2c_client *client)
-{
-   struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
-   int err;
-   struct rtc_device *rtc = i2c_get_clientdata(client);
-
-   if (rtc)
-   rtc_device_unregister(rtc);
-
-   if ((err = i2c_detach_client(client)))
-   return err;
-
-   kfree(pcf8563);
-
-   return 0;
 }
 
 static int __init pcf8563_init(void)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19 4/5] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

2008-01-11 Thread Jon Smirl
Convert MPC i2c driver from being a platform_driver to an open firmware 
version. Error returns were improved. Routine names were changed from fsl_ to 
mpc_ to make them match the file name.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 arch/powerpc/sysdev/fsl_soc.c |   96 --
 drivers/i2c/busses/i2c-mpc.c  |  183 -
 2 files changed, 180 insertions(+), 99 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 94e5c73..d6ef264 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -318,102 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include 
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-  int bus_num)
-{
-   struct device_node *node = NULL;
-   const char *compatible;
-
-   while ((node = of_get_next_child(adap_node, node))) {
-   struct i2c_board_info info = {};
-   const u32 *addr;
-   int len;
-
-   addr = of_get_property(node, "reg", );
-   if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
-   printk(KERN_WARNING "fsl_soc.c: invalid i2c device 
entry\n");
-   continue;
-   }
-
-   info.irq = irq_of_parse_and_map(node, 0);
-   if (info.irq == NO_IRQ)
-   info.irq = -1;
-
-   compatible = of_get_property(node, "compatible", );
-   if (!compatible) {
-   printk(KERN_WARNING "i2c-mpc.c: invalid entry, missing 
compatible attribute\n");
-   continue;
-   }
-   strncpy(info.type, compatible, sizeof(info.type));
-
-   info.addr = *addr;
-
-   i2c_register_board_info(bus_num, , 1);
-   }
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-   struct device_node *np;
-   unsigned int i;
-   struct platform_device *i2c_dev;
-   int ret;
-
-   for (np = NULL, i = 0;
-(np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
-i++) {
-   struct resource r[2];
-   struct fsl_i2c_platform_data i2c_data;
-   const unsigned char *flags = NULL;
-
-   memset(, 0, sizeof(r));
-   memset(_data, 0, sizeof(i2c_data));
-
-   ret = of_address_to_resource(np, 0, [0]);
-   if (ret)
-   goto err;
-
-   of_irq_to_resource(np, 0, [1]);
-
-   i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
-   if (IS_ERR(i2c_dev)) {
-   ret = PTR_ERR(i2c_dev);
-   goto err;
-   }
-
-   i2c_data.device_flags = 0;
-   flags = of_get_property(np, "dfsrr", NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-   flags = of_get_property(np, "fsl5200-clocking", NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-   ret =
-   platform_device_add_data(i2c_dev, _data,
-sizeof(struct
-   fsl_i2c_platform_data));
-   if (ret)
-   goto unreg;
-
-   of_register_i2c_devices(np, i);
-   }
-
-   return 0;
-
-unreg:
-   platform_device_unregister(i2c_dev);
-err:
-   return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
-
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
 {
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 7c35a8f..91fa73c 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 
@@ -25,13 +25,13 @@
 #include 
 #include 
 
-#define MPC_I2C_ADDR  0x00
+#define DRV_NAME "mpc-i2c"
+
 #define MPC_I2C_FDR0x04
 #define MPC_I2C_CR 0x08
 #define MPC_I2C_SR 0x0c
 #define MPC_I2C_DR 0x10
 #define MPC_I2C_DFSRR 0x14
-#define MPC_I2C_REGION 0x20
 
 #define CCR_MEN  0x80
 #define CCR_MIEN 0x40
@@ -316,6 +316,181 @@ static struct i2c_adapter mpc_ops = {
.retries = 1
 };
 
+struct i2c_driver_device {
+   char*of_device;
+   char*i2c_driver;
+   char*i2c_type;
+};
+
+#ifdef CONFIG_PPC_MERGE
+
+static void of_register_i2c_devices(struct i2c_adapter *adap, struct 
device_node *adap_node)
+{
+   struct device_node *node = NULL;
+
+   while ((node = of_get_next_child(adap_node, node))) {
+   struct i2c_board_info info;
+ 

[PATCH 19 3/5] Clean up error returns

2008-01-11 Thread Jon Smirl
Return errors that were being ignored in the mpc-i2c driver

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/i2c/busses/i2c-mpc.c |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index d8de4ac..7c35a8f 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -180,7 +180,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
 static int mpc_write(struct mpc_i2c *i2c, int target,
 const u8 * data, int length, int restart)
 {
-   int i;
+   int i, result;
unsigned timeout = i2c->adap.timeout;
u32 flags = restart ? CCR_RSTA : 0;
 
@@ -192,15 +192,17 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
/* Write target byte */
writeb((target << 1), i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
 
for (i = 0; i < length; i++) {
/* Write data byte */
writeb(data[i], i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
}
 
return 0;
@@ -210,7 +212,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
u8 * data, int length, int restart)
 {
unsigned timeout = i2c->adap.timeout;
-   int i;
+   int i, result;
u32 flags = restart ? CCR_RSTA : 0;
 
/* Start with MEN */
@@ -221,8 +223,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
/* Write target address byte - this time with the read flag set */
writeb((target << 1) | 1, i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
 
if (length) {
if (length == 1)
@@ -234,8 +237,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
}
 
for (i = 0; i < length; i++) {
-   if (i2c_wait(i2c, timeout, 0) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 0);
+   if (result < 0)
+   return result;
 
/* Generate txack on next to last byte */
if (i == length - 2)
@@ -321,9 +325,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 
pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
 
-   if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
+   i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+   if (!i2c)
return -ENOMEM;
-   }
 
i2c->irq = platform_get_irq(pdev, 0);
if (i2c->irq < 0) {
@@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(>adap);
platform_set_drvdata(pdev, NULL);
 
-   if (i2c->irq != 0)
+   if (i2c->irq != NO_IRQ)
free_irq(i2c->irq, i2c);
 
iounmap(i2c->base);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19 2/5] Modify several rtc drivers to use the alias names list property of i2c

2008-01-11 Thread Jon Smirl
This patch modifies the ds1307, ds1374, and rs5c372 i2c drivers to support
device tree names using the new i2c mod alias support

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 arch/powerpc/sysdev/fsl_soc.c |   44 -
 drivers/rtc/rtc-ds1307.c  |   18 +
 drivers/rtc/rtc-ds1374.c  |7 +
 drivers/rtc/rtc-m41t80.c  |   55 -
 drivers/rtc/rtc-rs5c372.c |   14 ++
 5 files changed, 81 insertions(+), 57 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 3ace747..94e5c73 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -320,48 +320,12 @@ arch_initcall(gfar_of_init);
 
 #ifdef CONFIG_I2C_BOARDINFO
 #include 
-struct i2c_driver_device {
-   char*of_device;
-   char*i2c_driver;
-   char*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-   {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",},
-   {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",},
-   {"ricoh,rv5c386",  "rtc-rs5c372", "rv5c386",},
-   {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",},
-   {"dallas,ds1307",  "rtc-ds1307",  "ds1307",},
-   {"dallas,ds1337",  "rtc-ds1307",  "ds1337",},
-   {"dallas,ds1338",  "rtc-ds1307",  "ds1338",},
-   {"dallas,ds1339",  "rtc-ds1307",  "ds1339",},
-   {"dallas,ds1340",  "rtc-ds1307",  "ds1340",},
-   {"stm,m41t00", "rtc-ds1307",  "m41t00"},
-   {"dallas,ds1374",  "rtc-ds1374",  "rtc-ds1374",},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-struct i2c_board_info *info)
-{
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
-   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-   continue;
-   if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver,
-   KOBJ_NAME_LEN) >= KOBJ_NAME_LEN ||
-   strlcpy(info->type, i2c_devices[i].i2c_type,
-   I2C_NAME_SIZE) >= I2C_NAME_SIZE)
-   return -ENOMEM;
-   return 0;
-   }
-   return -ENODEV;
-}
 
 static void __init of_register_i2c_devices(struct device_node *adap_node,
   int bus_num)
 {
struct device_node *node = NULL;
+   const char *compatible;
 
while ((node = of_get_next_child(adap_node, node))) {
struct i2c_board_info info = {};
@@ -378,8 +342,12 @@ static void __init of_register_i2c_devices(struct 
device_node *adap_node,
if (info.irq == NO_IRQ)
info.irq = -1;
 
-   if (of_find_i2c_driver(node, ) < 0)
+   compatible = of_get_property(node, "compatible", );
+   if (!compatible) {
+   printk(KERN_WARNING "i2c-mpc.c: invalid entry, missing 
compatible attribute\n");
continue;
+   }
+   strncpy(info.type, compatible, sizeof(info.type));
 
info.addr = *addr;
 
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 9b0eab9..d4874ff 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -139,6 +139,17 @@ static inline const struct chip_desc *find_chip(const char 
*s)
return NULL;
 }
 
+static struct i2c_device_id ds1307_id[] = {
+   OF_I2C_ID("dallas,ds1307", ds_1307)
+   OF_I2C_ID("dallas,ds1337", ds_1337)
+   OF_I2C_ID("dallas,ds1338", ds_1338)
+   OF_I2C_ID("dallas,ds1339", ds_1339)
+   OF_I2C_ID("dallas,ds1340", ds_1340)
+   OF_I2C_ID("stm,m41t00", m41t00)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, ds1307_id);
+
 static int ds1307_get_time(struct device *dev, struct rtc_time *t)
 {
struct ds1307   *ds1307 = dev_get_drvdata(dev);
@@ -334,7 +345,11 @@ static int __devinit ds1307_probe(struct i2c_client 
*client, const struct i2c_de
const struct chip_desc  *chip;
struct i2c_adapter  *adapter = to_i2c_adapter(client->dev.parent);
 
-   chip = find_chip(client->name);
+   if (id)
+   chip = [id->driver_data];
+   else
+   chip = find_chip(client->name);
+
if (!chip) {
dev_err(>dev, "unknown chip type '%s'\n",
client->name);
@@ -537,6 +552,7 @@ static struct i2c_driver ds1307_driver = {
   

Re: [i2c] [PATCH 0/5] Version 17, series to add device tree naming to i2c

2008-01-11 Thread Jon Smirl
On 1/11/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Secondly, it promotes OF device names as acceptable aliases. This I
> don't think I agree with. While I see some value in moving the OF name
> -> Linux name translation to the drivers themselves (even though I
> don't see this as a mandatory move either), this doesn't imply that OF
> names should be used as aliases. I don't like the idea that different
> architectures will name the same device differently in a visible way.
> This could easily break user-space code that makes assumptions on the
> device names (libsensors comes to mind.) So, I think that this part
> will need some more discussion.

They're aliases.  On the x86 my e1000 Ethernet driver loads using this
alias name:
"pci:v8086d1010sv*sd*bc*sc*i*"
In fact, the e1000 driver has 63 alias names in addition to "e1000"

But it's still the e1000 driver after it is loaded.
[EMAIL PROTECTED]:/home/linux/drivers/net/e1000$ lsmod | grep e1000
e1000 115968  0

Loading a I2C driver with an OF alias name is not going to change the
module name after it is loaded. In fact, once the module is in memory
there's no way to tell what name was used to load it.

OF device names are set by the Open Firmware committee. It is not
reasonable to force the Linux names back into Open Firmware since this
would force the other operating systems using Open Firmware to adopt
the Linux names.

This issue hasn't been visible before since there was a global table
in the PowerPC code mapping all known Open Firmware names into linux
names. Keeping this as a global table doesn't scale. The mapping needs
to be done by each device individually.

>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 0/5] Version 17, series to add device tree naming to i2c

2008-01-11 Thread Jon Smirl
On 1/11/08, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Hi Jon,
>
> On Wed, 19 Dec 2007 23:41:36 -0500, Jon Smirl wrote:
> > Since copying i2c-mpc.c to maintain support for the ppc architecture seems 
> > to be an issue; instead rework i2c-mpc.c to use CONFIG_PPC_MERGE #ifdefs to 
> > support both the ppc and powerpc architecture. When ppc is deleted in six 
> > months these #ifdefs will need to be removed.
> >
> > Another rework of the i2c for powerpc device tree patch. This version 
> > implements standard alias naming only on the powerpc platform and only for 
> > the device tree names. The old naming mechanism of 
> > i2c_client.name,driver_name is left in place and not changed for 
> > non-powerpc platforms. This patch is fully capable of dynamically loading 
> > the i2c modules. You can modprobe in the i2c-mpc driver and the i2c modules 
> > described in the device tree will be automatically loaded. Modules also 
> > work if compiled in.
> >
> > The follow on patch to module-init-tools is also needed since the i2c 
> > subsystem has never implemented dynamic loading.
> >
> > The following series implements standard linux module aliasing for i2c 
> > modules on arch=powerpc. It then converts the mpc i2c driver from being a 
> > platform driver to an open firmware one. I2C device names are picked up 
> > from the device tree. Module aliasing is used to translate from device tree 
> > names into to linux kernel names. Several i2c drivers are updated to use 
> > the new aliasing.
>
> Now that I have read all the previous versions of this patch series
> and, more importantly, all objections that were raised on the way, I
> can start reviewing the latest iteration of your patches. I'll also do
> some testing, although I have no powerpc stuff here, but at least I
> want to make sure that there are no regressions introduced by your
> patches on x86.


Various people were worried about x86. Around version 15 I altered the
patches so that they only impacted PowerPC. If they impact x86 in
current form that is a bug.

When x86 is ready for it I do think dynamic module loading should be
implemented there also.
>
> --
> Jean Delvare
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 0/5] Version 17, series to add device tree naming to i2c

2008-01-11 Thread Jon Smirl
On 1/11/08, Jean Delvare [EMAIL PROTECTED] wrote:
 Hi Jon,

 On Wed, 19 Dec 2007 23:41:36 -0500, Jon Smirl wrote:
  Since copying i2c-mpc.c to maintain support for the ppc architecture seems 
  to be an issue; instead rework i2c-mpc.c to use CONFIG_PPC_MERGE #ifdefs to 
  support both the ppc and powerpc architecture. When ppc is deleted in six 
  months these #ifdefs will need to be removed.
 
  Another rework of the i2c for powerpc device tree patch. This version 
  implements standard alias naming only on the powerpc platform and only for 
  the device tree names. The old naming mechanism of 
  i2c_client.name,driver_name is left in place and not changed for 
  non-powerpc platforms. This patch is fully capable of dynamically loading 
  the i2c modules. You can modprobe in the i2c-mpc driver and the i2c modules 
  described in the device tree will be automatically loaded. Modules also 
  work if compiled in.
 
  The follow on patch to module-init-tools is also needed since the i2c 
  subsystem has never implemented dynamic loading.
 
  The following series implements standard linux module aliasing for i2c 
  modules on arch=powerpc. It then converts the mpc i2c driver from being a 
  platform driver to an open firmware one. I2C device names are picked up 
  from the device tree. Module aliasing is used to translate from device tree 
  names into to linux kernel names. Several i2c drivers are updated to use 
  the new aliasing.

 Now that I have read all the previous versions of this patch series
 and, more importantly, all objections that were raised on the way, I
 can start reviewing the latest iteration of your patches. I'll also do
 some testing, although I have no powerpc stuff here, but at least I
 want to make sure that there are no regressions introduced by your
 patches on x86.


Various people were worried about x86. Around version 15 I altered the
patches so that they only impacted PowerPC. If they impact x86 in
current form that is a bug.

When x86 is ready for it I do think dynamic module loading should be
implemented there also.

 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH 0/5] Version 17, series to add device tree naming to i2c

2008-01-11 Thread Jon Smirl
On 1/11/08, Jean Delvare [EMAIL PROTECTED] wrote:
 Secondly, it promotes OF device names as acceptable aliases. This I
 don't think I agree with. While I see some value in moving the OF name
 - Linux name translation to the drivers themselves (even though I
 don't see this as a mandatory move either), this doesn't imply that OF
 names should be used as aliases. I don't like the idea that different
 architectures will name the same device differently in a visible way.
 This could easily break user-space code that makes assumptions on the
 device names (libsensors comes to mind.) So, I think that this part
 will need some more discussion.

They're aliases.  On the x86 my e1000 Ethernet driver loads using this
alias name:
pci:v8086d1010sv*sd*bc*sc*i*
In fact, the e1000 driver has 63 alias names in addition to e1000

But it's still the e1000 driver after it is loaded.
[EMAIL PROTECTED]:/home/linux/drivers/net/e1000$ lsmod | grep e1000
e1000 115968  0

Loading a I2C driver with an OF alias name is not going to change the
module name after it is loaded. In fact, once the module is in memory
there's no way to tell what name was used to load it.

OF device names are set by the Open Firmware committee. It is not
reasonable to force the Linux names back into Open Firmware since this
would force the other operating systems using Open Firmware to adopt
the Linux names.

This issue hasn't been visible before since there was a global table
in the PowerPC code mapping all known Open Firmware names into linux
names. Keeping this as a global table doesn't scale. The mapping needs
to be done by each device individually.


 --
 Jean Delvare



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19 2/5] Modify several rtc drivers to use the alias names list property of i2c

2008-01-11 Thread Jon Smirl
This patch modifies the ds1307, ds1374, and rs5c372 i2c drivers to support
device tree names using the new i2c mod alias support

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 arch/powerpc/sysdev/fsl_soc.c |   44 -
 drivers/rtc/rtc-ds1307.c  |   18 +
 drivers/rtc/rtc-ds1374.c  |7 +
 drivers/rtc/rtc-m41t80.c  |   55 -
 drivers/rtc/rtc-rs5c372.c |   14 ++
 5 files changed, 81 insertions(+), 57 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 3ace747..94e5c73 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -320,48 +320,12 @@ arch_initcall(gfar_of_init);
 
 #ifdef CONFIG_I2C_BOARDINFO
 #include linux/i2c.h
-struct i2c_driver_device {
-   char*of_device;
-   char*i2c_driver;
-   char*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-   {ricoh,rs5c372a, rtc-rs5c372, rs5c372a,},
-   {ricoh,rs5c372b, rtc-rs5c372, rs5c372b,},
-   {ricoh,rv5c386,  rtc-rs5c372, rv5c386,},
-   {ricoh,rv5c387a, rtc-rs5c372, rv5c387a,},
-   {dallas,ds1307,  rtc-ds1307,  ds1307,},
-   {dallas,ds1337,  rtc-ds1307,  ds1337,},
-   {dallas,ds1338,  rtc-ds1307,  ds1338,},
-   {dallas,ds1339,  rtc-ds1307,  ds1339,},
-   {dallas,ds1340,  rtc-ds1307,  ds1340,},
-   {stm,m41t00, rtc-ds1307,  m41t00},
-   {dallas,ds1374,  rtc-ds1374,  rtc-ds1374,},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-struct i2c_board_info *info)
-{
-   int i;
-
-   for (i = 0; i  ARRAY_SIZE(i2c_devices); i++) {
-   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-   continue;
-   if (strlcpy(info-driver_name, i2c_devices[i].i2c_driver,
-   KOBJ_NAME_LEN) = KOBJ_NAME_LEN ||
-   strlcpy(info-type, i2c_devices[i].i2c_type,
-   I2C_NAME_SIZE) = I2C_NAME_SIZE)
-   return -ENOMEM;
-   return 0;
-   }
-   return -ENODEV;
-}
 
 static void __init of_register_i2c_devices(struct device_node *adap_node,
   int bus_num)
 {
struct device_node *node = NULL;
+   const char *compatible;
 
while ((node = of_get_next_child(adap_node, node))) {
struct i2c_board_info info = {};
@@ -378,8 +342,12 @@ static void __init of_register_i2c_devices(struct 
device_node *adap_node,
if (info.irq == NO_IRQ)
info.irq = -1;
 
-   if (of_find_i2c_driver(node, info)  0)
+   compatible = of_get_property(node, compatible, len);
+   if (!compatible) {
+   printk(KERN_WARNING i2c-mpc.c: invalid entry, missing 
compatible attribute\n);
continue;
+   }
+   strncpy(info.type, compatible, sizeof(info.type));
 
info.addr = *addr;
 
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 9b0eab9..d4874ff 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -139,6 +139,17 @@ static inline const struct chip_desc *find_chip(const char 
*s)
return NULL;
 }
 
+static struct i2c_device_id ds1307_id[] = {
+   OF_I2C_ID(dallas,ds1307, ds_1307)
+   OF_I2C_ID(dallas,ds1337, ds_1337)
+   OF_I2C_ID(dallas,ds1338, ds_1338)
+   OF_I2C_ID(dallas,ds1339, ds_1339)
+   OF_I2C_ID(dallas,ds1340, ds_1340)
+   OF_I2C_ID(stm,m41t00, m41t00)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, ds1307_id);
+
 static int ds1307_get_time(struct device *dev, struct rtc_time *t)
 {
struct ds1307   *ds1307 = dev_get_drvdata(dev);
@@ -334,7 +345,11 @@ static int __devinit ds1307_probe(struct i2c_client 
*client, const struct i2c_de
const struct chip_desc  *chip;
struct i2c_adapter  *adapter = to_i2c_adapter(client-dev.parent);
 
-   chip = find_chip(client-name);
+   if (id)
+   chip = chips[id-driver_data];
+   else
+   chip = find_chip(client-name);
+
if (!chip) {
dev_err(client-dev, unknown chip type '%s'\n,
client-name);
@@ -537,6 +552,7 @@ static struct i2c_driver ds1307_driver = {
},
.probe  = ds1307_probe,
.remove = __devexit_p(ds1307_remove),
+   .id_table   = ds1307_id,
 };
 
 static int __init ds1307_init(void)
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index dab6008..6dc05c4 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -41,6 +41,12 @@
 #define DS1374_REG_SR_AF   0x01 /* Alarm Flag */
 #define DS1374_REG_TCR 0x09 /* Trickle Charge */
 
+static struct i2c_device_id ds1374_id[] = {
+   OF_I2C_ID(dallas

[PATCH 19 3/5] Clean up error returns

2008-01-11 Thread Jon Smirl
Return errors that were being ignored in the mpc-i2c driver

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/i2c/busses/i2c-mpc.c |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index d8de4ac..7c35a8f 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -180,7 +180,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
 static int mpc_write(struct mpc_i2c *i2c, int target,
 const u8 * data, int length, int restart)
 {
-   int i;
+   int i, result;
unsigned timeout = i2c-adap.timeout;
u32 flags = restart ? CCR_RSTA : 0;
 
@@ -192,15 +192,17 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
/* Write target byte */
writeb((target  1), i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
 
for (i = 0; i  length; i++) {
/* Write data byte */
writeb(data[i], i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
}
 
return 0;
@@ -210,7 +212,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
u8 * data, int length, int restart)
 {
unsigned timeout = i2c-adap.timeout;
-   int i;
+   int i, result;
u32 flags = restart ? CCR_RSTA : 0;
 
/* Start with MEN */
@@ -221,8 +223,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
/* Write target address byte - this time with the read flag set */
writeb((target  1) | 1, i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
 
if (length) {
if (length == 1)
@@ -234,8 +237,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
}
 
for (i = 0; i  length; i++) {
-   if (i2c_wait(i2c, timeout, 0)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 0);
+   if (result  0)
+   return result;
 
/* Generate txack on next to last byte */
if (i == length - 2)
@@ -321,9 +325,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 
pdata = (struct fsl_i2c_platform_data *) pdev-dev.platform_data;
 
-   if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
+   i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+   if (!i2c)
return -ENOMEM;
-   }
 
i2c-irq = platform_get_irq(pdev, 0);
if (i2c-irq  0) {
@@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(i2c-adap);
platform_set_drvdata(pdev, NULL);
 
-   if (i2c-irq != 0)
+   if (i2c-irq != NO_IRQ)
free_irq(i2c-irq, i2c);
 
iounmap(i2c-base);

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19 4/5] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

2008-01-11 Thread Jon Smirl
Convert MPC i2c driver from being a platform_driver to an open firmware 
version. Error returns were improved. Routine names were changed from fsl_ to 
mpc_ to make them match the file name.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 arch/powerpc/sysdev/fsl_soc.c |   96 --
 drivers/i2c/busses/i2c-mpc.c  |  183 -
 2 files changed, 180 insertions(+), 99 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 94e5c73..d6ef264 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -318,102 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include linux/i2c.h
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-  int bus_num)
-{
-   struct device_node *node = NULL;
-   const char *compatible;
-
-   while ((node = of_get_next_child(adap_node, node))) {
-   struct i2c_board_info info = {};
-   const u32 *addr;
-   int len;
-
-   addr = of_get_property(node, reg, len);
-   if (!addr || len  sizeof(int) || *addr  (1  10) - 1) {
-   printk(KERN_WARNING fsl_soc.c: invalid i2c device 
entry\n);
-   continue;
-   }
-
-   info.irq = irq_of_parse_and_map(node, 0);
-   if (info.irq == NO_IRQ)
-   info.irq = -1;
-
-   compatible = of_get_property(node, compatible, len);
-   if (!compatible) {
-   printk(KERN_WARNING i2c-mpc.c: invalid entry, missing 
compatible attribute\n);
-   continue;
-   }
-   strncpy(info.type, compatible, sizeof(info.type));
-
-   info.addr = *addr;
-
-   i2c_register_board_info(bus_num, info, 1);
-   }
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-   struct device_node *np;
-   unsigned int i;
-   struct platform_device *i2c_dev;
-   int ret;
-
-   for (np = NULL, i = 0;
-(np = of_find_compatible_node(np, i2c, fsl-i2c)) != NULL;
-i++) {
-   struct resource r[2];
-   struct fsl_i2c_platform_data i2c_data;
-   const unsigned char *flags = NULL;
-
-   memset(r, 0, sizeof(r));
-   memset(i2c_data, 0, sizeof(i2c_data));
-
-   ret = of_address_to_resource(np, 0, r[0]);
-   if (ret)
-   goto err;
-
-   of_irq_to_resource(np, 0, r[1]);
-
-   i2c_dev = platform_device_register_simple(fsl-i2c, i, r, 2);
-   if (IS_ERR(i2c_dev)) {
-   ret = PTR_ERR(i2c_dev);
-   goto err;
-   }
-
-   i2c_data.device_flags = 0;
-   flags = of_get_property(np, dfsrr, NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-   flags = of_get_property(np, fsl5200-clocking, NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-   ret =
-   platform_device_add_data(i2c_dev, i2c_data,
-sizeof(struct
-   fsl_i2c_platform_data));
-   if (ret)
-   goto unreg;
-
-   of_register_i2c_devices(np, i);
-   }
-
-   return 0;
-
-unreg:
-   platform_device_unregister(i2c_dev);
-err:
-   return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
-
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
 {
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 7c35a8f..91fa73c 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,7 @@
 #include linux/module.h
 #include linux/sched.h
 #include linux/init.h
-#include linux/platform_device.h
+#include linux/of_platform.h
 
 #include asm/io.h
 #include linux/fsl_devices.h
@@ -25,13 +25,13 @@
 #include linux/interrupt.h
 #include linux/delay.h
 
-#define MPC_I2C_ADDR  0x00
+#define DRV_NAME mpc-i2c
+
 #define MPC_I2C_FDR0x04
 #define MPC_I2C_CR 0x08
 #define MPC_I2C_SR 0x0c
 #define MPC_I2C_DR 0x10
 #define MPC_I2C_DFSRR 0x14
-#define MPC_I2C_REGION 0x20
 
 #define CCR_MEN  0x80
 #define CCR_MIEN 0x40
@@ -316,6 +316,181 @@ static struct i2c_adapter mpc_ops = {
.retries = 1
 };
 
+struct i2c_driver_device {
+   char*of_device;
+   char*i2c_driver;
+   char*i2c_type;
+};
+
+#ifdef CONFIG_PPC_MERGE
+
+static void of_register_i2c_devices(struct i2c_adapter *adap, struct 
device_node *adap_node)
+{
+   struct device_node *node = NULL;
+
+   while ((node = of_get_next_child(adap_node, node))) {
+   struct

[PATCH 19 0/5] Version 18, series to add device tree naming to i2c

2008-01-11 Thread Jon Smirl
Updated to reflect comments in:
http://lkml.org/lkml/2008/1/11/272

Since copying i2c-mpc.c to maintain support for the ppc architecture seems to 
be an issue; instead rework i2c-mpc.c to use CONFIG_PPC_MERGE #ifdefs to 
support both the ppc and powerpc architecture. When ppc is deleted in six 
months these #ifdefs will need to be removed.

Another rework of the i2c for powerpc device tree patch. This version 
implements standard alias naming only on the powerpc platform and only for the 
device tree names. The old naming mechanism of i2c_client.name,driver_name is 
left in place and not changed for non-powerpc platforms. This patch is fully 
capable of dynamically loading the i2c modules. You can modprobe in the i2c-mpc 
driver and the i2c modules described in the device tree will be automatically 
loaded. Modules also work if compiled in.

The follow on patch to module-init-tools is also needed since the i2c subsystem 
has never implemented dynamic loading.
http://lkml.org/lkml/2007/12/17/493

The following series implements standard linux module aliasing for i2c modules 
on arch=powerpc. It then converts the mpc i2c driver from being a platform 
driver to an open firmware one. I2C device names are picked up from the device 
tree. Module aliasing is used to translate from device tree names into to linux 
kernel names. Several i2c drivers are updated to use the new aliasing. 

--
Jon Smirl
[EMAIL PROTECTED] 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19 5/5] Convert pfc8563 i2c driver from old style to new style

2008-01-11 Thread Jon Smirl
Convert pfc8563 i2c driver from old style to new style. The
driver is also modified to support device tree names via the
i2c mod alias mechanism.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/rtc/rtc-pcf8563.c |  107 +++--
 1 files changed, 27 insertions(+), 80 deletions(-)


diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 0242d80..e1ea2a0 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -25,10 +25,6 @@
  * located at 0x51 will pass the validation routine due to
  * the way the registers are implemented.
  */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Module parameters */
-I2C_CLIENT_INSMOD;
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -72,9 +68,6 @@ struct pcf8563 {
int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
-static int pcf8563_detach(struct i2c_client *client);
-
 /*
  * In the routines that deal directly with the pcf8563 hardware, we use
  * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
@@ -257,98 +250,52 @@ static const struct rtc_class_ops pcf8563_rtc_ops = {
.set_time   = pcf8563_rtc_set_time,
 };
 
-static int pcf8563_attach(struct i2c_adapter *adapter)
+static int pcf8563_remove(struct i2c_client *client)
 {
-   return i2c_probe(adapter, addr_data, pcf8563_probe);
+   struct rtc_device *rtc = i2c_get_clientdata(client);
+
+   if (rtc)
+   rtc_device_unregister(rtc);
+
+   return 0;
 }
 
+static struct i2c_device_id pcf8563_id[] = {
+   OF_I2C_ID(philips,pcf8563, 0)
+   OF_I2C_ID(epson,rtc8564, 0)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, pcf8563_id);
+
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id);
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
-   .name   = pcf8563,
+   .name   = rtc-pcf8563,
},
.id = I2C_DRIVERID_PCF8563,
-   .attach_adapter = pcf8563_attach,
-   .detach_client  = pcf8563_detach,
+   .probe = pcf8563_probe,
+   .remove = pcf8563_remove,
+   .id_table   = pcf8563_id,
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
-   struct pcf8563 *pcf8563;
-   struct i2c_client *client;
+   int result;
struct rtc_device *rtc;
 
-   int err = 0;
-
-   dev_dbg(adapter-dev, %s\n, __FUNCTION__);
-
-   if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
-   err = -ENODEV;
-   goto exit;
-   }
-
-   if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
-   err = -ENOMEM;
-   goto exit;
-   }
-
-   client = pcf8563-client;
-   client-addr = address;
-   client-driver = pcf8563_driver;
-   client-adapter = adapter;
-
-   strlcpy(client-name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
-
-   /* Verify the chip is really an PCF8563 */
-   if (kind  0) {
-   if (pcf8563_validate_client(client)  0) {
-   err = -ENODEV;
-   goto exit_kfree;
-   }
-   }
-
-   /* Inform the i2c layer */
-   if ((err = i2c_attach_client(client)))
-   goto exit_kfree;
-
-   dev_info(client-dev, chip found, driver version  DRV_VERSION \n);
+   result = pcf8563_validate_client(client);
+   if (result)
+   return result;
 
rtc = rtc_device_register(pcf8563_driver.driver.name, client-dev,
pcf8563_rtc_ops, THIS_MODULE);
-
-   if (IS_ERR(rtc)) {
-   err = PTR_ERR(rtc);
-   goto exit_detach;
-   }
+   if (IS_ERR(rtc))
+   return PTR_ERR(rtc);
 
i2c_set_clientdata(client, rtc);
 
return 0;
-
-exit_detach:
-   i2c_detach_client(client);
-
-exit_kfree:
-   kfree(pcf8563);
-
-exit:
-   return err;
-}
-
-static int pcf8563_detach(struct i2c_client *client)
-{
-   struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
-   int err;
-   struct rtc_device *rtc = i2c_get_clientdata(client);
-
-   if (rtc)
-   rtc_device_unregister(rtc);
-
-   if ((err = i2c_detach_client(client)))
-   return err;
-
-   kfree(pcf8563);
-
-   return 0;
 }
 
 static int __init pcf8563_init(void)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-11 Thread Jon Smirl
This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/hwmon/f75375s.c |4 ++--
 drivers/i2c/chips/ds1682.c  |2 +-
 drivers/i2c/chips/menelaus.c|2 +-
 drivers/i2c/chips/tps65010.c|2 +-
 drivers/i2c/chips/tsl2550.c |2 +-
 drivers/i2c/i2c-core.c  |   24 +++-
 drivers/rtc/rtc-ds1307.c|2 +-
 drivers/rtc/rtc-ds1374.c|2 +-
 drivers/rtc/rtc-m41t80.c|2 +-
 drivers/rtc/rtc-rs5c372.c   |2 +-
 include/linux/i2c.h |5 ++---
 include/linux/mod_devicetable.h |   19 +++
 scripts/mod/file2alias.c|   14 ++
 13 files changed, 68 insertions(+), 14 deletions(-)


diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 6892f76..2247de6 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -117,7 +117,7 @@ struct f75375_data {
 static int f75375_attach_adapter(struct i2c_adapter *adapter);
 static int f75375_detect(struct i2c_adapter *adapter, int address, int kind);
 static int f75375_detach_client(struct i2c_client *client);
-static int f75375_probe(struct i2c_client *client);
+static int f75375_probe(struct i2c_client *client, const struct i2c_device_id 
*id);
 static int f75375_remove(struct i2c_client *client);
 
 static struct i2c_driver f75375_legacy_driver = {
@@ -628,7 +628,7 @@ static void f75375_init(struct i2c_client *client, struct 
f75375_data *data,
 
 }
 
-static int f75375_probe(struct i2c_client *client)
+static int f75375_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
struct f75375_data *data = i2c_get_clientdata(client);
struct f75375s_platform_data *f75375s_pdata = client-dev.platform_data;
diff --git a/drivers/i2c/chips/ds1682.c b/drivers/i2c/chips/ds1682.c
index 9e94542..93c0441 100644
--- a/drivers/i2c/chips/ds1682.c
+++ b/drivers/i2c/chips/ds1682.c
@@ -200,7 +200,7 @@ static struct bin_attribute ds1682_eeprom_attr = {
 /*
  * Called when a ds1682 device is matched with this driver
  */
-static int ds1682_probe(struct i2c_client *client)
+static int ds1682_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
int rc;
 
diff --git a/drivers/i2c/chips/menelaus.c b/drivers/i2c/chips/menelaus.c
index 2dea012..89ef9b6 100644
--- a/drivers/i2c/chips/menelaus.c
+++ b/drivers/i2c/chips/menelaus.c
@@ -1149,7 +1149,7 @@ static inline void menelaus_rtc_init(struct menelaus_chip 
*m)
 
 static struct i2c_driver menelaus_i2c_driver;
 
-static int menelaus_probe(struct i2c_client *client)
+static int menelaus_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct menelaus_chip*menelaus;
int rev = 0, val;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index e320994..6b13642 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -465,7 +465,7 @@ static int __exit tps65010_remove(struct i2c_client *client)
return 0;
 }
 
-static int tps65010_probe(struct i2c_client *client)
+static int tps65010_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct tps65010 *tps;
int status;
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c
index 3de4b19..27c553d 100644
--- a/drivers/i2c/chips/tsl2550.c
+++ b/drivers/i2c/chips/tsl2550.c
@@ -364,7 +364,7 @@ static int tsl2550_init_client(struct i2c_client *client)
  */
 
 static struct i2c_driver tsl2550_driver;
-static int __devinit tsl2550_probe(struct i2c_client *client)
+static int __devinit tsl2550_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct i2c_adapter *adapter = to_i2c_adapter(client-dev.parent);
struct tsl2550_data *data;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..5f62230 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,6 +47,19 @@ static DEFINE_IDR(i2c_adapter_idr);
 
 /* - */
 
+static const struct i2c_device_id *i2c_match_id(
+   const struct i2c_device_id *id, struct i2c_client *client)
+{
+   /* only powerpc drivers implement the id_table,
+* it is empty on other platforms */
+   while (id-name[0]) {
+   if (strcmp(client-name, id-name) == 0)
+   return id;
+   id++;
+   }
+   return NULL;
+}
+
 static int i2c_device_match(struct device *dev, struct device_driver *drv)
 {
struct i2c_client   *client = to_i2c_client(dev);
@@ -58,6 +71,10 @@ static int i2c_device_match(struct device *dev, struct 
device_driver *drv

Re: [i2c] [PATCH 19 1/5] Implement module aliasing for i2c to translate from device tree names

2008-01-11 Thread Jon Smirl
Comment was wrong, I2C_OF_MODULE_PREFIX was needed. Add it back.

Implement module aliasing for i2c to translate from device tree names

This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/hwmon/f75375s.c |4 ++--
 drivers/i2c/chips/ds1682.c  |2 +-
 drivers/i2c/chips/menelaus.c|2 +-
 drivers/i2c/chips/tps65010.c|2 +-
 drivers/i2c/chips/tsl2550.c |2 +-
 drivers/i2c/i2c-core.c  |   24 +++-
 drivers/rtc/rtc-ds1307.c|2 +-
 drivers/rtc/rtc-ds1374.c|2 +-
 drivers/rtc/rtc-m41t80.c|2 +-
 drivers/rtc/rtc-rs5c372.c   |2 +-
 include/linux/i2c.h |5 ++---
 include/linux/mod_devicetable.h |   20 
 scripts/mod/file2alias.c|   12 
 13 files changed, 67 insertions(+), 14 deletions(-)


diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 6892f76..2247de6 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -117,7 +117,7 @@ struct f75375_data {
 static int f75375_attach_adapter(struct i2c_adapter *adapter);
 static int f75375_detect(struct i2c_adapter *adapter, int address, int kind);
 static int f75375_detach_client(struct i2c_client *client);
-static int f75375_probe(struct i2c_client *client);
+static int f75375_probe(struct i2c_client *client, const struct
i2c_device_id *id);
 static int f75375_remove(struct i2c_client *client);

 static struct i2c_driver f75375_legacy_driver = {
@@ -628,7 +628,7 @@ static void f75375_init(struct i2c_client *client,
struct f75375_data *data,

 }

-static int f75375_probe(struct i2c_client *client)
+static int f75375_probe(struct i2c_client *client, const struct
i2c_device_id *id)
 {
struct f75375_data *data = i2c_get_clientdata(client);
struct f75375s_platform_data *f75375s_pdata = client-dev.platform_data;
diff --git a/drivers/i2c/chips/ds1682.c b/drivers/i2c/chips/ds1682.c
index 9e94542..93c0441 100644
--- a/drivers/i2c/chips/ds1682.c
+++ b/drivers/i2c/chips/ds1682.c
@@ -200,7 +200,7 @@ static struct bin_attribute ds1682_eeprom_attr = {
 /*
  * Called when a ds1682 device is matched with this driver
  */
-static int ds1682_probe(struct i2c_client *client)
+static int ds1682_probe(struct i2c_client *client, const struct
i2c_device_id *id)
 {
int rc;

diff --git a/drivers/i2c/chips/menelaus.c b/drivers/i2c/chips/menelaus.c
index 2dea012..89ef9b6 100644
--- a/drivers/i2c/chips/menelaus.c
+++ b/drivers/i2c/chips/menelaus.c
@@ -1149,7 +1149,7 @@ static inline void menelaus_rtc_init(struct
menelaus_chip *m)

 static struct i2c_driver menelaus_i2c_driver;

-static int menelaus_probe(struct i2c_client *client)
+static int menelaus_probe(struct i2c_client *client, const struct
i2c_device_id *id)
 {
struct menelaus_chip*menelaus;
int rev = 0, val;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index e320994..6b13642 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -465,7 +465,7 @@ static int __exit tps65010_remove(struct i2c_client *client)
return 0;
 }

-static int tps65010_probe(struct i2c_client *client)
+static int tps65010_probe(struct i2c_client *client, const struct
i2c_device_id *id)
 {
struct tps65010 *tps;
int status;
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c
index 3de4b19..27c553d 100644
--- a/drivers/i2c/chips/tsl2550.c
+++ b/drivers/i2c/chips/tsl2550.c
@@ -364,7 +364,7 @@ static int tsl2550_init_client(struct i2c_client *client)
  */

 static struct i2c_driver tsl2550_driver;
-static int __devinit tsl2550_probe(struct i2c_client *client)
+static int __devinit tsl2550_probe(struct i2c_client *client, const
struct i2c_device_id *id)
 {
struct i2c_adapter *adapter = to_i2c_adapter(client-dev.parent);
struct tsl2550_data *data;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..5f62230 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,6 +47,19 @@ static DEFINE_IDR(i2c_adapter_idr);

 /* - */

+static const struct i2c_device_id *i2c_match_id(
+   const struct i2c_device_id *id, struct i2c_client *client)
+{
+   /* only powerpc drivers implement the id_table,
+* it is empty on other platforms */
+   while (id-name[0]) {
+   if (strcmp(client-name, id-name) == 0)
+   return id;
+   id++;
+   }
+   return NULL;
+}
+
 static int i2c_device_match(struct device *dev, struct device_driver *drv)
 {
struct i2c_client   *client = to_i2c_client(dev

Re: [2.6 patch] remove CONFIG_EXPERIMENTAL

2008-01-01 Thread Jon Smirl
On 1/1/08, Alan Cox <[EMAIL PROTECTED]> wrote:
> > I'm not claiming that all EXPERIMENTAL tags were wrong [1], but many
> > were wrong.
>
> So why not fix the wrong tags, and mark smbfs obsolete ?
>
> > Plus the fact that CONFIG_EXPERIMENTAL controlled so many different
> > things with one switch that CONFIG_EXPERIMENTAL=n .config's are really
> > rare.
>
> Agreed

CONFIG_EXPERIMENTAL is way to coarse. I always need to turn it on and
then it loses any value.

Why not encode the drivers status into the driver name so that is is
obvious when you are configuring the kernel?

Like this for a driver name:
   Compaq Smart Array 5xxx support (experimental)

Some drivers are already do this:
   Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)

Now the status is obvious on an item by item basis.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [2.6 patch] remove CONFIG_EXPERIMENTAL

2008-01-01 Thread Jon Smirl
On 1/1/08, Alan Cox [EMAIL PROTECTED] wrote:
  I'm not claiming that all EXPERIMENTAL tags were wrong [1], but many
  were wrong.

 So why not fix the wrong tags, and mark smbfs obsolete ?

  Plus the fact that CONFIG_EXPERIMENTAL controlled so many different
  things with one switch that CONFIG_EXPERIMENTAL=n .config's are really
  rare.

 Agreed

CONFIG_EXPERIMENTAL is way to coarse. I always need to turn it on and
then it loses any value.

Why not encode the drivers status into the driver name so that is is
obvious when you are configuring the kernel?

Like this for a driver name:
   Compaq Smart Array 5xxx support (experimental)

Some drivers are already do this:
   Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)

Now the status is obvious on an item by item basis.

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/5] Version 17, series to add device tree naming to i2c

2007-12-27 Thread Jon Smirl
On 12/19/07, Jon Smirl <[EMAIL PROTECTED]> wrote:
> Another rework of the i2c for powerpc device tree patch. This version 
> implements standard alias naming only on the powerpc platform and only for 
> the device tree names. The old naming mechanism of 
> i2c_client.name,driver_name is left in place and not changed for non-powerpc 
> platforms. This patch is fully capable of dynamically loading the i2c 
> modules. You can modprobe in the i2c-mpc driver and the i2c modules described 
> in the device tree will be automatically loaded. Modules also work if 
> compiled in.


Are there any further objections to this patch? Can it all go in
through the powerpc trees or do the i2c people want to send it on?

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/5] Version 17, series to add device tree naming to i2c

2007-12-27 Thread Jon Smirl
On 12/19/07, Jon Smirl [EMAIL PROTECTED] wrote:
 Another rework of the i2c for powerpc device tree patch. This version 
 implements standard alias naming only on the powerpc platform and only for 
 the device tree names. The old naming mechanism of 
 i2c_client.name,driver_name is left in place and not changed for non-powerpc 
 platforms. This patch is fully capable of dynamically loading the i2c 
 modules. You can modprobe in the i2c-mpc driver and the i2c modules described 
 in the device tree will be automatically loaded. Modules also work if 
 compiled in.


Are there any further objections to this patch? Can it all go in
through the powerpc trees or do the i2c people want to send it on?

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/5] Version 17, series to add device tree naming to i2c

2007-12-20 Thread Jon Smirl
Are there any other objections to this patch? If not, can it be
targeted for 2.6.25?

On 12/19/07, Jon Smirl <[EMAIL PROTECTED]> wrote:
> Since copying i2c-mpc.c to maintain support for the ppc architecture seems to 
> be an issue; instead rework i2c-mpc.c to use CONFIG_PPC_MERGE #ifdefs to 
> support both the ppc and powerpc architecture. When ppc is deleted in six 
> months these #ifdefs will need to be removed.
>
> Another rework of the i2c for powerpc device tree patch. This version 
> implements standard alias naming only on the powerpc platform and only for 
> the device tree names. The old naming mechanism of 
> i2c_client.name,driver_name is left in place and not changed for non-powerpc 
> platforms. This patch is fully capable of dynamically loading the i2c 
> modules. You can modprobe in the i2c-mpc driver and the i2c modules described 
> in the device tree will be automatically loaded. Modules also work if 
> compiled in.
>
> The follow on patch to module-init-tools is also needed since the i2c 
> subsystem has never implemented dynamic loading.
>
> The following series implements standard linux module aliasing for i2c 
> modules on arch=powerpc. It then converts the mpc i2c driver from being a 
> platform driver to an open firmware one. I2C device names are picked up from 
> the device tree. Module aliasing is used to translate from device tree names 
> into to linux kernel names. Several i2c drivers are updated to use the new 
> aliasing.
>
> --
> Jon Smirl
> [EMAIL PROTECTED]
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/5] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

2007-12-20 Thread Jon Smirl
On 12/20/07, David Gibson <[EMAIL PROTECTED]> wrote:
> On Wed, Dec 19, 2007 at 11:41:44PM -0500, Jon Smirl wrote:
> > Convert MPC i2c driver from being a platform_driver to an open
> > firmware version. Error returns were improved. Routine names were
> > changed from fsl_ to mpc_ to make them match the file name.
>
> In discussions BenH and I have had, we've actually concluded that
> moving this from platform drivers to of_platform drives is not
> actually a good idea.
>
> In fact we're planning to move away from of_platform devices and
> drivers and instead develop a framework for instantiating platform
> devices or i2c devices or whatever devices from the device tree nodes.

I have to work with what is in the kernel tree so this patch is based
the current kernel. A lot of time and testing has going into all the
revisions of this patch. It has been posted in various forms for the
last month and a half.

As for platform vs of_platform, IMHO of_platform should have been
derived from platform instead of being an unrelated structure. In the
current scheme of unrelated structures it makes more sense to use one
or the other and not mix them. I am in agreement with Olof that if and
when a new scheme is adopted the drivers should be converted then.

In my local builds I have disabled platform and use only of_platform.
An of_platform only system works fine and is capable of instantiating
everything from the device tree as this patch illustrates. Once this
patch goes in I'll post another series that shows how I went
of_platform only on mpc5200.

Everyone seems to be focusing on a small piece of driver
initialization code and ignoring the much more complicated part which
implements dynamic i2c driver loading. It's the complicated part of
the code that needs review.

Ben, I know we talked about not putting the alias names into their own
namespace. But the i2c people don't want to move onto the standard
kernel aliasing scheme for other platforms and asked for #ifdef
powerpc. In version 15 I removed the cross platform support and made
everything powerpc specific. .

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/5] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

2007-12-20 Thread Jon Smirl
On 12/20/07, David Gibson [EMAIL PROTECTED] wrote:
 On Wed, Dec 19, 2007 at 11:41:44PM -0500, Jon Smirl wrote:
  Convert MPC i2c driver from being a platform_driver to an open
  firmware version. Error returns were improved. Routine names were
  changed from fsl_ to mpc_ to make them match the file name.

 In discussions BenH and I have had, we've actually concluded that
 moving this from platform drivers to of_platform drives is not
 actually a good idea.

 In fact we're planning to move away from of_platform devices and
 drivers and instead develop a framework for instantiating platform
 devices or i2c devices or whatever devices from the device tree nodes.

I have to work with what is in the kernel tree so this patch is based
the current kernel. A lot of time and testing has going into all the
revisions of this patch. It has been posted in various forms for the
last month and a half.

As for platform vs of_platform, IMHO of_platform should have been
derived from platform instead of being an unrelated structure. In the
current scheme of unrelated structures it makes more sense to use one
or the other and not mix them. I am in agreement with Olof that if and
when a new scheme is adopted the drivers should be converted then.

In my local builds I have disabled platform and use only of_platform.
An of_platform only system works fine and is capable of instantiating
everything from the device tree as this patch illustrates. Once this
patch goes in I'll post another series that shows how I went
of_platform only on mpc5200.

Everyone seems to be focusing on a small piece of driver
initialization code and ignoring the much more complicated part which
implements dynamic i2c driver loading. It's the complicated part of
the code that needs review.

Ben, I know we talked about not putting the alias names into their own
namespace. But the i2c people don't want to move onto the standard
kernel aliasing scheme for other platforms and asked for #ifdef
powerpc. In version 15 I removed the cross platform support and made
everything powerpc specific. .

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/5] Version 17, series to add device tree naming to i2c

2007-12-20 Thread Jon Smirl
Are there any other objections to this patch? If not, can it be
targeted for 2.6.25?

On 12/19/07, Jon Smirl [EMAIL PROTECTED] wrote:
 Since copying i2c-mpc.c to maintain support for the ppc architecture seems to 
 be an issue; instead rework i2c-mpc.c to use CONFIG_PPC_MERGE #ifdefs to 
 support both the ppc and powerpc architecture. When ppc is deleted in six 
 months these #ifdefs will need to be removed.

 Another rework of the i2c for powerpc device tree patch. This version 
 implements standard alias naming only on the powerpc platform and only for 
 the device tree names. The old naming mechanism of 
 i2c_client.name,driver_name is left in place and not changed for non-powerpc 
 platforms. This patch is fully capable of dynamically loading the i2c 
 modules. You can modprobe in the i2c-mpc driver and the i2c modules described 
 in the device tree will be automatically loaded. Modules also work if 
 compiled in.

 The follow on patch to module-init-tools is also needed since the i2c 
 subsystem has never implemented dynamic loading.

 The following series implements standard linux module aliasing for i2c 
 modules on arch=powerpc. It then converts the mpc i2c driver from being a 
 platform driver to an open firmware one. I2C device names are picked up from 
 the device tree. Module aliasing is used to translate from device tree names 
 into to linux kernel names. Several i2c drivers are updated to use the new 
 aliasing.

 --
 Jon Smirl
 [EMAIL PROTECTED]
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to [EMAIL PROTECTED]
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/5] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

2007-12-19 Thread Jon Smirl
Convert MPC i2c driver from being a platform_driver to an open firmware 
version. Error returns were improved. Routine names were changed from fsl_ to 
mpc_ to make them match the file name.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 arch/powerpc/sysdev/fsl_soc.c |   96 --
 drivers/i2c/busses/i2c-mpc.c  |  183 -
 2 files changed, 180 insertions(+), 99 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 268638a..d6ef264 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -318,102 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include 
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-  int bus_num)
-{
-   struct device_node *node = NULL;
-   const char *compatible;
-
-   while ((node = of_get_next_child(adap_node, node))) {
-   struct i2c_board_info info = {};
-   const u32 *addr;
-   int len;
-
-   addr = of_get_property(node, "reg", );
-   if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
-   printk(KERN_WARNING "fsl_soc.c: invalid i2c device 
entry\n");
-   continue;
-   }
-
-   info.irq = irq_of_parse_and_map(node, 0);
-   if (info.irq == NO_IRQ)
-   info.irq = -1;
-
-   compatible = of_get_property(node, "compatible", );
-   if (!compatible) {
-   printk(KERN_WARNING "i2c-mpc.c: invalid entry, missing 
compatible attribute\n");
-   continue;
-   }
-   strncpy(info.driver_name, compatible, sizeof(info.driver_name));
-
-   info.addr = *addr;
-
-   i2c_register_board_info(bus_num, , 1);
-   }
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-   struct device_node *np;
-   unsigned int i;
-   struct platform_device *i2c_dev;
-   int ret;
-
-   for (np = NULL, i = 0;
-(np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
-i++) {
-   struct resource r[2];
-   struct fsl_i2c_platform_data i2c_data;
-   const unsigned char *flags = NULL;
-
-   memset(, 0, sizeof(r));
-   memset(_data, 0, sizeof(i2c_data));
-
-   ret = of_address_to_resource(np, 0, [0]);
-   if (ret)
-   goto err;
-
-   of_irq_to_resource(np, 0, [1]);
-
-   i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
-   if (IS_ERR(i2c_dev)) {
-   ret = PTR_ERR(i2c_dev);
-   goto err;
-   }
-
-   i2c_data.device_flags = 0;
-   flags = of_get_property(np, "dfsrr", NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-   flags = of_get_property(np, "fsl5200-clocking", NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-   ret =
-   platform_device_add_data(i2c_dev, _data,
-sizeof(struct
-   fsl_i2c_platform_data));
-   if (ret)
-   goto unreg;
-
-   of_register_i2c_devices(np, i);
-   }
-
-   return 0;
-
-unreg:
-   platform_device_unregister(i2c_dev);
-err:
-   return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
-
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
 {
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 7c35a8f..4f2e7ea 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 
@@ -25,13 +25,13 @@
 #include 
 #include 
 
-#define MPC_I2C_ADDR  0x00
+#define DRV_NAME "mpc-i2c"
+
 #define MPC_I2C_FDR0x04
 #define MPC_I2C_CR 0x08
 #define MPC_I2C_SR 0x0c
 #define MPC_I2C_DR 0x10
 #define MPC_I2C_DFSRR 0x14
-#define MPC_I2C_REGION 0x20
 
 #define CCR_MEN  0x80
 #define CCR_MIEN 0x40
@@ -316,6 +316,181 @@ static struct i2c_adapter mpc_ops = {
.retries = 1
 };
 
+struct i2c_driver_device {
+   char*of_device;
+   char*i2c_driver;
+   char*i2c_type;
+};
+
+#ifdef CONFIG_PPC_MERGE
+
+static void of_register_i2c_devices(struct i2c_adapter *adap, struct 
device_node *adap_node)
+{
+   struct device_node *node = NULL;
+
+   while ((node = of_get_next_child(adap_node, node))) {
+   struct

[PATCH 2/5] Modify several rtc drivers to use the alias names list property of i2c

2007-12-19 Thread Jon Smirl
This patch modifies the ds1307, ds1374, and rs5c372 i2c drivers to support
device tree names using the new i2c mod alias support

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 arch/powerpc/sysdev/fsl_soc.c |   44 
 drivers/rtc/rtc-ds1307.c  |   20 +-
 drivers/rtc/rtc-ds1374.c  |9 ++
 drivers/rtc/rtc-m41t80.c  |   57 -
 drivers/rtc/rtc-rs5c372.c |   16 ++--
 5 files changed, 85 insertions(+), 61 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 3ace747..268638a 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -320,48 +320,12 @@ arch_initcall(gfar_of_init);
 
 #ifdef CONFIG_I2C_BOARDINFO
 #include 
-struct i2c_driver_device {
-   char*of_device;
-   char*i2c_driver;
-   char*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-   {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",},
-   {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",},
-   {"ricoh,rv5c386",  "rtc-rs5c372", "rv5c386",},
-   {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",},
-   {"dallas,ds1307",  "rtc-ds1307",  "ds1307",},
-   {"dallas,ds1337",  "rtc-ds1307",  "ds1337",},
-   {"dallas,ds1338",  "rtc-ds1307",  "ds1338",},
-   {"dallas,ds1339",  "rtc-ds1307",  "ds1339",},
-   {"dallas,ds1340",  "rtc-ds1307",  "ds1340",},
-   {"stm,m41t00", "rtc-ds1307",  "m41t00"},
-   {"dallas,ds1374",  "rtc-ds1374",  "rtc-ds1374",},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-struct i2c_board_info *info)
-{
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
-   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-   continue;
-   if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver,
-   KOBJ_NAME_LEN) >= KOBJ_NAME_LEN ||
-   strlcpy(info->type, i2c_devices[i].i2c_type,
-   I2C_NAME_SIZE) >= I2C_NAME_SIZE)
-   return -ENOMEM;
-   return 0;
-   }
-   return -ENODEV;
-}
 
 static void __init of_register_i2c_devices(struct device_node *adap_node,
   int bus_num)
 {
struct device_node *node = NULL;
+   const char *compatible;
 
while ((node = of_get_next_child(adap_node, node))) {
struct i2c_board_info info = {};
@@ -378,8 +342,12 @@ static void __init of_register_i2c_devices(struct 
device_node *adap_node,
if (info.irq == NO_IRQ)
info.irq = -1;
 
-   if (of_find_i2c_driver(node, ) < 0)
+   compatible = of_get_property(node, "compatible", );
+   if (!compatible) {
+   printk(KERN_WARNING "i2c-mpc.c: invalid entry, missing 
compatible attribute\n");
continue;
+   }
+   strncpy(info.driver_name, compatible, sizeof(info.driver_name));
 
info.addr = *addr;
 
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index bc1c7fe..d4874ff 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -139,6 +139,17 @@ static inline const struct chip_desc *find_chip(const char 
*s)
return NULL;
 }
 
+static struct i2c_device_id ds1307_id[] = {
+   OF_I2C_ID("dallas,ds1307", ds_1307)
+   OF_I2C_ID("dallas,ds1337", ds_1337)
+   OF_I2C_ID("dallas,ds1338", ds_1338)
+   OF_I2C_ID("dallas,ds1339", ds_1339)
+   OF_I2C_ID("dallas,ds1340", ds_1340)
+   OF_I2C_ID("stm,m41t00", m41t00)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, ds1307_id);
+
 static int ds1307_get_time(struct device *dev, struct rtc_time *t)
 {
struct ds1307   *ds1307 = dev_get_drvdata(dev);
@@ -326,7 +337,7 @@ static struct bin_attribute nvram = {
 
 static struct i2c_driver ds1307_driver;
 
-static int __devinit ds1307_probe(struct i2c_client *client)
+static int __devinit ds1307_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct ds1307   *ds1307;
int err = -ENODEV;
@@ -334,7 +345,11 @@ static int __devinit ds1307_probe(struct i2c_client 
*client)
const struct chip_desc  *chip;
struct i2c_adapter  *adapter = to_i2c_adapter(client->dev.parent);
 
-   chip = find_chip(client->

[PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2007-12-19 Thread Jon Smirl
This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/i2c/i2c-core.c  |   32 ++--
 include/linux/i2c.h |9 -
 include/linux/mod_devicetable.h |   20 
 scripts/mod/file2alias.c|   19 +++
 4 files changed, 69 insertions(+), 11 deletions(-)


diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..fce06fd 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,10 +47,25 @@ static DEFINE_IDR(i2c_adapter_idr);
 
 /* - */
 
-static int i2c_device_match(struct device *dev, struct device_driver *drv)
+static const struct i2c_device_id *i2c_device_match(const struct i2c_device_id 
*id, struct i2c_client *client)
+{
+   /* only powerpc drivers implement the id_table,
+* it is empty on other platforms */
+   if (id) {
+   while (id->name[0]) {
+   if (strcmp(client->driver_name, id->name) == 0)
+   return id;
+   id++;
+   }
+   }
+   return NULL;
+}
+
+static int i2c_bus_match(struct device *dev, struct device_driver *drv)
 {
struct i2c_client   *client = to_i2c_client(dev);
struct i2c_driver   *driver = to_i2c_driver(drv);
+   const struct i2c_device_id *found_id;
 
/* make legacy i2c drivers bypass driver model probing entirely;
 * such drivers scan each i2c adapter/bus themselves.
@@ -58,9 +73,11 @@ static int i2c_device_match(struct device *dev, struct 
device_driver *drv)
if (!is_newstyle_driver(driver))
return 0;
 
-   /* new style drivers use the same kind of driver matching policy
-* as platform devices or SPI:  compare device and driver IDs.
-*/
+   /* match on an id table if there is one */
+   found_id = i2c_device_match(driver->id_table, client);
+   if (found_id)
+   return 1;
+
return strcmp(client->driver_name, drv->name) == 0;
 }
 
@@ -89,12 +106,15 @@ static int i2c_device_probe(struct device *dev)
 {
struct i2c_client   *client = to_i2c_client(dev);
struct i2c_driver   *driver = to_i2c_driver(dev->driver);
+   const struct i2c_device_id *id;
 
if (!driver->probe)
return -ENODEV;
client->driver = driver;
dev_dbg(dev, "probe\n");
-   return driver->probe(client);
+
+   id = i2c_device_match(driver->id_table, client);
+   return driver->probe(client, id);
 }
 
 static int i2c_device_remove(struct device *dev)
@@ -189,7 +209,7 @@ static struct device_attribute i2c_dev_attrs[] = {
 static struct bus_type i2c_bus_type = {
.name   = "i2c",
.dev_attrs  = i2c_dev_attrs,
-   .match  = i2c_device_match,
+   .match  = i2c_bus_match,
.uevent = i2c_device_uevent,
.probe  = i2c_device_probe,
.remove = i2c_device_remove,
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a100c9f..49fc682 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -126,7 +126,7 @@ struct i2c_driver {
 * With the driver model, device enumeration is NEVER done by drivers;
 * it's done by infrastructure.  (NEW STYLE DRIVERS ONLY)
 */
-   int (*probe)(struct i2c_client *);
+   int (*probe)(struct i2c_client *, const struct i2c_device_id *id);
int (*remove)(struct i2c_client *);
 
/* driver model interfaces that don't relate to enumeration  */
@@ -141,11 +141,10 @@ struct i2c_driver {
 
struct device_driver driver;
struct list_head list;
+   struct i2c_device_id *id_table;
 };
 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
 
-#define I2C_NAME_SIZE  20
-
 /**
  * struct i2c_client - represent an I2C slave device
  * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
@@ -179,7 +178,7 @@ struct i2c_client {
/* to the client*/
struct device dev;  /* the device structure */
int irq;/* irq issued by device (or -1) */
-   char driver_name[KOBJ_NAME_LEN];
+   char driver_name[I2C_NAME_SIZE];
struct list_head list;
struct completion released;
 };
@@ -223,7 +222,7 @@ static inline void i2c_set_clientdata (struct i2c_client 
*dev, void *data)
  * with the adapter already known.
  */
 struct i2c_board_info {
-   chardriver_name[KOBJ_NAME_LEN];
+   char  

[PATCH 0/5] Version 17, series to add device tree naming to i2c

2007-12-19 Thread Jon Smirl
Since copying i2c-mpc.c to maintain support for the ppc architecture seems to 
be an issue; instead rework i2c-mpc.c to use CONFIG_PPC_MERGE #ifdefs to 
support both the ppc and powerpc architecture. When ppc is deleted in six 
months these #ifdefs will need to be removed.

Another rework of the i2c for powerpc device tree patch. This version 
implements standard alias naming only on the powerpc platform and only for the 
device tree names. The old naming mechanism of i2c_client.name,driver_name is 
left in place and not changed for non-powerpc platforms. This patch is fully 
capable of dynamically loading the i2c modules. You can modprobe in the i2c-mpc 
driver and the i2c modules described in the device tree will be automatically 
loaded. Modules also work if compiled in.

The follow on patch to module-init-tools is also needed since the i2c subsystem 
has never implemented dynamic loading.

The following series implements standard linux module aliasing for i2c modules 
on arch=powerpc. It then converts the mpc i2c driver from being a platform 
driver to an open firmware one. I2C device names are picked up from the device 
tree. Module aliasing is used to translate from device tree names into to linux 
kernel names. Several i2c drivers are updated to use the new aliasing. 

--
Jon Smirl
[EMAIL PROTECTED] 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] Convert pfc8563 i2c driver from old style to new style

2007-12-19 Thread Jon Smirl
Convert pfc8563 i2c driver from old style to new style. The
driver is also modified to support device tree names via the
i2c mod alias mechanism.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/rtc/rtc-pcf8563.c |  107 +++--
 1 files changed, 27 insertions(+), 80 deletions(-)


diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 0242d80..e1ea2a0 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -25,10 +25,6 @@
  * located at 0x51 will pass the validation routine due to
  * the way the registers are implemented.
  */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Module parameters */
-I2C_CLIENT_INSMOD;
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -72,9 +68,6 @@ struct pcf8563 {
int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
-static int pcf8563_detach(struct i2c_client *client);
-
 /*
  * In the routines that deal directly with the pcf8563 hardware, we use
  * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
@@ -257,98 +250,52 @@ static const struct rtc_class_ops pcf8563_rtc_ops = {
.set_time   = pcf8563_rtc_set_time,
 };
 
-static int pcf8563_attach(struct i2c_adapter *adapter)
+static int pcf8563_remove(struct i2c_client *client)
 {
-   return i2c_probe(adapter, _data, pcf8563_probe);
+   struct rtc_device *rtc = i2c_get_clientdata(client);
+
+   if (rtc)
+   rtc_device_unregister(rtc);
+
+   return 0;
 }
 
+static struct i2c_device_id pcf8563_id[] = {
+   OF_I2C_ID("philips,pcf8563", 0)
+   OF_I2C_ID("epson,rtc8564", 0)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, pcf8563_id);
+
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id);
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
-   .name   = "pcf8563",
+   .name   = "rtc-pcf8563",
},
.id = I2C_DRIVERID_PCF8563,
-   .attach_adapter = _attach,
-   .detach_client  = _detach,
+   .probe = _probe,
+   .remove = _remove,
+   .id_table   = pcf8563_id,
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
-   struct pcf8563 *pcf8563;
-   struct i2c_client *client;
+   int result;
struct rtc_device *rtc;
 
-   int err = 0;
-
-   dev_dbg(>dev, "%s\n", __FUNCTION__);
-
-   if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
-   err = -ENODEV;
-   goto exit;
-   }
-
-   if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
-   err = -ENOMEM;
-   goto exit;
-   }
-
-   client = >client;
-   client->addr = address;
-   client->driver = _driver;
-   client->adapter = adapter;
-
-   strlcpy(client->name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
-
-   /* Verify the chip is really an PCF8563 */
-   if (kind < 0) {
-   if (pcf8563_validate_client(client) < 0) {
-   err = -ENODEV;
-   goto exit_kfree;
-   }
-   }
-
-   /* Inform the i2c layer */
-   if ((err = i2c_attach_client(client)))
-   goto exit_kfree;
-
-   dev_info(>dev, "chip found, driver version " DRV_VERSION "\n");
+   result = pcf8563_validate_client(client);
+   if (result)
+   return result;
 
rtc = rtc_device_register(pcf8563_driver.driver.name, >dev,
_rtc_ops, THIS_MODULE);
-
-   if (IS_ERR(rtc)) {
-   err = PTR_ERR(rtc);
-   goto exit_detach;
-   }
+   if (IS_ERR(rtc))
+   return PTR_ERR(rtc);
 
i2c_set_clientdata(client, rtc);
 
return 0;
-
-exit_detach:
-   i2c_detach_client(client);
-
-exit_kfree:
-   kfree(pcf8563);
-
-exit:
-   return err;
-}
-
-static int pcf8563_detach(struct i2c_client *client)
-{
-   struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
-   int err;
-   struct rtc_device *rtc = i2c_get_clientdata(client);
-
-   if (rtc)
-   rtc_device_unregister(rtc);
-
-   if ((err = i2c_detach_client(client)))
-   return err;
-
-   kfree(pcf8563);
-
-   return 0;
 }
 
 static int __init pcf8563_init(void)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] Clean up error returns

2007-12-19 Thread Jon Smirl
Return errors that were being ignored in the mpc-i2c driver

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/i2c/busses/i2c-mpc.c |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index d8de4ac..7c35a8f 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -180,7 +180,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
 static int mpc_write(struct mpc_i2c *i2c, int target,
 const u8 * data, int length, int restart)
 {
-   int i;
+   int i, result;
unsigned timeout = i2c->adap.timeout;
u32 flags = restart ? CCR_RSTA : 0;
 
@@ -192,15 +192,17 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
/* Write target byte */
writeb((target << 1), i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
 
for (i = 0; i < length; i++) {
/* Write data byte */
writeb(data[i], i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
}
 
return 0;
@@ -210,7 +212,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
u8 * data, int length, int restart)
 {
unsigned timeout = i2c->adap.timeout;
-   int i;
+   int i, result;
u32 flags = restart ? CCR_RSTA : 0;
 
/* Start with MEN */
@@ -221,8 +223,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
/* Write target address byte - this time with the read flag set */
writeb((target << 1) | 1, i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
 
if (length) {
if (length == 1)
@@ -234,8 +237,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
}
 
for (i = 0; i < length; i++) {
-   if (i2c_wait(i2c, timeout, 0) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 0);
+   if (result < 0)
+   return result;
 
/* Generate txack on next to last byte */
if (i == length - 2)
@@ -321,9 +325,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 
pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
 
-   if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
+   i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+   if (!i2c)
return -ENOMEM;
-   }
 
i2c->irq = platform_get_irq(pdev, 0);
if (i2c->irq < 0) {
@@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(>adap);
platform_set_drvdata(pdev, NULL);
 
-   if (i2c->irq != 0)
+   if (i2c->irq != NO_IRQ)
free_irq(i2c->irq, i2c);
 
iounmap(i2c->base);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] Clean up error returns

2007-12-19 Thread Jon Smirl
Return errors that were being ignored in the mpc-i2c driver

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/i2c/busses/i2c-mpc.c |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index d8de4ac..7c35a8f 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -180,7 +180,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
 static int mpc_write(struct mpc_i2c *i2c, int target,
 const u8 * data, int length, int restart)
 {
-   int i;
+   int i, result;
unsigned timeout = i2c-adap.timeout;
u32 flags = restart ? CCR_RSTA : 0;
 
@@ -192,15 +192,17 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
/* Write target byte */
writeb((target  1), i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
 
for (i = 0; i  length; i++) {
/* Write data byte */
writeb(data[i], i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
}
 
return 0;
@@ -210,7 +212,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
u8 * data, int length, int restart)
 {
unsigned timeout = i2c-adap.timeout;
-   int i;
+   int i, result;
u32 flags = restart ? CCR_RSTA : 0;
 
/* Start with MEN */
@@ -221,8 +223,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
/* Write target address byte - this time with the read flag set */
writeb((target  1) | 1, i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
 
if (length) {
if (length == 1)
@@ -234,8 +237,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
}
 
for (i = 0; i  length; i++) {
-   if (i2c_wait(i2c, timeout, 0)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 0);
+   if (result  0)
+   return result;
 
/* Generate txack on next to last byte */
if (i == length - 2)
@@ -321,9 +325,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 
pdata = (struct fsl_i2c_platform_data *) pdev-dev.platform_data;
 
-   if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
+   i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+   if (!i2c)
return -ENOMEM;
-   }
 
i2c-irq = platform_get_irq(pdev, 0);
if (i2c-irq  0) {
@@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(i2c-adap);
platform_set_drvdata(pdev, NULL);
 
-   if (i2c-irq != 0)
+   if (i2c-irq != NO_IRQ)
free_irq(i2c-irq, i2c);
 
iounmap(i2c-base);

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] Version 17, series to add device tree naming to i2c

2007-12-19 Thread Jon Smirl
Since copying i2c-mpc.c to maintain support for the ppc architecture seems to 
be an issue; instead rework i2c-mpc.c to use CONFIG_PPC_MERGE #ifdefs to 
support both the ppc and powerpc architecture. When ppc is deleted in six 
months these #ifdefs will need to be removed.

Another rework of the i2c for powerpc device tree patch. This version 
implements standard alias naming only on the powerpc platform and only for the 
device tree names. The old naming mechanism of i2c_client.name,driver_name is 
left in place and not changed for non-powerpc platforms. This patch is fully 
capable of dynamically loading the i2c modules. You can modprobe in the i2c-mpc 
driver and the i2c modules described in the device tree will be automatically 
loaded. Modules also work if compiled in.

The follow on patch to module-init-tools is also needed since the i2c subsystem 
has never implemented dynamic loading.

The following series implements standard linux module aliasing for i2c modules 
on arch=powerpc. It then converts the mpc i2c driver from being a platform 
driver to an open firmware one. I2C device names are picked up from the device 
tree. Module aliasing is used to translate from device tree names into to linux 
kernel names. Several i2c drivers are updated to use the new aliasing. 

--
Jon Smirl
[EMAIL PROTECTED] 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] Convert pfc8563 i2c driver from old style to new style

2007-12-19 Thread Jon Smirl
Convert pfc8563 i2c driver from old style to new style. The
driver is also modified to support device tree names via the
i2c mod alias mechanism.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/rtc/rtc-pcf8563.c |  107 +++--
 1 files changed, 27 insertions(+), 80 deletions(-)


diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 0242d80..e1ea2a0 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -25,10 +25,6 @@
  * located at 0x51 will pass the validation routine due to
  * the way the registers are implemented.
  */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Module parameters */
-I2C_CLIENT_INSMOD;
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -72,9 +68,6 @@ struct pcf8563 {
int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
-static int pcf8563_detach(struct i2c_client *client);
-
 /*
  * In the routines that deal directly with the pcf8563 hardware, we use
  * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
@@ -257,98 +250,52 @@ static const struct rtc_class_ops pcf8563_rtc_ops = {
.set_time   = pcf8563_rtc_set_time,
 };
 
-static int pcf8563_attach(struct i2c_adapter *adapter)
+static int pcf8563_remove(struct i2c_client *client)
 {
-   return i2c_probe(adapter, addr_data, pcf8563_probe);
+   struct rtc_device *rtc = i2c_get_clientdata(client);
+
+   if (rtc)
+   rtc_device_unregister(rtc);
+
+   return 0;
 }
 
+static struct i2c_device_id pcf8563_id[] = {
+   OF_I2C_ID(philips,pcf8563, 0)
+   OF_I2C_ID(epson,rtc8564, 0)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, pcf8563_id);
+
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id);
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
-   .name   = pcf8563,
+   .name   = rtc-pcf8563,
},
.id = I2C_DRIVERID_PCF8563,
-   .attach_adapter = pcf8563_attach,
-   .detach_client  = pcf8563_detach,
+   .probe = pcf8563_probe,
+   .remove = pcf8563_remove,
+   .id_table   = pcf8563_id,
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
-   struct pcf8563 *pcf8563;
-   struct i2c_client *client;
+   int result;
struct rtc_device *rtc;
 
-   int err = 0;
-
-   dev_dbg(adapter-dev, %s\n, __FUNCTION__);
-
-   if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
-   err = -ENODEV;
-   goto exit;
-   }
-
-   if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
-   err = -ENOMEM;
-   goto exit;
-   }
-
-   client = pcf8563-client;
-   client-addr = address;
-   client-driver = pcf8563_driver;
-   client-adapter = adapter;
-
-   strlcpy(client-name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
-
-   /* Verify the chip is really an PCF8563 */
-   if (kind  0) {
-   if (pcf8563_validate_client(client)  0) {
-   err = -ENODEV;
-   goto exit_kfree;
-   }
-   }
-
-   /* Inform the i2c layer */
-   if ((err = i2c_attach_client(client)))
-   goto exit_kfree;
-
-   dev_info(client-dev, chip found, driver version  DRV_VERSION \n);
+   result = pcf8563_validate_client(client);
+   if (result)
+   return result;
 
rtc = rtc_device_register(pcf8563_driver.driver.name, client-dev,
pcf8563_rtc_ops, THIS_MODULE);
-
-   if (IS_ERR(rtc)) {
-   err = PTR_ERR(rtc);
-   goto exit_detach;
-   }
+   if (IS_ERR(rtc))
+   return PTR_ERR(rtc);
 
i2c_set_clientdata(client, rtc);
 
return 0;
-
-exit_detach:
-   i2c_detach_client(client);
-
-exit_kfree:
-   kfree(pcf8563);
-
-exit:
-   return err;
-}
-
-static int pcf8563_detach(struct i2c_client *client)
-{
-   struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
-   int err;
-   struct rtc_device *rtc = i2c_get_clientdata(client);
-
-   if (rtc)
-   rtc_device_unregister(rtc);
-
-   if ((err = i2c_detach_client(client)))
-   return err;
-
-   kfree(pcf8563);
-
-   return 0;
 }
 
 static int __init pcf8563_init(void)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] Modify several rtc drivers to use the alias names list property of i2c

2007-12-19 Thread Jon Smirl
This patch modifies the ds1307, ds1374, and rs5c372 i2c drivers to support
device tree names using the new i2c mod alias support

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 arch/powerpc/sysdev/fsl_soc.c |   44 
 drivers/rtc/rtc-ds1307.c  |   20 +-
 drivers/rtc/rtc-ds1374.c  |9 ++
 drivers/rtc/rtc-m41t80.c  |   57 -
 drivers/rtc/rtc-rs5c372.c |   16 ++--
 5 files changed, 85 insertions(+), 61 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 3ace747..268638a 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -320,48 +320,12 @@ arch_initcall(gfar_of_init);
 
 #ifdef CONFIG_I2C_BOARDINFO
 #include linux/i2c.h
-struct i2c_driver_device {
-   char*of_device;
-   char*i2c_driver;
-   char*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-   {ricoh,rs5c372a, rtc-rs5c372, rs5c372a,},
-   {ricoh,rs5c372b, rtc-rs5c372, rs5c372b,},
-   {ricoh,rv5c386,  rtc-rs5c372, rv5c386,},
-   {ricoh,rv5c387a, rtc-rs5c372, rv5c387a,},
-   {dallas,ds1307,  rtc-ds1307,  ds1307,},
-   {dallas,ds1337,  rtc-ds1307,  ds1337,},
-   {dallas,ds1338,  rtc-ds1307,  ds1338,},
-   {dallas,ds1339,  rtc-ds1307,  ds1339,},
-   {dallas,ds1340,  rtc-ds1307,  ds1340,},
-   {stm,m41t00, rtc-ds1307,  m41t00},
-   {dallas,ds1374,  rtc-ds1374,  rtc-ds1374,},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-struct i2c_board_info *info)
-{
-   int i;
-
-   for (i = 0; i  ARRAY_SIZE(i2c_devices); i++) {
-   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-   continue;
-   if (strlcpy(info-driver_name, i2c_devices[i].i2c_driver,
-   KOBJ_NAME_LEN) = KOBJ_NAME_LEN ||
-   strlcpy(info-type, i2c_devices[i].i2c_type,
-   I2C_NAME_SIZE) = I2C_NAME_SIZE)
-   return -ENOMEM;
-   return 0;
-   }
-   return -ENODEV;
-}
 
 static void __init of_register_i2c_devices(struct device_node *adap_node,
   int bus_num)
 {
struct device_node *node = NULL;
+   const char *compatible;
 
while ((node = of_get_next_child(adap_node, node))) {
struct i2c_board_info info = {};
@@ -378,8 +342,12 @@ static void __init of_register_i2c_devices(struct 
device_node *adap_node,
if (info.irq == NO_IRQ)
info.irq = -1;
 
-   if (of_find_i2c_driver(node, info)  0)
+   compatible = of_get_property(node, compatible, len);
+   if (!compatible) {
+   printk(KERN_WARNING i2c-mpc.c: invalid entry, missing 
compatible attribute\n);
continue;
+   }
+   strncpy(info.driver_name, compatible, sizeof(info.driver_name));
 
info.addr = *addr;
 
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index bc1c7fe..d4874ff 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -139,6 +139,17 @@ static inline const struct chip_desc *find_chip(const char 
*s)
return NULL;
 }
 
+static struct i2c_device_id ds1307_id[] = {
+   OF_I2C_ID(dallas,ds1307, ds_1307)
+   OF_I2C_ID(dallas,ds1337, ds_1337)
+   OF_I2C_ID(dallas,ds1338, ds_1338)
+   OF_I2C_ID(dallas,ds1339, ds_1339)
+   OF_I2C_ID(dallas,ds1340, ds_1340)
+   OF_I2C_ID(stm,m41t00, m41t00)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, ds1307_id);
+
 static int ds1307_get_time(struct device *dev, struct rtc_time *t)
 {
struct ds1307   *ds1307 = dev_get_drvdata(dev);
@@ -326,7 +337,7 @@ static struct bin_attribute nvram = {
 
 static struct i2c_driver ds1307_driver;
 
-static int __devinit ds1307_probe(struct i2c_client *client)
+static int __devinit ds1307_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct ds1307   *ds1307;
int err = -ENODEV;
@@ -334,7 +345,11 @@ static int __devinit ds1307_probe(struct i2c_client 
*client)
const struct chip_desc  *chip;
struct i2c_adapter  *adapter = to_i2c_adapter(client-dev.parent);
 
-   chip = find_chip(client-name);
+   if (id)
+   chip = chips[id-driver_data];
+   else
+   chip = find_chip(client-name);
+
if (!chip) {
dev_err(client-dev, unknown chip type '%s'\n,
client-name);
@@ -537,6 +552,7 @@ static struct i2c_driver ds1307_driver = {
},
.probe  = ds1307_probe,
.remove = __devexit_p(ds1307_remove),
+   .id_table   = ds1307_id,
 };
 
 static int __init ds1307_init(void)
diff --git

[PATCH 1/5] Implement module aliasing for i2c to translate from device tree names

2007-12-19 Thread Jon Smirl
This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/i2c/i2c-core.c  |   32 ++--
 include/linux/i2c.h |9 -
 include/linux/mod_devicetable.h |   20 
 scripts/mod/file2alias.c|   19 +++
 4 files changed, 69 insertions(+), 11 deletions(-)


diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..fce06fd 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,10 +47,25 @@ static DEFINE_IDR(i2c_adapter_idr);
 
 /* - */
 
-static int i2c_device_match(struct device *dev, struct device_driver *drv)
+static const struct i2c_device_id *i2c_device_match(const struct i2c_device_id 
*id, struct i2c_client *client)
+{
+   /* only powerpc drivers implement the id_table,
+* it is empty on other platforms */
+   if (id) {
+   while (id-name[0]) {
+   if (strcmp(client-driver_name, id-name) == 0)
+   return id;
+   id++;
+   }
+   }
+   return NULL;
+}
+
+static int i2c_bus_match(struct device *dev, struct device_driver *drv)
 {
struct i2c_client   *client = to_i2c_client(dev);
struct i2c_driver   *driver = to_i2c_driver(drv);
+   const struct i2c_device_id *found_id;
 
/* make legacy i2c drivers bypass driver model probing entirely;
 * such drivers scan each i2c adapter/bus themselves.
@@ -58,9 +73,11 @@ static int i2c_device_match(struct device *dev, struct 
device_driver *drv)
if (!is_newstyle_driver(driver))
return 0;
 
-   /* new style drivers use the same kind of driver matching policy
-* as platform devices or SPI:  compare device and driver IDs.
-*/
+   /* match on an id table if there is one */
+   found_id = i2c_device_match(driver-id_table, client);
+   if (found_id)
+   return 1;
+
return strcmp(client-driver_name, drv-name) == 0;
 }
 
@@ -89,12 +106,15 @@ static int i2c_device_probe(struct device *dev)
 {
struct i2c_client   *client = to_i2c_client(dev);
struct i2c_driver   *driver = to_i2c_driver(dev-driver);
+   const struct i2c_device_id *id;
 
if (!driver-probe)
return -ENODEV;
client-driver = driver;
dev_dbg(dev, probe\n);
-   return driver-probe(client);
+
+   id = i2c_device_match(driver-id_table, client);
+   return driver-probe(client, id);
 }
 
 static int i2c_device_remove(struct device *dev)
@@ -189,7 +209,7 @@ static struct device_attribute i2c_dev_attrs[] = {
 static struct bus_type i2c_bus_type = {
.name   = i2c,
.dev_attrs  = i2c_dev_attrs,
-   .match  = i2c_device_match,
+   .match  = i2c_bus_match,
.uevent = i2c_device_uevent,
.probe  = i2c_device_probe,
.remove = i2c_device_remove,
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a100c9f..49fc682 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -126,7 +126,7 @@ struct i2c_driver {
 * With the driver model, device enumeration is NEVER done by drivers;
 * it's done by infrastructure.  (NEW STYLE DRIVERS ONLY)
 */
-   int (*probe)(struct i2c_client *);
+   int (*probe)(struct i2c_client *, const struct i2c_device_id *id);
int (*remove)(struct i2c_client *);
 
/* driver model interfaces that don't relate to enumeration  */
@@ -141,11 +141,10 @@ struct i2c_driver {
 
struct device_driver driver;
struct list_head list;
+   struct i2c_device_id *id_table;
 };
 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
 
-#define I2C_NAME_SIZE  20
-
 /**
  * struct i2c_client - represent an I2C slave device
  * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
@@ -179,7 +178,7 @@ struct i2c_client {
/* to the client*/
struct device dev;  /* the device structure */
int irq;/* irq issued by device (or -1) */
-   char driver_name[KOBJ_NAME_LEN];
+   char driver_name[I2C_NAME_SIZE];
struct list_head list;
struct completion released;
 };
@@ -223,7 +222,7 @@ static inline void i2c_set_clientdata (struct i2c_client 
*dev, void *data)
  * with the adapter already known.
  */
 struct i2c_board_info {
-   chardriver_name[KOBJ_NAME_LEN];
+   chardriver_name[I2C_NAME_SIZE];
chartype[I2C_NAME_SIZE

[PATCH 4/5] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

2007-12-19 Thread Jon Smirl
Convert MPC i2c driver from being a platform_driver to an open firmware 
version. Error returns were improved. Routine names were changed from fsl_ to 
mpc_ to make them match the file name.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 arch/powerpc/sysdev/fsl_soc.c |   96 --
 drivers/i2c/busses/i2c-mpc.c  |  183 -
 2 files changed, 180 insertions(+), 99 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 268638a..d6ef264 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -318,102 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include linux/i2c.h
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-  int bus_num)
-{
-   struct device_node *node = NULL;
-   const char *compatible;
-
-   while ((node = of_get_next_child(adap_node, node))) {
-   struct i2c_board_info info = {};
-   const u32 *addr;
-   int len;
-
-   addr = of_get_property(node, reg, len);
-   if (!addr || len  sizeof(int) || *addr  (1  10) - 1) {
-   printk(KERN_WARNING fsl_soc.c: invalid i2c device 
entry\n);
-   continue;
-   }
-
-   info.irq = irq_of_parse_and_map(node, 0);
-   if (info.irq == NO_IRQ)
-   info.irq = -1;
-
-   compatible = of_get_property(node, compatible, len);
-   if (!compatible) {
-   printk(KERN_WARNING i2c-mpc.c: invalid entry, missing 
compatible attribute\n);
-   continue;
-   }
-   strncpy(info.driver_name, compatible, sizeof(info.driver_name));
-
-   info.addr = *addr;
-
-   i2c_register_board_info(bus_num, info, 1);
-   }
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-   struct device_node *np;
-   unsigned int i;
-   struct platform_device *i2c_dev;
-   int ret;
-
-   for (np = NULL, i = 0;
-(np = of_find_compatible_node(np, i2c, fsl-i2c)) != NULL;
-i++) {
-   struct resource r[2];
-   struct fsl_i2c_platform_data i2c_data;
-   const unsigned char *flags = NULL;
-
-   memset(r, 0, sizeof(r));
-   memset(i2c_data, 0, sizeof(i2c_data));
-
-   ret = of_address_to_resource(np, 0, r[0]);
-   if (ret)
-   goto err;
-
-   of_irq_to_resource(np, 0, r[1]);
-
-   i2c_dev = platform_device_register_simple(fsl-i2c, i, r, 2);
-   if (IS_ERR(i2c_dev)) {
-   ret = PTR_ERR(i2c_dev);
-   goto err;
-   }
-
-   i2c_data.device_flags = 0;
-   flags = of_get_property(np, dfsrr, NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-   flags = of_get_property(np, fsl5200-clocking, NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-   ret =
-   platform_device_add_data(i2c_dev, i2c_data,
-sizeof(struct
-   fsl_i2c_platform_data));
-   if (ret)
-   goto unreg;
-
-   of_register_i2c_devices(np, i);
-   }
-
-   return 0;
-
-unreg:
-   platform_device_unregister(i2c_dev);
-err:
-   return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
-
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
 {
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 7c35a8f..4f2e7ea 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,7 @@
 #include linux/module.h
 #include linux/sched.h
 #include linux/init.h
-#include linux/platform_device.h
+#include linux/of_platform.h
 
 #include asm/io.h
 #include linux/fsl_devices.h
@@ -25,13 +25,13 @@
 #include linux/interrupt.h
 #include linux/delay.h
 
-#define MPC_I2C_ADDR  0x00
+#define DRV_NAME mpc-i2c
+
 #define MPC_I2C_FDR0x04
 #define MPC_I2C_CR 0x08
 #define MPC_I2C_SR 0x0c
 #define MPC_I2C_DR 0x10
 #define MPC_I2C_DFSRR 0x14
-#define MPC_I2C_REGION 0x20
 
 #define CCR_MEN  0x80
 #define CCR_MIEN 0x40
@@ -316,6 +316,181 @@ static struct i2c_adapter mpc_ops = {
.retries = 1
 };
 
+struct i2c_driver_device {
+   char*of_device;
+   char*i2c_driver;
+   char*i2c_type;
+};
+
+#ifdef CONFIG_PPC_MERGE
+
+static void of_register_i2c_devices(struct i2c_adapter *adap, struct 
device_node *adap_node)
+{
+   struct device_node *node = NULL;
+
+   while ((node = of_get_next_child(adap_node, node

[PATCH 3/7] Modify several rtc drivers to use the alias names list property of i2c

2007-12-17 Thread Jon Smirl
This patch modifies the ds1307, ds1374, and rs5c372 i2c drivers to support
device tree names using the new i2c mod alias support

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 arch/powerpc/sysdev/fsl_soc.c |   44 
 drivers/rtc/rtc-ds1307.c  |   20 +-
 drivers/rtc/rtc-ds1374.c  |9 ++
 drivers/rtc/rtc-m41t80.c  |   57 -
 drivers/rtc/rtc-rs5c372.c |   16 ++--
 5 files changed, 85 insertions(+), 61 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 3ace747..268638a 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -320,48 +320,12 @@ arch_initcall(gfar_of_init);
 
 #ifdef CONFIG_I2C_BOARDINFO
 #include 
-struct i2c_driver_device {
-   char*of_device;
-   char*i2c_driver;
-   char*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-   {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",},
-   {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",},
-   {"ricoh,rv5c386",  "rtc-rs5c372", "rv5c386",},
-   {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",},
-   {"dallas,ds1307",  "rtc-ds1307",  "ds1307",},
-   {"dallas,ds1337",  "rtc-ds1307",  "ds1337",},
-   {"dallas,ds1338",  "rtc-ds1307",  "ds1338",},
-   {"dallas,ds1339",  "rtc-ds1307",  "ds1339",},
-   {"dallas,ds1340",  "rtc-ds1307",  "ds1340",},
-   {"stm,m41t00", "rtc-ds1307",  "m41t00"},
-   {"dallas,ds1374",  "rtc-ds1374",  "rtc-ds1374",},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-struct i2c_board_info *info)
-{
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
-   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-   continue;
-   if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver,
-   KOBJ_NAME_LEN) >= KOBJ_NAME_LEN ||
-   strlcpy(info->type, i2c_devices[i].i2c_type,
-   I2C_NAME_SIZE) >= I2C_NAME_SIZE)
-   return -ENOMEM;
-   return 0;
-   }
-   return -ENODEV;
-}
 
 static void __init of_register_i2c_devices(struct device_node *adap_node,
   int bus_num)
 {
struct device_node *node = NULL;
+   const char *compatible;
 
while ((node = of_get_next_child(adap_node, node))) {
struct i2c_board_info info = {};
@@ -378,8 +342,12 @@ static void __init of_register_i2c_devices(struct 
device_node *adap_node,
if (info.irq == NO_IRQ)
info.irq = -1;
 
-   if (of_find_i2c_driver(node, ) < 0)
+   compatible = of_get_property(node, "compatible", );
+   if (!compatible) {
+   printk(KERN_WARNING "i2c-mpc.c: invalid entry, missing 
compatible attribute\n");
continue;
+   }
+   strncpy(info.driver_name, compatible, sizeof(info.driver_name));
 
info.addr = *addr;
 
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index bc1c7fe..d4874ff 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -139,6 +139,17 @@ static inline const struct chip_desc *find_chip(const char 
*s)
return NULL;
 }
 
+static struct i2c_device_id ds1307_id[] = {
+   OF_I2C_ID("dallas,ds1307", ds_1307)
+   OF_I2C_ID("dallas,ds1337", ds_1337)
+   OF_I2C_ID("dallas,ds1338", ds_1338)
+   OF_I2C_ID("dallas,ds1339", ds_1339)
+   OF_I2C_ID("dallas,ds1340", ds_1340)
+   OF_I2C_ID("stm,m41t00", m41t00)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, ds1307_id);
+
 static int ds1307_get_time(struct device *dev, struct rtc_time *t)
 {
struct ds1307   *ds1307 = dev_get_drvdata(dev);
@@ -326,7 +337,7 @@ static struct bin_attribute nvram = {
 
 static struct i2c_driver ds1307_driver;
 
-static int __devinit ds1307_probe(struct i2c_client *client)
+static int __devinit ds1307_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct ds1307   *ds1307;
int err = -ENODEV;
@@ -334,7 +345,11 @@ static int __devinit ds1307_probe(struct i2c_client 
*client)
const struct chip_desc  *chip;
st

[PATCH 6/7] Convert pfc8563 i2c driver from old style to new style

2007-12-17 Thread Jon Smirl
Convert pfc8563 i2c driver from old style to new style. The
driver is also modified to support device tree names via the
i2c mod alias mechanism.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/rtc/rtc-pcf8563.c |  107 +++--
 1 files changed, 27 insertions(+), 80 deletions(-)


diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 0242d80..e1ea2a0 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -25,10 +25,6 @@
  * located at 0x51 will pass the validation routine due to
  * the way the registers are implemented.
  */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Module parameters */
-I2C_CLIENT_INSMOD;
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -72,9 +68,6 @@ struct pcf8563 {
int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
-static int pcf8563_detach(struct i2c_client *client);
-
 /*
  * In the routines that deal directly with the pcf8563 hardware, we use
  * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
@@ -257,98 +250,52 @@ static const struct rtc_class_ops pcf8563_rtc_ops = {
.set_time   = pcf8563_rtc_set_time,
 };
 
-static int pcf8563_attach(struct i2c_adapter *adapter)
+static int pcf8563_remove(struct i2c_client *client)
 {
-   return i2c_probe(adapter, _data, pcf8563_probe);
+   struct rtc_device *rtc = i2c_get_clientdata(client);
+
+   if (rtc)
+   rtc_device_unregister(rtc);
+
+   return 0;
 }
 
+static struct i2c_device_id pcf8563_id[] = {
+   OF_I2C_ID("philips,pcf8563", 0)
+   OF_I2C_ID("epson,rtc8564", 0)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, pcf8563_id);
+
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id);
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
-   .name   = "pcf8563",
+   .name   = "rtc-pcf8563",
},
.id = I2C_DRIVERID_PCF8563,
-   .attach_adapter = _attach,
-   .detach_client  = _detach,
+   .probe = _probe,
+   .remove = _remove,
+   .id_table   = pcf8563_id,
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
-   struct pcf8563 *pcf8563;
-   struct i2c_client *client;
+   int result;
struct rtc_device *rtc;
 
-   int err = 0;
-
-   dev_dbg(>dev, "%s\n", __FUNCTION__);
-
-   if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
-   err = -ENODEV;
-   goto exit;
-   }
-
-   if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
-   err = -ENOMEM;
-   goto exit;
-   }
-
-   client = >client;
-   client->addr = address;
-   client->driver = _driver;
-   client->adapter = adapter;
-
-   strlcpy(client->name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
-
-   /* Verify the chip is really an PCF8563 */
-   if (kind < 0) {
-   if (pcf8563_validate_client(client) < 0) {
-   err = -ENODEV;
-   goto exit_kfree;
-   }
-   }
-
-   /* Inform the i2c layer */
-   if ((err = i2c_attach_client(client)))
-   goto exit_kfree;
-
-   dev_info(>dev, "chip found, driver version " DRV_VERSION "\n");
+   result = pcf8563_validate_client(client);
+   if (result)
+   return result;
 
rtc = rtc_device_register(pcf8563_driver.driver.name, >dev,
_rtc_ops, THIS_MODULE);
-
-   if (IS_ERR(rtc)) {
-   err = PTR_ERR(rtc);
-   goto exit_detach;
-   }
+   if (IS_ERR(rtc))
+   return PTR_ERR(rtc);
 
i2c_set_clientdata(client, rtc);
 
return 0;
-
-exit_detach:
-   i2c_detach_client(client);
-
-exit_kfree:
-   kfree(pcf8563);
-
-exit:
-   return err;
-}
-
-static int pcf8563_detach(struct i2c_client *client)
-{
-   struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
-   int err;
-   struct rtc_device *rtc = i2c_get_clientdata(client);
-
-   if (rtc)
-   rtc_device_unregister(rtc);
-
-   if ((err = i2c_detach_client(client)))
-   return err;
-
-   kfree(pcf8563);
-
-   return 0;
 }
 
 static int __init pcf8563_init(void)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/7] Makefile

2007-12-17 Thread Jon Smirl
Ignore this patch, I forgot to remove it before mailing the series.

On 12/17/07, Jon Smirl <[EMAIL PROTECTED]> wrote:
> Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
>
> Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
> ---
>
>  Makefile |3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
>
> diff --git a/Makefile b/Makefile
> index c1825aa..15ada3f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -35,6 +35,9 @@ MAKEFLAGS += -rR --no-print-directory
>  # To put more focus on warnings, be less verbose as default
>  # Use 'make V=1' to see the full commands
>
> +ARCH=powerpc
> +CROSS_COMPILE=powerpc-603e-linux-gnu-
> +
>  ifdef V
>ifeq ("$(origin V)", "command line")
>  KBUILD_VERBOSE = $(V)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/7] Makefile

2007-12-17 Thread Jon Smirl
Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 Makefile |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)


diff --git a/Makefile b/Makefile
index c1825aa..15ada3f 100644
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,9 @@ MAKEFLAGS += -rR --no-print-directory
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
 
+ARCH=powerpc
+CROSS_COMPILE=powerpc-603e-linux-gnu-
+
 ifdef V
   ifeq ("$(origin V)", "command line")
 KBUILD_VERBOSE = $(V)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] update module-init-tools to support the i2c subsystem

2007-12-17 Thread Jon Smirl
Follow on to: "Series to add device tree naming to i2c"
Teach module-init-tools about the i2c subsystem.

diff --git a/depmod.c b/depmod.c
index 0281c79..209eb0c 100644
--- a/depmod.c
+++ b/depmod.c
@@ -793,6 +793,7 @@ static struct depfile depfiles[] = {
{ "modules.inputmap", output_input_table },
{ "modules.ofmap", output_of_table },
{ "modules.seriomap", output_serio_table },
+   { "modules.i2cmap", output_i2c_table },
{ "modules.alias", output_aliases },
{ "modules.symbols", output_symbols },
 };
diff --git a/depmod.h b/depmod.h
index 6cea36e..1040214 100644
--- a/depmod.h
+++ b/depmod.h
@@ -55,6 +55,8 @@ struct module
unsigned int input_table_size;
unsigned int serio_size;
void *serio_table;
+   unsigned int i2c_size;
+   void *i2c_table;
unsigned int of_size;
void *of_table;

diff --git a/moduleops_core.c b/moduleops_core.c
index 56c85d3..a7ca350 100644
--- a/moduleops_core.c
+++ b/moduleops_core.c
@@ -230,6 +230,11 @@ static void PERBIT(fetch_tables)(struct module *module)
"__mod_serio_device_table",
NULL, module->conv);

+   module->i2c_size = PERBIT(I2C_DEVICE_SIZE);
+   module->i2c_table = PERBIT(deref_sym)(module->data,
+   "__mod_i2c_device_table",
+   NULL, module->conv);
+
module->of_size = PERBIT(OF_DEVICE_SIZE);
module->of_table = PERBIT(deref_sym)(module->data,
"__mod_of_device_table",
diff --git a/tables.c b/tables.c
index 6dfd165..82e162d 100644
--- a/tables.c
+++ b/tables.c
@@ -496,6 +496,35 @@ void output_serio_table(struct module *modules, FILE *out)
 }


+static void output_i2c_entry(struct i2c_device_id *i2c, char *name, FILE *out)
+{
+   fprintf(out,
+   "%-20s %-20s\n",
+   name,
+   i2c->name);
+}
+
+
+void output_i2c_table(struct module *modules, FILE *out)
+{
+   struct module *i;
+
+   fprintf(out, "# i2c module name\n");
+
+   for (i = modules; i; i = i->next) {
+   struct i2c_device_id *e;
+   char shortname[strlen(i->pathname) + 1];
+
+   if (!i->i2c_table)
+   continue;
+
+   make_shortname(shortname, i->pathname);
+   for (e = i->i2c_table; e->name[0]; e = (void *)e + i->i2c_size)
+   output_i2c_entry(e, shortname, out);
+   }
+}
+
+
 static void
 strip_whitespace (char *str, char chr)
 {
diff --git a/tables.h b/tables.h
index e5f6f35..263369d 100644
--- a/tables.h
+++ b/tables.h
@@ -164,6 +164,12 @@ struct serio_device_id {
 #define SERIO_DEVICE_SIZE32 (4 * 1)
 #define SERIO_DEVICE_SIZE64 (4 * 1 + 4)

+struct i2c_device_id {
+   char name[48];
+};
+#define I2C_DEVICE_SIZE32 (48 + 4)
+#define I2C_DEVICE_SIZE64 (48 + 8)
+
 struct of_device_id {
char name[32];
char type[32];
@@ -182,6 +188,7 @@ void output_ccw_table(struct module *modules, FILE *out);
 void output_isapnp_table(struct module *modules, FILE *out);
 void output_input_table(struct module *modules, FILE *out);
 void output_serio_table(struct module *modules, FILE *out);
+void output_i2c_table(struct module *modules, FILE *out);
 void output_of_table(struct module *modules, FILE *out);

 #endif /* MODINITTOOLS_TABLES_H */

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/7] Implement module aliasing for i2c to translate from device tree names

2007-12-17 Thread Jon Smirl
This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/i2c/i2c-core.c  |   32 ++--
 include/linux/i2c.h |9 -
 include/linux/mod_devicetable.h |   20 
 scripts/mod/file2alias.c|   19 +++
 4 files changed, 69 insertions(+), 11 deletions(-)


diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..fce06fd 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,10 +47,25 @@ static DEFINE_IDR(i2c_adapter_idr);
 
 /* - */
 
-static int i2c_device_match(struct device *dev, struct device_driver *drv)
+static const struct i2c_device_id *i2c_device_match(const struct i2c_device_id 
*id, struct i2c_client *client)
+{
+   /* only powerpc drivers implement the id_table,
+* it is empty on other platforms */
+   if (id) {
+   while (id->name[0]) {
+   if (strcmp(client->driver_name, id->name) == 0)
+   return id;
+   id++;
+   }
+   }
+   return NULL;
+}
+
+static int i2c_bus_match(struct device *dev, struct device_driver *drv)
 {
struct i2c_client   *client = to_i2c_client(dev);
struct i2c_driver   *driver = to_i2c_driver(drv);
+   const struct i2c_device_id *found_id;
 
/* make legacy i2c drivers bypass driver model probing entirely;
 * such drivers scan each i2c adapter/bus themselves.
@@ -58,9 +73,11 @@ static int i2c_device_match(struct device *dev, struct 
device_driver *drv)
if (!is_newstyle_driver(driver))
return 0;
 
-   /* new style drivers use the same kind of driver matching policy
-* as platform devices or SPI:  compare device and driver IDs.
-*/
+   /* match on an id table if there is one */
+   found_id = i2c_device_match(driver->id_table, client);
+   if (found_id)
+   return 1;
+
return strcmp(client->driver_name, drv->name) == 0;
 }
 
@@ -89,12 +106,15 @@ static int i2c_device_probe(struct device *dev)
 {
struct i2c_client   *client = to_i2c_client(dev);
struct i2c_driver   *driver = to_i2c_driver(dev->driver);
+   const struct i2c_device_id *id;
 
if (!driver->probe)
return -ENODEV;
client->driver = driver;
dev_dbg(dev, "probe\n");
-   return driver->probe(client);
+
+   id = i2c_device_match(driver->id_table, client);
+   return driver->probe(client, id);
 }
 
 static int i2c_device_remove(struct device *dev)
@@ -189,7 +209,7 @@ static struct device_attribute i2c_dev_attrs[] = {
 static struct bus_type i2c_bus_type = {
.name   = "i2c",
.dev_attrs  = i2c_dev_attrs,
-   .match  = i2c_device_match,
+   .match  = i2c_bus_match,
.uevent = i2c_device_uevent,
.probe  = i2c_device_probe,
.remove = i2c_device_remove,
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a100c9f..49fc682 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -126,7 +126,7 @@ struct i2c_driver {
 * With the driver model, device enumeration is NEVER done by drivers;
 * it's done by infrastructure.  (NEW STYLE DRIVERS ONLY)
 */
-   int (*probe)(struct i2c_client *);
+   int (*probe)(struct i2c_client *, const struct i2c_device_id *id);
int (*remove)(struct i2c_client *);
 
/* driver model interfaces that don't relate to enumeration  */
@@ -141,11 +141,10 @@ struct i2c_driver {
 
struct device_driver driver;
struct list_head list;
+   struct i2c_device_id *id_table;
 };
 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
 
-#define I2C_NAME_SIZE  20
-
 /**
  * struct i2c_client - represent an I2C slave device
  * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
@@ -179,7 +178,7 @@ struct i2c_client {
/* to the client*/
struct device dev;  /* the device structure */
int irq;/* irq issued by device (or -1) */
-   char driver_name[KOBJ_NAME_LEN];
+   char driver_name[I2C_NAME_SIZE];
struct list_head list;
struct completion released;
 };
@@ -223,7 +222,7 @@ static inline void i2c_set_clientdata (struct i2c_client 
*dev, void *data)
  * with the adapter alread

[PATCH 4/7] Clean up error returns

2007-12-17 Thread Jon Smirl
Return errors that were being ignored in the mpc-i2c driver

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 drivers/i2c/busses/i2c-mpc.c |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index d8de4ac..7c35a8f 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -180,7 +180,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
 static int mpc_write(struct mpc_i2c *i2c, int target,
 const u8 * data, int length, int restart)
 {
-   int i;
+   int i, result;
unsigned timeout = i2c->adap.timeout;
u32 flags = restart ? CCR_RSTA : 0;
 
@@ -192,15 +192,17 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
/* Write target byte */
writeb((target << 1), i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
 
for (i = 0; i < length; i++) {
/* Write data byte */
writeb(data[i], i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
}
 
return 0;
@@ -210,7 +212,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
u8 * data, int length, int restart)
 {
unsigned timeout = i2c->adap.timeout;
-   int i;
+   int i, result;
u32 flags = restart ? CCR_RSTA : 0;
 
/* Start with MEN */
@@ -221,8 +223,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
/* Write target address byte - this time with the read flag set */
writeb((target << 1) | 1, i2c->base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result < 0)
+   return result;
 
if (length) {
if (length == 1)
@@ -234,8 +237,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
}
 
for (i = 0; i < length; i++) {
-   if (i2c_wait(i2c, timeout, 0) < 0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 0);
+   if (result < 0)
+   return result;
 
/* Generate txack on next to last byte */
if (i == length - 2)
@@ -321,9 +325,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 
pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
 
-   if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
+   i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+   if (!i2c)
return -ENOMEM;
-   }
 
i2c->irq = platform_get_irq(pdev, 0);
if (i2c->irq < 0) {
@@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(>adap);
platform_set_drvdata(pdev, NULL);
 
-   if (i2c->irq != 0)
+   if (i2c->irq != NO_IRQ)
free_irq(i2c->irq, i2c);
 
iounmap(i2c->base);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/7] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

2007-12-17 Thread Jon Smirl
Convert MPC i2c driver from being a platform_driver to an open firmware 
version. Error returns were improved. Routine names were changed from fsl_ to 
mpc_ to make them match the file name.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 arch/powerpc/sysdev/fsl_soc.c |   96 
 drivers/i2c/busses/i2c-mpc.c  |  167 +
 2 files changed, 119 insertions(+), 144 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 268638a..d6ef264 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -318,102 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include 
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-  int bus_num)
-{
-   struct device_node *node = NULL;
-   const char *compatible;
-
-   while ((node = of_get_next_child(adap_node, node))) {
-   struct i2c_board_info info = {};
-   const u32 *addr;
-   int len;
-
-   addr = of_get_property(node, "reg", );
-   if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
-   printk(KERN_WARNING "fsl_soc.c: invalid i2c device 
entry\n");
-   continue;
-   }
-
-   info.irq = irq_of_parse_and_map(node, 0);
-   if (info.irq == NO_IRQ)
-   info.irq = -1;
-
-   compatible = of_get_property(node, "compatible", );
-   if (!compatible) {
-   printk(KERN_WARNING "i2c-mpc.c: invalid entry, missing 
compatible attribute\n");
-   continue;
-   }
-   strncpy(info.driver_name, compatible, sizeof(info.driver_name));
-
-   info.addr = *addr;
-
-   i2c_register_board_info(bus_num, , 1);
-   }
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-   struct device_node *np;
-   unsigned int i;
-   struct platform_device *i2c_dev;
-   int ret;
-
-   for (np = NULL, i = 0;
-(np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
-i++) {
-   struct resource r[2];
-   struct fsl_i2c_platform_data i2c_data;
-   const unsigned char *flags = NULL;
-
-   memset(, 0, sizeof(r));
-   memset(_data, 0, sizeof(i2c_data));
-
-   ret = of_address_to_resource(np, 0, [0]);
-   if (ret)
-   goto err;
-
-   of_irq_to_resource(np, 0, [1]);
-
-   i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
-   if (IS_ERR(i2c_dev)) {
-   ret = PTR_ERR(i2c_dev);
-   goto err;
-   }
-
-   i2c_data.device_flags = 0;
-   flags = of_get_property(np, "dfsrr", NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-   flags = of_get_property(np, "fsl5200-clocking", NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-   ret =
-   platform_device_add_data(i2c_dev, _data,
-sizeof(struct
-   fsl_i2c_platform_data));
-   if (ret)
-   goto unreg;
-
-   of_register_i2c_devices(np, i);
-   }
-
-   return 0;
-
-unreg:
-   platform_device_unregister(i2c_dev);
-err:
-   return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
-
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
 {
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 7c35a8f..fc46207 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 
@@ -25,13 +25,13 @@
 #include 
 #include 
 
-#define MPC_I2C_ADDR  0x00
+#define DRV_NAME "mpc-i2c"
+
 #define MPC_I2C_FDR0x04
 #define MPC_I2C_CR 0x08
 #define MPC_I2C_SR 0x0c
 #define MPC_I2C_DR 0x10
 #define MPC_I2C_DFSRR 0x14
-#define MPC_I2C_REGION 0x20
 
 #define CCR_MEN  0x80
 #define CCR_MIEN 0x40
@@ -316,105 +316,176 @@ static struct i2c_adapter mpc_ops = {
.retries = 1
 };
 
-static int fsl_i2c_probe(struct platform_device *pdev)
+struct i2c_driver_device {
+   char*of_device;
+   char*i2c_driver;
+   char*i2c_type;
+};
+
+static void of_register_i2c_devices(struct i2c_adapter *adap, struct 
device_node *adap_node)

[PATCH 1/7] Copy mpc-i2c to preserve support for ARCH=ppc and allow changes on ARCH=powerpc

2007-12-17 Thread Jon Smirl
Temporarily copy the mpc-i2c driver to continue support for the ppc 
architecture until it is removed in mid-2008. This file should be deleted as 
part of ppc's final removal.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 arch/ppc/configs/TQM8540_defconfig |2 
 arch/ppc/configs/TQM8541_defconfig |2 
 arch/ppc/configs/TQM8555_defconfig |2 
 arch/ppc/configs/TQM8560_defconfig |2 
 arch/ppc/configs/mpc834x_sys_defconfig |2 
 arch/ppc/configs/mpc8540_ads_defconfig |2 
 arch/ppc/configs/mpc8548_cds_defconfig |2 
 arch/ppc/configs/mpc8555_cds_defconfig |2 
 arch/ppc/configs/mpc8560_ads_defconfig |2 
 drivers/i2c/busses/Kconfig |   16 +
 drivers/i2c/busses/Makefile|1 
 drivers/i2c/busses/i2c-mpc-ppc.c   |  418 
 12 files changed, 443 insertions(+), 10 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-ppc.c


diff --git a/arch/ppc/configs/TQM8540_defconfig 
b/arch/ppc/configs/TQM8540_defconfig
index f33f0e7..7098ed0 100644
--- a/arch/ppc/configs/TQM8540_defconfig
+++ b/arch/ppc/configs/TQM8540_defconfig
@@ -684,7 +684,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/TQM8541_defconfig 
b/arch/ppc/configs/TQM8541_defconfig
index e00cd62..2137d01 100644
--- a/arch/ppc/configs/TQM8541_defconfig
+++ b/arch/ppc/configs/TQM8541_defconfig
@@ -687,7 +687,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_MPC8260 is not set
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
diff --git a/arch/ppc/configs/TQM8555_defconfig 
b/arch/ppc/configs/TQM8555_defconfig
index 43a0d9d..f2317b6 100644
--- a/arch/ppc/configs/TQM8555_defconfig
+++ b/arch/ppc/configs/TQM8555_defconfig
@@ -687,7 +687,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/TQM8560_defconfig 
b/arch/ppc/configs/TQM8560_defconfig
index a814d17..6c19121 100644
--- a/arch/ppc/configs/TQM8560_defconfig
+++ b/arch/ppc/configs/TQM8560_defconfig
@@ -694,7 +694,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_MPC8260 is not set
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
diff --git a/arch/ppc/configs/mpc834x_sys_defconfig 
b/arch/ppc/configs/mpc834x_sys_defconfig
index d90c8a7..cd568d2 100644
--- a/arch/ppc/configs/mpc834x_sys_defconfig
+++ b/arch/ppc/configs/mpc834x_sys_defconfig
@@ -562,7 +562,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/mpc8540_ads_defconfig 
b/arch/ppc/configs/mpc8540_ads_defconfig
index bf676eb..5819835 100644
--- a/arch/ppc/configs/mpc8540_ads_defconfig
+++ b/arch/ppc/configs/mpc8540_ads_defconfig
@@ -452,7 +452,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_AMD8111 is not set
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PIIX4 is not set
diff --git a/arch/ppc/configs/mpc8548_cds_defconfig 
b/arch/ppc/configs/mpc8548_cds_defconfig
index f36fc5d..e5b5071 100644
--- a/arch/ppc/configs/mpc8548_cds_defconfig
+++ b/arch/ppc/configs/mpc8548_cds_defconfig
@@ -413,7 +413,7 @@ CONFIG_I2C_CHARDEV=y
 #
 # I2C Hardware Bus support
 #
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PCA_ISA is not set
 
diff --git a/arch/ppc/configs/mpc8555_cds_defconfig 
b/arch/ppc/configs/mpc8555_cds_defconfig
index 4f1e320..08dbab0 100644
--- a/arch/ppc/configs/mpc8555_cds_defconfig
+++ b/arch/ppc/configs/mpc8555_cds_defconfig
@@ -518,7 +518,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/mpc8560_ads_defconfig 
b/arch/ppc/configs/mpc8560_ads_defconfig
index f12d48f..0e0080b 100644
--- a/arch/ppc/configs/mpc8560_a

[PATCH 0/7] Series to add device tree naming to i2c

2007-12-17 Thread Jon Smirl
Another rework of the i2c for powerpc device tree patch. This version 
implements standard alias naming only on the powerpc platform and only for the 
device tree names. The old naming mechanism of i2c_client.name,driver_name is 
left in place and not changed for non-powerpc platforms. This patch is fully 
capable of dynamically loading the i2c modules. You can modprobe in the i2c-mpc 
driver and the i2c modules described in the device tree will be automatically 
loaded. Modules also work if compiled in.

The follow on patch to module-init-tools is also needed since the i2c subsystem 
has never implemented dynamic loading.

Since the i2c-mpc driver also supports the ppc architecture the i2c-mpc driver 
was copied to i2c-mpc-ppc before changes were made. The i2c-mpc-ppc driver 
should be deleted in six months when the rest of the ppc architecture is 
removed.

The following series implements standard linux module aliasing for i2c modules 
on arch=powerpc. It then converts the mpc i2c driver from being a platform 
driver to an open firmware one. I2C device names are picked up from the device 
tree. Module aliasing is used to translate from device tree names into to linux 
kernel names. Several i2c drivers are updated to use the new aliasing. 

--
Jon Smirl
[EMAIL PROTECTED] 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/7] Series to add device tree naming to i2c

2007-12-17 Thread Jon Smirl
Another rework of the i2c for powerpc device tree patch. This version 
implements standard alias naming only on the powerpc platform and only for the 
device tree names. The old naming mechanism of i2c_client.name,driver_name is 
left in place and not changed for non-powerpc platforms. This patch is fully 
capable of dynamically loading the i2c modules. You can modprobe in the i2c-mpc 
driver and the i2c modules described in the device tree will be automatically 
loaded. Modules also work if compiled in.

The follow on patch to module-init-tools is also needed since the i2c subsystem 
has never implemented dynamic loading.

Since the i2c-mpc driver also supports the ppc architecture the i2c-mpc driver 
was copied to i2c-mpc-ppc before changes were made. The i2c-mpc-ppc driver 
should be deleted in six months when the rest of the ppc architecture is 
removed.

The following series implements standard linux module aliasing for i2c modules 
on arch=powerpc. It then converts the mpc i2c driver from being a platform 
driver to an open firmware one. I2C device names are picked up from the device 
tree. Module aliasing is used to translate from device tree names into to linux 
kernel names. Several i2c drivers are updated to use the new aliasing. 

--
Jon Smirl
[EMAIL PROTECTED] 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/7] Copy mpc-i2c to preserve support for ARCH=ppc and allow changes on ARCH=powerpc

2007-12-17 Thread Jon Smirl
Temporarily copy the mpc-i2c driver to continue support for the ppc 
architecture until it is removed in mid-2008. This file should be deleted as 
part of ppc's final removal.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 arch/ppc/configs/TQM8540_defconfig |2 
 arch/ppc/configs/TQM8541_defconfig |2 
 arch/ppc/configs/TQM8555_defconfig |2 
 arch/ppc/configs/TQM8560_defconfig |2 
 arch/ppc/configs/mpc834x_sys_defconfig |2 
 arch/ppc/configs/mpc8540_ads_defconfig |2 
 arch/ppc/configs/mpc8548_cds_defconfig |2 
 arch/ppc/configs/mpc8555_cds_defconfig |2 
 arch/ppc/configs/mpc8560_ads_defconfig |2 
 drivers/i2c/busses/Kconfig |   16 +
 drivers/i2c/busses/Makefile|1 
 drivers/i2c/busses/i2c-mpc-ppc.c   |  418 
 12 files changed, 443 insertions(+), 10 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-ppc.c


diff --git a/arch/ppc/configs/TQM8540_defconfig 
b/arch/ppc/configs/TQM8540_defconfig
index f33f0e7..7098ed0 100644
--- a/arch/ppc/configs/TQM8540_defconfig
+++ b/arch/ppc/configs/TQM8540_defconfig
@@ -684,7 +684,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/TQM8541_defconfig 
b/arch/ppc/configs/TQM8541_defconfig
index e00cd62..2137d01 100644
--- a/arch/ppc/configs/TQM8541_defconfig
+++ b/arch/ppc/configs/TQM8541_defconfig
@@ -687,7 +687,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_MPC8260 is not set
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
diff --git a/arch/ppc/configs/TQM8555_defconfig 
b/arch/ppc/configs/TQM8555_defconfig
index 43a0d9d..f2317b6 100644
--- a/arch/ppc/configs/TQM8555_defconfig
+++ b/arch/ppc/configs/TQM8555_defconfig
@@ -687,7 +687,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/TQM8560_defconfig 
b/arch/ppc/configs/TQM8560_defconfig
index a814d17..6c19121 100644
--- a/arch/ppc/configs/TQM8560_defconfig
+++ b/arch/ppc/configs/TQM8560_defconfig
@@ -694,7 +694,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_MPC8260 is not set
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
diff --git a/arch/ppc/configs/mpc834x_sys_defconfig 
b/arch/ppc/configs/mpc834x_sys_defconfig
index d90c8a7..cd568d2 100644
--- a/arch/ppc/configs/mpc834x_sys_defconfig
+++ b/arch/ppc/configs/mpc834x_sys_defconfig
@@ -562,7 +562,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/mpc8540_ads_defconfig 
b/arch/ppc/configs/mpc8540_ads_defconfig
index bf676eb..5819835 100644
--- a/arch/ppc/configs/mpc8540_ads_defconfig
+++ b/arch/ppc/configs/mpc8540_ads_defconfig
@@ -452,7 +452,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_AMD8111 is not set
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PIIX4 is not set
diff --git a/arch/ppc/configs/mpc8548_cds_defconfig 
b/arch/ppc/configs/mpc8548_cds_defconfig
index f36fc5d..e5b5071 100644
--- a/arch/ppc/configs/mpc8548_cds_defconfig
+++ b/arch/ppc/configs/mpc8548_cds_defconfig
@@ -413,7 +413,7 @@ CONFIG_I2C_CHARDEV=y
 #
 # I2C Hardware Bus support
 #
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PCA_ISA is not set
 
diff --git a/arch/ppc/configs/mpc8555_cds_defconfig 
b/arch/ppc/configs/mpc8555_cds_defconfig
index 4f1e320..08dbab0 100644
--- a/arch/ppc/configs/mpc8555_cds_defconfig
+++ b/arch/ppc/configs/mpc8555_cds_defconfig
@@ -518,7 +518,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/mpc8560_ads_defconfig 
b/arch/ppc/configs/mpc8560_ads_defconfig
index f12d48f..0e0080b 100644
--- a/arch/ppc/configs/mpc8560_ads_defconfig
+++ b/arch/ppc

[PATCH 5/7] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

2007-12-17 Thread Jon Smirl
Convert MPC i2c driver from being a platform_driver to an open firmware 
version. Error returns were improved. Routine names were changed from fsl_ to 
mpc_ to make them match the file name.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 arch/powerpc/sysdev/fsl_soc.c |   96 
 drivers/i2c/busses/i2c-mpc.c  |  167 +
 2 files changed, 119 insertions(+), 144 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 268638a..d6ef264 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -318,102 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include linux/i2c.h
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-  int bus_num)
-{
-   struct device_node *node = NULL;
-   const char *compatible;
-
-   while ((node = of_get_next_child(adap_node, node))) {
-   struct i2c_board_info info = {};
-   const u32 *addr;
-   int len;
-
-   addr = of_get_property(node, reg, len);
-   if (!addr || len  sizeof(int) || *addr  (1  10) - 1) {
-   printk(KERN_WARNING fsl_soc.c: invalid i2c device 
entry\n);
-   continue;
-   }
-
-   info.irq = irq_of_parse_and_map(node, 0);
-   if (info.irq == NO_IRQ)
-   info.irq = -1;
-
-   compatible = of_get_property(node, compatible, len);
-   if (!compatible) {
-   printk(KERN_WARNING i2c-mpc.c: invalid entry, missing 
compatible attribute\n);
-   continue;
-   }
-   strncpy(info.driver_name, compatible, sizeof(info.driver_name));
-
-   info.addr = *addr;
-
-   i2c_register_board_info(bus_num, info, 1);
-   }
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-   struct device_node *np;
-   unsigned int i;
-   struct platform_device *i2c_dev;
-   int ret;
-
-   for (np = NULL, i = 0;
-(np = of_find_compatible_node(np, i2c, fsl-i2c)) != NULL;
-i++) {
-   struct resource r[2];
-   struct fsl_i2c_platform_data i2c_data;
-   const unsigned char *flags = NULL;
-
-   memset(r, 0, sizeof(r));
-   memset(i2c_data, 0, sizeof(i2c_data));
-
-   ret = of_address_to_resource(np, 0, r[0]);
-   if (ret)
-   goto err;
-
-   of_irq_to_resource(np, 0, r[1]);
-
-   i2c_dev = platform_device_register_simple(fsl-i2c, i, r, 2);
-   if (IS_ERR(i2c_dev)) {
-   ret = PTR_ERR(i2c_dev);
-   goto err;
-   }
-
-   i2c_data.device_flags = 0;
-   flags = of_get_property(np, dfsrr, NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-   flags = of_get_property(np, fsl5200-clocking, NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-   ret =
-   platform_device_add_data(i2c_dev, i2c_data,
-sizeof(struct
-   fsl_i2c_platform_data));
-   if (ret)
-   goto unreg;
-
-   of_register_i2c_devices(np, i);
-   }
-
-   return 0;
-
-unreg:
-   platform_device_unregister(i2c_dev);
-err:
-   return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
-
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
 {
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 7c35a8f..fc46207 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,7 @@
 #include linux/module.h
 #include linux/sched.h
 #include linux/init.h
-#include linux/platform_device.h
+#include linux/of_platform.h
 
 #include asm/io.h
 #include linux/fsl_devices.h
@@ -25,13 +25,13 @@
 #include linux/interrupt.h
 #include linux/delay.h
 
-#define MPC_I2C_ADDR  0x00
+#define DRV_NAME mpc-i2c
+
 #define MPC_I2C_FDR0x04
 #define MPC_I2C_CR 0x08
 #define MPC_I2C_SR 0x0c
 #define MPC_I2C_DR 0x10
 #define MPC_I2C_DFSRR 0x14
-#define MPC_I2C_REGION 0x20
 
 #define CCR_MEN  0x80
 #define CCR_MIEN 0x40
@@ -316,105 +316,176 @@ static struct i2c_adapter mpc_ops = {
.retries = 1
 };
 
-static int fsl_i2c_probe(struct platform_device *pdev)
+struct i2c_driver_device {
+   char*of_device;
+   char*i2c_driver;
+   char*i2c_type;
+};
+
+static void of_register_i2c_devices(struct i2c_adapter *adap, struct 
device_node *adap_node

[PATCH 2/7] Implement module aliasing for i2c to translate from device tree names

2007-12-17 Thread Jon Smirl
This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/i2c/i2c-core.c  |   32 ++--
 include/linux/i2c.h |9 -
 include/linux/mod_devicetable.h |   20 
 scripts/mod/file2alias.c|   19 +++
 4 files changed, 69 insertions(+), 11 deletions(-)


diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..fce06fd 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,10 +47,25 @@ static DEFINE_IDR(i2c_adapter_idr);
 
 /* - */
 
-static int i2c_device_match(struct device *dev, struct device_driver *drv)
+static const struct i2c_device_id *i2c_device_match(const struct i2c_device_id 
*id, struct i2c_client *client)
+{
+   /* only powerpc drivers implement the id_table,
+* it is empty on other platforms */
+   if (id) {
+   while (id-name[0]) {
+   if (strcmp(client-driver_name, id-name) == 0)
+   return id;
+   id++;
+   }
+   }
+   return NULL;
+}
+
+static int i2c_bus_match(struct device *dev, struct device_driver *drv)
 {
struct i2c_client   *client = to_i2c_client(dev);
struct i2c_driver   *driver = to_i2c_driver(drv);
+   const struct i2c_device_id *found_id;
 
/* make legacy i2c drivers bypass driver model probing entirely;
 * such drivers scan each i2c adapter/bus themselves.
@@ -58,9 +73,11 @@ static int i2c_device_match(struct device *dev, struct 
device_driver *drv)
if (!is_newstyle_driver(driver))
return 0;
 
-   /* new style drivers use the same kind of driver matching policy
-* as platform devices or SPI:  compare device and driver IDs.
-*/
+   /* match on an id table if there is one */
+   found_id = i2c_device_match(driver-id_table, client);
+   if (found_id)
+   return 1;
+
return strcmp(client-driver_name, drv-name) == 0;
 }
 
@@ -89,12 +106,15 @@ static int i2c_device_probe(struct device *dev)
 {
struct i2c_client   *client = to_i2c_client(dev);
struct i2c_driver   *driver = to_i2c_driver(dev-driver);
+   const struct i2c_device_id *id;
 
if (!driver-probe)
return -ENODEV;
client-driver = driver;
dev_dbg(dev, probe\n);
-   return driver-probe(client);
+
+   id = i2c_device_match(driver-id_table, client);
+   return driver-probe(client, id);
 }
 
 static int i2c_device_remove(struct device *dev)
@@ -189,7 +209,7 @@ static struct device_attribute i2c_dev_attrs[] = {
 static struct bus_type i2c_bus_type = {
.name   = i2c,
.dev_attrs  = i2c_dev_attrs,
-   .match  = i2c_device_match,
+   .match  = i2c_bus_match,
.uevent = i2c_device_uevent,
.probe  = i2c_device_probe,
.remove = i2c_device_remove,
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a100c9f..49fc682 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -126,7 +126,7 @@ struct i2c_driver {
 * With the driver model, device enumeration is NEVER done by drivers;
 * it's done by infrastructure.  (NEW STYLE DRIVERS ONLY)
 */
-   int (*probe)(struct i2c_client *);
+   int (*probe)(struct i2c_client *, const struct i2c_device_id *id);
int (*remove)(struct i2c_client *);
 
/* driver model interfaces that don't relate to enumeration  */
@@ -141,11 +141,10 @@ struct i2c_driver {
 
struct device_driver driver;
struct list_head list;
+   struct i2c_device_id *id_table;
 };
 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
 
-#define I2C_NAME_SIZE  20
-
 /**
  * struct i2c_client - represent an I2C slave device
  * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
@@ -179,7 +178,7 @@ struct i2c_client {
/* to the client*/
struct device dev;  /* the device structure */
int irq;/* irq issued by device (or -1) */
-   char driver_name[KOBJ_NAME_LEN];
+   char driver_name[I2C_NAME_SIZE];
struct list_head list;
struct completion released;
 };
@@ -223,7 +222,7 @@ static inline void i2c_set_clientdata (struct i2c_client 
*dev, void *data)
  * with the adapter already known.
  */
 struct i2c_board_info {
-   chardriver_name[KOBJ_NAME_LEN];
+   char

[PATCH 4/7] Clean up error returns

2007-12-17 Thread Jon Smirl
Return errors that were being ignored in the mpc-i2c driver

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/i2c/busses/i2c-mpc.c |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index d8de4ac..7c35a8f 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -180,7 +180,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
 static int mpc_write(struct mpc_i2c *i2c, int target,
 const u8 * data, int length, int restart)
 {
-   int i;
+   int i, result;
unsigned timeout = i2c-adap.timeout;
u32 flags = restart ? CCR_RSTA : 0;
 
@@ -192,15 +192,17 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
/* Write target byte */
writeb((target  1), i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
 
for (i = 0; i  length; i++) {
/* Write data byte */
writeb(data[i], i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
}
 
return 0;
@@ -210,7 +212,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
u8 * data, int length, int restart)
 {
unsigned timeout = i2c-adap.timeout;
-   int i;
+   int i, result;
u32 flags = restart ? CCR_RSTA : 0;
 
/* Start with MEN */
@@ -221,8 +223,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
/* Write target address byte - this time with the read flag set */
writeb((target  1) | 1, i2c-base + MPC_I2C_DR);
 
-   if (i2c_wait(i2c, timeout, 1)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 1);
+   if (result  0)
+   return result;
 
if (length) {
if (length == 1)
@@ -234,8 +237,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
}
 
for (i = 0; i  length; i++) {
-   if (i2c_wait(i2c, timeout, 0)  0)
-   return -1;
+   result = i2c_wait(i2c, timeout, 0);
+   if (result  0)
+   return result;
 
/* Generate txack on next to last byte */
if (i == length - 2)
@@ -321,9 +325,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 
pdata = (struct fsl_i2c_platform_data *) pdev-dev.platform_data;
 
-   if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
+   i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+   if (!i2c)
return -ENOMEM;
-   }
 
i2c-irq = platform_get_irq(pdev, 0);
if (i2c-irq  0) {
@@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(i2c-adap);
platform_set_drvdata(pdev, NULL);
 
-   if (i2c-irq != 0)
+   if (i2c-irq != NO_IRQ)
free_irq(i2c-irq, i2c);
 
iounmap(i2c-base);

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] update module-init-tools to support the i2c subsystem

2007-12-17 Thread Jon Smirl
Follow on to: Series to add device tree naming to i2c
Teach module-init-tools about the i2c subsystem.

diff --git a/depmod.c b/depmod.c
index 0281c79..209eb0c 100644
--- a/depmod.c
+++ b/depmod.c
@@ -793,6 +793,7 @@ static struct depfile depfiles[] = {
{ modules.inputmap, output_input_table },
{ modules.ofmap, output_of_table },
{ modules.seriomap, output_serio_table },
+   { modules.i2cmap, output_i2c_table },
{ modules.alias, output_aliases },
{ modules.symbols, output_symbols },
 };
diff --git a/depmod.h b/depmod.h
index 6cea36e..1040214 100644
--- a/depmod.h
+++ b/depmod.h
@@ -55,6 +55,8 @@ struct module
unsigned int input_table_size;
unsigned int serio_size;
void *serio_table;
+   unsigned int i2c_size;
+   void *i2c_table;
unsigned int of_size;
void *of_table;

diff --git a/moduleops_core.c b/moduleops_core.c
index 56c85d3..a7ca350 100644
--- a/moduleops_core.c
+++ b/moduleops_core.c
@@ -230,6 +230,11 @@ static void PERBIT(fetch_tables)(struct module *module)
__mod_serio_device_table,
NULL, module-conv);

+   module-i2c_size = PERBIT(I2C_DEVICE_SIZE);
+   module-i2c_table = PERBIT(deref_sym)(module-data,
+   __mod_i2c_device_table,
+   NULL, module-conv);
+
module-of_size = PERBIT(OF_DEVICE_SIZE);
module-of_table = PERBIT(deref_sym)(module-data,
__mod_of_device_table,
diff --git a/tables.c b/tables.c
index 6dfd165..82e162d 100644
--- a/tables.c
+++ b/tables.c
@@ -496,6 +496,35 @@ void output_serio_table(struct module *modules, FILE *out)
 }


+static void output_i2c_entry(struct i2c_device_id *i2c, char *name, FILE *out)
+{
+   fprintf(out,
+   %-20s %-20s\n,
+   name,
+   i2c-name);
+}
+
+
+void output_i2c_table(struct module *modules, FILE *out)
+{
+   struct module *i;
+
+   fprintf(out, # i2c module name\n);
+
+   for (i = modules; i; i = i-next) {
+   struct i2c_device_id *e;
+   char shortname[strlen(i-pathname) + 1];
+
+   if (!i-i2c_table)
+   continue;
+
+   make_shortname(shortname, i-pathname);
+   for (e = i-i2c_table; e-name[0]; e = (void *)e + i-i2c_size)
+   output_i2c_entry(e, shortname, out);
+   }
+}
+
+
 static void
 strip_whitespace (char *str, char chr)
 {
diff --git a/tables.h b/tables.h
index e5f6f35..263369d 100644
--- a/tables.h
+++ b/tables.h
@@ -164,6 +164,12 @@ struct serio_device_id {
 #define SERIO_DEVICE_SIZE32 (4 * 1)
 #define SERIO_DEVICE_SIZE64 (4 * 1 + 4)

+struct i2c_device_id {
+   char name[48];
+};
+#define I2C_DEVICE_SIZE32 (48 + 4)
+#define I2C_DEVICE_SIZE64 (48 + 8)
+
 struct of_device_id {
char name[32];
char type[32];
@@ -182,6 +188,7 @@ void output_ccw_table(struct module *modules, FILE *out);
 void output_isapnp_table(struct module *modules, FILE *out);
 void output_input_table(struct module *modules, FILE *out);
 void output_serio_table(struct module *modules, FILE *out);
+void output_i2c_table(struct module *modules, FILE *out);
 void output_of_table(struct module *modules, FILE *out);

 #endif /* MODINITTOOLS_TABLES_H */

-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/7] Makefile

2007-12-17 Thread Jon Smirl
Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 Makefile |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)


diff --git a/Makefile b/Makefile
index c1825aa..15ada3f 100644
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,9 @@ MAKEFLAGS += -rR --no-print-directory
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
 
+ARCH=powerpc
+CROSS_COMPILE=powerpc-603e-linux-gnu-
+
 ifdef V
   ifeq ($(origin V), command line)
 KBUILD_VERBOSE = $(V)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/7] Makefile

2007-12-17 Thread Jon Smirl
Ignore this patch, I forgot to remove it before mailing the series.

On 12/17/07, Jon Smirl [EMAIL PROTECTED] wrote:
 Signed-off-by: Jon Smirl [EMAIL PROTECTED]

 Signed-off-by: Jon Smirl [EMAIL PROTECTED]
 ---

  Makefile |3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)


 diff --git a/Makefile b/Makefile
 index c1825aa..15ada3f 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -35,6 +35,9 @@ MAKEFLAGS += -rR --no-print-directory
  # To put more focus on warnings, be less verbose as default
  # Use 'make V=1' to see the full commands

 +ARCH=powerpc
 +CROSS_COMPILE=powerpc-603e-linux-gnu-
 +
  ifdef V
ifeq ($(origin V), command line)
  KBUILD_VERBOSE = $(V)

 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to [EMAIL PROTECTED]
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/



-- 
Jon Smirl
[EMAIL PROTECTED]
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/7] Modify several rtc drivers to use the alias names list property of i2c

2007-12-17 Thread Jon Smirl
This patch modifies the ds1307, ds1374, and rs5c372 i2c drivers to support
device tree names using the new i2c mod alias support

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 arch/powerpc/sysdev/fsl_soc.c |   44 
 drivers/rtc/rtc-ds1307.c  |   20 +-
 drivers/rtc/rtc-ds1374.c  |9 ++
 drivers/rtc/rtc-m41t80.c  |   57 -
 drivers/rtc/rtc-rs5c372.c |   16 ++--
 5 files changed, 85 insertions(+), 61 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 3ace747..268638a 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -320,48 +320,12 @@ arch_initcall(gfar_of_init);
 
 #ifdef CONFIG_I2C_BOARDINFO
 #include linux/i2c.h
-struct i2c_driver_device {
-   char*of_device;
-   char*i2c_driver;
-   char*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-   {ricoh,rs5c372a, rtc-rs5c372, rs5c372a,},
-   {ricoh,rs5c372b, rtc-rs5c372, rs5c372b,},
-   {ricoh,rv5c386,  rtc-rs5c372, rv5c386,},
-   {ricoh,rv5c387a, rtc-rs5c372, rv5c387a,},
-   {dallas,ds1307,  rtc-ds1307,  ds1307,},
-   {dallas,ds1337,  rtc-ds1307,  ds1337,},
-   {dallas,ds1338,  rtc-ds1307,  ds1338,},
-   {dallas,ds1339,  rtc-ds1307,  ds1339,},
-   {dallas,ds1340,  rtc-ds1307,  ds1340,},
-   {stm,m41t00, rtc-ds1307,  m41t00},
-   {dallas,ds1374,  rtc-ds1374,  rtc-ds1374,},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-struct i2c_board_info *info)
-{
-   int i;
-
-   for (i = 0; i  ARRAY_SIZE(i2c_devices); i++) {
-   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-   continue;
-   if (strlcpy(info-driver_name, i2c_devices[i].i2c_driver,
-   KOBJ_NAME_LEN) = KOBJ_NAME_LEN ||
-   strlcpy(info-type, i2c_devices[i].i2c_type,
-   I2C_NAME_SIZE) = I2C_NAME_SIZE)
-   return -ENOMEM;
-   return 0;
-   }
-   return -ENODEV;
-}
 
 static void __init of_register_i2c_devices(struct device_node *adap_node,
   int bus_num)
 {
struct device_node *node = NULL;
+   const char *compatible;
 
while ((node = of_get_next_child(adap_node, node))) {
struct i2c_board_info info = {};
@@ -378,8 +342,12 @@ static void __init of_register_i2c_devices(struct 
device_node *adap_node,
if (info.irq == NO_IRQ)
info.irq = -1;
 
-   if (of_find_i2c_driver(node, info)  0)
+   compatible = of_get_property(node, compatible, len);
+   if (!compatible) {
+   printk(KERN_WARNING i2c-mpc.c: invalid entry, missing 
compatible attribute\n);
continue;
+   }
+   strncpy(info.driver_name, compatible, sizeof(info.driver_name));
 
info.addr = *addr;
 
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index bc1c7fe..d4874ff 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -139,6 +139,17 @@ static inline const struct chip_desc *find_chip(const char 
*s)
return NULL;
 }
 
+static struct i2c_device_id ds1307_id[] = {
+   OF_I2C_ID(dallas,ds1307, ds_1307)
+   OF_I2C_ID(dallas,ds1337, ds_1337)
+   OF_I2C_ID(dallas,ds1338, ds_1338)
+   OF_I2C_ID(dallas,ds1339, ds_1339)
+   OF_I2C_ID(dallas,ds1340, ds_1340)
+   OF_I2C_ID(stm,m41t00, m41t00)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, ds1307_id);
+
 static int ds1307_get_time(struct device *dev, struct rtc_time *t)
 {
struct ds1307   *ds1307 = dev_get_drvdata(dev);
@@ -326,7 +337,7 @@ static struct bin_attribute nvram = {
 
 static struct i2c_driver ds1307_driver;
 
-static int __devinit ds1307_probe(struct i2c_client *client)
+static int __devinit ds1307_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 {
struct ds1307   *ds1307;
int err = -ENODEV;
@@ -334,7 +345,11 @@ static int __devinit ds1307_probe(struct i2c_client 
*client)
const struct chip_desc  *chip;
struct i2c_adapter  *adapter = to_i2c_adapter(client-dev.parent);
 
-   chip = find_chip(client-name);
+   if (id)
+   chip = chips[id-driver_data];
+   else
+   chip = find_chip(client-name);
+
if (!chip) {
dev_err(client-dev, unknown chip type '%s'\n,
client-name);
@@ -537,6 +552,7 @@ static struct i2c_driver ds1307_driver = {
},
.probe  = ds1307_probe,
.remove = __devexit_p(ds1307_remove

[PATCH 6/7] Convert pfc8563 i2c driver from old style to new style

2007-12-17 Thread Jon Smirl
Convert pfc8563 i2c driver from old style to new style. The
driver is also modified to support device tree names via the
i2c mod alias mechanism.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

 drivers/rtc/rtc-pcf8563.c |  107 +++--
 1 files changed, 27 insertions(+), 80 deletions(-)


diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 0242d80..e1ea2a0 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -25,10 +25,6 @@
  * located at 0x51 will pass the validation routine due to
  * the way the registers are implemented.
  */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Module parameters */
-I2C_CLIENT_INSMOD;
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -72,9 +68,6 @@ struct pcf8563 {
int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
-static int pcf8563_detach(struct i2c_client *client);
-
 /*
  * In the routines that deal directly with the pcf8563 hardware, we use
  * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
@@ -257,98 +250,52 @@ static const struct rtc_class_ops pcf8563_rtc_ops = {
.set_time   = pcf8563_rtc_set_time,
 };
 
-static int pcf8563_attach(struct i2c_adapter *adapter)
+static int pcf8563_remove(struct i2c_client *client)
 {
-   return i2c_probe(adapter, addr_data, pcf8563_probe);
+   struct rtc_device *rtc = i2c_get_clientdata(client);
+
+   if (rtc)
+   rtc_device_unregister(rtc);
+
+   return 0;
 }
 
+static struct i2c_device_id pcf8563_id[] = {
+   OF_I2C_ID(philips,pcf8563, 0)
+   OF_I2C_ID(epson,rtc8564, 0)
+   {},
+};
+MODULE_DEVICE_TABLE(i2c, pcf8563_id);
+
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id);
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
-   .name   = pcf8563,
+   .name   = rtc-pcf8563,
},
.id = I2C_DRIVERID_PCF8563,
-   .attach_adapter = pcf8563_attach,
-   .detach_client  = pcf8563_detach,
+   .probe = pcf8563_probe,
+   .remove = pcf8563_remove,
+   .id_table   = pcf8563_id,
 };
 
-static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
+static int pcf8563_probe(struct i2c_client *client, const struct i2c_device_id 
*id)
 {
-   struct pcf8563 *pcf8563;
-   struct i2c_client *client;
+   int result;
struct rtc_device *rtc;
 
-   int err = 0;
-
-   dev_dbg(adapter-dev, %s\n, __FUNCTION__);
-
-   if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
-   err = -ENODEV;
-   goto exit;
-   }
-
-   if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
-   err = -ENOMEM;
-   goto exit;
-   }
-
-   client = pcf8563-client;
-   client-addr = address;
-   client-driver = pcf8563_driver;
-   client-adapter = adapter;
-
-   strlcpy(client-name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
-
-   /* Verify the chip is really an PCF8563 */
-   if (kind  0) {
-   if (pcf8563_validate_client(client)  0) {
-   err = -ENODEV;
-   goto exit_kfree;
-   }
-   }
-
-   /* Inform the i2c layer */
-   if ((err = i2c_attach_client(client)))
-   goto exit_kfree;
-
-   dev_info(client-dev, chip found, driver version  DRV_VERSION \n);
+   result = pcf8563_validate_client(client);
+   if (result)
+   return result;
 
rtc = rtc_device_register(pcf8563_driver.driver.name, client-dev,
pcf8563_rtc_ops, THIS_MODULE);
-
-   if (IS_ERR(rtc)) {
-   err = PTR_ERR(rtc);
-   goto exit_detach;
-   }
+   if (IS_ERR(rtc))
+   return PTR_ERR(rtc);
 
i2c_set_clientdata(client, rtc);
 
return 0;
-
-exit_detach:
-   i2c_detach_client(client);
-
-exit_kfree:
-   kfree(pcf8563);
-
-exit:
-   return err;
-}
-
-static int pcf8563_detach(struct i2c_client *client)
-{
-   struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
-   int err;
-   struct rtc_device *rtc = i2c_get_clientdata(client);
-
-   if (rtc)
-   rtc_device_unregister(rtc);
-
-   if ((err = i2c_detach_client(client)))
-   return err;
-
-   kfree(pcf8563);
-
-   return 0;
 }
 
 static int __init pcf8563_init(void)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [2.6 patch] some overdue I2C driver removal

2007-11-28 Thread Jon Smirl
On 11/28/07, Lennart Sorensen <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 28, 2007 at 11:23:57AM +0100, Jean Delvare wrote:
> > There's no driver to write (i2c-gpio is the driver). Instead, the
> > scx200 platform needs to implement the standard GPIO API. I don't think
> > that it has happened yet, and last time this was discussed, someone
> > (can't remember who, sorry), complained that the GPIO API "sucked" and
> > that the scx200 platform would not be updated to use it. I didn't buy
> > the claim due to a lack of argumentation and the fact that the GPIO
> > infrastructure seems to work well enough for many other platforms.
> >
> > As far as I can see, the ixp2000 platform also doesn't implement the
> > standard GPIO API yet, so of the 3 drivers that are about to be
> > removed, only i2c-ixp4xx can be removed without functionality loss at
> > the moment. Lennert, Russell, are there any plans to convert the
> > ixp2000 platform to use the generic GPIO layer?
> >
> > Maybe I shouldn't have added this entry in feature-removal-schedule.txt
> > in the first place: these drivers should ideally be dropped in favor of
> > i2c-gpio, but it can only happen for platforms that implement the
> > standard GPIO API. As I am not the one who will convert these
> > platforms, and some of them might as well never be converted (I don't
> > know how active they are nowadays), there's not much I can do.
>
> Well if I get a chance I might try to do it for the scx200 at some point
> (since I do use it) although given the current i2c driver works just
> fine and I have no need for the rest of the gpio lines what so ever
> there isn't that much insentive to do so yet.
>
> Removing the existing i2c driver would seem like a mistake at this time
> though.

Hasn't their been a one year notice that these drivers were going to
be removed? How about removing them and putting them into a tarball on
the i2c web site with a note explaining about how they need to be
updated to use the gpio driver? Then if someone really wants to use
the old drivers they can use them out of tree.

-- 
Jon Smirl
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [2.6 patch] some overdue I2C driver removal

2007-11-28 Thread Jon Smirl
On 11/28/07, Lennart Sorensen [EMAIL PROTECTED] wrote:
 On Wed, Nov 28, 2007 at 11:23:57AM +0100, Jean Delvare wrote:
  There's no driver to write (i2c-gpio is the driver). Instead, the
  scx200 platform needs to implement the standard GPIO API. I don't think
  that it has happened yet, and last time this was discussed, someone
  (can't remember who, sorry), complained that the GPIO API sucked and
  that the scx200 platform would not be updated to use it. I didn't buy
  the claim due to a lack of argumentation and the fact that the GPIO
  infrastructure seems to work well enough for many other platforms.
 
  As far as I can see, the ixp2000 platform also doesn't implement the
  standard GPIO API yet, so of the 3 drivers that are about to be
  removed, only i2c-ixp4xx can be removed without functionality loss at
  the moment. Lennert, Russell, are there any plans to convert the
  ixp2000 platform to use the generic GPIO layer?
 
  Maybe I shouldn't have added this entry in feature-removal-schedule.txt
  in the first place: these drivers should ideally be dropped in favor of
  i2c-gpio, but it can only happen for platforms that implement the
  standard GPIO API. As I am not the one who will convert these
  platforms, and some of them might as well never be converted (I don't
  know how active they are nowadays), there's not much I can do.

 Well if I get a chance I might try to do it for the scx200 at some point
 (since I do use it) although given the current i2c driver works just
 fine and I have no need for the rest of the gpio lines what so ever
 there isn't that much insentive to do so yet.

 Removing the existing i2c driver would seem like a mistake at this time
 though.

Hasn't their been a one year notice that these drivers were going to
be removed? How about removing them and putting them into a tarball on
the i2c web site with a note explaining about how they need to be
updated to use the gpio driver? Then if someone really wants to use
the old drivers they can use them out of tree.

-- 
Jon Smirl
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] Fix i2c module parameter permissions for read/write

2007-11-04 Thread Jon Smirl
On 11/4/07, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Hi John,
>
> On Sun, 4 Nov 2007 00:55:15 -0400, Jon Smirl wrote:
> > The permissions of i2c module parameters were set to zero making the
> > parameters invisible and unsettable from the kernel command line. This
> > patch changes the permissions to the standard 0644 read/write.
>
> These permissions have nothing to do with the kernel command line. They
> define whether a file is created in sysfs for the respective module
> parameter. Even with permissions set to 0, you can still set the value
> in question from the kernel command line with .=.

I figured out later by inserting printks into the driver that they
were being set from the command line, but without changing the
permissions there was no way to read them to verify.  The permissions
should at least be set to 0444 to allow them to be read.

IMHO the I2C_CLIENT_INSMOD macros could use some rework since they use
side effects to set variables without being explicit about it.

The real problem was unrelated to this, it was an off by one error in
the i2c bus numbering code of my embedded processor. That made the
parameters not work since I was setting them on a different bus.

Changed to 0444.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 8033e6b..395e430 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -588,7 +588,7 @@ union i2c_smbus_data {
 #define I2C_CLIENT_MODULE_PARM(var,desc) \
  static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
  static unsigned int var##_num; \
-  module_param_array(var, short, ##_num, 0); \
+  module_param_array(var, short, ##_num, 0444); \
  MODULE_PARM_DESC(var,desc)

 #define I2C_CLIENT_MODULE_PARM_FORCE(name) \


-- 
Jon Smirl
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [i2c] [PATCH] Fix i2c module parameter permissions for read/write

2007-11-04 Thread Jon Smirl
On 11/4/07, Jean Delvare [EMAIL PROTECTED] wrote:
 Hi John,

 On Sun, 4 Nov 2007 00:55:15 -0400, Jon Smirl wrote:
  The permissions of i2c module parameters were set to zero making the
  parameters invisible and unsettable from the kernel command line. This
  patch changes the permissions to the standard 0644 read/write.

 These permissions have nothing to do with the kernel command line. They
 define whether a file is created in sysfs for the respective module
 parameter. Even with permissions set to 0, you can still set the value
 in question from the kernel command line with module.parm=value.

I figured out later by inserting printks into the driver that they
were being set from the command line, but without changing the
permissions there was no way to read them to verify.  The permissions
should at least be set to 0444 to allow them to be read.

IMHO the I2C_CLIENT_INSMOD macros could use some rework since they use
side effects to set variables without being explicit about it.

The real problem was unrelated to this, it was an off by one error in
the i2c bus numbering code of my embedded processor. That made the
parameters not work since I was setting them on a different bus.

Changed to 0444.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 8033e6b..395e430 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -588,7 +588,7 @@ union i2c_smbus_data {
 #define I2C_CLIENT_MODULE_PARM(var,desc) \
  static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
  static unsigned int var##_num; \
-  module_param_array(var, short, var##_num, 0); \
+  module_param_array(var, short, var##_num, 0444); \
  MODULE_PARM_DESC(var,desc)

 #define I2C_CLIENT_MODULE_PARM_FORCE(name) \


-- 
Jon Smirl
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Fix i2c module parameter permissions for read/write

2007-11-03 Thread Jon Smirl
The permissions of i2c module parameters were set to zero making the
parameters invisible and unsettable from the kernel command line. This
patch changes the permissions to the standard 0644 read/write.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 8033e6b..395e430 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -588,7 +588,7 @@ union i2c_smbus_data {
 #define I2C_CLIENT_MODULE_PARM(var,desc) \
   static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
   static unsigned int var##_num; \
-  module_param_array(var, short, ##_num, 0); \
+  module_param_array(var, short, ##_num, 0644); \
   MODULE_PARM_DESC(var,desc)

 #define I2C_CLIENT_MODULE_PARM_FORCE(name) \


-- 
Jon Smirl
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Fix i2c module parameter permissions for read/write

2007-11-03 Thread Jon Smirl
The permissions of i2c module parameters were set to zero making the
parameters invisible and unsettable from the kernel command line. This
patch changes the permissions to the standard 0644 read/write.

Signed-off-by: Jon Smirl [EMAIL PROTECTED]
---

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 8033e6b..395e430 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -588,7 +588,7 @@ union i2c_smbus_data {
 #define I2C_CLIENT_MODULE_PARM(var,desc) \
   static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
   static unsigned int var##_num; \
-  module_param_array(var, short, var##_num, 0); \
+  module_param_array(var, short, var##_num, 0644); \
   MODULE_PARM_DESC(var,desc)

 #define I2C_CLIENT_MODULE_PARM_FORCE(name) \


-- 
Jon Smirl
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/5] Net: ath5k, license is GPLv2

2007-08-29 Thread Jon Smirl
On 8/29/07, Alan Cox <[EMAIL PROTECTED]> wrote:
> > > to remove the BSD/other license.   Jiri can release *his* code as GPLv2
> > > only, but I suspect the files as a whole really should be dual BSD/GPLv2,
> > > due to the numerous other stakeholders in those files.
> >
> > This mess has been occurring in the kernel for years. The DRM graphics
> > drivers are used in both BSD and Linux. It is quite easy to contribute
> > something to this code via LKML and think you are doing it under the
> > GPL. Doesn't a patch against the kernel have to be GPL? When these
> > patches get pulled back into BSD and distributed with it, did BSD get
> > infected with the GPL? AFAIK this has never been legally sorted out.
>
> I'm not aware anyone has felt it needed "sorting out". Its not exactly
> complicated.
>
> BSD non advertising is compatible with GPL
>
> The GPL says:
> "when you distribute the same sections as part of a whole which
> is a work based on the Program, the distribution of the whole
> must be on the terms of this License, "
>
> The BSD license doesn't conflict with that
>
> The GPL (and copyright law also say)
>
> "If identifiable sections of that work are not derived from the Program,
> and can be reasonably considered independent and separate works in
> themselves, then this License, and its terms, do not apply to ..."
>
> All a bit irrelevant anyway as Ath5K code (not the .h file) say:
>
>  * Alternatively, this software may be distributed under the terms of the
>  * GNU General Public License ("GPL") version 2 as published by the Free
>  * Software Foundation.
>
> So Jiri is choosing to distribute it under the GPL, and with his changes
> GPL only.
>
> So whats the problem ?

BSD code can definitely be brought into a GPL project as you describe.
The problem is the other direction.

Aren't patches made against the kernel GPL'd if the author doesn't
explicitly grant them more liberal BSD license in addition?

The problem then comes in taking the patches that were only made
available against GPL code and reshipping them under the BSD license
without the author explicitly agreeing to this.

What if a patch spans both code that is pure GPL and code imported
from BSD, how do you license it?

-- 
Jon Smirl
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/5] Net: ath5k, license is GPLv2

2007-08-29 Thread Jon Smirl
On 8/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> The heck with "good idea" - it's unclear to me if Jiri is even *allowed*
> to remove the BSD/other license.   Jiri can release *his* code as GPLv2
> only, but I suspect the files as a whole really should be dual BSD/GPLv2,
> due to the numerous other stakeholders in those files.

This mess has been occurring in the kernel for years. The DRM graphics
drivers are used in both BSD and Linux. It is quite easy to contribute
something to this code via LKML and think you are doing it under the
GPL. Doesn't a patch against the kernel have to be GPL? When these
patches get pulled back into BSD and distributed with it, did BSD get
infected with the GPL? AFAIK this has never been legally sorted out.

-- 
Jon Smirl
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   >