{"action":"created","issue":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3751","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3751/labels{/name}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3751/comments","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3751/events","html_url":"https://github.com/RIOT-OS/RIOT/pull/3751","id":104077681,"number":3751,"title":"samd21/i2c: add feedback in case transfer failed","user":{"login":"daniel-k","id":224128,"avatar_url":"https://avatars.githubusercontent.com/u/224128?v=3","gravatar_id":"","url":"https://api.github.com/users/daniel-k","html_url":"https://github.com/daniel-k","followers_url":"https://api.github.com/users/daniel-k/followers","following_url":"https://api.github.com/users/daniel-k/following{/other_user}","gists_url":"https://api.github.com/users/daniel-k/gists{/gist_id}","starred_url":"https://api.github.com/users/daniel-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniel-k/subscriptions","organizations_url":"https://api.github.com/users/daniel-k/orgs","repos_url":"https://api.github.com/users/daniel-k/repos","events_url":"https://api.github.com/users/daniel-k/events{/privacy}","received_events_url":"https://api.github.com/users/daniel-k/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/Device%20driver","name":"Device driver","color":"0052cc"},{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/enhancement","name":"enhancement","color":"f17070"}],"state":"open","locked":false,"assignee":{"login":"bapclenet","id":4921425,"avatar_url":"https://avatars.githubusercontent.com/u/4921425?v=3","gravatar_id":"","url":"https://api.github.com/users/bapclenet","html_url":"https://github.com/bapclenet","followers_url":"https://api.github.com/users/bapclenet/followers","following_url":"https://api.github.com/users/bapclenet/following{/other_user}","gists_url":"https://api.github.com/users/bapclenet/gists{/gist_id}","starred_url":"https://api.github.com/users/bapclenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bapclenet/subscriptions","organizations_url":"https://api.github.com/users/bapclenet/orgs","repos_url":"https://api.github.com/users/bapclenet/repos","events_url":"https://api.github.com/users/bapclenet/events{/privacy}","received_events_url":"https://api.github.com/users/bapclenet/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-08-31T15:38:33Z","updated_at":"2015-09-04T16:39:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3751","html_url":"https://github.com/RIOT-OS/RIOT/pull/3751","diff_url":"https://github.com/RIOT-OS/RIOT/pull/3751.diff","patch_url":"https://github.com/RIOT-OS/RIOT/pull/3751.patch"},"body":"According to the I2C interface the return value of any read or write function is either 'the bytes transfered' or `-1` in case of undefined device.\r\n\r\nWith this PR those functions now return `0` in case of general failure, so the user/driver code can react accordingly."},"comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments/137786695","html_url":"https://github.com/RIOT-OS/RIOT/pull/3751#issuecomment-137786695","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3751","id":137786695,"user":{"login":"bapclenet","id":4921425,"avatar_url":"https://avatars.githubusercontent.com/u/4921425?v=3","gravatar_id":"","url":"https://api.github.com/users/bapclenet","html_url":"https://github.com/bapclenet","followers_url":"https://api.github.com/users/bapclenet/followers","following_url":"https://api.github.com/users/bapclenet/following{/other_user}","gists_url":"https://api.github.com/users/bapclenet/gists{/gist_id}","starred_url":"https://api.github.com/users/bapclenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bapclenet/subscriptions","organizations_url":"https://api.github.com/users/bapclenet/orgs","repos_url":"https://api.github.com/users/bapclenet/repos","events_url":"https://api.github.com/users/bapclenet/events{/privacy}","received_events_url":"https://api.github.com/users/bapclenet/received_events","type":"User","site_admin":false},"created_at":"2015-09-04T16:39:46Z","updated_at":"2015-09-04T16:39:46Z","body":"I definitely agree with PR, this is great that you had a look at it! I don't see any errors here. \r\nJust why do we need to return -4 for a kind of error if we don't return it afterwards? \r\nI mean, you wrote:\r\n\r\n    static inline int _write(SercomI2cm *dev, char *data, int length)\r\n    ...\r\n    return -4;\r\n\r\nAnd then \r\n\r\n    if(_write(i2c, (char *)(&reg), 1) < 0) return 0;\r\n\r\n\r\n-4 will never be handle by the device driver. So I don't know if it is really useful to return different value for different errors. What's your opinion?"}}