Commit 3528c58e authored by Kevin Hilman's avatar Kevin Hilman
Browse files

OMAP: omap_device: when building return platform_device instead of omap_device



All of the device init and device driver interaction with omap_device
is done using platform_device pointers.  To make this more explicit,
have omap_device return a platform_device pointer instead of an
omap_device pointer.

All current users of the omap_device pointer were only using it to get
at the platform_device pointer or struct device pointer, so fixing all
of the users was trivial.

This also makes it more difficult for device init code to directly
access members of struct omap_device, and allows for easier changing
of omap_device internals.

Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent a2a28ad9
Loading
Loading
Loading
Loading
+22 −22
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ static int __init omap3_l3_init(void)
{
	int l;
	struct omap_hwmod *oh;
	struct omap_device *od;
	struct platform_device *pdev;
	char oh_name[L3_MODULES_MAX_LEN];

	/*
@@ -61,12 +61,12 @@ static int __init omap3_l3_init(void)
	if (!oh)
		pr_err("could not look up %s\n", oh_name);

	od = omap_device_build("omap_l3_smx", 0, oh, NULL, 0,
	pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0,
							   NULL, 0, 0);

	WARN(IS_ERR(od), "could not build omap_device for %s\n", oh_name);
	WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);

	return IS_ERR(od) ? PTR_ERR(od) : 0;
	return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
}
postcore_initcall(omap3_l3_init);

@@ -74,7 +74,7 @@ static int __init omap4_l3_init(void)
{
	int l, i;
	struct omap_hwmod *oh[3];
	struct omap_device *od;
	struct platform_device *pdev;
	char oh_name[L3_MODULES_MAX_LEN];

	/*
@@ -92,12 +92,12 @@ static int __init omap4_l3_init(void)
			pr_err("could not look up %s\n", oh_name);
	}

	od = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
	pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
						     0, NULL, 0, 0);

	WARN(IS_ERR(od), "could not build omap_device for %s\n", oh_name);
	WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);

	return IS_ERR(od) ? PTR_ERR(od) : 0;
	return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
}
postcore_initcall(omap4_l3_init);

@@ -232,7 +232,7 @@ struct omap_device_pm_latency omap_keyboard_latency[] = {
int __init omap4_keyboard_init(struct omap4_keypad_platform_data
			*sdp4430_keypad_data, struct omap_board_data *bdata)
{
	struct omap_device *od;
	struct platform_device *pdev;
	struct omap_hwmod *oh;
	struct omap4_keypad_platform_data *keypad_data;
	unsigned int id = -1;
@@ -247,15 +247,15 @@ int __init omap4_keyboard_init(struct omap4_keypad_platform_data

	keypad_data = sdp4430_keypad_data;

	od = omap_device_build(name, id, oh, keypad_data,
	pdev = omap_device_build(name, id, oh, keypad_data,
			sizeof(struct omap4_keypad_platform_data),
			omap_keyboard_latency,
			ARRAY_SIZE(omap_keyboard_latency), 0);

	if (IS_ERR(od)) {
	if (IS_ERR(pdev)) {
		WARN(1, "Can't build omap_device for %s:%s.\n",
						name, oh->name);
		return PTR_ERR(od);
		return PTR_ERR(pdev);
	}
	oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);

@@ -274,7 +274,7 @@ static struct omap_device_pm_latency mbox_latencies[] = {
static inline void omap_init_mbox(void)
{
	struct omap_hwmod *oh;
	struct omap_device *od;
	struct platform_device *pdev;

	oh = omap_hwmod_lookup("mailbox");
	if (!oh) {
@@ -282,10 +282,10 @@ static inline void omap_init_mbox(void)
		return;
	}

	od = omap_device_build("omap-mailbox", -1, oh, NULL, 0,
	pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0,
				mbox_latencies, ARRAY_SIZE(mbox_latencies), 0);
	WARN(IS_ERR(od), "%s: could not build device, err %ld\n",
						__func__, PTR_ERR(od));
	WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
						__func__, PTR_ERR(pdev));
}
#else
static inline void omap_init_mbox(void) { }
@@ -344,7 +344,7 @@ struct omap_device_pm_latency omap_mcspi_latency[] = {

static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
{
	struct omap_device *od;
	struct platform_device *pdev;
	char *name = "omap2_mcspi";
	struct omap2_mcspi_platform_config *pdata;
	static int spi_num;
@@ -371,10 +371,10 @@ static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
	}

	spi_num++;
	od = omap_device_build(name, spi_num, oh, pdata,
	pdev = omap_device_build(name, spi_num, oh, pdata,
				sizeof(*pdata),	omap_mcspi_latency,
				ARRAY_SIZE(omap_mcspi_latency), 0);
	WARN(IS_ERR(od), "Can't build omap_device for %s:%s\n",
	WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
				name, oh->name);
	kfree(pdata);
	return 0;
@@ -709,7 +709,7 @@ static struct omap_device_pm_latency omap_wdt_latency[] = {
static int __init omap_init_wdt(void)
{
	int id = -1;
	struct omap_device *od;
	struct platform_device *pdev;
	struct omap_hwmod *oh;
	char *oh_name = "wd_timer2";
	char *dev_name = "omap_wdt";
@@ -723,10 +723,10 @@ static int __init omap_init_wdt(void)
		return -EINVAL;
	}

	od = omap_device_build(dev_name, id, oh, NULL, 0,
	pdev = omap_device_build(dev_name, id, oh, NULL, 0,
				omap_wdt_latency,
				ARRAY_SIZE(omap_wdt_latency), 0);
	WARN(IS_ERR(od), "Can't build omap_device for %s:%s.\n",
	WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
				dev_name, oh->name);
	return 0;
}
+3 −3
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ int __init omap_display_init(struct omap_dss_board_info *board_data)
{
	int r = 0;
	struct omap_hwmod *oh;
	struct omap_device *od;
	struct platform_device *pdev;
	int i, oh_count;
	struct omap_display_platform_data pdata;
	const struct omap_dss_hwmod_data *curr_dss_hwmod;
@@ -108,13 +108,13 @@ int __init omap_display_init(struct omap_dss_board_info *board_data)
			return -ENODEV;
		}

		od = omap_device_build(curr_dss_hwmod[i].dev_name,
		pdev = omap_device_build(curr_dss_hwmod[i].dev_name,
				curr_dss_hwmod[i].id, oh, &pdata,
				sizeof(struct omap_display_platform_data),
				omap_dss_latency,
				ARRAY_SIZE(omap_dss_latency), 0);

		if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n",
		if (WARN((IS_ERR(pdev)), "Could not build omap_device for %s\n",
				curr_dss_hwmod[i].oh_name))
			return -ENODEV;
	}
+8 −8
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ static u32 configure_dma_errata(void)
/* One time initializations */
static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused)
{
	struct omap_device			*od;
	struct platform_device			*pdev;
	struct omap_system_dma_plat_info	*p;
	struct resource				*mem;
	char					*name = "omap_dma_system";
@@ -258,23 +258,23 @@ static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused)

	p->errata		= configure_dma_errata();

	od = omap_device_build(name, 0, oh, p, sizeof(*p),
	pdev = omap_device_build(name, 0, oh, p, sizeof(*p),
			omap2_dma_latency, ARRAY_SIZE(omap2_dma_latency), 0);
	kfree(p);
	if (IS_ERR(od)) {
	if (IS_ERR(pdev)) {
		pr_err("%s: Can't build omap_device for %s:%s.\n",
			__func__, name, oh->name);
		return PTR_ERR(od);
		return PTR_ERR(pdev);
	}

	mem = platform_get_resource(&od->pdev, IORESOURCE_MEM, 0);
	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!mem) {
		dev_err(&od->pdev.dev, "%s: no mem resource\n", __func__);
		dev_err(&pdev->dev, "%s: no mem resource\n", __func__);
		return -EINVAL;
	}
	dma_base = ioremap(mem->start, resource_size(mem));
	if (!dma_base) {
		dev_err(&od->pdev.dev, "%s: ioremap fail\n", __func__);
		dev_err(&pdev->dev, "%s: ioremap fail\n", __func__);
		return -ENOMEM;
	}

@@ -283,7 +283,7 @@ static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused)
					(d->lch_count), GFP_KERNEL);

	if (!d->chan) {
		dev_err(&od->pdev.dev, "%s: kzalloc fail\n", __func__);
		dev_err(&pdev->dev, "%s: kzalloc fail\n", __func__);
		return -ENOMEM;
	}
	return 0;
