diff options
Diffstat (limited to 'drivers/misc/eeprom/at25.c')
-rw-r--r-- | drivers/misc/eeprom/at25.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c index 634f72929e12..0a1af93ec638 100644 --- a/drivers/misc/eeprom/at25.c +++ b/drivers/misc/eeprom/at25.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/spi/spi.h> | 19 | #include <linux/spi/spi.h> |
20 | #include <linux/spi/eeprom.h> | 20 | #include <linux/spi/eeprom.h> |
21 | #include <linux/of.h> | 21 | #include <linux/property.h> |
22 | 22 | ||
23 | /* | 23 | /* |
24 | * NOTE: this is an *EEPROM* driver. The vagaries of product naming | 24 | * NOTE: this is an *EEPROM* driver. The vagaries of product naming |
@@ -301,35 +301,33 @@ static ssize_t at25_mem_write(struct memory_accessor *mem, const char *buf, | |||
301 | 301 | ||
302 | /*-------------------------------------------------------------------------*/ | 302 | /*-------------------------------------------------------------------------*/ |
303 | 303 | ||
304 | static int at25_np_to_chip(struct device *dev, | 304 | static int at25_fw_to_chip(struct device *dev, struct spi_eeprom *chip) |
305 | struct device_node *np, | ||
306 | struct spi_eeprom *chip) | ||
307 | { | 305 | { |
308 | u32 val; | 306 | u32 val; |
309 | 307 | ||
310 | memset(chip, 0, sizeof(*chip)); | 308 | memset(chip, 0, sizeof(*chip)); |
311 | strncpy(chip->name, np->name, sizeof(chip->name)); | 309 | strncpy(chip->name, "at25", sizeof(chip->name)); |
312 | 310 | ||
313 | if (of_property_read_u32(np, "size", &val) == 0 || | 311 | if (device_property_read_u32(dev, "size", &val) == 0 || |
314 | of_property_read_u32(np, "at25,byte-len", &val) == 0) { | 312 | device_property_read_u32(dev, "at25,byte-len", &val) == 0) { |
315 | chip->byte_len = val; | 313 | chip->byte_len = val; |
316 | } else { | 314 | } else { |
317 | dev_err(dev, "Error: missing \"size\" property\n"); | 315 | dev_err(dev, "Error: missing \"size\" property\n"); |
318 | return -ENODEV; | 316 | return -ENODEV; |
319 | } | 317 | } |
320 | 318 | ||
321 | if (of_property_read_u32(np, "pagesize", &val) == 0 || | 319 | if (device_property_read_u32(dev, "pagesize", &val) == 0 || |
322 | of_property_read_u32(np, "at25,page-size", &val) == 0) { | 320 | device_property_read_u32(dev, "at25,page-size", &val) == 0) { |
323 | chip->page_size = (u16)val; | 321 | chip->page_size = (u16)val; |
324 | } else { | 322 | } else { |
325 | dev_err(dev, "Error: missing \"pagesize\" property\n"); | 323 | dev_err(dev, "Error: missing \"pagesize\" property\n"); |
326 | return -ENODEV; | 324 | return -ENODEV; |
327 | } | 325 | } |
328 | 326 | ||
329 | if (of_property_read_u32(np, "at25,addr-mode", &val) == 0) { | 327 | if (device_property_read_u32(dev, "at25,addr-mode", &val) == 0) { |
330 | chip->flags = (u16)val; | 328 | chip->flags = (u16)val; |
331 | } else { | 329 | } else { |
332 | if (of_property_read_u32(np, "address-width", &val)) { | 330 | if (device_property_read_u32(dev, "address-width", &val)) { |
333 | dev_err(dev, | 331 | dev_err(dev, |
334 | "Error: missing \"address-width\" property\n"); | 332 | "Error: missing \"address-width\" property\n"); |
335 | return -ENODEV; | 333 | return -ENODEV; |
@@ -350,7 +348,7 @@ static int at25_np_to_chip(struct device *dev, | |||
350 | val); | 348 | val); |
351 | return -ENODEV; | 349 | return -ENODEV; |
352 | } | 350 | } |
353 | if (of_find_property(np, "read-only", NULL)) | 351 | if (device_property_present(dev, "read-only")) |
354 | chip->flags |= EE_READONLY; | 352 | chip->flags |= EE_READONLY; |
355 | } | 353 | } |
356 | return 0; | 354 | return 0; |
@@ -360,21 +358,15 @@ static int at25_probe(struct spi_device *spi) | |||
360 | { | 358 | { |
361 | struct at25_data *at25 = NULL; | 359 | struct at25_data *at25 = NULL; |
362 | struct spi_eeprom chip; | 360 | struct spi_eeprom chip; |
363 | struct device_node *np = spi->dev.of_node; | ||
364 | int err; | 361 | int err; |
365 | int sr; | 362 | int sr; |
366 | int addrlen; | 363 | int addrlen; |
367 | 364 | ||
368 | /* Chip description */ | 365 | /* Chip description */ |
369 | if (!spi->dev.platform_data) { | 366 | if (!spi->dev.platform_data) { |
370 | if (np) { | 367 | err = at25_fw_to_chip(&spi->dev, &chip); |
371 | err = at25_np_to_chip(&spi->dev, np, &chip); | 368 | if (err) |
372 | if (err) | 369 | return err; |
373 | return err; | ||
374 | } else { | ||
375 | dev_err(&spi->dev, "Error: no chip description\n"); | ||
376 | return -ENODEV; | ||
377 | } | ||
378 | } else | 370 | } else |
379 | chip = *(struct spi_eeprom *)spi->dev.platform_data; | 371 | chip = *(struct spi_eeprom *)spi->dev.platform_data; |
380 | 372 | ||