Accepting request 339004 from Base:System
- Backport r6048 and r6053 in order to not conflict with linux-glibc-devel i2c-tools-r6048-Move-SMBus-helper-functions.patch i2c-tools-r6053-Add-smbus-header.patch (forwarded request 338994 from k0da) OBS-URL: https://build.opensuse.org/request/show/339004 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/i2c-tools?expand=0&rev=29
This commit is contained in:
commit
6c19ec8926
451
i2c-tools-r6048-Move-SMBus-helper-functions.patch
Normal file
451
i2c-tools-r6048-Move-SMBus-helper-functions.patch
Normal file
@ -0,0 +1,451 @@
|
||||
From 3ceb5a7870cb236981b7c3b5c5b9665dcb1ebe27 Mon Sep 17 00:00:00 2001
|
||||
From: Jean Delvare <khali@linux-fr.org>
|
||||
Date: Thu, 26 Apr 2012 10:10:22 +0000
|
||||
Subject: [PATCH] i2c-dev: Move SMBus helper functions to include/i2c/smbus.h
|
||||
|
||||
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6048 7894878c-1315-0410-8ee3-d5d059ff63e0
|
||||
---
|
||||
eepromer/24cXX.c | 3 +
|
||||
eepromer/24cXX.h | 2 +-
|
||||
eepromer/eeprom.c | 2 +
|
||||
eepromer/eepromer.c | 2 +
|
||||
include/Module.mk | 6 +-
|
||||
include/linux/i2c-dev.h | 257 ------------------------------------------------
|
||||
py-smbus/Module.mk | 2 +-
|
||||
py-smbus/smbusmodule.c | 3 +
|
||||
tools/Module.mk | 12 +--
|
||||
tools/i2cbusses.c | 4 +-
|
||||
tools/i2cdetect.c | 5 +-
|
||||
tools/i2cdump.c | 5 +-
|
||||
tools/i2cget.c | 5 +-
|
||||
tools/i2cset.c | 5 +-
|
||||
15 files changed, 41 insertions(+), 273 deletions(-)
|
||||
|
||||
diff --git a/include/Module.mk b/include/Module.mk
|
||||
index fda7cfb..4a9713c 100644
|
||||
--- a/include/Module.mk
|
||||
+++ b/include/Module.mk
|
||||
@@ -9,14 +9,14 @@
|
||||
|
||||
INCLUDE_DIR := include
|
||||
|
||||
-INCLUDE_TARGETS := linux/i2c-dev.h
|
||||
+INCLUDE_TARGETS := i2c/smbus.h
|
||||
|
||||
#
|
||||
# Commands
|
||||
#
|
||||
|
||||
install-include: $(addprefix $(INCLUDE_DIR)/,$(INCLUDE_TARGETS))
|
||||
- $(INSTALL_DIR) $(DESTDIR)$(incdir)/linux
|
||||
+ $(INSTALL_DIR) $(DESTDIR)$(incdir)/i2c
|
||||
for file in $(INCLUDE_TARGETS) ; do \
|
||||
$(INSTALL_DATA) $(INCLUDE_DIR)/$$file $(DESTDIR)$(incdir)/$$file ; done
|
||||
|
||||
diff --git a/include/linux/i2c-dev.h b/include/linux/i2c-dev.h
|
||||
index 23f7c2c..64166c6 100644
|
||||
--- a/include/linux/i2c-dev.h
|
||||
+++ b/include/linux/i2c-dev.h
|
||||
@@ -24,91 +24,9 @@
|
||||
#define _LINUX_I2C_DEV_H
|
||||
|
||||
#include <linux/types.h>
|
||||
-#include <sys/ioctl.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
-/* -- i2c.h -- */
|
||||
-
|
||||
-
|
||||
-/*
|
||||
- * I2C Message - used for pure i2c transaction, also from /dev interface
|
||||
- */
|
||||
-struct i2c_msg {
|
||||
- __u16 addr; /* slave address */
|
||||
- unsigned short flags;
|
||||
-#define I2C_M_TEN 0x10 /* we have a ten bit chip address */
|
||||
-#define I2C_M_RD 0x01
|
||||
-#define I2C_M_NOSTART 0x4000
|
||||
-#define I2C_M_REV_DIR_ADDR 0x2000
|
||||
-#define I2C_M_IGNORE_NAK 0x1000
|
||||
-#define I2C_M_NO_RD_ACK 0x0800
|
||||
- short len; /* msg length */
|
||||
- char *buf; /* pointer to msg data */
|
||||
-};
|
||||
-
|
||||
-/* To determine what functionality is present */
|
||||
-
|
||||
-#define I2C_FUNC_I2C 0x00000001
|
||||
-#define I2C_FUNC_10BIT_ADDR 0x00000002
|
||||
-#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
|
||||
-#define I2C_FUNC_SMBUS_PEC 0x00000008
|
||||
-#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
|
||||
-#define I2C_FUNC_SMBUS_QUICK 0x00010000
|
||||
-#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
|
||||
-#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
|
||||
-#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
|
||||
-#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
|
||||
-#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
|
||||
-#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
|
||||
-#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
|
||||
-#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
|
||||
-#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
|
||||
-#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
|
||||
-#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
|
||||
-
|
||||
-#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
|
||||
- I2C_FUNC_SMBUS_WRITE_BYTE)
|
||||
-#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
|
||||
- I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
|
||||
-#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
|
||||
- I2C_FUNC_SMBUS_WRITE_WORD_DATA)
|
||||
-#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
|
||||
- I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
|
||||
-#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
|
||||
- I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
|
||||
-
|
||||
-/* Old name, for compatibility */
|
||||
-#define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC
|
||||
-
|
||||
-/*
|
||||
- * Data for SMBus Messages
|
||||
- */
|
||||
-#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
|
||||
-#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
|
||||
-union i2c_smbus_data {
|
||||
- __u8 byte;
|
||||
- __u16 word;
|
||||
- __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
|
||||
- /* and one more for PEC */
|
||||
-};
|
||||
-
|
||||
-/* smbus_access read or write markers */
|
||||
-#define I2C_SMBUS_READ 1
|
||||
-#define I2C_SMBUS_WRITE 0
|
||||
-
|
||||
-/* SMBus transaction types (size parameter in the above functions)
|
||||
- Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
|
||||
-#define I2C_SMBUS_QUICK 0
|
||||
-#define I2C_SMBUS_BYTE 1
|
||||
-#define I2C_SMBUS_BYTE_DATA 2
|
||||
-#define I2C_SMBUS_WORD_DATA 3
|
||||
-#define I2C_SMBUS_PROC_CALL 4
|
||||
-#define I2C_SMBUS_BLOCK_DATA 5
|
||||
-#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
|
||||
-#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
|
||||
-#define I2C_SMBUS_I2C_BLOCK_DATA 8
|
||||
-
|
||||
|
||||
/* /dev/i2c-X ioctl commands. The ioctl's parameter is always an
|
||||
* unsigned long, except for:
|
||||
@@ -153,178 +71,4 @@ struct i2c_rdwr_ioctl_data {
|
||||
#define I2C_RDRW_IOCTL_MAX_MSGS 42
|
||||
|
||||
|
||||
-static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
|
||||
- int size, union i2c_smbus_data *data)
|
||||
-{
|
||||
- struct i2c_smbus_ioctl_data args;
|
||||
-
|
||||
- args.read_write = read_write;
|
||||
- args.command = command;
|
||||
- args.size = size;
|
||||
- args.data = data;
|
||||
- return ioctl(file,I2C_SMBUS,&args);
|
||||
-}
|
||||
-
|
||||
-
|
||||
-static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
|
||||
-{
|
||||
- return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_read_byte(int file)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))
|
||||
- return -1;
|
||||
- else
|
||||
- return 0x0FF & data.byte;
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
|
||||
-{
|
||||
- return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,
|
||||
- I2C_SMBUS_BYTE,NULL);
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
- I2C_SMBUS_BYTE_DATA,&data))
|
||||
- return -1;
|
||||
- else
|
||||
- return 0x0FF & data.byte;
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
|
||||
- __u8 value)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- data.byte = value;
|
||||
- return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
- I2C_SMBUS_BYTE_DATA, &data);
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
- I2C_SMBUS_WORD_DATA,&data))
|
||||
- return -1;
|
||||
- else
|
||||
- return 0x0FFFF & data.word;
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
|
||||
- __u16 value)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- data.word = value;
|
||||
- return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
- I2C_SMBUS_WORD_DATA, &data);
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- data.word = value;
|
||||
- if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
- I2C_SMBUS_PROC_CALL,&data))
|
||||
- return -1;
|
||||
- else
|
||||
- return 0x0FFFF & data.word;
|
||||
-}
|
||||
-
|
||||
-
|
||||
-/* Returns the number of read bytes */
|
||||
-static inline __s32 i2c_smbus_read_block_data(int file, __u8 command,
|
||||
- __u8 *values)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- int i;
|
||||
- if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
- I2C_SMBUS_BLOCK_DATA,&data))
|
||||
- return -1;
|
||||
- else {
|
||||
- for (i = 1; i <= data.block[0]; i++)
|
||||
- values[i-1] = data.block[i];
|
||||
- return data.block[0];
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
|
||||
- __u8 length, const __u8 *values)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- int i;
|
||||
- if (length > 32)
|
||||
- length = 32;
|
||||
- for (i = 1; i <= length; i++)
|
||||
- data.block[i] = values[i-1];
|
||||
- data.block[0] = length;
|
||||
- return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
- I2C_SMBUS_BLOCK_DATA, &data);
|
||||
-}
|
||||
-
|
||||
-/* Returns the number of read bytes */
|
||||
-/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
|
||||
- ask for less than 32 bytes, your code will only work with kernels
|
||||
- 2.6.23 and later. */
|
||||
-static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
|
||||
- __u8 length, __u8 *values)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- int i;
|
||||
-
|
||||
- if (length > 32)
|
||||
- length = 32;
|
||||
- data.block[0] = length;
|
||||
- if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
- length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
|
||||
- I2C_SMBUS_I2C_BLOCK_DATA,&data))
|
||||
- return -1;
|
||||
- else {
|
||||
- for (i = 1; i <= data.block[0]; i++)
|
||||
- values[i-1] = data.block[i];
|
||||
- return data.block[0];
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
|
||||
- __u8 length,
|
||||
- const __u8 *values)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- int i;
|
||||
- if (length > 32)
|
||||
- length = 32;
|
||||
- for (i = 1; i <= length; i++)
|
||||
- data.block[i] = values[i-1];
|
||||
- data.block[0] = length;
|
||||
- return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
- I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
|
||||
-}
|
||||
-
|
||||
-/* Returns the number of read bytes */
|
||||
-static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,
|
||||
- __u8 length, __u8 *values)
|
||||
-{
|
||||
- union i2c_smbus_data data;
|
||||
- int i;
|
||||
- if (length > 32)
|
||||
- length = 32;
|
||||
- for (i = 1; i <= length; i++)
|
||||
- data.block[i] = values[i-1];
|
||||
- data.block[0] = length;
|
||||
- if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
- I2C_SMBUS_BLOCK_PROC_CALL,&data))
|
||||
- return -1;
|
||||
- else {
|
||||
- for (i = 1; i <= data.block[0]; i++)
|
||||
- values[i-1] = data.block[i];
|
||||
- return data.block[0];
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-
|
||||
#endif /* _LINUX_I2C_DEV_H */
|
||||
diff --git a/py-smbus/Module.mk b/py-smbus/Module.mk
|
||||
index 138a789..fc2b201 100644
|
||||
--- a/py-smbus/Module.mk
|
||||
+++ b/py-smbus/Module.mk
|
||||
@@ -14,7 +14,7 @@ DISTUTILS := \
|
||||
cd $(PY_SMBUS_DIR) && \
|
||||
CPPFLAGS="$(CPPFLAGS) -I../include" $(PYTHON) setup.py
|
||||
|
||||
-all-python: $(INCLUDE_DIR)/linux/i2c-dev.h
|
||||
+all-python: $(INCLUDE_DIR)/i2c/smbus.h
|
||||
$(DISTUTILS) build
|
||||
|
||||
clean-python:
|
||||
diff --git a/py-smbus/smbusmodule.c b/py-smbus/smbusmodule.c
|
||||
index 86e8e13..d360a36 100644
|
||||
--- a/py-smbus/smbusmodule.c
|
||||
+++ b/py-smbus/smbusmodule.c
|
||||
@@ -22,7 +22,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
+#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
+#include <i2c/smbus.h>
|
||||
|
||||
/*
|
||||
** These are required to build this module against Linux older than 2.6.23.
|
||||
diff --git a/tools/Module.mk b/tools/Module.mk
|
||||
index 8ad8fc0..33ae774 100644
|
||||
--- a/tools/Module.mk
|
||||
+++ b/tools/Module.mk
|
||||
@@ -1,6 +1,6 @@
|
||||
# I2C tools for Linux
|
||||
#
|
||||
-# Copyright (C) 2007 Jean Delvare <jdelvare@suse.de>
|
||||
+# Copyright (C) 2007, 2012 Jean Delvare <khali@linux-fr.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -35,19 +35,19 @@ $(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cget.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)
|
||||
# Objects
|
||||
#
|
||||
|
||||
-$(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h version.h $(INCLUDE_DIR)/linux/i2c-dev.h
|
||||
+$(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/i2c/smbus.h
|
||||
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
|
||||
|
||||
-$(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/linux/i2c-dev.h
|
||||
+$(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h
|
||||
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
|
||||
|
||||
-$(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/linux/i2c-dev.h
|
||||
+$(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h
|
||||
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
|
||||
|
||||
-$(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/linux/i2c-dev.h
|
||||
+$(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h
|
||||
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
|
||||
|
||||
-$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/linux/i2c-dev.h
|
||||
+$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h
|
||||
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
|
||||
|
||||
$(TOOLS_DIR)/util.o: $(TOOLS_DIR)/util.c $(TOOLS_DIR)/util.h
|
||||
diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
|
||||
index 7a1b7cb..b3093aa 100644
|
||||
--- a/tools/i2cbusses.c
|
||||
+++ b/tools/i2cbusses.c
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include "i2cbusses.h"
|
||||
+#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
|
||||
enum adt { adt_dummy, adt_isa, adt_i2c, adt_smbus, adt_unknown };
|
||||
diff --git a/tools/i2cdetect.c b/tools/i2cdetect.c
|
||||
index 07b3d97..675a150 100644
|
||||
--- a/tools/i2cdetect.c
|
||||
+++ b/tools/i2cdetect.c
|
||||
@@ -26,7 +26,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
+#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
+#include <i2c/smbus.h>
|
||||
#include "i2cbusses.h"
|
||||
#include "../version.h"
|
||||
|
||||
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
|
||||
index 2fc98fd..a7bba72 100644
|
||||
--- a/tools/i2cdump.c
|
||||
+++ b/tools/i2cdump.c
|
||||
@@ -26,7 +26,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
+#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
+#include <i2c/smbus.h>
|
||||
#include "i2cbusses.h"
|
||||
#include "util.h"
|
||||
#include "../version.h"
|
||||
diff --git a/tools/i2cget.c b/tools/i2cget.c
|
||||
index 7053d0f..2503942 100644
|
||||
--- a/tools/i2cget.c
|
||||
+++ b/tools/i2cget.c
|
||||
@@ -29,7 +29,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
+#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
+#include <i2c/smbus.h>
|
||||
#include "i2cbusses.h"
|
||||
#include "util.h"
|
||||
#include "../version.h"
|
||||
diff --git a/tools/i2cset.c b/tools/i2cset.c
|
||||
index e143b65..0ccc1a0 100644
|
||||
--- a/tools/i2cset.c
|
||||
+++ b/tools/i2cset.c
|
||||
@@ -26,7 +26,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
+#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
+#include <i2c/smbus.h>
|
||||
#include "i2cbusses.h"
|
||||
#include "util.h"
|
||||
#include "../version.h"
|
229
i2c-tools-r6053-Add-smbus-header.patch
Normal file
229
i2c-tools-r6053-Add-smbus-header.patch
Normal file
@ -0,0 +1,229 @@
|
||||
From dbabf68c5b04a85b6fb457c539f304a84cd62eef Mon Sep 17 00:00:00 2001
|
||||
From: Jean Delvare <khali@linux-fr.org>
|
||||
Date: Mon, 21 May 2012 16:46:51 +0000
|
||||
Subject: [PATCH] Add header file missed from a previous commit.
|
||||
|
||||
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6053 7894878c-1315-0410-8ee3-d5d059ff63e0
|
||||
---
|
||||
include/i2c/smbus.h | 212 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 212 insertions(+)
|
||||
create mode 100644 include/i2c/smbus.h
|
||||
|
||||
diff --git a/include/i2c/smbus.h b/include/i2c/smbus.h
|
||||
new file mode 100644
|
||||
index 0000000..bf7ed37
|
||||
--- /dev/null
|
||||
+++ b/include/i2c/smbus.h
|
||||
@@ -0,0 +1,212 @@
|
||||
+/*
|
||||
+ smbus.h - SMBus level access helper functions
|
||||
+
|
||||
+ Copyright (C) 1995-97 Simon G. Vogl
|
||||
+ Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
|
||||
+
|
||||
+ This program is free software; you can redistribute it and/or modify
|
||||
+ it under the terms of the GNU General Public License as published by
|
||||
+ the Free Software Foundation; either version 2 of the License, or
|
||||
+ (at your option) any later version.
|
||||
+
|
||||
+ This program is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ GNU General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU General Public License
|
||||
+ along with this program; if not, write to the Free Software
|
||||
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
+ MA 02110-1301 USA.
|
||||
+*/
|
||||
+
|
||||
+#ifndef LIB_I2C_SMBUS_H
|
||||
+#define LIB_I2C_SMBUS_H
|
||||
+
|
||||
+#include <sys/ioctl.h>
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/i2c.h>
|
||||
+#include <linux/i2c-dev.h>
|
||||
+
|
||||
+/* Compatibility defines */
|
||||
+#ifndef I2C_SMBUS_I2C_BLOCK_BROKEN
|
||||
+#define I2C_SMBUS_I2C_BLOCK_BROKEN I2C_SMBUS_I2C_BLOCK_DATA
|
||||
+#endif
|
||||
+#ifndef I2C_FUNC_SMBUS_PEC
|
||||
+#define I2C_FUNC_SMBUS_PEC I2C_FUNC_SMBUS_HWPEC_CALC
|
||||
+#endif
|
||||
+
|
||||
+static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
|
||||
+ int size, union i2c_smbus_data *data)
|
||||
+{
|
||||
+ struct i2c_smbus_ioctl_data args;
|
||||
+
|
||||
+ args.read_write = read_write;
|
||||
+ args.command = command;
|
||||
+ args.size = size;
|
||||
+ args.data = data;
|
||||
+ return ioctl(file, I2C_SMBUS, &args);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
|
||||
+{
|
||||
+ return i2c_smbus_access(file, value, 0, I2C_SMBUS_QUICK, NULL);
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_read_byte(int file)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ if (i2c_smbus_access(file, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data))
|
||||
+ return -1;
|
||||
+ else
|
||||
+ return 0x0FF & data.byte;
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
|
||||
+{
|
||||
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, value,
|
||||
+ I2C_SMBUS_BYTE, NULL);
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ if (i2c_smbus_access(file, I2C_SMBUS_READ, command,
|
||||
+ I2C_SMBUS_BYTE_DATA, &data))
|
||||
+ return -1;
|
||||
+ else
|
||||
+ return 0x0FF & data.byte;
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
|
||||
+ __u8 value)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ data.byte = value;
|
||||
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
+ I2C_SMBUS_BYTE_DATA, &data);
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ if (i2c_smbus_access(file, I2C_SMBUS_READ, command,
|
||||
+ I2C_SMBUS_WORD_DATA, &data))
|
||||
+ return -1;
|
||||
+ else
|
||||
+ return 0x0FFFF & data.word;
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
|
||||
+ __u16 value)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ data.word = value;
|
||||
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
+ I2C_SMBUS_WORD_DATA, &data);
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ data.word = value;
|
||||
+ if (i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
+ I2C_SMBUS_PROC_CALL, &data))
|
||||
+ return -1;
|
||||
+ else
|
||||
+ return 0x0FFFF & data.word;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* Returns the number of read bytes */
|
||||
+static inline __s32 i2c_smbus_read_block_data(int file, __u8 command,
|
||||
+ __u8 *values)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ int i;
|
||||
+ if (i2c_smbus_access(file, I2C_SMBUS_READ, command,
|
||||
+ I2C_SMBUS_BLOCK_DATA, &data))
|
||||
+ return -1;
|
||||
+ else {
|
||||
+ for (i = 1; i <= data.block[0]; i++)
|
||||
+ values[i-1] = data.block[i];
|
||||
+ return data.block[0];
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
|
||||
+ __u8 length, const __u8 *values)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ int i;
|
||||
+ if (length > 32)
|
||||
+ length = 32;
|
||||
+ for (i = 1; i <= length; i++)
|
||||
+ data.block[i] = values[i-1];
|
||||
+ data.block[0] = length;
|
||||
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
+ I2C_SMBUS_BLOCK_DATA, &data);
|
||||
+}
|
||||
+
|
||||
+/* Returns the number of read bytes */
|
||||
+/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
|
||||
+ ask for less than 32 bytes, your code will only work with kernels
|
||||
+ 2.6.23 and later. */
|
||||
+static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
|
||||
+ __u8 length, __u8 *values)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ int i;
|
||||
+
|
||||
+ if (length > 32)
|
||||
+ length = 32;
|
||||
+ data.block[0] = length;
|
||||
+ if (i2c_smbus_access(file, I2C_SMBUS_READ, command,
|
||||
+ length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
|
||||
+ I2C_SMBUS_I2C_BLOCK_DATA, &data))
|
||||
+ return -1;
|
||||
+ else {
|
||||
+ for (i = 1; i <= data.block[0]; i++)
|
||||
+ values[i-1] = data.block[i];
|
||||
+ return data.block[0];
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
|
||||
+ __u8 length,
|
||||
+ const __u8 *values)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ int i;
|
||||
+ if (length > 32)
|
||||
+ length = 32;
|
||||
+ for (i = 1; i <= length; i++)
|
||||
+ data.block[i] = values[i-1];
|
||||
+ data.block[0] = length;
|
||||
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
+ I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
|
||||
+}
|
||||
+
|
||||
+/* Returns the number of read bytes */
|
||||
+static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,
|
||||
+ __u8 length, __u8 *values)
|
||||
+{
|
||||
+ union i2c_smbus_data data;
|
||||
+ int i;
|
||||
+ if (length > 32)
|
||||
+ length = 32;
|
||||
+ for (i = 1; i <= length; i++)
|
||||
+ data.block[i] = values[i-1];
|
||||
+ data.block[0] = length;
|
||||
+ if (i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
+ I2C_SMBUS_BLOCK_PROC_CALL, &data))
|
||||
+ return -1;
|
||||
+ else {
|
||||
+ for (i = 1; i <= data.block[0]; i++)
|
||||
+ values[i-1] = data.block[i];
|
||||
+ return data.block[0];
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#endif /* LIB_I2C_SMBUS_H */
|
@ -1,3 +1,12 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 14 14:32:05 UTC 2015 - dvaleev@suse.com
|
||||
|
||||
- Backport r6048 and r6053 in order to not conflict with
|
||||
linux-glibc-devel
|
||||
i2c-tools-r6048-Move-SMBus-helper-functions.patch
|
||||
i2c-tools-r6053-Add-smbus-header.patch
|
||||
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jun 19 07:40:41 UTC 2014 - jdelvare@suse.com
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package i2c-tools
|
||||
#
|
||||
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -30,6 +30,8 @@ Source1: http://dl.lm-sensors.org/%{name}/releases/%{name}-%{version}.tar
|
||||
Patch0: i2c-tools-r6250-ddr3-fix-ext-temp-refresh.diff
|
||||
Patch90: i2c-tools-hackweek-9-dependencies.diff
|
||||
Patch91: i2c-tools-hackweek-9-improve-DDR3-support.diff
|
||||
Patch92: i2c-tools-r6053-Add-smbus-header.patch
|
||||
Patch93: i2c-tools-r6048-Move-SMBus-helper-functions.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
ExcludeArch: s390 s390x
|
||||
|
||||
@ -52,6 +54,8 @@ Authors:
|
||||
%patch0 -p1
|
||||
%patch90 -p1
|
||||
%patch91 -p1
|
||||
%patch92 -p1
|
||||
%patch93 -p1
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" CC="%{__cc}"
|
||||
@ -65,7 +69,8 @@ rm -f $RPM_BUILD_ROOT/usr/bin/decode-edid
|
||||
%defattr(-,root,root)
|
||||
/usr/bin/*
|
||||
/usr/sbin/*
|
||||
/usr/include/linux/*
|
||||
%dir /usr/include/i2c
|
||||
/usr/include/i2c/smbus.h
|
||||
%doc /usr/share/man/man1/*.1.gz
|
||||
%doc /usr/share/man/man8/*.8.gz
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user