~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/i2c-dev.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/i2c-dev.h (Version linux-6.12-rc7) and /include/linux/i2c-dev.h (Version linux-2.4.37.11)


  1 /* SPDX-License-Identifier: GPL-2.0-or-later * << 
  2 /*                                                  1 /*
  3     i2c-dev.h - i2c-bus driver, char device in      2     i2c-dev.h - i2c-bus driver, char device interface
  4                                                     3 
  5     Copyright (C) 1995-97 Simon G. Vogl             4     Copyright (C) 1995-97 Simon G. Vogl
  6     Copyright (C) 1998-99 Frodo Looijaard <fro      5     Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
  7                                                     6 
                                                   >>   7     This program is free software; you can redistribute it and/or modify
                                                   >>   8     it under the terms of the GNU General Public License as published by
                                                   >>   9     the Free Software Foundation; either version 2 of the License, or
                                                   >>  10     (at your option) any later version.
                                                   >>  11 
                                                   >>  12     This program is distributed in the hope that it will be useful,
                                                   >>  13     but WITHOUT ANY WARRANTY; without even the implied warranty of
                                                   >>  14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                                                   >>  15     GNU General Public License for more details.
                                                   >>  16 
                                                   >>  17     You should have received a copy of the GNU General Public License
                                                   >>  18     along with this program; if not, write to the Free Software
                                                   >>  19     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  8 */                                                 20 */
  9 #ifndef _LINUX_I2C_DEV_H                       << 
 10 #define _LINUX_I2C_DEV_H                       << 
 11                                                    21 
 12 #include <uapi/linux/i2c-dev.h>                !!  22 /* $Id: i2c-dev.h,v 1.9 2001/08/15 03:04:58 mds Exp $ */
                                                   >>  23 
                                                   >>  24 #ifndef I2C_DEV_H
                                                   >>  25 #define I2C_DEV_H
                                                   >>  26 
                                                   >>  27 
                                                   >>  28 #include <linux/types.h>
                                                   >>  29 #include <linux/i2c.h>
                                                   >>  30 
                                                   >>  31 /* Some IOCTL commands are defined in <linux/i2c.h> */
                                                   >>  32 /* Note: 10-bit addresses are NOT supported! */
                                                   >>  33 
                                                   >>  34 /* This is the structure as used in the I2C_SMBUS ioctl call */
                                                   >>  35 struct i2c_smbus_ioctl_data {
                                                   >>  36         __u8 read_write;
                                                   >>  37         __u8 command;
                                                   >>  38         __u32 size;
                                                   >>  39         union i2c_smbus_data *data;
                                                   >>  40 };
                                                   >>  41 
                                                   >>  42 /* This is the structure as used in the I2C_RDWR ioctl call */
                                                   >>  43 struct i2c_rdwr_ioctl_data {
                                                   >>  44         struct i2c_msg *msgs;   /* pointers to i2c_msgs */
                                                   >>  45         __u32 nmsgs;            /* number of i2c_msgs */
                                                   >>  46 };
                                                   >>  47 
                                                   >>  48 #ifndef __KERNEL__
                                                   >>  49 
                                                   >>  50 #include <sys/ioctl.h>
                                                   >>  51 
                                                   >>  52 static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, 
                                                   >>  53                                      int size, union i2c_smbus_data *data)
                                                   >>  54 {
                                                   >>  55         struct i2c_smbus_ioctl_data args;
                                                   >>  56 
                                                   >>  57         args.read_write = read_write;
                                                   >>  58         args.command = command;
                                                   >>  59         args.size = size;
                                                   >>  60         args.data = data;
                                                   >>  61         return ioctl(file,I2C_SMBUS,&args);
                                                   >>  62 }
                                                   >>  63 
                                                   >>  64 
                                                   >>  65 static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
                                                   >>  66 {
                                                   >>  67         return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
                                                   >>  68 }
                                                   >>  69         
                                                   >>  70 static inline __s32 i2c_smbus_read_byte(int file)
                                                   >>  71 {
                                                   >>  72         union i2c_smbus_data data;
                                                   >>  73         if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))
                                                   >>  74                 return -1;
                                                   >>  75         else
                                                   >>  76                 return 0x0FF & data.byte;
                                                   >>  77 }
                                                   >>  78 
                                                   >>  79 static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
                                                   >>  80 {
                                                   >>  81         return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,
                                                   >>  82                                 I2C_SMBUS_BYTE,NULL);
                                                   >>  83 }
                                                   >>  84 
                                                   >>  85 static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
                                                   >>  86 {
                                                   >>  87         union i2c_smbus_data data;
                                                   >>  88         if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
                                                   >>  89                              I2C_SMBUS_BYTE_DATA,&data))
                                                   >>  90                 return -1;
                                                   >>  91         else
                                                   >>  92                 return 0x0FF & data.byte;
                                                   >>  93 }
                                                   >>  94 
                                                   >>  95 static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command, 
                                                   >>  96                                               __u8 value)
                                                   >>  97 {
                                                   >>  98         union i2c_smbus_data data;
                                                   >>  99         data.byte = value;
                                                   >> 100         return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
                                                   >> 101                                 I2C_SMBUS_BYTE_DATA, &data);
                                                   >> 102 }
                                                   >> 103 
                                                   >> 104 static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
                                                   >> 105 {
                                                   >> 106         union i2c_smbus_data data;
                                                   >> 107         if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
                                                   >> 108                              I2C_SMBUS_WORD_DATA,&data))
                                                   >> 109                 return -1;
                                                   >> 110         else
                                                   >> 111                 return 0x0FFFF & data.word;
                                                   >> 112 }
                                                   >> 113 
                                                   >> 114 static inline __s32 i2c_smbus_write_word_data(int file, __u8 command, 
                                                   >> 115                                               __u16 value)
                                                   >> 116 {
                                                   >> 117         union i2c_smbus_data data;
                                                   >> 118         data.word = value;
                                                   >> 119         return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
                                                   >> 120                                 I2C_SMBUS_WORD_DATA, &data);
                                                   >> 121 }
                                                   >> 122 
                                                   >> 123 static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
                                                   >> 124 {
                                                   >> 125         union i2c_smbus_data data;
                                                   >> 126         data.word = value;
                                                   >> 127         if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
                                                   >> 128                              I2C_SMBUS_PROC_CALL,&data))
                                                   >> 129                 return -1;
                                                   >> 130         else
                                                   >> 131                 return 0x0FFFF & data.word;
                                                   >> 132 }
                                                   >> 133 
                                                   >> 134 
                                                   >> 135 /* Returns the number of read bytes */
                                                   >> 136 static inline __s32 i2c_smbus_read_block_data(int file, __u8 command, 
                                                   >> 137                                               __u8 *values)
                                                   >> 138 {
                                                   >> 139         union i2c_smbus_data data;
                                                   >> 140         int i;
                                                   >> 141         if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
                                                   >> 142                              I2C_SMBUS_BLOCK_DATA,&data))
                                                   >> 143                 return -1;
                                                   >> 144         else {
                                                   >> 145                 for (i = 1; i <= data.block[0]; i++)
                                                   >> 146                         values[i-1] = data.block[i];
                                                   >> 147                         return data.block[0];
                                                   >> 148         }
                                                   >> 149 }
                                                   >> 150 
                                                   >> 151 static inline __s32 i2c_smbus_write_block_data(int file, __u8 command, 
                                                   >> 152                                                __u8 length, __u8 *values)
                                                   >> 153 {
                                                   >> 154         union i2c_smbus_data data;
                                                   >> 155         int i;
                                                   >> 156         if (length > 32)
                                                   >> 157                 length = 32;
                                                   >> 158         for (i = 1; i <= length; i++)
                                                   >> 159                 data.block[i] = values[i-1];
                                                   >> 160         data.block[0] = length;
                                                   >> 161         return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
                                                   >> 162                                 I2C_SMBUS_BLOCK_DATA, &data);
                                                   >> 163 }
                                                   >> 164 
                                                   >> 165 static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
                                                   >> 166                                                __u8 length, __u8 *values)
                                                   >> 167 {
                                                   >> 168         union i2c_smbus_data data;
                                                   >> 169         int i;
                                                   >> 170         if (length > 32)
                                                   >> 171                 length = 32;
                                                   >> 172         for (i = 1; i <= length; i++)
                                                   >> 173                 data.block[i] = values[i-1];
                                                   >> 174         data.block[0] = length;
                                                   >> 175         return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
                                                   >> 176                                 I2C_SMBUS_I2C_BLOCK_DATA, &data);
                                                   >> 177 }
                                                   >> 178 
                                                   >> 179 #endif /* ndef __KERNEL__ */
 13                                                   180 
 14 #define I2C_MAJOR       89              /* Dev !! 181 #endif
 15 #endif /* _LINUX_I2C_DEV_H */                  << 
 16                                                   182 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php