Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 273271
b: refs/heads/master
c: 9fe678f
h: refs/heads/master
i:
  273269: 16d4448
  273267: cb3f132
  273263: 44fbafd
v: v3
  • Loading branch information
Clifton Barnes authored and Linus Torvalds committed Nov 2, 2011
1 parent ebfe4a6 commit 916c179
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 853eee72f74f449797f0500ea19fc1bf497428d8
refs/heads/master: 9fe678fa2feb4aaac0b4220de63e1b7f8ccebae6
48 changes: 35 additions & 13 deletions trunk/drivers/w1/slaves/w1_ds2780.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,64 @@
#include "../w1_family.h"
#include "w1_ds2780.h"

int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count,
int io)
static int w1_ds2780_do_io(struct device *dev, char *buf, int addr,
size_t count, int io)
{
struct w1_slave *sl = container_of(dev, struct w1_slave, dev);

if (!dev)
return -ENODEV;
if (addr > DS2780_DATA_SIZE || addr < 0)
return 0;

mutex_lock(&sl->master->mutex);

if (addr > DS2780_DATA_SIZE || addr < 0) {
count = 0;
goto out;
}
count = min_t(int, count, DS2780_DATA_SIZE - addr);

if (w1_reset_select_slave(sl) == 0) {
if (io) {
w1_write_8(sl->master, W1_DS2780_WRITE_DATA);
w1_write_8(sl->master, addr);
w1_write_block(sl->master, buf, count);
/* XXX w1_write_block returns void, not n_written */
} else {
w1_write_8(sl->master, W1_DS2780_READ_DATA);
w1_write_8(sl->master, addr);
count = w1_read_block(sl->master, buf, count);
}
}

out:
return count;
}

int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count,
int io)
{
struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
int ret;

if (!dev)
return -ENODEV;

mutex_lock(&sl->master->mutex);

ret = w1_ds2780_do_io(dev, buf, addr, count, io);

mutex_unlock(&sl->master->mutex);

return count;
return ret;
}
EXPORT_SYMBOL(w1_ds2780_io);

int w1_ds2780_io_nolock(struct device *dev, char *buf, int addr, size_t count,
int io)
{
int ret;

if (!dev)
return -ENODEV;

ret = w1_ds2780_do_io(dev, buf, addr, count, io);

return ret;
}
EXPORT_SYMBOL(w1_ds2780_io_nolock);

int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd)
{
struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/w1/slaves/w1_ds2780.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@

extern int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count,
int io);
extern int w1_ds2780_io_nolock(struct device *dev, char *buf, int addr,
size_t count, int io);
extern int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd);

#endif /* !_W1_DS2780_H */

0 comments on commit 916c179

Please sign in to comment.