Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: ab3100-otp: Convert to managed resources for allocating memory

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Lee Jones and committed by
Samuel Ortiz
5feac05d b3fff177

+5 -9
+5 -9
drivers/mfd/ab3100-otp.c
··· 187 187 int err = 0; 188 188 int i; 189 189 190 - otp = kzalloc(sizeof(struct ab3100_otp), GFP_KERNEL); 190 + otp = devm_kzalloc(&pdev->dev, sizeof(struct ab3100_otp), GFP_KERNEL); 191 191 if (!otp) { 192 192 dev_err(&pdev->dev, "could not allocate AB3100 OTP device\n"); 193 193 return -ENOMEM; ··· 199 199 200 200 err = ab3100_otp_read(otp); 201 201 if (err) 202 - goto err_otp_read; 202 + return err; 203 203 204 204 dev_info(&pdev->dev, "AB3100 OTP readout registered\n"); 205 205 ··· 208 208 err = device_create_file(&pdev->dev, 209 209 &ab3100_otp_attrs[i]); 210 210 if (err) 211 - goto err_create_file; 211 + goto err; 212 212 } 213 213 214 214 /* debugfs entries */ 215 215 err = ab3100_otp_init_debugfs(&pdev->dev, otp); 216 216 if (err) 217 - goto err_init_debugfs; 217 + goto err; 218 218 219 219 return 0; 220 220 221 - err_init_debugfs: 222 - err_create_file: 221 + err: 223 222 while (--i >= 0) 224 223 device_remove_file(&pdev->dev, &ab3100_otp_attrs[i]); 225 - err_otp_read: 226 - kfree(otp); 227 224 return err; 228 225 } 229 226 ··· 233 236 device_remove_file(&pdev->dev, 234 237 &ab3100_otp_attrs[i]); 235 238 ab3100_otp_exit_debugfs(otp); 236 - kfree(otp); 237 239 return 0; 238 240 } 239 241