* [PATCH] m25p80: add support for a callback to platform code on successful device probe
@ 2010-08-10 6:42 Sudhakar Rajashekhara
2010-08-10 7:17 ` Mike Frysinger
2010-08-10 13:41 ` Sergei Shtylyov
0 siblings, 2 replies; 9+ messages in thread
From: Sudhakar Rajashekhara @ 2010-08-10 6:42 UTC (permalink / raw)
To: linux-mtd
Cc: david-b, davinci-linux-open-source, Sudhakar Rajashekhara,
--cc=dwmw2
On some platforms, MTD device can hold MAC address, calibration
data, serial numbers etc.
On TI's DA850/OMAP-L138/AM18xx EVM, MAC address is stored on
the last sector of the SPI flash, which is exported as an MTD
device.
This patch adds two new members to the 'flash_platform_data'
structure, a function handler which will be called after
add_mtd_device() and an argument to be passed to this function,
for example: offset to read from.
Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
---
drivers/mtd/devices/m25p80.c | 15 +++++++++++++--
include/linux/spi/flash.h | 2 ++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 81e49a9..b832091 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -765,6 +765,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
struct m25p *flash;
struct flash_info *info;
unsigned i;
+ int ret;
/* Platform data helps sort out which chip type we have, as
* well as how this board partitions it. If we don't have
@@ -924,13 +925,23 @@ static int __devinit m25p_probe(struct spi_device *spi)
(long long)(parts[i].size >> 10));
}
flash->partitioned = 1;
- return add_mtd_partitions(&flash->mtd, parts, nr_parts);
+ ret = add_mtd_partitions(&flash->mtd, parts, nr_parts);
+ if (!ret)
+ goto out;
+
+ return ret;
}
} else if (data && data->nr_parts)
dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
data->nr_parts, data->name);
- return add_mtd_device(&flash->mtd) == 1 ? -ENODEV : 0;
+ ret = add_mtd_device(&flash->mtd);
+
+out:
+ if (data->setup && !ret)
+ (data->setup)(&flash->mtd, (void *)data->context);
+
+ return (ret == 1) ? -ENODEV : 0;
}
diff --git a/include/linux/spi/flash.h b/include/linux/spi/flash.h
index 3f22932..daa4875 100644
--- a/include/linux/spi/flash.h
+++ b/include/linux/spi/flash.h
@@ -24,6 +24,8 @@ struct flash_platform_data {
unsigned int nr_parts;
char *type;
+ void (*setup)(struct mtd_info *, void *context);
+ void *context;
/* we'll likely add more ... use JEDEC IDs, etc */
};
--
1.5.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] m25p80: add support for a callback to platform code on successful device probe
2010-08-10 6:42 [PATCH] m25p80: add support for a callback to platform code on successful device probe Sudhakar Rajashekhara
@ 2010-08-10 7:17 ` Mike Frysinger
2010-08-10 9:26 ` Sudhakar Rajashekhara
2010-08-10 13:41 ` Sergei Shtylyov
1 sibling, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2010-08-10 7:17 UTC (permalink / raw)
To: Sudhakar Rajashekhara
Cc: david-b, dwmw2, davinci-linux-open-source, linux-mtd
On Tue, Aug 10, 2010 at 02:42, Sudhakar Rajashekhara wrote:
> On some platforms, MTD device can hold MAC address, calibration
> data, serial numbers etc.
pretty standard behavior ...
> On TI's DA850/OMAP-L138/AM18xx EVM, MAC address is stored on
> the last sector of the SPI flash, which is exported as an MTD
> device.
again, nothing unique here ...
> This patch adds two new members to the 'flash_platform_data'
> structure, a function handler which will be called after
> add_mtd_device() and an argument to be passed to this function,
> for example: offset to read from.
... and your changelog falls apart. the intro gives no basis that i
can see as to why you need these hooks.
please give examples of what you're actually trying to accomplish and
how these hooks help you accomplish said goal and why it is necessary
that you do these things from kernel space instead of standard
userspace.
-mike
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] m25p80: add support for a callback to platform code on successful device probe
2010-08-10 7:17 ` Mike Frysinger
@ 2010-08-10 9:26 ` Sudhakar Rajashekhara
2010-08-10 13:07 ` David Brownell
0 siblings, 1 reply; 9+ messages in thread
From: Sudhakar Rajashekhara @ 2010-08-10 9:26 UTC (permalink / raw)
To: 'Mike Frysinger'
Cc: david-b, linux-mtd, davinci-linux-open-source, dwmw2
Hi,
On Tue, Aug 10, 2010 at 12:47:05, Mike Frysinger wrote:
> On Tue, Aug 10, 2010 at 02:42, Sudhakar Rajashekhara wrote:
> > On some platforms, MTD device can hold MAC address, calibration
> > data, serial numbers etc.
>
> pretty standard behavior ...
>
> > On TI's DA850/OMAP-L138/AM18xx EVM, MAC address is stored on
> > the last sector of the SPI flash, which is exported as an MTD
> > device.
>
> again, nothing unique here ...
>
> > This patch adds two new members to the 'flash_platform_data'
> > structure, a function handler which will be called after
> > add_mtd_device() and an argument to be passed to this function,
> > for example: offset to read from.
>
> ... and your changelog falls apart. the intro gives no basis that i
> can see as to why you need these hooks.
>
> please give examples of what you're actually trying to accomplish and
> how these hooks help you accomplish said goal and why it is necessary
> that you do these things from kernel space instead of standard
> userspace.
I have submitted an updated version of this patch in which I have
addressed your concerns.
Regards,
Sudhakar
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] m25p80: add support for a callback to platform code on successful device probe
2010-08-10 13:07 ` David Brownell
@ 2010-08-10 13:07 ` Sudhakar Rajashekhara
2010-08-10 19:02 ` Mike Frysinger
1 sibling, 0 replies; 9+ messages in thread
From: Sudhakar Rajashekhara @ 2010-08-10 13:07 UTC (permalink / raw)
To: 'David Brownell', 'Mike Frysinger'
Cc: linux-mtd, davinci-linux-open-source, dwmw2
On Tue, Aug 10, 2010 at 18:37:47, David Brownell wrote:
>
> > On Tue, Aug 10, 2010 at 12:47:05, Mike Frysinger wrote:
>
> > it is necessary
> > > that you do these things from kernel space instead of
> > standard
> > > userspace.
>
> Hard to get userspace to do this stuff if
> you're doing a network boot, and thus need
> to have the MAC address working early.. it's
> easy if the kernel can get the MAC address,
> else not possible to boot. Right?
>
You are absolutely right.
- Sudhakar
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] m25p80: add support for a callback to platform code on successful device probe
2010-08-10 9:26 ` Sudhakar Rajashekhara
@ 2010-08-10 13:07 ` David Brownell
2010-08-10 13:07 ` Sudhakar Rajashekhara
2010-08-10 19:02 ` Mike Frysinger
0 siblings, 2 replies; 9+ messages in thread
From: David Brownell @ 2010-08-10 13:07 UTC (permalink / raw)
To: 'Mike Frysinger', Sudhakar Rajashekhara
Cc: linux-mtd, davinci-linux-open-source, dwmw2
> On Tue, Aug 10, 2010 at 12:47:05, Mike Frysinger wrote:
> it is necessary
> > that you do these things from kernel space instead of
> standard
> > userspace.
Hard to get userspace to do this stuff if
you're doing a network boot, and thus need
to have the MAC address working early.. it's
easy if the kernel can get the MAC address,
else not possible to boot. Right?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] m25p80: add support for a callback to platform code on successful device probe
2010-08-10 6:42 [PATCH] m25p80: add support for a callback to platform code on successful device probe Sudhakar Rajashekhara
2010-08-10 7:17 ` Mike Frysinger
@ 2010-08-10 13:41 ` Sergei Shtylyov
1 sibling, 0 replies; 9+ messages in thread
From: Sergei Shtylyov @ 2010-08-10 13:41 UTC (permalink / raw)
To: Sudhakar Rajashekhara; +Cc: --cc=dwmw2, davinci-linux-open-source, linux-mtd
Hello.
Sudhakar Rajashekhara wrote:
> On some platforms, MTD device can hold MAC address, calibration
> data, serial numbers etc.
> On TI's DA850/OMAP-L138/AM18xx EVM, MAC address is stored on
> the last sector of the SPI flash, which is exported as an MTD
> device.
> This patch adds two new members to the 'flash_platform_data'
> structure, a function handler which will be called after
> add_mtd_device() and an argument to be passed to this function,
> for example: offset to read from.
> Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
> ---
> drivers/mtd/devices/m25p80.c | 15 +++++++++++++--
> include/linux/spi/flash.h | 2 ++
> 2 files changed, 15 insertions(+), 2 deletions(-)
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index 81e49a9..b832091 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
[...]
> @@ -924,13 +925,23 @@ static int __devinit m25p_probe(struct spi_device *spi)
> (long long)(parts[i].size >> 10));
> }
> flash->partitioned = 1;
> - return add_mtd_partitions(&flash->mtd, parts, nr_parts);
> + ret = add_mtd_partitions(&flash->mtd, parts, nr_parts);
> + if (!ret)
> + goto out;
> +
> + return ret;
> }
> } else if (data && data->nr_parts)
> dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
> data->nr_parts, data->name);
>
> - return add_mtd_device(&flash->mtd) == 1 ? -ENODEV : 0;
> + ret = add_mtd_device(&flash->mtd);
> +
> +out:
> + if (data->setup && !ret)
> + (data->setup)(&flash->mtd, (void *)data->context);
Parens not necessary around 'data->setup'.
> diff --git a/include/linux/spi/flash.h b/include/linux/spi/flash.h
> index 3f22932..daa4875 100644
> --- a/include/linux/spi/flash.h
> +++ b/include/linux/spi/flash.h
> @@ -24,6 +24,8 @@ struct flash_platform_data {
> unsigned int nr_parts;
>
> char *type;
> + void (*setup)(struct mtd_info *, void *context);
> + void *context;
>
> /* we'll likely add more ... use JEDEC IDs, etc */
> };
Hm, is m25p80.c the only SPI flash driver using this structure? I guess
not -- I'm seeing at least sst25l.c and mtd_dataflash.c...
WBR, Sergei
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] m25p80: add support for a callback to platform code on successful device probe
2010-08-10 13:07 ` David Brownell
2010-08-10 13:07 ` Sudhakar Rajashekhara
@ 2010-08-10 19:02 ` Mike Frysinger
2010-08-11 11:56 ` Sudhakar Rajashekhara
[not found] ` <-1845909207770903949@unknownmsgid>
1 sibling, 2 replies; 9+ messages in thread
From: Mike Frysinger @ 2010-08-10 19:02 UTC (permalink / raw)
To: David Brownell
Cc: linux-mtd, davinci-linux-open-source, Sudhakar Rajashekhara,
dwmw2
On Tue, Aug 10, 2010 at 09:07, David Brownell wrote:
>> On Tue, Aug 10, 2010 at 12:47:05, Mike Frysinger wrote:
>> it is necessary
>> > that you do these things from kernel space instead of
>> standard
>> > userspace.
>
> Hard to get userspace to do this stuff if
> you're doing a network boot, and thus need
> to have the MAC address working early.. it's
> easy if the kernel can get the MAC address,
> else not possible to boot. Right?
no, that isnt true at all. you can easily have a small initramfs to
handle all of your random setup. if that's too much overhead, you can
add a late initcall to your boards file that is run after the MTD
devices are probed and let that read the required information. all of
this is more than documented:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux
i still see these callbacks as unnecessary overhead to solve problems
that can already be done multiple ways with existing code.
-mike
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] m25p80: add support for a callback to platform code on successful device probe
2010-08-10 19:02 ` Mike Frysinger
@ 2010-08-11 11:56 ` Sudhakar Rajashekhara
[not found] ` <-1845909207770903949@unknownmsgid>
1 sibling, 0 replies; 9+ messages in thread
From: Sudhakar Rajashekhara @ 2010-08-11 11:56 UTC (permalink / raw)
To: 'Mike Frysinger', 'David Brownell'
Cc: dwmw2, davinci-linux-open-source, linux-mtd
Hi Mike,
On Wed, Aug 11, 2010 at 00:32:00, Mike Frysinger wrote:
> On Tue, Aug 10, 2010 at 09:07, David Brownell wrote:
> >> On Tue, Aug 10, 2010 at 12:47:05, Mike Frysinger wrote:
> >> it is necessary
> >> > that you do these things from kernel space instead of
> >> standard
> >> > userspace.
> >
> > Hard to get userspace to do this stuff if
> > you're doing a network boot, and thus need
> > to have the MAC address working early.. it's
> > easy if the kernel can get the MAC address,
> > else not possible to boot. Right?
>
> no, that isnt true at all. you can easily have a small initramfs to
> handle all of your random setup. if that's too much overhead, you can
> add a late initcall to your boards file that is run after the MTD
> devices are probed and let that read the required information. all of
> this is more than documented:
> http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux
>
I looked around in the kernel and found mtd_notifier callbacks which get
called upon addition of MTD device. Inside this callback, I am checking
for the device in which I am interested and doing a mtd->read to get the
MAC address. So this patch can be dropped.
Thanks,
Sudhakar
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] m25p80: add support for a callback to platform code on successful device probe
[not found] ` <-1845909207770903949@unknownmsgid>
@ 2010-08-11 17:27 ` Mike Frysinger
0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2010-08-11 17:27 UTC (permalink / raw)
To: Sudhakar Rajashekhara
Cc: David Brownell, linux-mtd, davinci-linux-open-source, dwmw2
On Wed, Aug 11, 2010 at 07:56, Sudhakar Rajashekhara wrote:
> On Wed, Aug 11, 2010 at 00:32:00, Mike Frysinger wrote:
>> On Tue, Aug 10, 2010 at 09:07, David Brownell wrote:
>> >> On Tue, Aug 10, 2010 at 12:47:05, Mike Frysinger wrote:
>> >> it is necessary
>> >> > that you do these things from kernel space instead of
>> >> standard
>> >> > userspace.
>> >
>> > Hard to get userspace to do this stuff if
>> > you're doing a network boot, and thus need
>> > to have the MAC address working early.. it's
>> > easy if the kernel can get the MAC address,
>> > else not possible to boot. Right?
>>
>> no, that isnt true at all. you can easily have a small initramfs to
>> handle all of your random setup. if that's too much overhead, you can
>> add a late initcall to your boards file that is run after the MTD
>> devices are probed and let that read the required information. all of
>> this is more than documented:
>> http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux
>
> I looked around in the kernel and found mtd_notifier callbacks which get
> called upon addition of MTD device. Inside this callback, I am checking
> for the device in which I am interested and doing a mtd->read to get the
> MAC address. So this patch can be dropped.
thanks for the follow up explanation
-mike
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-08-11 17:44 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-10 6:42 [PATCH] m25p80: add support for a callback to platform code on successful device probe Sudhakar Rajashekhara
2010-08-10 7:17 ` Mike Frysinger
2010-08-10 9:26 ` Sudhakar Rajashekhara
2010-08-10 13:07 ` David Brownell
2010-08-10 13:07 ` Sudhakar Rajashekhara
2010-08-10 19:02 ` Mike Frysinger
2010-08-11 11:56 ` Sudhakar Rajashekhara
[not found] ` <-1845909207770903949@unknownmsgid>
2010-08-11 17:27 ` Mike Frysinger
2010-08-10 13:41 ` Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).