aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-14 15:54:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-14 15:54:40 -0500
commit96895199c8648db475b38aac5fe6a04ec14a49c4 (patch)
tree3cb2a2a68a4750de20cf3deddd4a897189164ea9 /drivers/misc
parent8fd9589ced9a4ab1cf23296fa1c17d07e883f734 (diff)
parent6cf710d47633be388e831713738626d1911163c8 (diff)
Merge branch 'i2c/for-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang: "For 3.19, the I2C subsystem has to offer special candy this time. Right in time for Christmas :) - I2C slave framework: finally, a generic mechanism for Linux being an I2C slave (if the bus driver supports that). Docs are still missing but will come later this cycle, the code is good enough to go. - I2C muxes represent their topology in sysfs much more detailed. This will help users to navigate around much easier. - irq population of i2c clients is now done at probe time, not device creation time, to have better support for deferred probing. - new drivers for Imagination SCB, Amlogic Meson - DMA support added for Freescale IMX, Renesas SHMobile - slightly bigger driver updates to OMAP, i801, AT91, and rk3x (mostly quirk handling, timing updates, and using better kernel interfaces) - eeprom driver can now write with byte-access (very slow, but OK to have) - and the bunch of smaller fixes, cleanups, ID updates..." * 'i2c/for-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (56 commits) i2c: sh_mobile: remove unneeded DMA mask i2c: rcar: add slave support i2c: slave-eeprom: add eeprom simulator driver i2c: core changes for slave support MAINTAINERS: add I2C dt bindings also to I2C realm i2c: designware: Fix falling time bindings doc i2c: davinci: switch to use platform_get_irq Documentation: i2c: Use PM ops instead of legacy suspend/resume i2c: sh_mobile: optimize irq entry i2c: pxa: add support for SCCB devices omap: i2c: don't check bus state IP rev3.3 and earlier i2c: s3c2410: Handle i2c sys_cfg register in i2c driver i2c: rk3x: add Kconfig dependency on COMMON_CLK i2c: omap: add notes related to i2c multimaster mode i2c: omap: don't reset controller if Arbitration Lost detected i2c: omap: implement workaround for handling invalid BB-bit values i2c: omap: cleanup register definitions i2c: rk3x: handle dynamic clock rate changes correctly i2c: at91: enable probe deferring on dma channel request i2c: at91: remove legacy DMA support ...
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/eeprom/at24.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index d87f77f790d6..2d3db81be099 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -56,6 +56,7 @@ struct at24_data {
56 struct at24_platform_data chip; 56 struct at24_platform_data chip;
57 struct memory_accessor macc; 57 struct memory_accessor macc;
58 int use_smbus; 58 int use_smbus;
59 int use_smbus_write;
59 60
60 /* 61 /*
61 * Lock protects against activities from other Linux tasks, 62 * Lock protects against activities from other Linux tasks,
@@ -324,7 +325,7 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
324{ 325{
325 struct i2c_client *client; 326 struct i2c_client *client;
326 struct i2c_msg msg; 327 struct i2c_msg msg;
327 ssize_t status; 328 ssize_t status = 0;
328 unsigned long timeout, write_time; 329 unsigned long timeout, write_time;
329 unsigned next_page; 330 unsigned next_page;
330 331
@@ -365,9 +366,18 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
365 timeout = jiffies + msecs_to_jiffies(write_timeout); 366 timeout = jiffies + msecs_to_jiffies(write_timeout);
366 do { 367 do {
367 write_time = jiffies; 368 write_time = jiffies;
368 if (at24->use_smbus) { 369 if (at24->use_smbus_write) {
369 status = i2c_smbus_write_i2c_block_data(client, 370 switch (at24->use_smbus_write) {
370 offset, count, buf); 371 case I2C_SMBUS_I2C_BLOCK_DATA:
372 status = i2c_smbus_write_i2c_block_data(client,
373 offset, count, buf);
374 break;
375 case I2C_SMBUS_BYTE_DATA:
376 status = i2c_smbus_write_byte_data(client,
377 offset, buf[0]);
378 break;
379 }
380
371 if (status == 0) 381 if (status == 0)
372 status = count; 382 status = count;
373 } else { 383 } else {
@@ -487,6 +497,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
487 struct at24_platform_data chip; 497 struct at24_platform_data chip;
488 bool writable; 498 bool writable;
489 int use_smbus = 0; 499 int use_smbus = 0;
500 int use_smbus_write = 0;
490 struct at24_data *at24; 501 struct at24_data *at24;
491 int err; 502 int err;
492 unsigned i, num_addresses; 503 unsigned i, num_addresses;
@@ -546,6 +557,18 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
546 } 557 }
547 } 558 }
548 559
560 /* Use I2C operations unless we're stuck with SMBus extensions. */
561 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
562 if (i2c_check_functionality(client->adapter,
563 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
564 use_smbus_write = I2C_SMBUS_I2C_BLOCK_DATA;
565 } else if (i2c_check_functionality(client->adapter,
566 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
567 use_smbus_write = I2C_SMBUS_BYTE_DATA;
568 chip.page_size = 1;
569 }
570 }
571
549 if (chip.flags & AT24_FLAG_TAKE8ADDR) 572 if (chip.flags & AT24_FLAG_TAKE8ADDR)
550 num_addresses = 8; 573 num_addresses = 8;
551 else 574 else
@@ -559,6 +582,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
559 582
560 mutex_init(&at24->lock); 583 mutex_init(&at24->lock);
561 at24->use_smbus = use_smbus; 584 at24->use_smbus = use_smbus;
585 at24->use_smbus_write = use_smbus_write;
562 at24->chip = chip; 586 at24->chip = chip;
563 at24->num_addresses = num_addresses; 587 at24->num_addresses = num_addresses;
564 588
@@ -576,8 +600,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
576 600
577 writable = !(chip.flags & AT24_FLAG_READONLY); 601 writable = !(chip.flags & AT24_FLAG_READONLY);
578 if (writable) { 602 if (writable) {
579 if (!use_smbus || i2c_check_functionality(client->adapter, 603 if (!use_smbus || use_smbus_write) {
580 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
581 604
582 unsigned write_max = chip.page_size; 605 unsigned write_max = chip.page_size;
583 606