Skip to content

Commit 9ec4aa5

Browse files
committed
fixup! media: apple: isp: Working t602x and multiple formats and more fixes
Use __free() for scope based cleanup of device_node. Reported-by: kernel test robot <[email protected]> Reported-by: Julia Lawall <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Janne Grunau <[email protected]>
1 parent 16011c1 commit 9ec4aa5

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

drivers/media/platform/apple/isp/isp-drv.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ static int isp_of_read_coord(struct device *dev, struct device_node *np,
160160
static int apple_isp_init_presets(struct apple_isp *isp)
161161
{
162162
struct device *dev = isp->dev;
163-
struct device_node *np, *child;
163+
struct device_node *child;
164164
struct isp_preset *preset;
165165
int err = 0;
166166

167-
np = of_get_child_by_name(dev->of_node, "sensor-presets");
167+
struct device_node *np __free(device_node) =
168+
of_get_child_by_name(dev->of_node, "sensor-presets");
168169
if (!np) {
169170
dev_err(dev, "failed to get DT node 'presets'\n");
170171
return -EINVAL;
@@ -173,16 +174,13 @@ static int apple_isp_init_presets(struct apple_isp *isp)
173174
isp->num_presets = of_get_child_count(np);
174175
if (!isp->num_presets) {
175176
dev_err(dev, "no sensor presets found\n");
176-
err = -EINVAL;
177-
goto err;
177+
return -EINVAL;
178178
}
179179

180180
isp->presets = devm_kzalloc(
181181
dev, sizeof(*isp->presets) * isp->num_presets, GFP_KERNEL);
182-
if (!isp->presets) {
183-
err = -ENOMEM;
184-
goto err;
185-
}
182+
if (!isp->presets)
183+
return -ENOMEM;
186184

187185
preset = isp->presets;
188186
for_each_child_of_node(np, child) {
@@ -193,23 +191,23 @@ static int apple_isp_init_presets(struct apple_isp *isp)
193191
if (err) {
194192
dev_err(dev, "no apple,config-index property\n");
195193
of_node_put(child);
196-
goto err;
194+
return err;
197195
}
198196

199197
err = isp_of_read_coord(dev, child, "apple,input-size",
200198
&preset->input_dim);
201199
if (err)
202-
goto err;
200+
return err;
203201
err = isp_of_read_coord(dev, child, "apple,output-size",
204202
&preset->output_dim);
205203
if (err)
206-
goto err;
204+
return err;
207205

208206
err = of_property_read_u32_array(child, "apple,crop", xywh, 4);
209207
if (err) {
210208
dev_err(dev, "failed to read 'apple,crop' property\n");
211209
of_node_put(child);
212-
goto err;
210+
return err;
213211
}
214212
preset->crop_offset.x = xywh[0];
215213
preset->crop_offset.y = xywh[1];
@@ -219,9 +217,7 @@ static int apple_isp_init_presets(struct apple_isp *isp)
219217
preset++;
220218
}
221219

222-
err:
223-
of_node_put(np);
224-
return err;
220+
return 0;
225221
}
226222

227223
static const char * isp_fw2str(enum isp_firmware_version version)

0 commit comments

Comments
 (0)