+4 −4
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ static struct omap_device_pm_latency omap_gpio_latency[] = {

static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
{
	struct omap_device *od;
	struct platform_device *pdev;
	struct omap_gpio_platform_data *pdata;
	struct omap_gpio_dev_attr *dev_attr;
	char *name = "omap_gpio";
@@ -107,16 +107,16 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
		return -EINVAL;
	}

	od = omap_device_build(name, id - 1, oh, pdata,
	pdev = omap_device_build(name, id - 1, oh, pdata,
				sizeof(*pdata),	omap_gpio_latency,
				ARRAY_SIZE(omap_gpio_latency),
				false);
	kfree(pdata);

	if (IS_ERR(od)) {
	if (IS_ERR(pdev)) {
		WARN(1, "Can't build omap_device for %s:%s.\n",
					name, oh->name);
		return PTR_ERR(od);
		return PTR_ERR(pdev);
	}

	omap_device_disable_idle_on_suspend(od);
+4 −4
Original line number Diff line number Diff line
@@ -430,7 +430,7 @@ static struct omap_device_pm_latency omap_hsmmc_latency[] = {
void __init omap_init_hsmmc(struct omap2_hsmmc_info *hsmmcinfo, int ctrl_nr)
{
	struct omap_hwmod *oh;
	struct omap_device *od;
	struct platform_device *pdev;
	struct omap_device_pm_latency *ohl;
	char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
	struct omap_mmc_platform_data *mmc_data;
@@ -471,9 +471,9 @@ void __init omap_init_hsmmc(struct omap2_hsmmc_info *hsmmcinfo, int ctrl_nr)
		mmc_data->controller_flags = mmc_dev_attr->flags;
	}

	od = omap_device_build(name, ctrl_nr - 1, oh, mmc_data,
	pdev = omap_device_build(name, ctrl_nr - 1, oh, mmc_data,
		sizeof(struct omap_mmc_platform_data), ohl, ohl_cnt, false);
	if (IS_ERR(od)) {
	if (IS_ERR(pdev)) {
		WARN(1, "Can't build omap_device for %s:%s.\n", name, oh->name);
		kfree(mmc_data->slots[0].name);
		goto done;
@@ -482,7 +482,7 @@ void __init omap_init_hsmmc(struct omap2_hsmmc_info *hsmmcinfo, int ctrl_nr)
	 * return device handle to board setup code
	 * required to populate for regulator framework structure
	 */
	hsmmcinfo->dev = &od->pdev.dev;
	hsmmcinfo->dev = &pdev->dev;

done:
	kfree(mmc_data);
Loading