From: Martin Schlemmer <azarah@gentoo.org>
To: Greg KH <greg@kroah.com>
Cc: Jan Dittmer <j.dittmer@portrix.net>,
Mark Studebaker <mds@paradyne.com>,
KML <linux-kernel@vger.kernel.org>,
Dominik Brodowski <linux@brodo.de>,
sensors@Stimpy.netroedge.com
Subject: Re: lm sensors sysfs file structure
Date: 27 Mar 2003 21:15:23 +0200 [thread overview]
Message-ID: <1048792523.7569.102.camel@nosferatu.lan> (raw)
In-Reply-To: <20030327185222.GI32667@kroah.com>
[-- Attachment #1: Type: text/plain, Size: 2519 bytes --]
On Thu, 2003-03-27 at 20:52, Greg KH wrote:
> > Is this the way you want to go? Just an example for the voltages.
>
> That looks very good to me, nice
While we are at it, some form question. The w83781d have a
magnitude of files in sysfs if you split them like this, so
I went for the shorter (easier?) way.
This ok, or should I split it up a bit more. Note that I
have not done much for indentation yet.
------------------------------------------------------
#define show_in_reg(reg) \
static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct w83781d_data *data = i2c_get_clientdata(client); \
w83781d_update_client(client); \
\
return sprintf(buf,"%ld\n", \
IN_FROM_REG(data->reg[nr])); \
}
show_in_reg(in);
show_in_reg(in_min);
show_in_reg(in_max);
#define store_in_reg(REG,reg) \
static ssize_t store_##reg (struct device *dev, const char *buf, size_t
count, int nr) \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct w83781d_data *data = i2c_get_clientdata(client); \
int reg, ret; \
\
ret = sscanf(buf, "%d", ®); \
if (ret == -1) return -EINVAL; \
if (ret >= 1) { \
data->reg[nr] = IN_TO_REG(reg); \
w83781d_write_value(client, W83781D_REG_IN_##REG(nr),
data->reg[nr]); \
} \
return count; \
}
store_in_reg(MIN, in_min);
store_in_reg(MAX, in_max);
#define show_in_offset(offset) \
static ssize_t \
show_in_##offset (struct device *dev, char *buf) \
{ \
return show_in(dev, buf, 0x##offset); \
} \
static DEVICE_ATTR(in_input##offset, S_IRUGO | S_IWUSR,
show_in_##offset, NULL)
#define show_in_reg_offset(reg,offset) \
static ssize_t show_##reg##offset (struct device *dev, char *buf) \
{ \
return show_##reg (dev, buf, 0x##offset); \
} \
static ssize_t store_##reg##offset (struct device *dev, const char *buf,
size_t count) \
{ \
return store_##reg (dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(##reg##offset, S_IRUGO| S_IWUSR, show_##reg##offset,
store_##reg##offset)
#define show_in_offsets(offset) \
show_in_offset(offset); \
show_in_reg_offset(in_min, offset); \
show_in_reg_offset(in_max, offset);
show_in_offsets(0);
show_in_offsets(1);
show_in_offsets(2);
show_in_offsets(3);
show_in_offsets(4);
show_in_offsets(5);
show_in_offsets(6);
show_in_offsets(7);
show_in_offsets(8);
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2003-03-27 19:08 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-25 8:53 i2c driver changes for 2.5.66; adding w83781d support Martin Schlemmer
2003-03-25 17:56 ` Greg KH
2003-03-26 19:04 ` w83781d i2c driver updated for 2.5.66 (without sysfs support) Martin Schlemmer
2003-03-26 19:40 ` Jan Dittmer
2003-03-26 19:54 ` Martin Schlemmer
2003-03-26 20:26 ` Greg KH
2003-03-26 20:43 ` Christoph Hellwig
2003-03-26 21:23 ` Greg KH
2003-03-26 22:26 ` Mark Studebaker
2003-03-26 22:52 ` lm sensors sysfs file structure Greg KH
2003-03-27 10:46 ` Jan Dittmer
2003-03-27 10:50 ` Martin Schlemmer
2003-03-27 12:27 ` Jan Dittmer
2003-03-27 12:33 ` Martin Schlemmer
2003-03-27 13:05 ` Jan Dittmer
2003-03-27 13:31 ` Jean Delvare
2003-03-27 17:16 ` Mark M. Hoffman
2003-03-27 17:25 ` Greg KH
2003-03-27 18:06 ` Jan Dittmer
2003-03-27 18:13 ` Greg KH
2003-03-30 19:23 ` Pavel Machek
2003-04-01 6:44 ` Greg KH
2003-04-01 20:22 ` Pavel Machek
2003-04-01 23:27 ` Dave Jones
2003-04-03 0:28 ` Greg KH
2003-04-03 10:49 ` Dave Jones
2003-04-03 18:43 ` Dominik Brodowski
2003-03-27 18:40 ` Jan Dittmer
2003-03-27 18:52 ` Greg KH
2003-03-27 18:17 ` Patrick Mochel
2003-03-27 18:57 ` Jan Dittmer
2003-03-27 19:15 ` Martin Schlemmer [this message]
2003-03-27 19:25 ` Greg KH
2003-03-27 19:42 ` Greg KH
2003-03-27 20:32 ` Jan Dittmer
2003-03-27 21:53 ` Greg KH
2003-03-27 22:23 ` Mark M. Hoffman
2003-03-28 6:05 ` Martin Schlemmer
2003-03-28 18:34 ` Pavel Machek
2003-03-26 20:29 ` w83781d i2c driver updated for 2.5.66 (without sysfs support) Greg KH
2003-03-26 23:34 ` Martin Schlemmer
2003-03-26 23:46 ` Greg KH
2003-03-30 12:47 ` [PATCH-2.5] w83781d i2c driver updated for 2.5.66-bk4 (with sysfs support, empty tree) Martin Schlemmer
2003-04-02 22:22 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2003-03-27 23:00 lm sensors sysfs file structure Albert Cahalan
2003-03-27 23:10 ` Greg KH
2003-03-28 7:21 ` Martin Schlemmer
2003-03-28 7:40 ` Greg KH
2003-04-03 21:19 Grover, Andrew
2003-04-14 15:16 ` Patrick Mochel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1048792523.7569.102.camel@nosferatu.lan \
--to=azarah@gentoo.org \
--cc=greg@kroah.com \
--cc=j.dittmer@portrix.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@brodo.de \
--cc=mds@paradyne.com \
--cc=sensors@Stimpy.netroedge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox