public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mason <slash.tmp@free.fr>
To: Mans Rullgard <mans@mansr.com>
Cc: Javier Martinez Canillas <javier@dowhile0.org>,
	Andrew Lunn <andrew@lunn.ch>, LKML <linux-kernel@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Jason Cooper <jason@lakedaemon.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: Grafting old platform drivers onto a new DT kernel
Date: Mon, 9 Nov 2015 18:03:47 +0100	[thread overview]
Message-ID: <5640D1F3.1010100@free.fr> (raw)
In-Reply-To: <yw1xpozj5ezj.fsf@unicorn.mansr.com>

On 09/11/2015 17:12, Måns Rullgård wrote:

> Mason writes:
> 
>> On 09/11/2015 16:40, Måns Rullgård wrote:
>>
>>> The simplest solution for you is probably to add a quick and dirty DT
>>> binding to the old driver.  If it doesn't use any driver-specific
>>> platform data struct, you only need to set .of_match_table in the
>>> struct platform_driver.  If there is a platform data struct, you'll also
>>> need to write some code to populate it from DT properties.  It shouldn't
>>> take more than a few minutes per driver in most cases.
>>
>> I'll try that approach, although I fear that "a few minutes per driver"
>> is an optimistic assessment.
> 
> If the driver only needs an MMIO region and an IRQ, it is literally five
> lines of code.

It took me 7 days to figure out there were 2 lines missing in the
interrupt controller driver.

My problem is that I don't understand the platform API, nor the
interaction with the DT API.

Let me see...

In arch/arm/mach-tangox/platform_dev.c

static struct platform_device tangox_sdhci0_device = { ... };
static struct platform_device tangox_sdhci1_device = { ... };

static void tangox_init_sdhci(void)
{
	if (tangox_sdio_enabled(0))
		platform_device_register(&tangox_sdhci0_device);

	if (tangox_sdio_enabled(1))
		platform_device_register(&tangox_sdhci1_device);
}

called from tangox_init_devices() which is marked arch_initcall.



In the driver

static struct platform_driver tangox_platform_sdio0 = {
	.remove		= sdhci_tangox_remove,
	.suspend	= sdhci_tangox_suspend,
	.resume		= sdhci_tangox_resume,
	.driver		= {
		.name	= "tangox-sdhci",
		.owner	= THIS_MODULE,
	},
};


static struct platform_driver tangox_platform_sdio0 = {
	.remove		= sdhci_tangox_remove,
	.driver		= {
		.name	= "tangox-sdhci",
		.owner	= THIS_MODULE,
	},
};

static int __init tangox_sdhci_drv_init(void) {
	return platform_driver_probe(&tangox_platform_sdio0, sdhci_tangox_probe);
}

static void __exit tangox_sdhci_drv_exit(void) {
	platform_driver_unregister(&tangox_platform_sdio0);
}

module_init(tangox_sdhci_drv_init);
module_exit(tangox_sdhci_drv_exit);


The old way:

1) call platform_device_register() with a "struct platform_device"
2) call platform_driver_probe with a "struct platform_driver"

The new way(?)

The mess in 2) is hidden behind module_platform_driver?
The platform_device_register() is done by the DT core?
The struct platform_driver requires a probe function?

Regards.


  reply	other threads:[~2015-11-09 17:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05 11:02 Grafting old platform drivers onto a new DT kernel Mason
2015-11-05 15:15 ` Andrew Lunn
2015-11-05 15:42   ` Javier Martinez Canillas
2015-11-09 15:15     ` Mason
2015-11-09 15:36       ` Marc Zyngier
2016-02-03 15:33         ` Sebastian Frias
2015-11-09 15:40       ` Måns Rullgård
2015-11-09 16:07         ` Mason
2015-11-09 16:12           ` Måns Rullgård
2015-11-09 17:03             ` Mason [this message]
2015-11-09 17:13               ` Måns Rullgård
2015-11-10 12:44                 ` Mason
2015-11-10 12:56                   ` Arnd Bergmann
2015-11-09 16:26       ` Russell King - ARM Linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5640D1F3.1010100@free.fr \
    --to=slash.tmp@free.fr \
    --cc=andrew@lunn.ch \
    --cc=jason@lakedaemon.net \
    --cc=javier@dowhile0.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mans@mansr.com \
    --cc=marc.zyngier@arm.com \
    --cc=tglx@linutronix.de \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox