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

misc: at25: Make use of device property API

Make use of device property API in this driver so that both DT and ACPI
based systems can use this driver.

In addition we hard-code the name of the chip to be "at25" for the
reason that there is no common mechanism to fetch name of the firmware
node. The only existing user (arch/arm/boot/dts/phy3250.dts) uses the
same name so it should continue to work.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Mika Westerberg and committed by
Rafael J. Wysocki
f60e7074 733e6251

+13 -21
+13 -21
drivers/misc/eeprom/at25.c
··· 18 18 19 19 #include <linux/spi/spi.h> 20 20 #include <linux/spi/eeprom.h> 21 - #include <linux/of.h> 21 + #include <linux/property.h> 22 22 23 23 /* 24 24 * NOTE: this is an *EEPROM* driver. The vagaries of product naming ··· 301 301 302 302 /*-------------------------------------------------------------------------*/ 303 303 304 - static int at25_np_to_chip(struct device *dev, 305 - struct device_node *np, 306 - struct spi_eeprom *chip) 304 + static int at25_fw_to_chip(struct device *dev, struct spi_eeprom *chip) 307 305 { 308 306 u32 val; 309 307 310 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 || 314 - of_property_read_u32(np, "at25,byte-len", &val) == 0) { 311 + if (device_property_read_u32(dev, "size", &val) == 0 || 312 + device_property_read_u32(dev, "at25,byte-len", &val) == 0) { 315 313 chip->byte_len = val; 316 314 } else { 317 315 dev_err(dev, "Error: missing \"size\" property\n"); 318 316 return -ENODEV; 319 317 } 320 318 321 - if (of_property_read_u32(np, "pagesize", &val) == 0 || 322 - of_property_read_u32(np, "at25,page-size", &val) == 0) { 319 + if (device_property_read_u32(dev, "pagesize", &val) == 0 || 320 + device_property_read_u32(dev, "at25,page-size", &val) == 0) { 323 321 chip->page_size = (u16)val; 324 322 } else { 325 323 dev_err(dev, "Error: missing \"pagesize\" property\n"); 326 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 328 chip->flags = (u16)val; 331 329 } else { 332 - if (of_property_read_u32(np, "address-width", &val)) { 330 + if (device_property_read_u32(dev, "address-width", &val)) { 333 331 dev_err(dev, 334 332 "Error: missing \"address-width\" property\n"); 335 333 return -ENODEV; ··· 348 350 val); 349 351 return -ENODEV; 350 352 } 351 - if (of_find_property(np, "read-only", NULL)) 353 + if (device_property_present(dev, "read-only")) 352 354 chip->flags |= EE_READONLY; 353 355 } 354 356 return 0; ··· 358 360 { 359 361 struct at25_data *at25 = NULL; 360 362 struct spi_eeprom chip; 361 - struct device_node *np = spi->dev.of_node; 362 363 int err; 363 364 int sr; 364 365 int addrlen; 365 366 366 367 /* Chip description */ 367 368 if (!spi->dev.platform_data) { 368 - if (np) { 369 - err = at25_np_to_chip(&spi->dev, np, &chip); 370 - if (err) 371 - return err; 372 - } else { 373 - dev_err(&spi->dev, "Error: no chip description\n"); 374 - return -ENODEV; 375 - } 369 + err = at25_fw_to_chip(&spi->dev, &chip); 370 + if (err) 371 + return err; 376 372 } else 377 373 chip = *(struct spi_eeprom *)spi->dev.platform_data; 378 374