aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/max77686.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index 5bd24670e1b6..f27a21831583 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -85,12 +85,12 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
85 pdata = max77686_i2c_parse_dt_pdata(&i2c->dev); 85 pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
86 86
87 if (!pdata) { 87 if (!pdata) {
88 ret = -EIO;
89 dev_err(&i2c->dev, "No platform data found.\n"); 88 dev_err(&i2c->dev, "No platform data found.\n");
90 goto err; 89 return -EIO;
91 } 90 }
92 91
93 max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL); 92 max77686 = devm_kzalloc(&i2c->dev,
93 sizeof(struct max77686_dev), GFP_KERNEL);
94 if (max77686 == NULL) 94 if (max77686 == NULL)
95 return -ENOMEM; 95 return -ENOMEM;
96 96
@@ -108,7 +108,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
108 ret = PTR_ERR(max77686->regmap); 108 ret = PTR_ERR(max77686->regmap);
109 dev_err(max77686->dev, "Failed to allocate register map: %d\n", 109 dev_err(max77686->dev, "Failed to allocate register map: %d\n",
110 ret); 110 ret);
111 kfree(max77686);
112 return ret; 111 return ret;
113 } 112 }
114 113
@@ -116,8 +115,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
116 MAX77686_REG_DEVICE_ID, &data) < 0) { 115 MAX77686_REG_DEVICE_ID, &data) < 0) {
117 dev_err(max77686->dev, 116 dev_err(max77686->dev,
118 "device not found on this channel (this is not an error)\n"); 117 "device not found on this channel (this is not an error)\n");
119 ret = -ENODEV; 118 return -ENODEV;
120 goto err;
121 } else 119 } else
122 dev_info(max77686->dev, "device found\n"); 120 dev_info(max77686->dev, "device found\n");
123 121
@@ -128,17 +126,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
128 126
129 ret = mfd_add_devices(max77686->dev, -1, max77686_devs, 127 ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
130 ARRAY_SIZE(max77686_devs), NULL, 0, NULL); 128 ARRAY_SIZE(max77686_devs), NULL, 0, NULL);
129 if (ret < 0) {
130 mfd_remove_devices(max77686->dev);
131 i2c_unregister_device(max77686->rtc);
132 }
131 133
132 if (ret < 0)
133 goto err_mfd;
134
135 return ret;
136
137err_mfd:
138 mfd_remove_devices(max77686->dev);
139 i2c_unregister_device(max77686->rtc);
140err:
141 kfree(max77686);
142 return ret; 134 return ret;
143} 135}
144 136
@@ -148,7 +140,6 @@ static int max77686_i2c_remove(struct i2c_client *i2c)
148 140
149 mfd_remove_devices(max77686->dev); 141 mfd_remove_devices(max77686->dev);
150 i2c_unregister_device(max77686->rtc); 142 i2c_unregister_device(max77686->rtc);
151 kfree(max77686);
152 143
153 return 0; 144 return 0;
154} 145}