Skip to content

Commit 6a341fd

Browse files
committed
gpu: host1x: Use of_device_get_match_data()
Avoid some boilerplate by calling of_device_get_match_data() instead of open-coding the equivalent in the driver. While at it, shuffle around some code to avoid unnecessary local variables. Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent 9e66317 commit 6a341fd

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

‎drivers/gpu/host1x/dev.c‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,16 @@ MODULE_DEVICE_TABLE(of, host1x_of_match);
116116

117117
static int host1x_probe(struct platform_device *pdev)
118118
{
119-
const struct of_device_id *id;
120119
struct host1x *host;
121120
struct resource *regs;
122121
int syncpt_irq;
123122
int err;
124123

125-
id = of_match_device(host1x_of_match, &pdev->dev);
126-
if (!id)
127-
return -EINVAL;
124+
host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
125+
if (!host)
126+
return -ENOMEM;
127+
128+
host->info = of_device_get_match_data(&pdev->dev);
128129

129130
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
130131
if (!regs) {
@@ -138,15 +139,10 @@ static int host1x_probe(struct platform_device *pdev)
138139
return syncpt_irq;
139140
}
140141

141-
host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
142-
if (!host)
143-
return -ENOMEM;
144-
145142
mutex_init(&host->devices_lock);
146143
INIT_LIST_HEAD(&host->devices);
147144
INIT_LIST_HEAD(&host->list);
148145
host->dev = &pdev->dev;
149-
host->info = id->data;
150146

151147
/* set common host1x device data */
152148
platform_set_drvdata(pdev, host);

0 commit comments

Comments
 (0)