aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/phy/spi_ks8995.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/net/phy/spi_ks8995.c b/drivers/net/phy/spi_ks8995.c
index 22b047f1fcdc..eab57fc5b967 100644
--- a/drivers/net/phy/spi_ks8995.c
+++ b/drivers/net/phy/spi_ks8995.c
@@ -277,7 +277,7 @@ static int ks8995_probe(struct spi_device *spi)
277 /* Chip description */ 277 /* Chip description */
278 pdata = spi->dev.platform_data; 278 pdata = spi->dev.platform_data;
279 279
280 ks = kzalloc(sizeof(*ks), GFP_KERNEL); 280 ks = devm_kzalloc(&spi->dev, sizeof(*ks), GFP_KERNEL);
281 if (!ks) 281 if (!ks)
282 return -ENOMEM; 282 return -ENOMEM;
283 283
@@ -291,14 +291,14 @@ static int ks8995_probe(struct spi_device *spi)
291 err = spi_setup(spi); 291 err = spi_setup(spi);
292 if (err) { 292 if (err) {
293 dev_err(&spi->dev, "spi_setup failed, err=%d\n", err); 293 dev_err(&spi->dev, "spi_setup failed, err=%d\n", err);
294 goto err_drvdata; 294 return err;
295 } 295 }
296 296
297 err = ks8995_read(ks, ids, KS8995_REG_ID0, sizeof(ids)); 297 err = ks8995_read(ks, ids, KS8995_REG_ID0, sizeof(ids));
298 if (err < 0) { 298 if (err < 0) {
299 dev_err(&spi->dev, "unable to read id registers, err=%d\n", 299 dev_err(&spi->dev, "unable to read id registers, err=%d\n",
300 err); 300 err);
301 goto err_drvdata; 301 return err;
302 } 302 }
303 303
304 switch (ids[0]) { 304 switch (ids[0]) {
@@ -306,8 +306,7 @@ static int ks8995_probe(struct spi_device *spi)
306 break; 306 break;
307 default: 307 default:
308 dev_err(&spi->dev, "unknown family id:%02x\n", ids[0]); 308 dev_err(&spi->dev, "unknown family id:%02x\n", ids[0]);
309 err = -ENODEV; 309 return -ENODEV;
310 goto err_drvdata;
311 } 310 }
312 311
313 memcpy(&ks->regs_attr, &ks8995_registers_attr, sizeof(ks->regs_attr)); 312 memcpy(&ks->regs_attr, &ks8995_registers_attr, sizeof(ks->regs_attr));
@@ -320,24 +319,24 @@ static int ks8995_probe(struct spi_device *spi)
320 dev_err(&spi->dev, 319 dev_err(&spi->dev,
321 "unable to read chip id register, err=%d\n", 320 "unable to read chip id register, err=%d\n",
322 err); 321 err);
323 goto err_drvdata; 322 return err;
324 } 323 }
325 if ((val & 0x80) == 0) { 324 if ((val & 0x80) == 0) {
326 dev_err(&spi->dev, "unknown chip:%02x,0\n", ids[1]); 325 dev_err(&spi->dev, "unknown chip:%02x,0\n", ids[1]);
327 goto err_drvdata; 326 return err;
328 } 327 }
329 ks->regs_attr.size = KSZ8864_REGS_SIZE; 328 ks->regs_attr.size = KSZ8864_REGS_SIZE;
330 } 329 }
331 330
332 err = ks8995_reset(ks); 331 err = ks8995_reset(ks);
333 if (err) 332 if (err)
334 goto err_drvdata; 333 return err;
335 334
336 err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr); 335 err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr);
337 if (err) { 336 if (err) {
338 dev_err(&spi->dev, "unable to create sysfs file, err=%d\n", 337 dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
339 err); 338 err);
340 goto err_drvdata; 339 return err;
341 } 340 }
342 341
343 if (get_chip_id(ids[1]) == CHIPID_M) { 342 if (get_chip_id(ids[1]) == CHIPID_M) {
@@ -350,21 +349,12 @@ static int ks8995_probe(struct spi_device *spi)
350 } 349 }
351 350
352 return 0; 351 return 0;
353
354err_drvdata:
355 kfree(ks);
356 return err;
357} 352}
358 353
359static int ks8995_remove(struct spi_device *spi) 354static int ks8995_remove(struct spi_device *spi)
360{ 355{
361 struct ks8995_data *ks8995;
362
363 ks8995 = spi_get_drvdata(spi);
364 sysfs_remove_bin_file(&spi->dev.kobj, &ks8995_registers_attr); 356 sysfs_remove_bin_file(&spi->dev.kobj, &ks8995_registers_attr);
365 357
366 kfree(ks8995);
367
368 return 0; 358 return 0;
369} 359}
370 360