title: I2C_SLAVE ioctl purpose
body: <p>I am writing code for implementing a simple <code>i2c</code> read/write function using the general linux <code>i2c</code> driver <code>linux/i2c-dev.h</code></p>
  
  <p>I am confused about the <code>ioctl</code> : <code>I2C_SLAVE</code></p>
  
  <p>The kernel documentation states as follows :</p>
  
  <blockquote>
    <p>You can do plain i2c transactions by using read(2) and write(2) calls.
    You do not need to pass the address byte; instead, set it through
    ioctl I2C_SLAVE before you try to access the device</p>
  </blockquote>
  
  <p>However I am using the <code>ioctl I2C_RDWR</code> where I again set the slave address  using <code>i2c_msg.addr</code>.</p>
  
  <p>The kernel documentation also mentions the following :</p>
  
  <blockquote>
    <p>Some ioctl() calls are for administrative tasks and are handled by
    i2c-dev directly. Examples include I2C_SLAVE</p>
  </blockquote>
  
  <p>So is it must to use the <code>ioctl I2C_SLAVE</code>? If so do I need to set it just once or every time I perform a read and write?</p>
  
  <p>If I had an <code>i2c</code> device I could have just tested the code on the device and would not have bothered you guys but unfortunately I don't have one right now. </p>
  
  <p>Thanks for the help.</p>