]> git.pld-linux.org Git - packages/kernel.git/blob - 2.6.0-sensors-chip-update-4of4-lkml.patch
+CONFIG_IP_NF_MATCH_LAYER7=m
[packages/kernel.git] / 2.6.0-sensors-chip-update-4of4-lkml.patch
1 --- linux-2.6.0-test11-mmh/drivers/i2c/chips/lm75.c.old 2003-12-14 18:02:18.000000000 -0500
2 +++ linux-2.6.0-test11-mmh/drivers/i2c/chips/lm75.c     2003-12-14 19:28:08.000000000 -0500
3 @@ -25,6 +25,7 @@
4  #include <linux/slab.h>
5  #include <linux/i2c.h>
6  #include <linux/i2c-sensor.h>
7 +#include "lm75.h"
8  
9  
10  /* Addresses to scan */
11 @@ -44,13 +45,6 @@
12  #define LM75_REG_TEMP_HYST     0x02
13  #define LM75_REG_TEMP_OS       0x03
14  
15 -/* Conversions. Rounding and limit checking is only done on the TO_REG
16 -   variants. Note that you should be a bit careful with which arguments
17 -   these macros are called: arguments may be evaluated more than once.
18 -   Fixing this is just not worth it. */
19 -#define TEMP_FROM_REG(val)     ((((val & 0x7fff) >> 7) * 5) | ((val & 0x8000)?-256:0))
20 -#define TEMP_TO_REG(val)       (SENSORS_LIMIT((val<0?(0x200+((val)/5))<<7:(((val) + 2) / 5) << 7),0,0xffff))
21 -
22  /* Each client has this additional data */
23  struct lm75_data {
24         struct semaphore        update_lock;
25 @@ -83,15 +77,12 @@
26  static int lm75_id = 0;
27  
28  #define show(value)    \
29 -static ssize_t show_##value(struct device *dev, char *buf)     \
30 -{                                                              \
31 -       struct i2c_client *client = to_i2c_client(dev);         \
32 -       struct lm75_data *data = i2c_get_clientdata(client);    \
33 -       int temp;                                               \
34 -                                                               \
35 -       lm75_update_client(client);                             \
36 -       temp = TEMP_FROM_REG(data->value);                      \
37 -       return sprintf(buf, "%d\n", temp * 100);                \
38 +static ssize_t show_##value(struct device *dev, char *buf)             \
39 +{                                                                      \
40 +       struct i2c_client *client = to_i2c_client(dev);                 \
41 +       struct lm75_data *data = i2c_get_clientdata(client);            \
42 +       lm75_update_client(client);                                     \
43 +       return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value));   \
44  }
45  show(temp_max);
46  show(temp_hyst);
47 @@ -102,9 +93,8 @@
48  {                                                              \
49         struct i2c_client *client = to_i2c_client(dev);         \
50         struct lm75_data *data = i2c_get_clientdata(client);    \
51 -       int temp = simple_strtoul(buf, NULL, 10) / 100;         \
52 -                                                               \
53 -       data->value = TEMP_TO_REG(temp);                        \
54 +       int temp = simple_strtoul(buf, NULL, 10);               \
55 +       data->value = LM75_TEMP_TO_REG(temp);                   \
56         lm75_write_value(client, reg, data->value);             \
57         return count;                                           \
58  }
59 --- linux-2.6.0-test11-mmh/drivers/i2c/chips/lm75.h.old 2003-12-14 18:05:09.000000000 -0500
60 +++ linux-2.6.0-test11-mmh/drivers/i2c/chips/lm75.h     2003-12-14 18:32:46.000000000 -0500
61 @@ -0,0 +1,49 @@
62 +/*
63 +    lm75.h - Part of lm_sensors, Linux kernel modules for hardware
64 +             monitoring
65 +    Copyright (c) 2003 Mark M. Hoffman <mhoffman@lightlink.com>
66 +
67 +    This program is free software; you can redistribute it and/or modify
68 +    it under the terms of the GNU General Public License as published by
69 +    the Free Software Foundation; either version 2 of the License, or
70 +    (at your option) any later version.
71 +
72 +    This program is distributed in the hope that it will be useful,
73 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
74 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
75 +    GNU General Public License for more details.
76 +
77 +    You should have received a copy of the GNU General Public License
78 +    along with this program; if not, write to the Free Software
79 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
80 +*/
81 +
82 +/*
83 +    This file contains common code for encoding/decoding LM75 type
84 +    temperature readings, which are emulated by many of the chips
85 +    we support.  As the user is unlikely to load more than one driver
86 +    which contains this code, we don't worry about the wasted space.
87 +*/
88 +
89 +#include <linux/i2c-sensor.h>
90 +
91 +/* straight from the datasheet */
92 +#define LM75_TEMP_MIN (-55000)
93 +#define LM75_TEMP_MAX 125000
94 +
95 +/* TEMP: 0.001C/bit (-55C to +125C)
96 +   REG: (0.5C/bit, two's complement) << 7 */
97 +static inline u16 LM75_TEMP_TO_REG(int temp)
98 +{
99 +       int ntemp = SENSORS_LIMIT(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
100 +       ntemp += (ntemp<0 ? -250 : 250);
101 +       return (u16)((ntemp / 500) << 7);
102 +}
103 +
104 +static inline int LM75_TEMP_FROM_REG(u16 reg)
105 +{
106 +       /* use integer division instead of equivalent right shift to
107 +          guarantee arithmetic shift and preserve the sign */
108 +       return ((s16)reg / 128) * 500;
109 +}
110 +
This page took 0.057885 seconds and 3 git commands to generate.