msm: kgsl: use more static initializers for struct kgsl_device

There are many fields in kgsl_device that are always initialized
the same way. Move them to a macro, KGSL_DEVICE_COMMON_INIT,
so the correct static initializers can be used by both 3d and 2d.

Change-Id: I8362957548199112517457e0f94bfe2bd5f707f9
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
This commit is contained in:
Jeremy Gebben
2012-05-16 09:00:21 -06:00
parent 3d45def14b
commit 84d75d0949
4 changed files with 27 additions and 34 deletions
+1 -7
View File
@@ -69,10 +69,9 @@ static const struct kgsl_functable adreno_functable;
static struct adreno_device device_3d0 = {
.dev = {
KGSL_DEVICE_COMMON_INIT(device_3d0.dev),
.name = DEVICE_3D0_NAME,
.id = KGSL_DEVICE_3D0,
.ver_major = DRIVER_VERSION_MAJOR,
.ver_minor = DRIVER_VERSION_MINOR,
.mh = {
.mharb = ADRENO_CFG_MHARB,
/* Remove 1k boundary check in z470 to avoid a GPU
@@ -92,9 +91,6 @@ static struct adreno_device device_3d0 = {
.pwrctrl = {
.irq_name = KGSL_3D0_IRQ,
},
.mutex = __MUTEX_INITIALIZER(device_3d0.dev.mutex),
.state = KGSL_STATE_INIT,
.active_cnt = 0,
.iomemname = KGSL_3D0_REG_MEMORY,
.ftbl = &adreno_functable,
#ifdef CONFIG_HAS_EARLYSUSPEND
@@ -482,8 +478,6 @@ adreno_probe(struct platform_device *pdev)
adreno_dev = ADRENO_DEVICE(device);
device->parentdev = &pdev->dev;
init_completion(&device->recovery_gate);
status = adreno_ringbuffer_init(device);
if (status != 0)
goto error;
+2 -16
View File
@@ -385,7 +385,7 @@ kgsl_destroy_context(struct kgsl_device_private *dev_priv,
idr_remove(&dev_priv->device->context_idr, id);
}
static void kgsl_timestamp_expired(struct work_struct *work)
void kgsl_timestamp_expired(struct work_struct *work)
{
struct kgsl_device *device = container_of(work, struct kgsl_device,
ts_expired_ws);
@@ -415,6 +415,7 @@ static void kgsl_timestamp_expired(struct work_struct *work)
mutex_unlock(&device->mutex);
}
EXPORT_SYMBOL(kgsl_timestamp_expired);
static void kgsl_check_idle_locked(struct kgsl_device *device)
{
@@ -2417,27 +2418,14 @@ kgsl_register_device(struct kgsl_device *device)
dev_set_drvdata(device->parentdev, device);
/* Generic device initialization */
init_waitqueue_head(&device->wait_queue);
kgsl_cffdump_open(device->id);
init_completion(&device->hwaccess_gate);
init_completion(&device->suspend_gate);
ATOMIC_INIT_NOTIFIER_HEAD(&device->ts_notifier_list);
setup_timer(&device->idle_timer, kgsl_timer, (unsigned long) device);
ret = kgsl_create_device_workqueue(device);
if (ret)
goto err_devlist;
INIT_WORK(&device->idle_check_ws, kgsl_idle_check);
INIT_WORK(&device->ts_expired_ws, kgsl_timestamp_expired);
INIT_LIST_HEAD(&device->events);
device->last_expired_ctxt_id = KGSL_CONTEXT_INVALID;
ret = kgsl_mmu_init(device);
if (ret != 0)
goto err_dest_work_q;
@@ -2450,8 +2438,6 @@ kgsl_register_device(struct kgsl_device *device)
pm_qos_add_request(&device->pm_qos_req_dma, PM_QOS_CPU_DMA_LATENCY,
PM_QOS_DEFAULT_VALUE);
idr_init(&device->context_idr);
/* Initalize the snapshot engine */
kgsl_device_snapshot_init(device);
+20
View File
@@ -199,6 +199,26 @@ struct kgsl_device {
s64 on_time;
};
void kgsl_timestamp_expired(struct work_struct *work);
#define KGSL_DEVICE_COMMON_INIT(_dev) \
.hwaccess_gate = COMPLETION_INITIALIZER((_dev).hwaccess_gate),\
.suspend_gate = COMPLETION_INITIALIZER((_dev).suspend_gate),\
.recovery_gate = COMPLETION_INITIALIZER((_dev).recovery_gate),\
.ts_notifier_list = ATOMIC_NOTIFIER_INIT((_dev).ts_notifier_list),\
.idle_check_ws = __WORK_INITIALIZER((_dev).idle_check_ws,\
kgsl_idle_check),\
.ts_expired_ws = __WORK_INITIALIZER((_dev).ts_expired_ws,\
kgsl_timestamp_expired),\
.context_idr = IDR_INIT((_dev).context_idr),\
.events = LIST_HEAD_INIT((_dev).events),\
.wait_queue = __WAIT_QUEUE_HEAD_INITIALIZER((_dev).wait_queue),\
.mutex = __MUTEX_INITIALIZER((_dev).mutex),\
.state = KGSL_STATE_INIT,\
.ver_major = DRIVER_VERSION_MAJOR,\
.ver_minor = DRIVER_VERSION_MINOR,\
.last_expired_ctxt_id = KGSL_CONTEXT_INVALID
struct kgsl_context {
uint32_t id;
+4 -11
View File
@@ -132,10 +132,9 @@ static const struct kgsl_functable z180_functable;
static struct z180_device device_2d0 = {
.dev = {
KGSL_DEVICE_COMMON_INIT(device_2d0.dev),
.name = DEVICE_2D0_NAME,
.id = KGSL_DEVICE_2D0,
.ver_major = DRIVER_VERSION_MAJOR,
.ver_minor = DRIVER_VERSION_MINOR,
.mh = {
.mharb = Z180_CFG_MHARB,
.mh_intf_cfg1 = 0x00032f07,
@@ -152,20 +151,17 @@ static struct z180_device device_2d0 = {
.pwrctrl = {
.irq_name = KGSL_2D0_IRQ,
},
.mutex = __MUTEX_INITIALIZER(device_2d0.dev.mutex),
.state = KGSL_STATE_INIT,
.active_cnt = 0,
.iomemname = KGSL_2D0_REG_MEMORY,
.ftbl = &z180_functable,
},
.cmdwin_lock = __SPIN_LOCK_INITIALIZER(device_2d1.cmdwin_lock),
};
static struct z180_device device_2d1 = {
.dev = {
KGSL_DEVICE_COMMON_INIT(device_2d1.dev),
.name = DEVICE_2D1_NAME,
.id = KGSL_DEVICE_2D1,
.ver_major = DRIVER_VERSION_MAJOR,
.ver_minor = DRIVER_VERSION_MINOR,
.mh = {
.mharb = Z180_CFG_MHARB,
.mh_intf_cfg1 = 0x00032f07,
@@ -182,12 +178,10 @@ static struct z180_device device_2d1 = {
.pwrctrl = {
.irq_name = KGSL_2D1_IRQ,
},
.mutex = __MUTEX_INITIALIZER(device_2d1.dev.mutex),
.state = KGSL_STATE_INIT,
.active_cnt = 0,
.iomemname = KGSL_2D1_REG_MEMORY,
.ftbl = &z180_functable,
},
.cmdwin_lock = __SPIN_LOCK_INITIALIZER(device_2d1.cmdwin_lock),
};
static irqreturn_t z180_irq_handler(struct kgsl_device *device)
@@ -524,7 +518,6 @@ static int __devinit z180_probe(struct platform_device *pdev)
device->parentdev = &pdev->dev;
z180_dev = Z180_DEVICE(device);
spin_lock_init(&z180_dev->cmdwin_lock);
status = z180_ringbuffer_init(device);
if (status != 0)