* [PATCH] drivers: mtd: devices: make m25p80 dt adapted.
@ 2013-08-02 6:49 Sourav Poddar
2013-08-02 6:52 ` Sourav Poddar
2013-08-03 2:22 ` Huang Shijie
0 siblings, 2 replies; 4+ messages in thread
From: Sourav Poddar @ 2013-08-02 6:49 UTC (permalink / raw)
To: dwmw2, artem.bityutskiy, linux-mtd, devicetree-discuss
Cc: Sourav Poddar, linux-omap, pekon, balbi
This patch helps gettimg m25p80 probed through dt.
To get the id of the exact flash type supported for dt case,
data->type is getting parsed from dt entry.
Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
---
drivers/mtd/devices/m25p80.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 33098bf..cbfb9b3 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -855,6 +855,13 @@ static const struct spi_device_id m25p_ids[] = {
};
MODULE_DEVICE_TABLE(spi, m25p_ids);
+#ifdef CONFIG_OF
+static const struct of_device_id m25p_dt_ids[] = {
+ { .compatible = "m25p80", },
+ { /* sentinel */ }
+};
+#endif
+
static const struct spi_device_id *jedec_probe(struct spi_device *spi)
{
int tmp;
@@ -909,6 +916,7 @@ static int m25p_probe(struct spi_device *spi)
unsigned i;
struct mtd_part_parser_data ppdata;
struct device_node __maybe_unused *np = spi->dev.of_node;
+ int len;
#ifdef CONFIG_MTD_OF_PARTS
if (!of_device_is_available(np))
@@ -920,7 +928,18 @@ static int m25p_probe(struct spi_device *spi)
* a chip ID, try the JEDEC id commands; they'll work for most
* newer chips, even if we don't recognize the particular chip.
*/
- data = spi->dev.platform_data;
+ if (!np) {
+ data = spi->dev.platform_data;
+ } else {
+ data = devm_kzalloc(&spi->dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ data->type = (char *) of_get_property(np, "type", &len);
+ if (!data->type || strlen(data->type) > len)
+ return -ENODEV;
+ }
+
if (data && data->type) {
const struct spi_device_id *plat_id;
@@ -1098,6 +1117,7 @@ static struct spi_driver m25p80_driver = {
.driver = {
.name = "m25p80",
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(m25p_dt_ids),
},
.id_table = m25p_ids,
.probe = m25p_probe,
--
1.7.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: mtd: devices: make m25p80 dt adapted.
2013-08-02 6:49 [PATCH] drivers: mtd: devices: make m25p80 dt adapted Sourav Poddar
@ 2013-08-02 6:52 ` Sourav Poddar
2013-08-03 2:22 ` Huang Shijie
1 sibling, 0 replies; 4+ messages in thread
From: Sourav Poddar @ 2013-08-02 6:52 UTC (permalink / raw)
To: Sourav Poddar
Cc: dwmw2, artem.bityutskiy, linux-mtd, devicetree, balbi, pekon,
linux-omap
+ correct device tree mailing list
On Friday 02 August 2013 12:19 PM, Sourav Poddar wrote:
> This patch helps gettimg m25p80 probed through dt.
> To get the id of the exact flash type supported for dt case,
> data->type is getting parsed from dt entry.
>
> Signed-off-by: Sourav Poddar<sourav.poddar@ti.com>
> ---
> drivers/mtd/devices/m25p80.c | 22 +++++++++++++++++++++-
> 1 files changed, 21 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index 33098bf..cbfb9b3 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -855,6 +855,13 @@ static const struct spi_device_id m25p_ids[] = {
> };
> MODULE_DEVICE_TABLE(spi, m25p_ids);
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id m25p_dt_ids[] = {
> + { .compatible = "m25p80", },
> + { /* sentinel */ }
> +};
> +#endif
> +
> static const struct spi_device_id *jedec_probe(struct spi_device *spi)
> {
> int tmp;
> @@ -909,6 +916,7 @@ static int m25p_probe(struct spi_device *spi)
> unsigned i;
> struct mtd_part_parser_data ppdata;
> struct device_node __maybe_unused *np = spi->dev.of_node;
> + int len;
>
> #ifdef CONFIG_MTD_OF_PARTS
> if (!of_device_is_available(np))
> @@ -920,7 +928,18 @@ static int m25p_probe(struct spi_device *spi)
> * a chip ID, try the JEDEC id commands; they'll work for most
> * newer chips, even if we don't recognize the particular chip.
> */
> - data = spi->dev.platform_data;
> + if (!np) {
> + data = spi->dev.platform_data;
> + } else {
> + data = devm_kzalloc(&spi->dev, sizeof(*data), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
> +
> + data->type = (char *) of_get_property(np, "type",&len);
> + if (!data->type || strlen(data->type)> len)
> + return -ENODEV;
> + }
> +
> if (data&& data->type) {
> const struct spi_device_id *plat_id;
>
> @@ -1098,6 +1117,7 @@ static struct spi_driver m25p80_driver = {
> .driver = {
> .name = "m25p80",
> .owner = THIS_MODULE,
> + .of_match_table = of_match_ptr(m25p_dt_ids),
> },
> .id_table = m25p_ids,
> .probe = m25p_probe,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: mtd: devices: make m25p80 dt adapted.
2013-08-03 2:22 ` Huang Shijie
@ 2013-08-02 15:11 ` Sourav Poddar
0 siblings, 0 replies; 4+ messages in thread
From: Sourav Poddar @ 2013-08-02 15:11 UTC (permalink / raw)
To: Huang Shijie
Cc: dwmw2, artem.bityutskiy, linux-mtd, devicetree-discuss,
linux-omap, pekon, balbi
Hi Huang,
On Saturday 03 August 2013 07:52 AM, Huang Shijie wrote:
> On Fri, Aug 02, 2013 at 12:19:30PM +0530, Sourav Poddar wrote:
>> This patch helps gettimg m25p80 probed through dt.
> without this patch, we also can get the right SPI NOR type from the
> dt entry.
>
> Could you explain why we should get the m25p80 probed though the DT?
> or give an example.
>
Actually Yes, I misunderstood the dt bindings to be used for this driver
completely. With the following, I was able to work properly without this
patch.
+ m25p80@0 {
+ compatible = "s25fl256s1";
spi-max-frequency = <48000000>;
s25fl,three-byte;
reg = <0x00>;
Sorry for the noise. Patch can be discarded.
> thanks
> Huang Shijie
>> To get the id of the exact flash type supported for dt case,
>> data->type is getting parsed from dt entry.
>>
>> Signed-off-by: Sourav Poddar<sourav.poddar@ti.com>
>> ---
>> drivers/mtd/devices/m25p80.c | 22 +++++++++++++++++++++-
>> 1 files changed, 21 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
>> index 33098bf..cbfb9b3 100644
>> --- a/drivers/mtd/devices/m25p80.c
>> +++ b/drivers/mtd/devices/m25p80.c
>> @@ -855,6 +855,13 @@ static const struct spi_device_id m25p_ids[] = {
>> };
>> MODULE_DEVICE_TABLE(spi, m25p_ids);
>>
>> +#ifdef CONFIG_OF
>> +static const struct of_device_id m25p_dt_ids[] = {
>> + { .compatible = "m25p80", },
>> + { /* sentinel */ }
>> +};
>> +#endif
>> +
>> static const struct spi_device_id *jedec_probe(struct spi_device *spi)
>> {
>> int tmp;
>> @@ -909,6 +916,7 @@ static int m25p_probe(struct spi_device *spi)
>> unsigned i;
>> struct mtd_part_parser_data ppdata;
>> struct device_node __maybe_unused *np = spi->dev.of_node;
>> + int len;
>>
>> #ifdef CONFIG_MTD_OF_PARTS
>> if (!of_device_is_available(np))
>> @@ -920,7 +928,18 @@ static int m25p_probe(struct spi_device *spi)
>> * a chip ID, try the JEDEC id commands; they'll work for most
>> * newer chips, even if we don't recognize the particular chip.
>> */
>> - data = spi->dev.platform_data;
>> + if (!np) {
>> + data = spi->dev.platform_data;
>> + } else {
>> + data = devm_kzalloc(&spi->dev, sizeof(*data), GFP_KERNEL);
>> + if (!data)
>> + return -ENOMEM;
>> +
>> + data->type = (char *) of_get_property(np, "type",&len);
>> + if (!data->type || strlen(data->type)> len)
>> + return -ENODEV;
>> + }
>> +
>> if (data&& data->type) {
>> const struct spi_device_id *plat_id;
>>
>> @@ -1098,6 +1117,7 @@ static struct spi_driver m25p80_driver = {
>> .driver = {
>> .name = "m25p80",
>> .owner = THIS_MODULE,
>> + .of_match_table = of_match_ptr(m25p_dt_ids),
>> },
>> .id_table = m25p_ids,
>> .probe = m25p_probe,
>> --
>> 1.7.1
>>
>>
>> ______________________________________________________
>> Linux MTD discussion mailing list
>> http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: mtd: devices: make m25p80 dt adapted.
2013-08-02 6:49 [PATCH] drivers: mtd: devices: make m25p80 dt adapted Sourav Poddar
2013-08-02 6:52 ` Sourav Poddar
@ 2013-08-03 2:22 ` Huang Shijie
2013-08-02 15:11 ` Sourav Poddar
1 sibling, 1 reply; 4+ messages in thread
From: Huang Shijie @ 2013-08-03 2:22 UTC (permalink / raw)
To: Sourav Poddar
Cc: dwmw2, artem.bityutskiy, linux-mtd, devicetree-discuss,
linux-omap, pekon, balbi
On Fri, Aug 02, 2013 at 12:19:30PM +0530, Sourav Poddar wrote:
> This patch helps gettimg m25p80 probed through dt.
without this patch, we also can get the right SPI NOR type from the
dt entry.
Could you explain why we should get the m25p80 probed though the DT?
or give an example.
thanks
Huang Shijie
> To get the id of the exact flash type supported for dt case,
> data->type is getting parsed from dt entry.
>
> Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
> ---
> drivers/mtd/devices/m25p80.c | 22 +++++++++++++++++++++-
> 1 files changed, 21 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index 33098bf..cbfb9b3 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -855,6 +855,13 @@ static const struct spi_device_id m25p_ids[] = {
> };
> MODULE_DEVICE_TABLE(spi, m25p_ids);
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id m25p_dt_ids[] = {
> + { .compatible = "m25p80", },
> + { /* sentinel */ }
> +};
> +#endif
> +
> static const struct spi_device_id *jedec_probe(struct spi_device *spi)
> {
> int tmp;
> @@ -909,6 +916,7 @@ static int m25p_probe(struct spi_device *spi)
> unsigned i;
> struct mtd_part_parser_data ppdata;
> struct device_node __maybe_unused *np = spi->dev.of_node;
> + int len;
>
> #ifdef CONFIG_MTD_OF_PARTS
> if (!of_device_is_available(np))
> @@ -920,7 +928,18 @@ static int m25p_probe(struct spi_device *spi)
> * a chip ID, try the JEDEC id commands; they'll work for most
> * newer chips, even if we don't recognize the particular chip.
> */
> - data = spi->dev.platform_data;
> + if (!np) {
> + data = spi->dev.platform_data;
> + } else {
> + data = devm_kzalloc(&spi->dev, sizeof(*data), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
> +
> + data->type = (char *) of_get_property(np, "type", &len);
> + if (!data->type || strlen(data->type) > len)
> + return -ENODEV;
> + }
> +
> if (data && data->type) {
> const struct spi_device_id *plat_id;
>
> @@ -1098,6 +1117,7 @@ static struct spi_driver m25p80_driver = {
> .driver = {
> .name = "m25p80",
> .owner = THIS_MODULE,
> + .of_match_table = of_match_ptr(m25p_dt_ids),
> },
> .id_table = m25p_ids,
> .probe = m25p_probe,
> --
> 1.7.1
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-03 2:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-02 6:49 [PATCH] drivers: mtd: devices: make m25p80 dt adapted Sourav Poddar
2013-08-02 6:52 ` Sourav Poddar
2013-08-03 2:22 ` Huang Shijie
2013-08-02 15:11 ` Sourav Poddar
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).