Skip to content

Commit

Permalink
OMAP: omap_device: when building return platform_device instead of om…
Browse files Browse the repository at this point in the history
…ap_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: Kevin Hilman <khilman@ti.com>
  • Loading branch information
Kevin Hilman committed Sep 15, 2011
1 parent a2a28ad commit 3528c58
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 71 deletions.
44 changes: 22 additions & 22 deletions arch/arm/mach-omap2/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

/*
Expand All @@ -61,20 +61,20 @@ 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);

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];

/*
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -274,18 +274,18 @@ 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) {
pr_err("%s: unable to find hwmod\n", __func__);
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) { }
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/mach-omap2/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions arch/arm/mach-omap2/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-omap2/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-omap2/hsmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-omap2/hwspinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int __init hwspinlocks_init(void)
{
int retval = 0;
struct omap_hwmod *oh;
struct omap_device *od;
struct platform_device *pdev;
const char *oh_name = "spinlock";
const char *dev_name = "omap_hwspinlock";

Expand All @@ -48,13 +48,13 @@ int __init hwspinlocks_init(void)
if (oh == NULL)
return -EINVAL;

od = omap_device_build(dev_name, 0, oh, NULL, 0,
pdev = omap_device_build(dev_name, 0, oh, NULL, 0,
omap_spinlock_latency,
ARRAY_SIZE(omap_spinlock_latency), false);
if (IS_ERR(od)) {
if (IS_ERR(pdev)) {
pr_err("Can't build omap_device for %s:%s\n", dev_name,
oh_name);
retval = PTR_ERR(od);
retval = PTR_ERR(pdev);
}

return retval;
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-omap2/mcbsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused)
char *name = "omap-mcbsp";
struct omap_hwmod *oh_device[2];
struct omap_mcbsp_platform_data *pdata = NULL;
struct omap_device *od;
struct platform_device *pdev;

sscanf(oh->name, "mcbsp%d", &id);

Expand Down Expand Up @@ -144,14 +144,14 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused)
(struct omap_mcbsp_dev_attr *)(oh->dev_attr))->sidetone);
count++;
}
od = omap_device_build_ss(name, id, oh_device, count, pdata,
pdev = omap_device_build_ss(name, id, oh_device, count, pdata,
sizeof(*pdata), omap2_mcbsp_latency,
ARRAY_SIZE(omap2_mcbsp_latency), false);
kfree(pdata);
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);
}
omap_mcbsp_count++;
return 0;
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-omap2/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ EXPORT_SYMBOL(omap4_get_dsp_device);
static int _init_omap_device(char *name, struct device **new_dev)
{
struct omap_hwmod *oh;
struct omap_device *od;
struct platform_device *pdev;

oh = omap_hwmod_lookup(name);
if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
__func__, name))
return -ENODEV;

od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n",
pdev = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
if (WARN(IS_ERR(pdev), "%s: could not build omap_device for %s\n",
__func__, name))
return -ENODEV;

*new_dev = &od->pdev.dev;
*new_dev = &pdev->dev;

return 0;
}
Expand Down
12 changes: 6 additions & 6 deletions arch/arm/mach-omap2/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
{
struct omap_uart_state *uart;
struct omap_hwmod *oh;
struct omap_device *od;
struct platform_device *pdev;
void *pdata = NULL;
u32 pdata_size = 0;
char *name;
Expand Down Expand Up @@ -799,10 +799,10 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
if (WARN_ON(!oh))
return;

od = omap_device_build(name, uart->num, oh, pdata, pdata_size,
pdev = omap_device_build(name, uart->num, oh, pdata, pdata_size,
omap_uart_latency,
ARRAY_SIZE(omap_uart_latency), false);
WARN(IS_ERR(od), "Could not build omap_device for %s: %s.\n",
WARN(IS_ERR(pdev), "Could not build omap_device for %s: %s.\n",
name, oh->name);

omap_device_disable_idle_on_suspend(od);
Expand All @@ -812,7 +812,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
uart->regshift = 2;
uart->mapbase = oh->slaves[0]->addr->pa_start;
uart->membase = omap_hwmod_get_mpu_rt_va(oh);
uart->pdev = &od->pdev;
uart->pdev = pdev;

oh->dev_attr = uart;

Expand Down Expand Up @@ -846,8 +846,8 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)

if ((cpu_is_omap34xx() && uart->padconf) ||
(uart->wk_en && uart->wk_mask)) {
device_init_wakeup(&od->pdev.dev, true);
DEV_CREATE_FILE(&od->pdev.dev, &dev_attr_sleep_timeout);
device_init_wakeup(&pdev->dev, true);
DEV_CREATE_FILE(&pdev->dev, &dev_attr_sleep_timeout);
}

/* Enable the MDR1 errata for OMAP3 */
Expand Down
Loading

0 comments on commit 3528c58

Please sign in to comment.