s3cmci_def_pdata vs. pdev->dev.platform_data
Ben Dooks
ben-linux at fluff.org
Tue Nov 18 22:17:02 CET 2008
On Tue, Nov 18, 2008 at 07:03:17PM -0200, Werner Almesberger wrote:
> Hi Ben,
>
> when compiling s3cmci as a module and doing an insmod-rmmod-insmod
> sequence, s3cmci_probe often oopses because the platform data contains
> garbage.
>
> The reason for this is that I'm not providing any platform data, and
> thus s3cmci tries to put its own defaults:
>
> if (!host->pdata) {
> pdev->dev.platform_data = &s3cmci_def_pdata;
> host->pdata = &s3cmci_def_pdata;
> }
>
> s3cmci_def_pdata is inside the module, so the pointer in
> pdev->dev.platform_data becomes invalid after the module is unloaded.
>
> This is easy enough to work around by providing empty platform data
> in mach-gta02.c (patch attached), but I wonder if we can't do better
> than this.
I think the better idea is that we don't set pdev->dev.platform_data
as in my view this is clearly wrong if we are making it point at data
that may go away once the module is removed.
> Do we actually need to "patch" pdev->dev.platform_data ? Inside s3cmci,
> all accesses to the platform data go through host->pdata, so this
> seems fine.
>
> I've built a kernel without platform data in mach-gta02.c that doesn't
> modify pdev->dev.platform_data and it seems to work.
>
> Can you please suggest the best course of action ?
>
> Thanks,
> - Werner
> workaround-s3cmci-reload.patch
>
> When compiling s3cmci as a module and doing an insmod-rmmod-insmod
> sequence, s3cmci_probe often oopses because the platform data contains
> garbage.
>
> The reason for this is that I'm not providing any platform data (removed
> in gta02-mmc-mci.patch), and thus s3cmci tries to put its own defaults:
>
> if (!host->pdata) {
> pdev->dev.platform_data = &s3cmci_def_pdata;
> host->pdata = &s3cmci_def_pdata;
> }
>
> s3cmci_def_pdata is inside the module, so the pointer in
> pdev->dev.platform_data becomes invalid after the module is unloaded.
>
> This patch works around the problem by providing empty platform data
> in mach-gta02.c instead of relying on s3cmci to do this.
>
> Not-Yet-Signed-off-by: Werner Almesberger <werner at openmoko.org>
>
> Index: ktrack/arch/arm/mach-s3c2440/mach-gta02.c
> ===================================================================
> --- ktrack.orig/arch/arm/mach-s3c2440/mach-gta02.c 2008-11-18 18:36:16.000000000 -0200
> +++ ktrack/arch/arm/mach-s3c2440/mach-gta02.c 2008-11-18 18:38:03.000000000 -0200
> @@ -903,6 +903,8 @@
> .software_ecc = 1,
> };
>
> +static struct s3c24xx_mci_pdata gta02_mmc_cfg; /* all values are defaults */
> +
> static void gta02_udc_command(enum s3c2410_udc_cmd_e cmd)
> {
> printk(KERN_DEBUG "%s(%d)\n", __func__, cmd);
> @@ -1580,6 +1582,7 @@
>
> s3c_device_usb.dev.platform_data = >a02_usb_info;
> s3c_device_nand.dev.platform_data = >a02_nand_info;
> + s3c_device_sdi.dev.platform_data = >a02_mmc_cfg;
>
> /* acc sensor chip selects */
> s3c2410_gpio_setpin(S3C2410_GPD12, 1);
--
--
Ben
Q: What's a light-year?
A: One-third less calories than a regular year.
More information about the openmoko-kernel
mailing list