2004-06-22 17:26:03

by Greg KH

[permalink] [raw]
Subject: [BK PATCH] Driver Core patches for 2.6.7

Hi,

Here are a bunch of driver core and i2c patches for 2.6.7 (I merged the
two trees, as they were conflicting in spots.) They contain:
- some sysfs and driver model attribute core changes
- fixes to the kernel where people didn't put a ';' at the end
of their driver and device attribute definitions.
- i2c bug fixes
- sysfs class support for raw devices, allowing udev to work
with raw devices. This patch is shipping in the SuSE kernel.
- other sysfs class support patches.
- sparse cleanups.

These patches used to be in the -mm tree, until last -mm release where
it conflicted with the scsi code too much. That merge has been fixed
here.

Please pull from:
bk://kernel.bkbits.net/gregkh/linux/driver-2.6

thanks,

greg k-h

p.s. I'll send these as patches in response to this email to lkml for
those who want to see them.

MAINTAINERS | 18 +-
arch/i386/kernel/cpuid.c | 123 +++++++++++----
arch/i386/kernel/msr.c | 71 ++++++++
drivers/base/base.h | 5
drivers/base/bus.c | 202 ++++++++++++++++--------
drivers/base/class.c | 117 +++++++++++---
drivers/base/class_simple.c | 12 -
drivers/base/core.c | 48 ++---
drivers/base/driver.c | 16 -
drivers/base/firmware.c | 6
drivers/base/firmware_class.c | 10 -
drivers/base/init.c | 4
drivers/base/interface.c | 18 +-
drivers/base/node.c | 14 -
drivers/base/platform.c | 200 ++++++++++++++++++------
drivers/base/power/main.c | 14 -
drivers/base/power/power.h | 8
drivers/base/power/resume.c | 12 -
drivers/base/power/runtime.c | 8
drivers/base/power/shutdown.c | 18 +-
drivers/base/power/suspend.c | 42 ++---
drivers/base/power/sysfs.c | 18 +-
drivers/base/sys.c | 102 ++++++------
drivers/char/raw.c | 25 ++-
drivers/i2c/busses/i2c-piix4.c | 2
drivers/i2c/chips/asb100.c | 66 ++++----
drivers/i2c/chips/it87.c | 102 ++++++------
drivers/i2c/chips/lm78.c | 22 +-
drivers/i2c/chips/lm85.c | 26 +--
drivers/i2c/chips/via686a.c | 18 +-
drivers/i2c/chips/w83627hf.c | 308 ++++++++++++++++++++++++--------------
drivers/i2c/chips/w83781d.c | 41 ++---
drivers/i2c/chips/w83l785ts.c | 4
drivers/i2c/i2c-dev.c | 7
drivers/pci/pci-driver.c | 1
drivers/pci/pci-sysfs.c | 33 +---
drivers/pci/pci.h | 1
drivers/scsi/scsi_debug.c | 52 +++---
drivers/scsi/scsi_sysfs.c | 14 -
drivers/scsi/scsi_transport_spi.c | 6
drivers/usb/core/devio.c | 19 +-
fs/sysfs/inode.c | 7
include/linux/device.h | 43 ++---
include/linux/i2c-id.h | 12 +
include/linux/module.h | 19 ++
include/linux/sysfs.h | 23 ++
kernel/module.c | 200 ++++++++++++++++++++++++
47 files changed, 1437 insertions(+), 700 deletions(-)
-----


<frank.a.uepping:t-online.de>:
o Driver Core: fix struct device::release issue

<jmunsin:iki.fi>:
o I2C: drivers/i2c/chips/it87.c cleanup patch

Andrew Morton:
o I2C: w83627hf.c build fix

Dmitry Torokhov:
o Driver Core: Whitespace fixes
o Driver Core: Suppress platform device suffixes

Greg Kroah-Hartman:
o USB: sparse fixups for devio.c
o merge fixups
o I2C: sparse cleanups again, based on comments from lkml
o I2C: sparse cleanups for drivers/i2c/*
o Driver Core: more whitespace fixups
o cpuid: fix hotplug cpu remove bug for class device
o Driver core: finally add a MAINTAINERS entry for it
o PCI: convert to using dev_attrs for all PCI devices
o Driver Model: And even more cleanup of silly scsi use of the *ATTR macros
o Driver Model: Cleanup the i2c driver silly use of the *ATTR macros which just broke
o Driver Model: More cleanup of silly scsi use of the *ATTR macros
o Add basic sysfs support for raw devices

Hanna V. Linder:
o Driver Model: Add class support to msr.c
o Add cpu hotplug support to cpuid.c
o Add class support to cpuid.c

Jean Delvare:
o I2C: Drop out-of-date code in w83781d and w83627hf
o I2C: update I2C IDs

Jonathan Corbet:
o Module section offsets in /sys/module

Mark M. Hoffman:
o I2C: add alternate VCORE calculations for w83627thf and w83637hf
o I2C: add alternate VCORE calculations for w83627thf and w83637hf

Patrick Mochel:
o [Driver Model] Add default device attributes to struct bus_type
o [Driver Model] Add default attributes for struct bus_type
o [Driver Model] Add default attributes for classes class devices
o [sysfs] Add attr_name() macro
o [Driver Model] Fix up silly scsi usage of DEVICE_ATTR() macros
o [Driver Model] Consolidate attribute definition macros

Russell King:
o Couple of sysfs patches
o Add platform_get_resource()

Sebastian Henschel:
o sysfs: fs/sysfs/inode.c: modify parents ctime and mtime on creation

Vojtech Pavlik:
o I2C i2c-piix: Don't treat ServerWorks servers as Laptops


2004-06-22 17:53:22

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.26, 2004/06/14 09:45:55-07:00, [email protected]

I2C: sparse cleanups again, based on comments from lkml

This is more like the original code.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/chips/it87.c | 5 +----
1 files changed, 1 insertion(+), 4 deletions(-)


diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c Tue Jun 22 09:46:48 2004
+++ b/drivers/i2c/chips/it87.c Tue Jun 22 09:46:48 2004
@@ -170,11 +170,8 @@
static int DIV_TO_REG(int val)
{
int answer = 0;
- val >>= 1;
- while (val) {
+ while ((val >>= 1) != 0)
answer++;
- val >>= 1;
- }
return answer;
}
#define DIV_FROM_REG(val) (1 << (val))

2004-06-22 17:51:53

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1826, 2004/06/22 09:25:34-07:00, [email protected]

[PATCH] I2C: Drop out-of-date code in w83781d and w83627hf

Here is a simple patch which drops some out-of-date code in the w83781d
and w83627hf i2c chip drivers. These bits are left over from the times
when chip drivers were setting default limits at init.


Signed-off-by: Jean Delvare <khali at linux-fr dot org>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/chips/w83627hf.c | 5 +----
drivers/i2c/chips/w83781d.c | 11 ++---------
2 files changed, 3 insertions(+), 13 deletions(-)


diff -Nru a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
--- a/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:46:17 2004
+++ b/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:46:17 2004
@@ -1240,7 +1240,7 @@
static void w83627hf_init_client(struct i2c_client *client)
{
struct w83627hf_data *data = i2c_get_clientdata(client);
- int vid = 0, i;
+ int i;
int type = data->type;
u8 tmp;

@@ -1283,9 +1283,6 @@
/* Convert VID to voltage based on default VRM */
data->vrm = DEFAULT_VRM;
}
-
- if (type != w83697hf)
- vid = vid_from_reg(vid, data->vrm);

tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
for (i = 1; i <= 3; i++) {
diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
--- a/drivers/i2c/chips/w83781d.c Tue Jun 22 09:46:17 2004
+++ b/drivers/i2c/chips/w83781d.c Tue Jun 22 09:46:17 2004
@@ -1491,7 +1491,7 @@
w83781d_init_client(struct i2c_client *client)
{
struct w83781d_data *data = i2c_get_clientdata(client);
- int vid = 0, i, p;
+ int i, p;
int type = data->type;
u8 tmp;

@@ -1513,14 +1513,7 @@
w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0);
}

- if (type != w83697hf) {
- vid = w83781d_read_value(client, W83781D_REG_VID_FANDIV) & 0x0f;
- vid |=
- (w83781d_read_value(client, W83781D_REG_CHIPID) & 0x01) <<
- 4;
- data->vrm = DEFAULT_VRM;
- vid = vid_from_reg(vid, data->vrm);
- }
+ data->vrm = 82;

if ((type != w83781d) && (type != as99127f)) {
tmp = w83781d_read_value(client, W83781D_REG_SCFG1);

2004-06-22 17:53:23

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.58, 2004/06/08 22:45:12-07:00, [email protected]

cpuid: fix hotplug cpu remove bug for class device.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


arch/i386/kernel/cpuid.c | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)


diff -Nru a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
--- a/arch/i386/kernel/cpuid.c Tue Jun 22 09:47:34 2004
+++ b/arch/i386/kernel/cpuid.c Tue Jun 22 09:47:34 2004
@@ -158,35 +158,27 @@
.open = cpuid_open,
};

-static void cpuid_class_simple_device_remove(void)
-{
- int i = 0;
- for_each_online_cpu(i)
- class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
- return;
-}
-
static int cpuid_class_simple_device_add(int i)
{
int err = 0;
struct class_device *class_err;

class_err = class_simple_device_add(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
- if (IS_ERR(class_err)) {
+ if (IS_ERR(class_err))
err = PTR_ERR(class_err);
- }
return err;
}
+
static int __devinit cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
{
unsigned int cpu = (unsigned long)hcpu;

- switch(action) {
+ switch (action) {
case CPU_ONLINE:
cpuid_class_simple_device_add(cpu);
break;
case CPU_DEAD:
- cpuid_class_simple_device_remove();
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu));
break;
}
return NOTIFY_OK;
@@ -224,7 +216,10 @@
goto out;

out_class:
- cpuid_class_simple_device_remove();
+ i = 0;
+ for_each_online_cpu(i) {
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
+ }
class_simple_destroy(cpuid_class);
out_chrdev:
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
@@ -234,7 +229,10 @@

void __exit cpuid_exit(void)
{
- cpuid_class_simple_device_remove();
+ int cpu = 0;
+
+ for_each_online_cpu(cpu)
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu));
class_simple_destroy(cpuid_class);
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
unregister_cpu_notifier(&cpuid_class_cpu_notifier);

2004-06-22 17:53:23

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.27, 2004/06/14 10:50:59-07:00, [email protected]

[PATCH] I2C: add alternate VCORE calculations for w83627thf and w83637hf

Pick a VRM (for VID interpretation) based on the VRM & OVT config,
if available. Props to Jean Delvare <[email protected]> for the
idea & code fragment.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/chips/w83627hf.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)


diff -Nru a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
--- a/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:46:43 2004
+++ b/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:46:43 2004
@@ -1275,12 +1275,15 @@
}

/* Read VRM & OVT Config only once */
- if (w83627thf == data->type || w83637hf == data->type)
+ if (w83627thf == data->type || w83637hf == data->type) {
data->vrm_ovt =
w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);
+ data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82;
+ } else {
+ /* Convert VID to voltage based on default VRM */
+ data->vrm = DEFAULT_VRM;
+ }

- /* Convert VID to voltage based on default VRM */
- data->vrm = DEFAULT_VRM;
if (type != w83697hf)
vid = vid_from_reg(vid, data->vrm);


2004-06-22 18:01:41

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.102.4, 2004/06/08 14:36:23-07:00, [email protected]

[PATCH] I2C: drivers/i2c/chips/it87.c cleanup patch

Attached is a cleanup patch for the it87 sensor driver, against
2.6.7-rc2. Jean Delvare has reviewed it.


Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/chips/it87.c | 48 +++++++++++++++++++++--------------------------
1 files changed, 22 insertions(+), 26 deletions(-)


diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c Tue Jun 22 09:47:50 2004
+++ b/drivers/i2c/chips/it87.c Tue Jun 22 09:47:50 2004
@@ -128,15 +128,15 @@

#define IT87_REG_FAN(nr) (0x0d + (nr))
#define IT87_REG_FAN_MIN(nr) (0x10 + (nr))
-#define IT87_REG_FAN_CTRL 0x13
+#define IT87_REG_FAN_MAIN_CTRL 0x13

#define IT87_REG_VIN(nr) (0x20 + (nr))
#define IT87_REG_TEMP(nr) (0x29 + (nr))

#define IT87_REG_VIN_MAX(nr) (0x30 + (nr) * 2)
#define IT87_REG_VIN_MIN(nr) (0x31 + (nr) * 2)
-#define IT87_REG_TEMP_HIGH(nr) (0x40 + ((nr) * 2))
-#define IT87_REG_TEMP_LOW(nr) (0x41 + ((nr) * 2))
+#define IT87_REG_TEMP_HIGH(nr) (0x40 + (nr) * 2)
+#define IT87_REG_TEMP_LOW(nr) (0x41 + (nr) * 2)

#define IT87_REG_I2C_ADDR 0x48

@@ -145,8 +145,8 @@

#define IT87_REG_CHIPID 0x58

-#define IN_TO_REG(val) (SENSORS_LIMIT((((val) * 10 + 8)/16),0,255))
-#define IN_FROM_REG(val) (((val) * 16) / 10)
+#define IN_TO_REG(val) (SENSORS_LIMIT((((val) + 8)/16),0,255))
+#define IN_FROM_REG(val) ((val) * 16)

static inline u8 FAN_TO_REG(long rpm, int div)
{
@@ -159,9 +159,9 @@

#define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==255?0:1350000/((val)*(div)))

-#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-5)/10):\
- ((val)+5)/10),0,255))
-#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10)
+#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-500)/1000):\
+ ((val)+500)/1000),-128,127))
+#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000)

#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\
205-(val)*5)
@@ -231,19 +231,19 @@
static ssize_t show_in(struct device *dev, char *buf, int nr)
{
struct it87_data *data = it87_update_device(dev);
- return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])*10 );
+ return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr]));
}

static ssize_t show_in_min(struct device *dev, char *buf, int nr)
{
struct it87_data *data = it87_update_device(dev);
- return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])*10 );
+ return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr]));
}

static ssize_t show_in_max(struct device *dev, char *buf, int nr)
{
struct it87_data *data = it87_update_device(dev);
- return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])*10 );
+ return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr]));
}

static ssize_t set_in_min(struct device *dev, const char *buf,
@@ -251,7 +251,7 @@
{
struct i2c_client *client = to_i2c_client(dev);
struct it87_data *data = i2c_get_clientdata(client);
- unsigned long val = simple_strtoul(buf, NULL, 10)/10;
+ unsigned long val = simple_strtoul(buf, NULL, 10);
data->in_min[nr] = IN_TO_REG(val);
it87_write_value(client, IT87_REG_VIN_MIN(nr),
data->in_min[nr]);
@@ -262,7 +262,7 @@
{
struct i2c_client *client = to_i2c_client(dev);
struct it87_data *data = i2c_get_clientdata(client);
- unsigned long val = simple_strtoul(buf, NULL, 10)/10;
+ unsigned long val = simple_strtoul(buf, NULL, 10);
data->in_max[nr] = IN_TO_REG(val);
it87_write_value(client, IT87_REG_VIN_MAX(nr),
data->in_max[nr]);
@@ -325,24 +325,24 @@
static ssize_t show_temp(struct device *dev, char *buf, int nr)
{
struct it87_data *data = it87_update_device(dev);
- return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])*100 );
+ return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr]));
}
static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
{
struct it87_data *data = it87_update_device(dev);
- return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])*100);
+ return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr]));
}
static ssize_t show_temp_min(struct device *dev, char *buf, int nr)
{
struct it87_data *data = it87_update_device(dev);
- return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])*100);
+ return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr]));
}
static ssize_t set_temp_max(struct device *dev, const char *buf,
size_t count, int nr)
{
struct i2c_client *client = to_i2c_client(dev);
struct it87_data *data = i2c_get_clientdata(client);
- int val = simple_strtol(buf, NULL, 10)/100;
+ int val = simple_strtol(buf, NULL, 10);
data->temp_high[nr] = TEMP_TO_REG(val);
it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]);
return count;
@@ -352,7 +352,7 @@
{
struct i2c_client *client = to_i2c_client(dev);
struct it87_data *data = i2c_get_clientdata(client);
- int val = simple_strtol(buf, NULL, 10)/100;
+ int val = simple_strtol(buf, NULL, 10);
data->temp_low[nr] = TEMP_TO_REG(val);
it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]);
return count;
@@ -773,9 +773,7 @@
We don't want to lock the whole ISA bus, so we lock each client
separately.
We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
- would slow down the IT87 access and should not be necessary.
- There are some ugly typecasts here, but the good new is - they should
- nowhere else be necessary! */
+ would slow down the IT87 access and should not be necessary. */
static int it87_read_value(struct i2c_client *client, u8 reg)
{
struct it87_data *data = i2c_get_clientdata(client);
@@ -795,9 +793,7 @@
We don't want to lock the whole ISA bus, so we lock each client
separately.
We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
- would slow down the IT87 access and should not be necessary.
- There are some ugly typecasts here, but the good new is - they should
- nowhere else be necessary! */
+ would slow down the IT87 access and should not be necessary. */
static int it87_write_value(struct i2c_client *client, u8 reg, u8 value)
{
struct it87_data *data = i2c_get_clientdata(client);
@@ -840,11 +836,11 @@
}

/* Check if tachometers are reset manually or by some reason */
- tmp = it87_read_value(client, IT87_REG_FAN_CTRL);
+ tmp = it87_read_value(client, IT87_REG_FAN_MAIN_CTRL);
if ((tmp & 0x70) == 0) {
/* Enable all fan tachometers */
tmp = (tmp & 0x8f) | 0x70;
- it87_write_value(client, IT87_REG_FAN_CTRL, tmp);
+ it87_write_value(client, IT87_REG_FAN_MAIN_CTRL, tmp);
}

/* Start monitoring */

2004-06-22 18:01:43

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.102.1, 2004/06/04 14:45:53-07:00, [email protected]

[PATCH] I2C i2c-piix: Don't treat ServerWorks servers as Laptops

I'm sending you this little obvious patch which should enable i2c-piix
to work on IBM servers with ServerWorks chipsets. It still will treat
any IBM/Intel machine as a laptop and refuse to work, but it's better
than before.


i2c: Treat only IBM machines with Intel chipsets as IBM laptops.


Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/busses/i2c-piix4.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)


diff -Nru a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
--- a/drivers/i2c/busses/i2c-piix4.c Tue Jun 22 09:48:20 2004
+++ b/drivers/i2c/busses/i2c-piix4.c Tue Jun 22 09:48:20 2004
@@ -138,7 +138,7 @@

dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev));

- if(ibm_dmi_probe()) {
+ if(ibm_dmi_probe() && PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) {
dev_err(&PIIX4_dev->dev, "IBM Laptop detected; this module "
"may corrupt your serial eeprom! Refusing to load "
"module!\n");

2004-06-22 18:02:56

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.102.2, 2004/06/04 14:46:39-07:00, [email protected]

[PATCH] I2C: update I2C IDs

> > Greg, should I send a patch to you with these?
>
> Sure, if it's needed.

Just noticed that I never sent the promised patch. Here it is. I also
added a few other IDs, since we have them in our (2.4) i2c CVS
repository. Having them in 2.6 as well will at least prevent collisions.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


include/linux/i2c-id.h | 12 ++++++++++++
1 files changed, 12 insertions(+)


diff -Nru a/include/linux/i2c-id.h b/include/linux/i2c-id.h
--- a/include/linux/i2c-id.h Tue Jun 22 09:48:15 2004
+++ b/include/linux/i2c-id.h Tue Jun 22 09:48:15 2004
@@ -101,6 +101,14 @@
#define I2C_DRIVERID_UDA1342 53 /* UDA1342 audio codec */
#define I2C_DRIVERID_ADV7170 54 /* video encoder */
#define I2C_DRIVERID_RADEON 55 /* I2C bus on Radeon boards */
+#define I2C_DRIVERID_MAX1617 56 /* temp sensor */
+#define I2C_DRIVERID_SAA7191 57 /* video encoder */
+#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */
+#define I2C_DRIVERID_BT832 59 /* CMOS camera video processor */
+#define I2C_DRIVERID_TDA9887 60 /* TDA988x IF-PLL demodulator */
+#define I2C_DRIVERID_OVCAMCHIP 61 /* OmniVision CMOS image sens. */
+#define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */
+#define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */


#define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */
@@ -264,6 +272,10 @@
#define I2C_HW_SMBUS_SCX200 0x0b
#define I2C_HW_SMBUS_NFORCE2 0x0c
#define I2C_HW_SMBUS_W9968CF 0x0d
+#define I2C_HW_SMBUS_OV511 0x0e /* OV511(+) USB 1.1 webcam ICs */
+#define I2C_HW_SMBUS_OV518 0x0f /* OV518(+) USB 1.1 webcam ICs */
+#define I2C_HW_SMBUS_OV519 0x10 /* OV519 USB 1.1 webcam IC */
+#define I2C_HW_SMBUS_OVFX2 0x11 /* Cypress/OmniVision FX2 webcam */

/* --- ISA pseudo-adapter */
#define I2C_HW_ISA 0x00

2004-06-22 18:02:56

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.49, 2004/06/03 12:38:31-07:00, [email protected]

[PATCH] Add class support to cpuid.c

This patch adds class support to arch/i386/kernel/cpuid.c. This enables udev
support. I have tested on a 2-way SMP system and on a 2-way built as UP.
Here are the results for the SMP:

[hlinder@w-hlinder2 hlinder]$ tree /sys/class/cpuid
/sys/class/cpuid
|-- cpu0
| `-- dev
`-- cpu1
`-- dev

2 directories, 2 files
[hlinder@w-hlinder2 hlinder]$ more /sys/class/cpuid/cpu0/dev
203:0
[hlinder@w-hlinder2 hlinder]$ more /sys/class/cpuid/cpu1/dev
203:1
[hlinder@w-hlinder2 hlinder]$

And for the UP:

[root@w-hlinder2 root]# tree /sys/class/cpuid
/sys/class/cpuid
`-- cpu0
`-- dev

1 directory, 1 file


Signed-off-by: Greg Kroah-Hartman <[email protected]>


arch/i386/kernel/cpuid.c | 38 ++++++++++++++++++++++++++++++++++++--
1 files changed, 36 insertions(+), 2 deletions(-)


diff -Nru a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
--- a/arch/i386/kernel/cpuid.c Tue Jun 22 09:48:45 2004
+++ b/arch/i386/kernel/cpuid.c Tue Jun 22 09:48:45 2004
@@ -36,12 +36,15 @@
#include <linux/fs.h>
#include <linux/smp_lock.h>
#include <linux/fs.h>
+#include <linux/device.h>

#include <asm/processor.h>
#include <asm/msr.h>
#include <asm/uaccess.h>
#include <asm/system.h>

+static struct class_simple *cpuid_class;
+
#ifdef CONFIG_SMP

struct cpuid_command {
@@ -155,17 +158,48 @@

int __init cpuid_init(void)
{
+ int i, err = 0;
+ struct class_device *class_err;
+ i = 0;
+
if (register_chrdev(CPUID_MAJOR, "cpu/cpuid", &cpuid_fops)) {
printk(KERN_ERR "cpuid: unable to get major %d for cpuid\n",
CPUID_MAJOR);
- return -EBUSY;
+ err = -EBUSY;
+ goto out;
+ }
+ cpuid_class = class_simple_create(THIS_MODULE, "cpuid");
+ if (IS_ERR(cpuid_class)) {
+ err = PTR_ERR(cpuid_class);
+ goto out_chrdev;
}
+ for_each_online_cpu(i) {
+ class_err = class_simple_device_add(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
+ if (IS_ERR(class_err)) {
+ err = PTR_ERR(class_err);
+ goto out_class;
+ }
+ }
+ err = 0;
+ goto out;

- return 0;
+out_class:
+ i = 0;
+ for_each_online_cpu(i)
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
+ class_simple_destroy(cpuid_class);
+out_chrdev:
+ unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
+out:
+ return err;
}

void __exit cpuid_exit(void)
{
+ int i = 0;
+ for_each_online_cpu(i)
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
+ class_simple_destroy(cpuid_class);
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
}


2004-06-22 18:11:19

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.25, 2004/06/11 17:22:53-07:00, [email protected]

[PATCH] sysfs: fs/sysfs/inode.c: modify parents ctime and mtime on creation

When a node is added to sysfs (e.g. a device plugged in via USB), the
filesystem fails to make this change visible in the parent directory's
ctime/mtime. This is in contrast to removing a device, because in that
case, sysfs makes use of the function simple_unlink from fs/libfs.c which
takes care of that. Instead of using simple_link from fs/libfs.c on
creation, sysfs implements its own mechanism. This patch hooks into the
function sysfs_create and sets the ctime and the mtime of the parent to
CURRENT_TIME.

Signed-off-by: Sebastian Henschel <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


fs/sysfs/inode.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletion(-)


diff -Nru a/fs/sysfs/inode.c b/fs/sysfs/inode.c
--- a/fs/sysfs/inode.c Tue Jun 22 09:46:53 2004
+++ b/fs/sysfs/inode.c Tue Jun 22 09:46:53 2004
@@ -46,8 +46,13 @@
struct inode * inode = NULL;
if (dentry) {
if (!dentry->d_inode) {
- if ((inode = sysfs_new_inode(mode)))
+ if ((inode = sysfs_new_inode(mode))) {
+ if (dentry->d_parent && dentry->d_parent->d_inode) {
+ struct inode *p_inode = dentry->d_parent->d_inode;
+ p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME;
+ }
goto Proceed;
+ }
else
error = -ENOMEM;
} else

2004-06-22 18:11:21

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.53, 2004/06/04 14:53:48-07:00, [email protected]

[PATCH] Driver Core: fix struct device::release issue

Signed-off-by: Greg Kroah-Hartman <[email protected]>


On Saturday 27 March 2004 02:14, Greg KH wrote:
> On Sat, Mar 06, 2004 at 12:47:24PM +0100, Frank A. Uepping wrote:
> > Hi,
> > if device_add fails (e.g. bus_add_device returns an error) then the release
> > method will be called for the device. Is this a bug or a feature?
>
> Are you sure this will happen? device_initialize() gets a reference
> that is still present after device_add() fails, right? So release()
> will not get called.
At the label PMError, kobject_unregister is called, which decrements the
recount by 2, which will result in calling release at label Done (put_device).

kobject_unregister should be superseded by kobject_del.
Here is a patch:


drivers/base/core.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)


diff -Nru a/drivers/base/core.c b/drivers/base/core.c
--- a/drivers/base/core.c Tue Jun 22 09:48:10 2004
+++ b/drivers/base/core.c Tue Jun 22 09:48:10 2004
@@ -245,7 +245,7 @@
BusError:
device_pm_remove(dev);
PMError:
- kobject_unregister(&dev->kobj);
+ kobject_del(&dev->kobj);
Error:
if (parent)
put_device(parent);

2004-06-22 18:18:36

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.28, 2004/06/18 13:37:04-07:00, [email protected]

[PATCH] Couple of sysfs patches

On Wed, Jun 16, 2004 at 05:51:03PM -0500, Dmitry Torokhov wrote:
> What about freeing the resources? Can it be put in platform_device_unregister
> or is it release handler task? I'd put it in unregister because when I call
> unregister I expect device be half-dead and release as much resources as it
> can.


Here's the updated patch - to be applied on top of the
platform_get_resource() patch sent previously.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/base/platform.c | 91 +++++++++++++++++++++++++++---------------------
include/linux/device.h | 1
2 files changed, 52 insertions(+), 40 deletions(-)


diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c Tue Jun 22 09:46:38 2004
+++ b/drivers/base/platform.c Tue Jun 22 09:46:38 2004
@@ -55,51 +55,24 @@
}

/**
- * platform_add_device - add one platform device
- * @dev: platform device
- *
- * Adds one platform device, claiming the memory resources
- */
-int platform_add_device(struct platform_device *dev)
-{
- int i;
-
- for (i = 0; i < dev->num_resources; i++) {
- struct resource *p, *r = &dev->resource[i];
-
- r->name = dev->dev.bus_id;
-
- p = NULL;
- if (r->flags & IORESOURCE_MEM)
- p = &iomem_resource;
- else if (r->flags & IORESOURCE_IO)
- p = &ioport_resource;
-
- if (p && request_resource(p, r)) {
- printk(KERN_ERR
- "%s%d: failed to claim resource %d\n",
- dev->name, dev->id, i);
- break;
- }
- }
- if (i == dev->num_resources)
- platform_device_register(dev);
- return 0;
-}
-
-/**
* platform_add_devices - add a numbers of platform devices
* @devs: array of platform devices to add
* @num: number of platform devices in array
*/
int platform_add_devices(struct platform_device **devs, int num)
{
- int i;
+ int i, ret = 0;

- for (i = 0; i < num; i++)
- platform_add_device(devs[i]);
+ for (i = 0; i < num; i++) {
+ ret = platform_device_register(devs[i]);
+ if (ret) {
+ while (--i >= 0)
+ platform_device_unregister(devs[i]);
+ break;
+ }
+ }

- return 0;
+ return ret;
}

/**
@@ -109,6 +82,8 @@
*/
int platform_device_register(struct platform_device * pdev)
{
+ int i, ret = 0;
+
if (!pdev)
return -EINVAL;

@@ -122,15 +97,53 @@
else
strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE);

+ for (i = 0; i < pdev->num_resources; i++) {
+ struct resource *p, *r = &pdev->resource[i];
+
+ r->name = pdev->dev.bus_id;
+
+ p = NULL;
+ if (r->flags & IORESOURCE_MEM)
+ p = &iomem_resource;
+ else if (r->flags & IORESOURCE_IO)
+ p = &ioport_resource;
+
+ if (p && request_resource(p, r)) {
+ printk(KERN_ERR
+ "%s: failed to claim resource %d\n",
+ pdev->dev.bus_id, i);
+ ret = -EBUSY;
+ goto failed;
+ }
+ }
+
pr_debug("Registering platform device '%s'. Parent at %s\n",
pdev->dev.bus_id, pdev->dev.parent->bus_id);
- return device_register(&pdev->dev);
+
+ ret = device_register(&pdev->dev);
+ if (ret == 0)
+ return ret;
+
+ failed:
+ while (--i >= 0)
+ if (pdev->resource[i].flags & (IORESOURCE_MEM|IORESOURCE_IO))
+ release_resource(&pdev->resource[i]);
+ return ret;
}

void platform_device_unregister(struct platform_device * pdev)
{
- if (pdev)
+ int i;
+
+ if (pdev) {
device_unregister(&pdev->dev);
+
+ for (i = 0; i < pdev->num_resources; i++) {
+ struct resource *r = &pdev->resource[i];
+ if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO))
+ release_resource(r);
+ }
+ }
}


diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Tue Jun 22 09:46:38 2004
+++ b/include/linux/device.h Tue Jun 22 09:46:38 2004
@@ -379,7 +379,6 @@

extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int);
extern int platform_get_irq(struct platform_device *, unsigned int);
-extern int platform_add_device(struct platform_device *);
extern int platform_add_devices(struct platform_device **, int);

/* drivers/base/power.c */

2004-06-22 18:17:25

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.21, 2004/06/10 09:34:27-07:00, [email protected]

[PATCH] Driver Core: Whitespace fixes

Whitespace and formatting changes (a,b,c -> a, b, c) in drivers/base

Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/base/base.h | 5 +-
drivers/base/class_simple.c | 12 ++--
drivers/base/core.c | 46 +++++++++---------
drivers/base/driver.c | 16 +++---
drivers/base/firmware.c | 6 +-
drivers/base/firmware_class.c | 10 ++--
drivers/base/init.c | 4 -
drivers/base/interface.c | 18 +++----
drivers/base/node.c | 14 ++---
drivers/base/platform.c | 18 +++----
drivers/base/power/main.c | 14 ++---
drivers/base/power/power.h | 8 +--
drivers/base/power/resume.c | 12 ++--
drivers/base/power/runtime.c | 8 +--
drivers/base/power/shutdown.c | 18 +++----
drivers/base/power/suspend.c | 42 ++++++++---------
drivers/base/power/sysfs.c | 18 +++----
drivers/base/sys.c | 102 +++++++++++++++++++++---------------------
18 files changed, 186 insertions(+), 185 deletions(-)


diff -Nru a/drivers/base/base.h b/drivers/base/base.h
--- a/drivers/base/base.h Tue Jun 22 09:47:14 2004
+++ b/drivers/base/base.h Tue Jun 22 09:47:14 2004
@@ -6,12 +6,13 @@

static inline struct class_device *to_class_dev(struct kobject *obj)
{
- return container_of(obj,struct class_device,kobj);
+ return container_of(obj, struct class_device, kobj);
}
+
static inline
struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
{
- return container_of(_attr,struct class_device_attribute,attr);
+ return container_of(_attr, struct class_device_attribute, attr);
}


diff -Nru a/drivers/base/class_simple.c b/drivers/base/class_simple.c
--- a/drivers/base/class_simple.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/class_simple.c Tue Jun 22 09:47:14 2004
@@ -3,7 +3,7 @@
*
* Copyright (c) 2003-2004 Greg Kroah-Hartman <[email protected]>
* Copyright (c) 2003-2004 IBM Corp.
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -111,7 +111,7 @@

/**
* class_simple_device_add - adds a class device to sysfs for a character driver
- * @cs: pointer to the struct class_simple that this device should be registered to.
+ * @cs: pointer to the struct class_simple that this device should be registered to.
* @dev: the dev_t for the device to be added.
* @device: a pointer to a struct device that is assiociated with this class device.
* @fmt: string for the class device's name
@@ -146,8 +146,8 @@
s_dev->dev = dev;
s_dev->class_dev.dev = device;
s_dev->class_dev.class = &cs->class;
-
- va_start(args,fmt);
+
+ va_start(args, fmt);
vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args);
va_end(args);
retval = class_device_register(&s_dev->class_dev);
@@ -173,10 +173,10 @@
* @cs: pointer to the struct class_simple to hold the pointer
* @hotplug: function pointer to the hotplug function
*
- * Implement and set a hotplug function to add environment variables specific to this
+ * Implement and set a hotplug function to add environment variables specific to this
* class on the hotplug event.
*/
-int class_simple_set_hotplug(struct class_simple *cs,
+int class_simple_set_hotplug(struct class_simple *cs,
int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size))
{
if ((cs == NULL) || (IS_ERR(cs)))
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
--- a/drivers/base/core.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/core.c Tue Jun 22 09:47:14 2004
@@ -3,7 +3,7 @@
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -28,8 +28,8 @@
* sysfs bindings for devices.
*/

-#define to_dev(obj) container_of(obj,struct device,kobj)
-#define to_dev_attr(_attr) container_of(_attr,struct device_attribute,attr)
+#define to_dev(obj) container_of(obj, struct device, kobj)
+#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)

extern struct attribute * dev_default_attrs[];

@@ -41,12 +41,12 @@
ssize_t ret = 0;

if (dev_attr->show)
- ret = dev_attr->show(dev,buf);
+ ret = dev_attr->show(dev, buf);
return ret;
}

static ssize_t
-dev_attr_store(struct kobject * kobj, struct attribute * attr,
+dev_attr_store(struct kobject * kobj, struct attribute * attr,
const char * buf, size_t count)
{
struct device_attribute * dev_attr = to_dev_attr(attr);
@@ -54,7 +54,7 @@
ssize_t ret = 0;

if (dev_attr->store)
- ret = dev_attr->store(dev,buf,count);
+ ret = dev_attr->store(dev, buf, count);
return ret;
}

@@ -153,7 +153,7 @@
{
int error = 0;
if (get_device(dev)) {
- error = sysfs_create_file(&dev->kobj,&attr->attr);
+ error = sysfs_create_file(&dev->kobj, &attr->attr);
put_device(dev);
}
return error;
@@ -168,7 +168,7 @@
void device_remove_file(struct device * dev, struct device_attribute * attr)
{
if (get_device(dev)) {
- sysfs_remove_file(&dev->kobj,&attr->attr);
+ sysfs_remove_file(&dev->kobj, &attr->attr);
put_device(dev);
}
}
@@ -179,7 +179,7 @@
* @dev: device.
*
* This prepares the device for use by other layers,
- * including adding it to the device hierarchy.
+ * including adding it to the device hierarchy.
* It is the first half of device_register(), if called by
* that, though it can also be called separately, so one
* may use @dev's fields (e.g. the refcount).
@@ -187,7 +187,7 @@

void device_initialize(struct device *dev)
{
- kobj_set_kset_s(dev,devices_subsys);
+ kobj_set_kset_s(dev, devices_subsys);
kobject_init(&dev->kobj);
INIT_LIST_HEAD(&dev->node);
INIT_LIST_HEAD(&dev->children);
@@ -200,7 +200,7 @@
* device_add - add device to device hierarchy.
* @dev: device.
*
- * This is part 2 of device_register(), though may be called
+ * This is part 2 of device_register(), though may be called
* separately _iff_ device_initialize() has been called separately.
*
* This adds it to the kobject hierarchy via kobject_add(), adds it
@@ -221,7 +221,7 @@
pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id);

/* first, register with generic layer. */
- kobject_set_name(&dev->kobj,dev->bus_id);
+ kobject_set_name(&dev->kobj, dev->bus_id);
if (parent)
dev->kobj.parent = &parent->kobj;

@@ -233,7 +233,7 @@
goto BusError;
down_write(&devices_subsys.rwsem);
if (parent)
- list_add_tail(&dev->node,&parent->children);
+ list_add_tail(&dev->node, &parent->children);
up_write(&devices_subsys.rwsem);

/* notify platform of device entry */
@@ -258,9 +258,9 @@
* @dev: pointer to the device structure
*
* This happens in two clean steps - initialize the device
- * and add it to the system. The two steps can be called
- * separately, but this is the easiest and most common.
- * I.e. you should only call the two helpers separately if
+ * and add it to the system. The two steps can be called
+ * separately, but this is the easiest and most common.
+ * I.e. you should only call the two helpers separately if
* have a clearly defined need to use and refcount the device
* before it is added to the hierarchy.
*/
@@ -301,13 +301,13 @@
* device_del - delete device from system.
* @dev: device.
*
- * This is the first part of the device unregistration
+ * This is the first part of the device unregistration
* sequence. This removes the device from the lists we control
- * from here, has it removed from the other driver model
+ * from here, has it removed from the other driver model
* subsystems it was added to in device_add(), and removes it
* from the kobject hierarchy.
*
- * NOTE: this should be called manually _iff_ device_add() was
+ * NOTE: this should be called manually _iff_ device_add() was
* also called manually.
*/

@@ -340,7 +340,7 @@
* we remove it from all the subsystems with device_del(), then
* we decrement the reference count via put_device(). If that
* is the final reference count, the device will be cleaned up
- * via device_release() above. Otherwise, the structure will
+ * via device_release() above. Otherwise, the structure will
* stick around until the final reference to the device is dropped.
*/
void device_unregister(struct device * dev)
@@ -358,7 +358,7 @@
* @fn: function to be called for each device.
*
* Iterate over @dev's child devices, and call @fn for each,
- * passing it @data.
+ * passing it @data.
*
* We check the return of @fn each time. If it returns anything
* other than 0, we break out and return that value.
@@ -370,8 +370,8 @@
int error = 0;

down_read(&devices_subsys.rwsem);
- list_for_each_entry(child,&dev->children,node) {
- if((error = fn(child,data)))
+ list_for_each_entry(child, &dev->children, node) {
+ if((error = fn(child, data)))
break;
}
up_read(&devices_subsys.rwsem);
diff -Nru a/drivers/base/driver.c b/drivers/base/driver.c
--- a/drivers/base/driver.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/driver.c Tue Jun 22 09:47:14 2004
@@ -3,7 +3,7 @@
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -15,8 +15,8 @@
#include <linux/string.h>
#include "base.h"

-#define to_dev(node) container_of(node,struct device,driver_list)
-#define to_drv(obj) container_of(obj,struct device_driver,kobj)
+#define to_dev(node) container_of(node, struct device, driver_list)
+#define to_drv(obj) container_of(obj, struct device_driver, kobj)

/**
* driver_create_file - create sysfs file for driver.
@@ -28,7 +28,7 @@
{
int error;
if (get_driver(drv)) {
- error = sysfs_create_file(&drv->kobj,&attr->attr);
+ error = sysfs_create_file(&drv->kobj, &attr->attr);
put_driver(drv);
} else
error = -EINVAL;
@@ -45,7 +45,7 @@
void driver_remove_file(struct device_driver * drv, struct driver_attribute * attr)
{
if (get_driver(drv)) {
- sysfs_remove_file(&drv->kobj,&attr->attr);
+ sysfs_remove_file(&drv->kobj, &attr->attr);
put_driver(drv);
}
}
@@ -76,7 +76,7 @@
* @drv: driver to register
*
* We pass off most of the work to the bus_add_driver() call,
- * since most of the things we have to do deal with the bus
+ * since most of the things we have to do deal with the bus
* structures.
*
* The one interesting aspect is that we initialize @drv->unload_sem
@@ -99,8 +99,8 @@
*
* Though, once that is done, we attempt to take @drv->unload_sem.
* This will block until the driver refcount reaches 0, and it is
- * released. Only modular drivers will call this function, and we
- * have to guarantee that it won't complete, letting the driver
+ * released. Only modular drivers will call this function, and we
+ * have to guarantee that it won't complete, letting the driver
* unload until all references are gone.
*/

diff -Nru a/drivers/base/firmware.c b/drivers/base/firmware.c
--- a/drivers/base/firmware.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/firmware.c Tue Jun 22 09:47:14 2004
@@ -3,7 +3,7 @@
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -12,11 +12,11 @@
#include <linux/module.h>
#include <linux/init.h>

-static decl_subsys(firmware,NULL,NULL);
+static decl_subsys(firmware, NULL, NULL);

int firmware_register(struct subsystem * s)
{
- kset_set_kset_s(s,firmware_subsys);
+ kset_set_kset_s(s, firmware_subsys);
return subsystem_register(s);
}

diff -Nru a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
--- a/drivers/base/firmware_class.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/firmware_class.c Tue Jun 22 09:47:14 2004
@@ -68,7 +68,7 @@
* firmware will be provided.
*
* Note: zero means 'wait for ever'
- *
+ *
**/
static ssize_t
firmware_timeout_store(struct class *class, const char *buf, size_t count)
@@ -121,7 +121,7 @@
/**
* firmware_loading_store: - loading control file
* Description:
- * The relevant values are:
+ * The relevant values are:
*
* 1: Start a load, discarding any previous partial load.
* 0: Conclude the load and handle the data to the driver code.
@@ -376,7 +376,7 @@
return retval;
}

-/**
+/**
* request_firmware: - request firmware to hotplug and wait for it
* Description:
* @firmware will be used to return a firmware image by the name
@@ -457,7 +457,7 @@

/**
* register_firmware: - provide a firmware image for later usage
- *
+ *
* Description:
* Make sure that @data will be available by requesting firmware @name.
*
@@ -541,7 +541,7 @@

ret = kernel_thread(request_firmware_work_func, fw_work,
CLONE_FS | CLONE_FILES);
-
+
if (ret < 0) {
fw_work->cont(NULL, fw_work->context);
return ret;
diff -Nru a/drivers/base/init.c b/drivers/base/init.c
--- a/drivers/base/init.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/init.c Tue Jun 22 09:47:14 2004
@@ -2,7 +2,7 @@
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -33,7 +33,7 @@
classes_init();
firmware_init();

- /* These are also core pieces, but must come after the
+ /* These are also core pieces, but must come after the
* core core pieces.
*/
platform_bus_init();
diff -Nru a/drivers/base/interface.c b/drivers/base/interface.c
--- a/drivers/base/interface.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/interface.c Tue Jun 22 09:47:14 2004
@@ -1,10 +1,10 @@
/*
- * drivers/base/interface.c - common driverfs interface that's exported to
+ * drivers/base/interface.c - common driverfs interface that's exported to
* the world for all devices.
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -16,33 +16,33 @@

/**
* detach_state - control the default power state for the device.
- *
- * This is the state the device enters when it's driver module is
+ *
+ * This is the state the device enters when it's driver module is
* unloaded. The value is an unsigned integer, in the range of 0-4.
* '0' indicates 'On', so no action will be taken when the driver is
* unloaded. This is the default behavior.
* '4' indicates 'Off', meaning the driver core will call the driver's
* shutdown method to quiesce the device.
- * 1-3 indicate a low-power state for the device to enter via the
- * driver's suspend method.
+ * 1-3 indicate a low-power state for the device to enter via the
+ * driver's suspend method.
*/

static ssize_t detach_show(struct device * dev, char * buf)
{
- return sprintf(buf,"%u\n",dev->detach_state);
+ return sprintf(buf, "%u\n", dev->detach_state);
}

static ssize_t detach_store(struct device * dev, const char * buf, size_t n)
{
u32 state;
- state = simple_strtoul(buf,NULL,10);
+ state = simple_strtoul(buf, NULL, 10);
if (state > 4)
return -EINVAL;
dev->detach_state = state;
return n;
}

-static DEVICE_ATTR(detach_state,0644,detach_show,detach_store);
+static DEVICE_ATTR(detach_state, 0644, detach_show, detach_store);


struct attribute * dev_default_attrs[] = {
diff -Nru a/drivers/base/node.c b/drivers/base/node.c
--- a/drivers/base/node.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/node.c Tue Jun 22 09:47:14 2004
@@ -29,7 +29,7 @@
return len;
}

-static SYSDEV_ATTR(cpumap,S_IRUGO,node_read_cpumap,NULL);
+static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumap, NULL);

/* Can be overwritten by architecture specific code. */
int __attribute__((weak)) hugetlb_report_node_meminfo(int node, char *buf)
@@ -54,17 +54,17 @@
"Node %d LowFree: %8lu kB\n",
nid, K(i.totalram),
nid, K(i.freeram),
- nid, K(i.totalram-i.freeram),
+ nid, K(i.totalram - i.freeram),
nid, K(i.totalhigh),
nid, K(i.freehigh),
- nid, K(i.totalram-i.totalhigh),
- nid, K(i.freeram-i.freehigh));
+ nid, K(i.totalram - i.totalhigh),
+ nid, K(i.freeram - i.freehigh));
n += hugetlb_report_node_meminfo(nid, buf + n);
return n;
}

-#undef K
-static SYSDEV_ATTR(meminfo,S_IRUGO,node_read_meminfo,NULL);
+#undef K
+static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);

static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
{
@@ -104,7 +104,7 @@
local_node,
other_node);
}
-static SYSDEV_ATTR(numastat,S_IRUGO,node_read_numastat,NULL);
+static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);

/*
* register_node - Setup a driverfs device for a node.
diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/platform.c Tue Jun 22 09:47:14 2004
@@ -3,7 +3,7 @@
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
- *
+ *
* This file is released under the GPLv2
*
* Please see Documentation/driver-model/platform.txt for more
@@ -116,14 +116,14 @@
pdev->dev.parent = &platform_bus;

pdev->dev.bus = &platform_bus_type;
-
+
if (pdev->id != -1)
snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s%u", pdev->name, pdev->id);
else
strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE);

pr_debug("Registering platform device '%s'. Parent at %s\n",
- pdev->dev.bus_id,pdev->dev.parent->bus_id);
+ pdev->dev.bus_id, pdev->dev.parent->bus_id);
return device_register(&pdev->dev);
}

@@ -139,13 +139,13 @@
* @dev: device.
* @drv: driver.
*
- * Platform device IDs are assumed to be encoded like this:
- * "<name><instance>", where <name> is a short description of the
- * type of device, like "pci" or "floppy", and <instance> is the
+ * Platform device IDs are assumed to be encoded like this:
+ * "<name><instance>", where <name> is a short description of the
+ * type of device, like "pci" or "floppy", and <instance> is the
* enumerated instance of the device, like '0' or '42'.
- * Driver IDs are simply "<name>".
- * So, extract the <name> from the platform_device structure,
- * and compare it against the name of the driver. Return whether
+ * Driver IDs are simply "<name>".
+ * So, extract the <name> from the platform_device structure,
+ * and compare it against the name of the driver. Return whether
* they match or not.
*/

diff -Nru a/drivers/base/power/main.c b/drivers/base/power/main.c
--- a/drivers/base/power/main.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/power/main.c Tue Jun 22 09:47:14 2004
@@ -12,10 +12,10 @@
* and add it to the list of power-controlled devices. sysfs entries for
* controlling device power management will also be added.
*
- * A different set of lists than the global subsystem list are used to
- * keep track of power info because we use different lists to hold
- * devices based on what stage of the power management process they
- * are in. The power domain dependencies may also differ from the
+ * A different set of lists than the global subsystem list are used to
+ * keep track of power info because we use different lists to hold
+ * devices based on what stage of the power management process they
+ * are in. The power domain dependencies may also differ from the
* ancestral dependencies that the subsystem list maintains.
*/

@@ -74,10 +74,10 @@

pr_debug("PM: Adding info for %s:%s\n",
dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
- atomic_set(&dev->power.pm_users,0);
+ atomic_set(&dev->power.pm_users, 0);
down(&dpm_sem);
- list_add_tail(&dev->power.entry,&dpm_active);
- device_pm_set_parent(dev,dev->parent);
+ list_add_tail(&dev->power.entry, &dpm_active);
+ device_pm_set_parent(dev, dev->parent);
if ((error = dpm_sysfs_add(dev)))
list_del(&dev->power.entry);
up(&dpm_sem);
diff -Nru a/drivers/base/power/power.h b/drivers/base/power/power.h
--- a/drivers/base/power/power.h Tue Jun 22 09:47:14 2004
+++ b/drivers/base/power/power.h Tue Jun 22 09:47:14 2004
@@ -27,7 +27,7 @@
*/
extern struct semaphore dpm_sem;

-/*
+/*
* The PM lists.
*/
extern struct list_head dpm_active;
@@ -37,12 +37,12 @@

static inline struct dev_pm_info * to_pm_info(struct list_head * entry)
{
- return container_of(entry,struct dev_pm_info,entry);
+ return container_of(entry, struct dev_pm_info, entry);
}

static inline struct device * to_device(struct list_head * entry)
{
- return container_of(to_pm_info(entry),struct device,power);
+ return container_of(to_pm_info(entry), struct device, power);
}

extern int device_pm_add(struct device *);
@@ -56,7 +56,7 @@
extern void dpm_sysfs_remove(struct device *);

/*
- * resume.c
+ * resume.c
*/

extern void dpm_resume(void);
diff -Nru a/drivers/base/power/resume.c b/drivers/base/power/resume.c
--- a/drivers/base/power/resume.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/power/resume.c Tue Jun 22 09:47:14 2004
@@ -39,7 +39,7 @@
if (!dev->power.prev_state)
resume_device(dev);

- list_add_tail(entry,&dpm_active);
+ list_add_tail(entry, &dpm_active);
}
}

@@ -48,7 +48,7 @@
* device_resume - Restore state of each device in system.
*
* Walk the dpm_off list, remove each entry, resume the device,
- * then add it to the dpm_active list.
+ * then add it to the dpm_active list.
*/

void device_resume(void)
@@ -62,14 +62,14 @@


/**
- * device_power_up_irq - Power on some devices.
+ * device_power_up_irq - Power on some devices.
*
- * Walk the dpm_off_irq list and power each device up. This
+ * Walk the dpm_off_irq list and power each device up. This
* is used for devices that required they be powered down with
* interrupts disabled. As devices are powered on, they are moved to
* the dpm_suspended list.
*
- * Interrupts must be disabled when calling this.
+ * Interrupts must be disabled when calling this.
*/

void dpm_power_up(void)
@@ -78,7 +78,7 @@
struct list_head * entry = dpm_off_irq.next;
list_del_init(entry);
resume_device(to_device(entry));
- list_add_tail(entry,&dpm_active);
+ list_add_tail(entry, &dpm_active);
}
}

diff -Nru a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
--- a/drivers/base/power/runtime.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/power/runtime.c Tue Jun 22 09:47:14 2004
@@ -24,9 +24,9 @@
* dpm_runtime_resume - Power one device back on.
* @dev: Device.
*
- * Bring one device back to the on state by first powering it
+ * Bring one device back to the on state by first powering it
* on, then restoring state. We only operate on devices that aren't
- * already on.
+ * already on.
* FIXME: We need to handle devices that are in an unknown state.
*/

@@ -55,7 +55,7 @@
if (dev->power.power_state)
runtime_resume(dev);

- if (!(error = suspend_device(dev,state)))
+ if (!(error = suspend_device(dev, state)))
dev->power.power_state = state;
Done:
up(&dpm_sem);
@@ -70,7 +70,7 @@
*
* This is an update mechanism for drivers to notify the core
* what power state a device is in. Device probing code may not
- * always be able to tell, but we need accurate information to
+ * always be able to tell, but we need accurate information to
* work reliably.
*/
void dpm_set_power_state(struct device * dev, u32 state)
diff -Nru a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
--- a/drivers/base/power/shutdown.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/power/shutdown.c Tue Jun 22 09:47:14 2004
@@ -1,9 +1,9 @@
/*
* shutdown.c - power management functions for the device tree.
- *
+ *
* Copyright (c) 2002-3 Patrick Mochel
* 2002-3 Open Source Development Lab
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -14,7 +14,7 @@

#include "power.h"

-#define to_dev(node) container_of(node,struct device,kobj.entry)
+#define to_dev(node) container_of(node, struct device, kobj.entry)

extern struct subsystem devices_subsys;

@@ -29,7 +29,7 @@
dev->driver->shutdown(dev);
return 0;
}
- return dpm_runtime_suspend(dev,dev->detach_state);
+ return dpm_runtime_suspend(dev, dev->detach_state);
}


@@ -38,8 +38,8 @@
* down last and resume them first. That way, we don't do anything stupid like
* shutting down the interrupt controller before any devices..
*
- * Note that there are not different stages for power management calls -
- * they only get one called once when interrupts are disabled.
+ * Note that there are not different stages for power management calls -
+ * they only get one called once when interrupts are disabled.
*/

extern int sysdev_shutdown(void);
@@ -50,10 +50,10 @@
void device_shutdown(void)
{
struct device * dev;
-
+
down_write(&devices_subsys.rwsem);
- list_for_each_entry_reverse(dev,&devices_subsys.kset.list,kobj.entry) {
- pr_debug("shutting down %s: ",dev->bus_id);
+ list_for_each_entry_reverse(dev, &devices_subsys.kset.list, kobj.entry) {
+ pr_debug("shutting down %s: ", dev->bus_id);
if (dev->driver && dev->driver->shutdown) {
pr_debug("Ok\n");
dev->driver->shutdown(dev);
diff -Nru a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
--- a/drivers/base/power/suspend.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/power/suspend.c Tue Jun 22 09:47:14 2004
@@ -1,5 +1,5 @@
/*
- * suspend.c - Functions for putting devices to sleep.
+ * suspend.c - Functions for putting devices to sleep.
*
* Copyright (c) 2003 Patrick Mochel
* Copyright (c) 2003 Open Source Development Labs
@@ -10,18 +10,18 @@

#include <linux/device.h>
#include "power.h"
-
+
extern int sysdev_suspend(u32 state);

/*
* The entries in the dpm_active list are in a depth first order, simply
- * because children are guaranteed to be discovered after parents, and
- * are inserted at the back of the list on discovery.
- *
+ * because children are guaranteed to be discovered after parents, and
+ * are inserted at the back of the list on discovery.
+ *
* All list on the suspend path are done in reverse order, so we operate
* on the leaves of the device tree (or forests, depending on how you want
- * to look at it ;) first. As nodes are removed from the back of the list,
- * they are inserted into the front of their destintation lists.
+ * to look at it ;) first. As nodes are removed from the back of the list,
+ * they are inserted into the front of their destintation lists.
*
* Things are the reverse on the resume path - iterations are done in
* forward order, and nodes are inserted at the back of their destination
@@ -44,7 +44,7 @@
dev->power.prev_state = dev->power.power_state;

if (dev->bus && dev->bus->suspend && !dev->power.power_state)
- error = dev->bus->suspend(dev,state);
+ error = dev->bus->suspend(dev, state);

return error;
}
@@ -52,16 +52,16 @@

/**
* device_suspend - Save state and stop all devices in system.
- * @state: Power state to put each device in.
+ * @state: Power state to put each device in.
*
* Walk the dpm_active list, call ->suspend() for each device, and move
- * it to dpm_off.
+ * it to dpm_off.
* Check the return value for each. If it returns 0, then we move the
- * the device to the dpm_off list. If it returns -EAGAIN, we move it to
- * the dpm_off_irq list. If we get a different error, try and back out.
+ * the device to the dpm_off list. If it returns -EAGAIN, we move it to
+ * the dpm_off_irq list. If we get a different error, try and back out.
*
* If we hit a failure with any of the devices, call device_resume()
- * above to bring the suspended devices back to life.
+ * above to bring the suspended devices back to life.
*
* Note this function leaves dpm_sem held to
* a) block other devices from registering.
@@ -78,14 +78,14 @@
while(!list_empty(&dpm_active)) {
struct list_head * entry = dpm_active.prev;
struct device * dev = to_device(entry);
- error = suspend_device(dev,state);
+ error = suspend_device(dev, state);

if (!error) {
list_del(&dev->power.entry);
- list_add(&dev->power.entry,&dpm_off);
+ list_add(&dev->power.entry, &dpm_off);
} else if (error == -EAGAIN) {
list_del(&dev->power.entry);
- list_add(&dev->power.entry,&dpm_off_irq);
+ list_add(&dev->power.entry, &dpm_off_irq);
} else {
printk(KERN_ERR "Could not suspend device %s: "
"error %d\n", kobject_name(&dev->kobj), error);
@@ -108,8 +108,8 @@
* @state: Power state to enter.
*
* Walk the dpm_off_irq list, calling ->power_down() for each device that
- * couldn't power down the device with interrupts enabled. When we're
- * done, power down system devices.
+ * couldn't power down the device with interrupts enabled. When we're
+ * done, power down system devices.
*/

int device_power_down(u32 state)
@@ -117,10 +117,10 @@
int error = 0;
struct device * dev;

- list_for_each_entry_reverse(dev,&dpm_off_irq,power.entry) {
- if ((error = suspend_device(dev,state)))
+ list_for_each_entry_reverse(dev, &dpm_off_irq, power.entry) {
+ if ((error = suspend_device(dev, state)))
break;
- }
+ }
if (error)
goto Error;
if ((error = sysdev_suspend(state)))
diff -Nru a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
--- a/drivers/base/power/sysfs.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/power/sysfs.c Tue Jun 22 09:47:14 2004
@@ -11,10 +11,10 @@
*
* show() returns the current power state of the device. '0' indicates
* the device is on. Other values (1-3) indicate the device is in a low
- * power state.
+ * power state.
*
- * store() sets the current power state, which is an integer value
- * between 0-3. If the device is on ('0'), and the value written is
+ * store() sets the current power state, which is an integer value
+ * between 0-3. If the device is on ('0'), and the value written is
* greater than 0, then the device is placed directly into the low-power
* state (via its driver's ->suspend() method).
* If the device is currently in a low-power state, and the value is 0,
@@ -26,7 +26,7 @@

static ssize_t state_show(struct device * dev, char * buf)
{
- return sprintf(buf,"%u\n",dev->power.power_state);
+ return sprintf(buf, "%u\n", dev->power.power_state);
}

static ssize_t state_store(struct device * dev, const char * buf, size_t n)
@@ -35,17 +35,17 @@
char * rest;
int error = 0;

- state = simple_strtoul(buf,&rest,10);
+ state = simple_strtoul(buf, &rest, 10);
if (*rest)
return -EINVAL;
if (state)
- error = dpm_runtime_suspend(dev,state);
+ error = dpm_runtime_suspend(dev, state);
else
dpm_runtime_resume(dev);
return error ? error : n;
}

-static DEVICE_ATTR(state,0644,state_show,state_store);
+static DEVICE_ATTR(state, 0644, state_show, state_store);


static struct attribute * power_attrs[] = {
@@ -59,10 +59,10 @@

int dpm_sysfs_add(struct device * dev)
{
- return sysfs_create_group(&dev->kobj,&pm_attr_group);
+ return sysfs_create_group(&dev->kobj, &pm_attr_group);
}

void dpm_sysfs_remove(struct device * dev)
{
- sysfs_remove_group(&dev->kobj,&pm_attr_group);
+ sysfs_remove_group(&dev->kobj, &pm_attr_group);
}
diff -Nru a/drivers/base/sys.c b/drivers/base/sys.c
--- a/drivers/base/sys.c Tue Jun 22 09:47:14 2004
+++ b/drivers/base/sys.c Tue Jun 22 09:47:14 2004
@@ -5,8 +5,8 @@
* 2002-3 Open Source Development Lab
*
* This file is released under the GPLv2
- *
- * This exports a 'system' bus type.
+ *
+ * This exports a 'system' bus type.
* By default, a 'sys' bus gets added to the root of the system. There will
* always be core system devices. Devices can use sysdev_register() to
* add themselves as children of the system bus.
@@ -24,31 +24,31 @@

extern struct subsystem devices_subsys;

-#define to_sysdev(k) container_of(k,struct sys_device,kobj)
-#define to_sysdev_attr(a) container_of(a,struct sysdev_attribute,attr)
+#define to_sysdev(k) container_of(k, struct sys_device, kobj)
+#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr)


-static ssize_t
+static ssize_t
sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
{
struct sys_device * sysdev = to_sysdev(kobj);
struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);

if (sysdev_attr->show)
- return sysdev_attr->show(sysdev,buffer);
+ return sysdev_attr->show(sysdev, buffer);
return 0;
}


static ssize_t
-sysdev_store(struct kobject * kobj, struct attribute * attr,
+sysdev_store(struct kobject * kobj, struct attribute * attr,
const char * buffer, size_t count)
{
struct sys_device * sysdev = to_sysdev(kobj);
struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);

if (sysdev_attr->store)
- return sysdev_attr->store(sysdev,buffer,count);
+ return sysdev_attr->store(sysdev, buffer, count);
return 0;
}

@@ -64,22 +64,22 @@

int sysdev_create_file(struct sys_device * s, struct sysdev_attribute * a)
{
- return sysfs_create_file(&s->kobj,&a->attr);
+ return sysfs_create_file(&s->kobj, &a->attr);
}


void sysdev_remove_file(struct sys_device * s, struct sysdev_attribute * a)
{
- sysfs_remove_file(&s->kobj,&a->attr);
+ sysfs_remove_file(&s->kobj, &a->attr);
}

EXPORT_SYMBOL(sysdev_create_file);
EXPORT_SYMBOL(sysdev_remove_file);

-/*
- * declare system_subsys
+/*
+ * declare system_subsys
*/
-decl_subsys(system,&ktype_sysdev,NULL);
+decl_subsys(system, &ktype_sysdev, NULL);

int sysdev_class_register(struct sysdev_class * cls)
{
@@ -87,7 +87,7 @@
kobject_name(&cls->kset.kobj));
INIT_LIST_HEAD(&cls->drivers);
cls->kset.subsys = &system_subsys;
- kset_set_kset_s(cls,system_subsys);
+ kset_set_kset_s(cls, system_subsys);
return kset_register(&cls->kset);
}

@@ -109,19 +109,19 @@
* @cls: Device class driver belongs to.
* @drv: Driver.
*
- * If @cls is valid, then @drv is inserted into @cls->drivers to be
+ * If @cls is valid, then @drv is inserted into @cls->drivers to be
* called on each operation on devices of that class. The refcount
- * of @cls is incremented.
- * Otherwise, @drv is inserted into global_drivers, and called for
+ * of @cls is incremented.
+ * Otherwise, @drv is inserted into global_drivers, and called for
* each device.
*/

-int sysdev_driver_register(struct sysdev_class * cls,
+int sysdev_driver_register(struct sysdev_class * cls,
struct sysdev_driver * drv)
{
down_write(&system_subsys.rwsem);
if (cls && kset_get(&cls->kset)) {
- list_add_tail(&drv->entry,&cls->drivers);
+ list_add_tail(&drv->entry, &cls->drivers);

/* If devices of this class already exist, tell the driver */
if (drv->add) {
@@ -130,7 +130,7 @@
drv->add(dev);
}
} else
- list_add_tail(&drv->entry,&global_drivers);
+ list_add_tail(&drv->entry, &global_drivers);
up_write(&system_subsys.rwsem);
return 0;
}
@@ -180,12 +180,12 @@

/* But make sure we point to the right type for sysfs translation */
sysdev->kobj.ktype = &ktype_sysdev;
- error = kobject_set_name(&sysdev->kobj,"%s%d",
- kobject_name(&cls->kset.kobj),sysdev->id);
+ error = kobject_set_name(&sysdev->kobj, "%s%d",
+ kobject_name(&cls->kset.kobj), sysdev->id);
if (error)
return error;

- pr_debug("Registering sys device '%s'\n",kobject_name(&sysdev->kobj));
+ pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));

/* Register the object */
error = kobject_register(&sysdev->kobj);
@@ -194,18 +194,18 @@
struct sysdev_driver * drv;

down_write(&system_subsys.rwsem);
- /* Generic notification is implicit, because it's that
- * code that should have called us.
+ /* Generic notification is implicit, because it's that
+ * code that should have called us.
*/

/* Notify global drivers */
- list_for_each_entry(drv,&global_drivers,entry) {
+ list_for_each_entry(drv, &global_drivers, entry) {
if (drv->add)
drv->add(sysdev);
}

/* Notify class auxillary drivers */
- list_for_each_entry(drv,&cls->drivers,entry) {
+ list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->add)
drv->add(sysdev);
}
@@ -219,12 +219,12 @@
struct sysdev_driver * drv;

down_write(&system_subsys.rwsem);
- list_for_each_entry(drv,&global_drivers,entry) {
+ list_for_each_entry(drv, &global_drivers, entry) {
if (drv->remove)
drv->remove(sysdev);
}

- list_for_each_entry(drv,&sysdev->cls->drivers,entry) {
+ list_for_each_entry(drv, &sysdev->cls->drivers, entry) {
if (drv->remove)
drv->remove(sysdev);
}
@@ -241,12 +241,12 @@
* Loop over each class of system devices, and the devices in each
* of those classes. For each device, we call the shutdown method for
* each driver registered for the device - the globals, the auxillaries,
- * and the class driver.
+ * and the class driver.
*
* Note: The list is iterated in reverse order, so that we shut down
* child devices before we shut down thier parents. The list ordering
* is guaranteed by virtue of the fact that child devices are registered
- * after their parents.
+ * after their parents.
*/

void sysdev_shutdown(void)
@@ -256,25 +256,25 @@
pr_debug("Shutting Down System Devices\n");

down_write(&system_subsys.rwsem);
- list_for_each_entry_reverse(cls,&system_subsys.kset.list,
+ list_for_each_entry_reverse(cls, &system_subsys.kset.list,
kset.kobj.entry) {
struct sys_device * sysdev;

pr_debug("Shutting down type '%s':\n",
kobject_name(&cls->kset.kobj));

- list_for_each_entry(sysdev,&cls->kset.list,kobj.entry) {
+ list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
struct sysdev_driver * drv;
- pr_debug(" %s\n",kobject_name(&sysdev->kobj));
+ pr_debug(" %s\n", kobject_name(&sysdev->kobj));

/* Call global drivers first. */
- list_for_each_entry(drv,&global_drivers,entry) {
+ list_for_each_entry(drv, &global_drivers, entry) {
if (drv->shutdown)
drv->shutdown(sysdev);
}

/* Call auxillary drivers next. */
- list_for_each_entry(drv,&cls->drivers,entry) {
+ list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->shutdown)
drv->shutdown(sysdev);
}
@@ -295,7 +295,7 @@
* We perform an almost identical operation as sys_device_shutdown()
* above, though calling ->suspend() instead. Interrupts are disabled
* when this called. Devices are responsible for both saving state and
- * quiescing or powering down the device.
+ * quiescing or powering down the device.
*
* This is only called by the device PM core, so we let them handle
* all synchronization.
@@ -307,32 +307,32 @@

pr_debug("Suspending System Devices\n");

- list_for_each_entry_reverse(cls,&system_subsys.kset.list,
+ list_for_each_entry_reverse(cls, &system_subsys.kset.list,
kset.kobj.entry) {
struct sys_device * sysdev;

pr_debug("Suspending type '%s':\n",
kobject_name(&cls->kset.kobj));

- list_for_each_entry(sysdev,&cls->kset.list,kobj.entry) {
+ list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
struct sysdev_driver * drv;
- pr_debug(" %s\n",kobject_name(&sysdev->kobj));
+ pr_debug(" %s\n", kobject_name(&sysdev->kobj));

/* Call global drivers first. */
- list_for_each_entry(drv,&global_drivers,entry) {
+ list_for_each_entry(drv, &global_drivers, entry) {
if (drv->suspend)
- drv->suspend(sysdev,state);
+ drv->suspend(sysdev, state);
}

/* Call auxillary drivers next. */
- list_for_each_entry(drv,&cls->drivers,entry) {
+ list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->suspend)
- drv->suspend(sysdev,state);
+ drv->suspend(sysdev, state);
}

/* Now call the generic one */
if (cls->suspend)
- cls->suspend(sysdev,state);
+ cls->suspend(sysdev, state);
}
}
return 0;
@@ -345,7 +345,7 @@
* Similar to sys_device_suspend(), but we iterate the list forwards
* to guarantee that parent devices are resumed before their children.
*
- * Note: Interrupts are disabled when called.
+ * Note: Interrupts are disabled when called.
*/

int sysdev_resume(void)
@@ -354,28 +354,28 @@

pr_debug("Resuming System Devices\n");

- list_for_each_entry(cls,&system_subsys.kset.list,kset.kobj.entry) {
+ list_for_each_entry(cls, &system_subsys.kset.list, kset.kobj.entry) {
struct sys_device * sysdev;

pr_debug("Resuming type '%s':\n",
kobject_name(&cls->kset.kobj));

- list_for_each_entry(sysdev,&cls->kset.list,kobj.entry) {
+ list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
struct sysdev_driver * drv;
- pr_debug(" %s\n",kobject_name(&sysdev->kobj));
+ pr_debug(" %s\n", kobject_name(&sysdev->kobj));

/* First, call the class-specific one */
if (cls->resume)
cls->resume(sysdev);

/* Call auxillary drivers next. */
- list_for_each_entry(drv,&cls->drivers,entry) {
+ list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->resume)
drv->resume(sysdev);
}

/* Call global drivers. */
- list_for_each_entry(drv,&global_drivers,entry) {
+ list_for_each_entry(drv, &global_drivers, entry) {
if (drv->resume)
drv->resume(sysdev);
}

2004-06-22 19:08:56

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1825, 2004/06/22 09:20:30-07:00, [email protected]

[PATCH] USB: sparse fixups for devio.c


drivers/usb/core/devio.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)


diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
--- a/drivers/usb/core/devio.c Tue Jun 22 09:46:22 2004
+++ b/drivers/usb/core/devio.c Tue Jun 22 09:46:22 2004
@@ -290,8 +290,11 @@
spin_lock_irqsave(&ps->lock, flags);
}
spin_unlock_irqrestore(&ps->lock, flags);
- while ((as = async_getcompleted(ps)))
+ as = async_getcompleted(ps);
+ while (as) {
free_async(as);
+ as = async_getcompleted(ps);
+ }
}

static void destroy_async_on_interface (struct dev_state *ps, unsigned int ifnum)
@@ -968,29 +971,27 @@
static int processcompl(struct async *as)
{
struct urb *urb = as->urb;
+ struct usbdevfs_urb __user *userurb = as->userurb;
unsigned int i;

if (as->userbuffer)
if (copy_to_user(as->userbuffer, urb->transfer_buffer, urb->transfer_buffer_length))
return -EFAULT;
- if (put_user(urb->status,
- &((struct usbdevfs_urb *)as->userurb)->status))
+ if (put_user(urb->status, &userurb->status))
return -EFAULT;
- if (put_user(urb->actual_length,
- &((struct usbdevfs_urb *)as->userurb)->actual_length))
+ if (put_user(urb->actual_length, &userurb->actual_length))
return -EFAULT;
- if (put_user(urb->error_count,
- &((struct usbdevfs_urb *)as->userurb)->error_count))
+ if (put_user(urb->error_count, &userurb->error_count))
return -EFAULT;

if (!(usb_pipeisoc(urb->pipe)))
return 0;
for (i = 0; i < urb->number_of_packets; i++) {
if (put_user(urb->iso_frame_desc[i].actual_length,
- &((struct usbdevfs_urb *)as->userurb)->iso_frame_desc[i].actual_length))
+ &userurb->iso_frame_desc[i].actual_length))
return -EFAULT;
if (put_user(urb->iso_frame_desc[i].status,
- &((struct usbdevfs_urb *)as->userurb)->iso_frame_desc[i].status))
+ &userurb->iso_frame_desc[i].status))
return -EFAULT;
}
return 0;

2004-06-22 18:11:20

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.24, 2004/06/11 17:22:14-07:00, [email protected]

[PATCH] Driver Model: Add class support to msr.c

This patch enables class support in arch/i386/kernel/msr.c. Very simliar
to cpuid (with the fixes Zwane/Greg made, thanks).

[root@w-hlinder2 root]# tree /sys/class/msr
/sys/class/msr
| -- msr0
| `-- dev
`-- msr1
`-- dev

2 directories, 2 files

Thanks to Randy Dunlap for pointing out the unnecessary tabs. Fixed.

Signed-off-by Hanna Linder <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


arch/i386/kernel/msr.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 69 insertions(+), 2 deletions(-)


diff -Nru a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
--- a/arch/i386/kernel/msr.c Tue Jun 22 09:46:58 2004
+++ b/arch/i386/kernel/msr.c Tue Jun 22 09:46:58 2004
@@ -35,12 +35,17 @@
#include <linux/smp_lock.h>
#include <linux/major.h>
#include <linux/fs.h>
+#include <linux/device.h>
+#include <linux/cpu.h>
+#include <linux/notifier.h>

#include <asm/processor.h>
#include <asm/msr.h>
#include <asm/uaccess.h>
#include <asm/system.h>

+static struct class_simple *msr_class;
+
/* Note: "err" is handled in a funny way below. Otherwise one version
of gcc or another breaks. */

@@ -255,20 +260,82 @@
.open = msr_open,
};

+static int msr_class_simple_device_add(int i)
+{
+ int err = 0;
+ struct class_device *class_err;
+
+ class_err = class_simple_device_add(msr_class, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i);
+ if (IS_ERR(class_err))
+ err = PTR_ERR(class_err);
+ return err;
+}
+
+static int __devinit msr_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
+{
+ unsigned int cpu = (unsigned long)hcpu;
+
+ switch (action) {
+ case CPU_ONLINE:
+ msr_class_simple_device_add(cpu);
+ break;
+ case CPU_DEAD:
+ class_simple_device_remove(MKDEV(MSR_MAJOR, cpu));
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block msr_class_cpu_notifier =
+{
+ .notifier_call = msr_class_cpu_callback,
+};
+
int __init msr_init(void)
{
+ int i, err = 0;
+ i = 0;
+
if (register_chrdev(MSR_MAJOR, "cpu/msr", &msr_fops)) {
printk(KERN_ERR "msr: unable to get major %d for msr\n",
MSR_MAJOR);
- return -EBUSY;
+ err = -EBUSY;
+ goto out;
+ }
+ msr_class = class_simple_create(THIS_MODULE, "msr");
+ if (IS_ERR(msr_class)) {
+ err = PTR_ERR(msr_class);
+ goto out_chrdev;
}
+ for_each_online_cpu(i) {
+ err = msr_class_simple_device_add(i);
+ if (err != 0)
+ goto out_class;
+ }
+ register_cpu_notifier(&msr_class_cpu_notifier);

- return 0;
+ err = 0;
+ goto out;
+
+out_class:
+ i = 0;
+ for_each_online_cpu(i)
+ class_simple_device_remove(MKDEV(MSR_MAJOR, i));
+ class_simple_destroy(msr_class);
+out_chrdev:
+ unregister_chrdev(MSR_MAJOR, "cpu/msr");
+out:
+ return err;
}

void __exit msr_exit(void)
{
+ int cpu = 0;
+ for_each_online_cpu(cpu)
+ class_simple_device_remove(MKDEV(MSR_MAJOR, cpu));
+ class_simple_destroy(msr_class);
unregister_chrdev(MSR_MAJOR, "cpu/msr");
+ unregister_cpu_notifier(&msr_class_cpu_notifier);
}

module_init(msr_init);

2004-06-22 18:07:16

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.55, 2004/06/04 16:48:04-07:00, [email protected]

Driver core: finally add a MAINTAINERS entry for it.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


MAINTAINERS | 6 ++++++
1 files changed, 6 insertions(+)


diff -Nru a/MAINTAINERS b/MAINTAINERS
--- a/MAINTAINERS Tue Jun 22 09:48:00 2004
+++ b/MAINTAINERS Tue Jun 22 09:48:00 2004
@@ -689,6 +689,12 @@
L: [email protected]
S: Maintained

+DRIVER CORE, KOBJECTS, AND SYSFS
+P: Greg Kroah-Hartman
+M: [email protected]
+L: [email protected]
+S: Supported
+
DRM DRIVERS
L: [email protected]
S: Supported

2004-06-22 19:27:13

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.22, 2004/06/10 09:36:26-07:00, [email protected]

Driver Core: more whitespace fixups

This catches the files I had to do by hand as Dmitry's patch differed from my tree.

Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/base/bus.c | 129 +++++++++++++++++++++++++--------------------------
drivers/base/class.c | 36 +++++++-------
2 files changed, 82 insertions(+), 83 deletions(-)


diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c Tue Jun 22 09:47:09 2004
+++ b/drivers/base/bus.c Tue Jun 22 09:47:09 2004
@@ -3,7 +3,7 @@
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -17,17 +17,17 @@
#include "base.h"
#include "power/power.h"

-#define to_dev(node) container_of(node,struct device,bus_list)
-#define to_drv(node) container_of(node,struct device_driver,kobj.entry)
+#define to_dev(node) container_of(node, struct device, bus_list)
+#define to_drv(node) container_of(node, struct device_driver, kobj.entry)

-#define to_bus_attr(_attr) container_of(_attr,struct bus_attribute,attr)
-#define to_bus(obj) container_of(obj,struct bus_type,subsys.kset.kobj)
+#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
+#define to_bus(obj) container_of(obj, struct bus_type, subsys.kset.kobj)

/*
* sysfs bindings for drivers
*/

-#define to_drv_attr(_attr) container_of(_attr,struct driver_attribute,attr)
+#define to_drv_attr(_attr) container_of(_attr, struct driver_attribute, attr)
#define to_driver(obj) container_of(obj, struct device_driver, kobj)


@@ -39,12 +39,12 @@
ssize_t ret = 0;

if (drv_attr->show)
- ret = drv_attr->show(drv,buf);
+ ret = drv_attr->show(drv, buf);
return ret;
}

static ssize_t
-drv_attr_store(struct kobject * kobj, struct attribute * attr,
+drv_attr_store(struct kobject * kobj, struct attribute * attr,
const char * buf, size_t count)
{
struct driver_attribute * drv_attr = to_drv_attr(attr);
@@ -52,7 +52,7 @@
ssize_t ret = 0;

if (drv_attr->store)
- ret = drv_attr->store(drv,buf,count);
+ ret = drv_attr->store(drv, buf, count);
return ret;
}

@@ -87,12 +87,12 @@
ssize_t ret = 0;

if (bus_attr->show)
- ret = bus_attr->show(bus,buf);
+ ret = bus_attr->show(bus, buf);
return ret;
}

static ssize_t
-bus_attr_store(struct kobject * kobj, struct attribute * attr,
+bus_attr_store(struct kobject * kobj, struct attribute * attr,
const char * buf, size_t count)
{
struct bus_attribute * bus_attr = to_bus_attr(attr);
@@ -100,7 +100,7 @@
ssize_t ret = 0;

if (bus_attr->store)
- ret = bus_attr->store(bus,buf,count);
+ ret = bus_attr->store(bus, buf, count);
return ret;
}

@@ -113,7 +113,7 @@
{
int error;
if (get_bus(bus)) {
- error = sysfs_create_file(&bus->subsys.kset.kobj,&attr->attr);
+ error = sysfs_create_file(&bus->subsys.kset.kobj, &attr->attr);
put_bus(bus);
} else
error = -EINVAL;
@@ -123,7 +123,7 @@
void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
{
if (get_bus(bus)) {
- sysfs_remove_file(&bus->subsys.kset.kobj,&attr->attr);
+ sysfs_remove_file(&bus->subsys.kset.kobj, &attr->attr);
put_bus(bus);
}
}
@@ -133,7 +133,7 @@

};

-decl_subsys(bus,&ktype_bus,NULL);
+decl_subsys(bus, &ktype_bus, NULL);

/**
* bus_for_each_dev - device iterator.
@@ -151,10 +151,10 @@
*
* NOTE: The device that returns a non-zero value is not retained
* in any way, nor is its refcount incremented. If the caller needs
- * to retain this data, it should do, and increment the reference
+ * to retain this data, it should do, and increment the reference
* count in the supplied callback.
*/
-int bus_for_each_dev(struct bus_type * bus, struct device * start,
+int bus_for_each_dev(struct bus_type * bus, struct device * start,
void * data, int (*fn)(struct device *, void *))
{
struct device *dev;
@@ -170,7 +170,7 @@
down_read(&bus->subsys.rwsem);
list_for_each_entry_continue(dev, head, bus_list) {
get_device(dev);
- error = fn(dev,data);
+ error = fn(dev, data);
put_device(dev);
if (error)
break;
@@ -193,7 +193,7 @@
* and return it. If @start is not NULL, we use it as the head
* of the list.
*
- * NOTE: we don't return the driver that returns a non-zero
+ * NOTE: we don't return the driver that returns a non-zero
* value, nor do we leave the reference count incremented for that
* driver. If the caller needs to know that info, it must set it
* in the callback. It must also be sure to increment the refcount
@@ -216,7 +216,7 @@
down_read(&bus->subsys.rwsem);
list_for_each_entry_continue(drv, head, kobj.entry) {
get_driver(drv);
- error = fn(drv,data);
+ error = fn(drv, data);
put_driver(drv);
if(error)
break;
@@ -233,8 +233,8 @@
* Allow manual attachment of a driver to a deivce.
* Caller must have already set @dev->driver.
*
- * Note that this does not modify the bus reference count
- * nor take the bus's rwsem. Please verify those are accounted
+ * Note that this does not modify the bus reference count
+ * nor take the bus's rwsem. Please verify those are accounted
* for before calling this. (It is ok to call with no other effort
* from a driver's probe() method.)
*/
@@ -242,9 +242,9 @@
void device_bind_driver(struct device * dev)
{
pr_debug("bound device '%s' to driver '%s'\n",
- dev->bus_id,dev->driver->name);
- list_add_tail(&dev->driver_list,&dev->driver->devices);
- sysfs_create_link(&dev->driver->kobj,&dev->kobj,
+ dev->bus_id, dev->driver->name);
+ list_add_tail(&dev->driver_list, &dev->driver->devices);
+ sysfs_create_link(&dev->driver->kobj, &dev->kobj,
kobject_name(&dev->kobj));
}

@@ -255,18 +255,18 @@
* @drv: driver.
*
* First, we call the bus's match function, which should compare
- * the device IDs the driver supports with the device IDs of the
- * device. Note we don't do this ourselves because we don't know
+ * the device IDs the driver supports with the device IDs of the
+ * device. Note we don't do this ourselves because we don't know
* the format of the ID structures, nor what is to be considered
* a match and what is not.
- *
- * If we find a match, we call @drv->probe(@dev) if it exists, and
+ *
+ * If we find a match, we call @drv->probe(@dev) if it exists, and
* call attach() above.
*/
static int bus_match(struct device * dev, struct device_driver * drv)
{
int error = -ENODEV;
- if (dev->bus->match(dev,drv)) {
+ if (dev->bus->match(dev, drv)) {
dev->driver = drv;
if (drv->probe) {
if ((error = drv->probe(dev))) {
@@ -285,7 +285,7 @@
* device_attach - try to attach device to a driver.
* @dev: device.
*
- * Walk the list of drivers that the bus has and call bus_match()
+ * Walk the list of drivers that the bus has and call bus_match()
* for each pair. If a compatible pair is found, break out and return.
*/
static int device_attach(struct device * dev)
@@ -300,15 +300,15 @@
}

if (bus->match) {
- list_for_each(entry,&bus->drivers.list) {
+ list_for_each(entry, &bus->drivers.list) {
struct device_driver * drv = to_drv(entry);
- error = bus_match(dev,drv);
- if (!error )
+ error = bus_match(dev, drv);
+ if (!error)
/* success, driver matched */
- return 1;
- if (error != -ENODEV)
+ return 1;
+ if (error != -ENODEV)
/* driver matched but the probe failed */
- printk(KERN_WARNING
+ printk(KERN_WARNING
"%s: probe of %s failed with error %d\n",
drv->name, dev->bus_id, error);
}
@@ -327,7 +327,7 @@
* If bus_match() returns 0 and the @dev->driver is set, we've found
* a compatible pair.
*
- * Note that we ignore the -ENODEV error from bus_match(), since it's
+ * Note that we ignore the -ENODEV error from bus_match(), since it's
* perfectly valid for a driver not to bind to any devices.
*/
void driver_attach(struct device_driver * drv)
@@ -339,13 +339,13 @@
if (!bus->match)
return;

- list_for_each(entry,&bus->devices.list) {
- struct device * dev = container_of(entry,struct device,bus_list);
+ list_for_each(entry, &bus->devices.list) {
+ struct device * dev = container_of(entry, struct device, bus_list);
if (!dev->driver) {
- error = bus_match(dev,drv);
+ error = bus_match(dev, drv);
if (error && (error != -ENODEV))
/* driver matched but the probe failed */
- printk(KERN_WARNING
+ printk(KERN_WARNING
"%s: probe of %s failed with error %d\n",
drv->name, dev->bus_id, error);
}
@@ -367,7 +367,7 @@
{
struct device_driver * drv = dev->driver;
if (drv) {
- sysfs_remove_link(&drv->kobj,kobject_name(&dev->kobj));
+ sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
list_del_init(&dev->driver_list);
device_detach_shutdown(dev);
if (drv->remove)
@@ -385,11 +385,10 @@
static void driver_detach(struct device_driver * drv)
{
struct list_head * entry, * next;
- list_for_each_safe(entry,next,&drv->devices) {
- struct device * dev = container_of(entry,struct device,driver_list);
+ list_for_each_safe(entry, next, &drv->devices) {
+ struct device * dev = container_of(entry, struct device, driver_list);
device_release_driver(dev);
}
-
}

static int device_add_attrs(struct bus_type * bus, struct device * dev)
@@ -439,12 +438,12 @@

if (bus) {
down_write(&dev->bus->subsys.rwsem);
- pr_debug("bus %s: add device %s\n",bus->name,dev->bus_id);
- list_add_tail(&dev->bus_list,&dev->bus->devices.list);
+ pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
+ list_add_tail(&dev->bus_list, &dev->bus->devices.list);
device_attach(dev);
up_write(&dev->bus->subsys.rwsem);
- device_add_attrs(bus,dev);
- sysfs_create_link(&bus->devices.kobj,&dev->kobj,dev->bus_id);
+ device_add_attrs(bus, dev);
+ sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
}
return error;
}
@@ -461,10 +460,10 @@
void bus_remove_device(struct device * dev)
{
if (dev->bus) {
- sysfs_remove_link(&dev->bus->devices.kobj,dev->bus_id);
- device_remove_attrs(dev->bus,dev);
+ sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
+ device_remove_attrs(dev->bus, dev);
down_write(&dev->bus->subsys.rwsem);
- pr_debug("bus %s: remove device %s\n",dev->bus->name,dev->bus_id);
+ pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
device_release_driver(dev);
list_del_init(&dev->bus_list);
up_write(&dev->bus->subsys.rwsem);
@@ -484,8 +483,8 @@
int error = 0;

if (bus) {
- pr_debug("bus %s: add driver %s\n",bus->name,drv->name);
- error = kobject_set_name(&drv->kobj,drv->name);
+ pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
+ error = kobject_set_name(&drv->kobj, drv->name);
if (error) {
put_bus(bus);
return error;
@@ -518,7 +517,7 @@
{
if (drv->bus) {
down_write(&drv->bus->subsys.rwsem);
- pr_debug("bus %s: remove driver %s\n",drv->bus->name,drv->name);
+ pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
driver_detach(drv);
up_write(&drv->bus->subsys.rwsem);
kobject_unregister(&drv->kobj);
@@ -560,7 +559,7 @@

struct bus_type * get_bus(struct bus_type * bus)
{
- return bus ? container_of(subsys_get(&bus->subsys),struct bus_type,subsys) : NULL;
+ return bus ? container_of(subsys_get(&bus->subsys), struct bus_type, subsys) : NULL;
}

void put_bus(struct bus_type * bus)
@@ -579,7 +578,7 @@

struct bus_type * find_bus(char * name)
{
- struct kobject * k = kset_find_obj(&bus_subsys.kset,name);
+ struct kobject * k = kset_find_obj(&bus_subsys.kset, name);
return k ? to_bus(k) : NULL;
}

@@ -624,19 +623,19 @@
*
* Once we have that, we registered the bus with the kobject
* infrastructure, then register the children subsystems it has:
- * the devices and drivers that belong to the bus.
+ * the devices and drivers that belong to the bus.
*/
int bus_register(struct bus_type * bus)
{
int retval;

- retval = kobject_set_name(&bus->subsys.kset.kobj,bus->name);
+ retval = kobject_set_name(&bus->subsys.kset.kobj, bus->name);
if (retval)
goto out;

- subsys_set_kset(bus,bus_subsys);
+ subsys_set_kset(bus, bus_subsys);
retval = subsystem_register(&bus->subsys);
- if (retval)
+ if (retval)
goto out;

kobject_set_name(&bus->devices.kobj, "devices");
@@ -653,7 +652,7 @@
goto bus_drivers_fail;
bus_add_attrs(bus);

- pr_debug("bus type '%s' registered\n",bus->name);
+ pr_debug("bus type '%s' registered\n", bus->name);
return 0;

bus_drivers_fail:
@@ -666,7 +665,7 @@


/**
- * bus_unregister - remove a bus from the system
+ * bus_unregister - remove a bus from the system
* @bus: bus.
*
* Unregister the child subsystems and the bus itself.
@@ -674,7 +673,7 @@
*/
void bus_unregister(struct bus_type * bus)
{
- pr_debug("bus %s: unregistering\n",bus->name);
+ pr_debug("bus %s: unregistering\n", bus->name);
bus_remove_attrs(bus);
kset_unregister(&bus->drivers);
kset_unregister(&bus->devices);
diff -Nru a/drivers/base/class.c b/drivers/base/class.c
--- a/drivers/base/class.c Tue Jun 22 09:47:09 2004
+++ b/drivers/base/class.c Tue Jun 22 09:47:09 2004
@@ -5,7 +5,7 @@
* Copyright (c) 2002-3 Open Source Development Labs
* Copyright (c) 2003-2004 Greg Kroah-Hartman
* Copyright (c) 2003-2004 IBM Corp.
- *
+ *
* This file is released under the GPLv2
*
*/
@@ -17,8 +17,8 @@
#include <linux/string.h>
#include "base.h"

-#define to_class_attr(_attr) container_of(_attr,struct class_attribute,attr)
-#define to_class(obj) container_of(obj,struct class,subsys.kset.kobj)
+#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
+#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj)

static ssize_t
class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
@@ -28,12 +28,12 @@
ssize_t ret = 0;

if (class_attr->show)
- ret = class_attr->show(dc,buf);
+ ret = class_attr->show(dc, buf);
return ret;
}

static ssize_t
-class_attr_store(struct kobject * kobj, struct attribute * attr,
+class_attr_store(struct kobject * kobj, struct attribute * attr,
const char * buf, size_t count)
{
struct class_attribute * class_attr = to_class_attr(attr);
@@ -41,7 +41,7 @@
ssize_t ret = 0;

if (class_attr->store)
- ret = class_attr->store(dc,buf,count);
+ ret = class_attr->store(dc, buf, count);
return ret;
}

@@ -69,14 +69,14 @@
};

/* Hotplug events for classes go to the class_obj subsys */
-static decl_subsys(class,&ktype_class,NULL);
+static decl_subsys(class, &ktype_class, NULL);


int class_create_file(struct class * cls, const struct class_attribute * attr)
{
int error;
if (cls) {
- error = sysfs_create_file(&cls->subsys.kset.kobj,&attr->attr);
+ error = sysfs_create_file(&cls->subsys.kset.kobj, &attr->attr);
} else
error = -EINVAL;
return error;
@@ -85,13 +85,13 @@
void class_remove_file(struct class * cls, const struct class_attribute * attr)
{
if (cls)
- sysfs_remove_file(&cls->subsys.kset.kobj,&attr->attr);
+ sysfs_remove_file(&cls->subsys.kset.kobj, &attr->attr);
}

struct class * class_get(struct class * cls)
{
if (cls)
- return container_of(subsys_get(&cls->subsys),struct class,subsys);
+ return container_of(subsys_get(&cls->subsys), struct class, subsys);
return NULL;
}

@@ -135,15 +135,15 @@
{
int error;

- pr_debug("device class '%s': registering\n",cls->name);
+ pr_debug("device class '%s': registering\n", cls->name);

INIT_LIST_HEAD(&cls->children);
INIT_LIST_HEAD(&cls->interfaces);
- error = kobject_set_name(&cls->subsys.kset.kobj,cls->name);
+ error = kobject_set_name(&cls->subsys.kset.kobj, cls->name);
if (error)
return error;

- subsys_set_kset(cls,class_subsys);
+ subsys_set_kset(cls, class_subsys);

error = subsystem_register(&cls->subsys);
if (!error) {
@@ -155,7 +155,7 @@

void class_unregister(struct class * cls)
{
- pr_debug("device class '%s': unregistering\n",cls->name);
+ pr_debug("device class '%s': unregistering\n", cls->name);
remove_class_attrs(cls);
subsystem_unregister(&cls->subsys);
}
@@ -215,12 +215,12 @@
ssize_t ret = 0;

if (class_dev_attr->show)
- ret = class_dev_attr->show(cd,buf);
+ ret = class_dev_attr->show(cd, buf);
return ret;
}

static ssize_t
-class_device_attr_store(struct kobject * kobj, struct attribute * attr,
+class_device_attr_store(struct kobject * kobj, struct attribute * attr,
const char * buf, size_t count)
{
struct class_device_attribute * class_dev_attr = to_class_dev_attr(attr);
@@ -228,7 +228,7 @@
ssize_t ret = 0;

if (class_dev_attr->store)
- ret = class_dev_attr->store(cd,buf,count);
+ ret = class_dev_attr->store(cd, buf, count);
return ret;
}

@@ -242,7 +242,7 @@
struct class_device *cd = to_class_dev(kobj);
struct class * cls = cd->class;

- pr_debug("device class '%s': release.\n",cd->class_id);
+ pr_debug("device class '%s': release.\n", cd->class_id);

if (cls->release)
cls->release(cd);

2004-06-22 19:28:25

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.46, 2004/06/03 09:48:45-07:00, [email protected]

Add basic sysfs support for raw devices

This is needed by people who use udev and want raw devices.
SuSE is shipping with this patch.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/char/raw.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletion(-)


diff -Nru a/drivers/char/raw.c b/drivers/char/raw.c
--- a/drivers/char/raw.c Tue Jun 22 09:49:10 2004
+++ b/drivers/char/raw.c Tue Jun 22 09:49:10 2004
@@ -18,6 +18,7 @@
#include <linux/capability.h>
#include <linux/uio.h>
#include <linux/cdev.h>
+#include <linux/device.h>

#include <asm/uaccess.h>

@@ -26,6 +27,7 @@
int inuse;
};

+static struct class_simple *raw_class;
static struct raw_device_data raw_devices[MAX_RAW_MINORS];
static DECLARE_MUTEX(raw_mutex);
static struct file_operations raw_ctl_fops; /* forward declaration */
@@ -123,6 +125,13 @@
return ioctl_by_bdev(bdev, command, arg);
}

+static void bind_device(struct raw_config_request rq)
+{
+ class_simple_device_remove(MKDEV(RAW_MAJOR, rq.raw_minor));
+ class_simple_device_add(raw_class, MKDEV(RAW_MAJOR, rq.raw_minor),
+ NULL, "raw%d", rq.raw_minor);
+}
+
/*
* Deal with ioctls against the raw-device control interface, to bind
* and unbind other raw devices.
@@ -191,12 +200,15 @@
if (rq.block_major == 0 && rq.block_minor == 0) {
/* unbind */
rawdev->binding = NULL;
+ class_simple_device_remove(MKDEV(RAW_MAJOR, rq.raw_minor));
} else {
rawdev->binding = bdget(dev);
if (rawdev->binding == NULL)
err = -ENOMEM;
- else
+ else {
__module_get(THIS_MODULE);
+ bind_device(rq);
+ }
}
up(&raw_mutex);
} else {
@@ -287,6 +299,15 @@
goto error;
}

+ raw_class = class_simple_create(THIS_MODULE, "raw");
+ if (IS_ERR(raw_class)) {
+ printk(KERN_ERR "Error creating raw class.\n");
+ cdev_del(&raw_cdev);
+ unregister_chrdev_region(dev, MAX_RAW_MINORS);
+ goto error;
+ }
+ class_simple_device_add(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
+
devfs_mk_cdev(MKDEV(RAW_MAJOR, 0),
S_IFCHR | S_IRUGO | S_IWUGO,
"raw/rawctl");
@@ -309,6 +330,8 @@
devfs_remove("raw/raw%d", i);
devfs_remove("raw/rawctl");
devfs_remove("raw");
+ class_simple_device_remove(MKDEV(RAW_MAJOR, 0));
+ class_simple_destroy(raw_class);
cdev_del(&raw_cdev);
unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS);
}

2004-06-22 18:07:15

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.20, 2004/06/10 09:25:58-07:00, [email protected]

[PATCH] Driver Core: Suppress platform device suffixes

Do not add numeric suffix to platform device name if device id is set to
-1. This can be used when there can be only one instance of a device
(like i8042).

Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/base/platform.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)


diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c Tue Jun 22 09:47:19 2004
+++ b/drivers/base/platform.c Tue Jun 22 09:47:19 2004
@@ -117,7 +117,10 @@

pdev->dev.bus = &platform_bus_type;

- snprintf(pdev->dev.bus_id,BUS_ID_SIZE,"%s%u",pdev->name,pdev->id);
+ if (pdev->id != -1)
+ snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s%u", pdev->name, pdev->id);
+ else
+ strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE);

pr_debug("Registering platform device '%s'. Parent at %s\n",
pdev->dev.bus_id,pdev->dev.parent->bus_id);

2004-06-22 18:07:14

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.56, 2004/06/08 16:26:12-07:00, [email protected]

[PATCH] Add cpu hotplug support to cpuid.c

Here is the patch that uses a cpu hotplug callback, to allow dynamic support
of cpu id for classes in sysfs.

This patch applies on top of the one I sent out earlier that Greg included.
I do not have access to hardware that supports cpu hotswapping (virtually or not)
so have not been able to test that aspect of the patch. However, the original
functionality of listing static cpu's still works.

Please consider for testing or inclusion.

Signed-off-by: Hanna Linder <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


arch/i386/kernel/cpuid.c | 59 ++++++++++++++++++++++++++++++++++++++---------
1 files changed, 48 insertions(+), 11 deletions(-)


diff -Nru a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
--- a/arch/i386/kernel/cpuid.c Tue Jun 22 09:47:45 2004
+++ b/arch/i386/kernel/cpuid.c Tue Jun 22 09:47:45 2004
@@ -37,6 +37,8 @@
#include <linux/smp_lock.h>
#include <linux/fs.h>
#include <linux/device.h>
+#include <linux/cpu.h>
+#include <linux/notifier.h>

#include <asm/processor.h>
#include <asm/msr.h>
@@ -156,10 +158,48 @@
.open = cpuid_open,
};

+static void cpuid_class_simple_device_remove(void)
+{
+ int i = 0;
+ for_each_online_cpu(i)
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
+ return;
+}
+
+static int cpuid_class_simple_device_add(int i)
+{
+ int err = 0;
+ struct class_device *class_err;
+
+ class_err = class_simple_device_add(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
+ if (IS_ERR(class_err)) {
+ err = PTR_ERR(class_err);
+ }
+ return err;
+}
+static int __devinit cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
+{
+ unsigned int cpu = (unsigned long)hcpu;
+
+ switch(action) {
+ case CPU_ONLINE:
+ cpuid_class_simple_device_add(cpu);
+ break;
+ case CPU_DEAD:
+ cpuid_class_simple_device_remove();
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block cpuid_class_cpu_notifier =
+{
+ .notifier_call = cpuid_class_cpu_callback,
+};
+
int __init cpuid_init(void)
{
int i, err = 0;
- struct class_device *class_err;
i = 0;

if (register_chrdev(CPUID_MAJOR, "cpu/cpuid", &cpuid_fops)) {
@@ -174,19 +214,17 @@
goto out_chrdev;
}
for_each_online_cpu(i) {
- class_err = class_simple_device_add(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
- if (IS_ERR(class_err)) {
- err = PTR_ERR(class_err);
+ err = cpuid_class_simple_device_add(i);
+ if (err != 0)
goto out_class;
- }
}
+ register_cpu_notifier(&cpuid_class_cpu_notifier);
+
err = 0;
goto out;

out_class:
- i = 0;
- for_each_online_cpu(i)
- class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
+ cpuid_class_simple_device_remove();
class_simple_destroy(cpuid_class);
out_chrdev:
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
@@ -196,11 +234,10 @@

void __exit cpuid_exit(void)
{
- int i = 0;
- for_each_online_cpu(i)
- class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
+ cpuid_class_simple_device_remove();
class_simple_destroy(cpuid_class);
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
+ unregister_cpu_notifier(&cpuid_class_cpu_notifier);
}

module_init(cpuid_init);

2004-06-22 18:07:14

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.85.2, 2004/06/03 08:44:34-07:00, [email protected]

[Driver Model] Fix up silly scsi usage of DEVICE_ATTR() macros.

- Hey, just because the macro incorrectly included a ';' doesn't mean
one shouldn't add one on their own.. (Or at least be consistent.)

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/scsi/scsi_sysfs.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)


diff -Nru a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c Tue Jun 22 09:49:15 2004
+++ b/drivers/scsi/scsi_sysfs.c Tue Jun 22 09:49:15 2004
@@ -320,7 +320,7 @@
sdev->timeout = timeout * HZ;
return count;
}
-static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout)
+static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);

static ssize_t
store_rescan_field (struct device *dev, const char *buf, size_t count)
@@ -328,7 +328,7 @@
scsi_rescan_device(dev);
return count;
}
-static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field)
+static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field);

static ssize_t sdev_store_delete(struct device *dev, const char *buf,
size_t count)

2004-06-22 18:07:13

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.54, 2004/06/04 15:54:01-07:00, [email protected]

[PATCH] Module section offsets in /sys/module

So here I am trying to write about how one can apply gdb to a running
kernel, and I'd like to tell people how to debug loadable modules. Only
with the 2.6 module loader, there's no way to find out where the various
sections in the module image ended up, so you can't do much. This patch
attempts to fix that by adding a "sections" subdirectory to every module's
entry in /sys/module; each attribute in that directory associates a
beginning address with the section name. Those attributes can be used by a
a simple script to generate an add-symbol-file command for gdb, something
like:

#!/bin/bash
#
# gdbline module image
#
# Outputs an add-symbol-file line suitable for pasting into gdb to examine
# a loaded module.
#
cd /sys/module/$1/sections
echo -n add-symbol-file $2 `/bin/cat .text`

for section in .[a-z]* *; do
if [ $section != ".text" ]; then
echo " \\"
echo -n " -s" $section `/bin/cat $section`
fi
done
echo

Currently, this feature is absent if CONFIG_KALLSYMS is not set. I do
wonder if CONFIG_DEBUG_INFO might not be a better choice, now that I think
about it. Section names are unmunged, so "ls -a" is needed to see most of
them.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


include/linux/module.h | 19 +++++++++
kernel/module.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+)


diff -Nru a/include/linux/module.h b/include/linux/module.h
--- a/include/linux/module.h Tue Jun 22 09:48:05 2004
+++ b/include/linux/module.h Tue Jun 22 09:48:05 2004
@@ -225,6 +225,22 @@
struct module_attribute attr[0];
};

+/* Similar stuff for section attributes. */
+#define MODULE_SECT_NAME_LEN 32
+struct module_sect_attr
+{
+ struct attribute attr;
+ char name[MODULE_SECT_NAME_LEN];
+ unsigned long address;
+};
+
+struct module_sections
+{
+ struct kobject kobj;
+ struct module_sect_attr attrs[0];
+};
+
+
struct module
{
enum module_state state;
@@ -298,6 +314,9 @@
Elf_Sym *symtab;
unsigned long num_symtab;
char *strtab;
+
+ /* Section attributes */
+ struct module_sections *sect_attrs;
#endif

/* Per-cpu data. */
diff -Nru a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c Tue Jun 22 09:48:05 2004
+++ b/kernel/module.c Tue Jun 22 09:48:05 2004
@@ -981,6 +981,104 @@
return ret;
}

+
+/*
+ * /sys/module/foo/sections stuff
+ * J. Corbet <[email protected]>
+ */
+#ifdef CONFIG_KALLSYMS
+static void module_sect_attrs_release(struct kobject *kobj)
+{
+ kfree(container_of(kobj, struct module_sections, kobj));
+}
+
+static ssize_t module_sect_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct module_sect_attr *sattr =
+ container_of(attr, struct module_sect_attr, attr);
+ return sprintf(buf, "0x%lx\n", sattr->address);
+}
+
+static struct sysfs_ops module_sect_ops = {
+ .show = module_sect_show,
+};
+
+static struct kobj_type module_sect_ktype = {
+ .sysfs_ops = &module_sect_ops,
+ .release = module_sect_attrs_release,
+};
+
+static void add_sect_attrs(struct module *mod, unsigned int nsect,
+ char *secstrings, Elf_Shdr *sechdrs)
+{
+ unsigned int nloaded = 0, i;
+ struct module_sect_attr *sattr;
+
+ if (!mod->mkobj)
+ return;
+
+ /* Count loaded sections and allocate structures */
+ for (i = 0; i < nsect; i++)
+ if (sechdrs[i].sh_flags & SHF_ALLOC)
+ nloaded++;
+ mod->sect_attrs = kmalloc(sizeof(struct module_sections) +
+ nloaded*sizeof(mod->sect_attrs->attrs[0]), GFP_KERNEL);
+ if (! mod->sect_attrs)
+ return;
+
+ /* sections entry setup */
+ memset(mod->sect_attrs, 0, sizeof(struct module_sections));
+ if (kobject_set_name(&mod->sect_attrs->kobj, "sections"))
+ goto out;
+ mod->sect_attrs->kobj.parent = &mod->mkobj->kobj;
+ mod->sect_attrs->kobj.ktype = &module_sect_ktype;
+ if (kobject_register(&mod->sect_attrs->kobj))
+ goto out;
+
+ /* And the section attributes. */
+ sattr = &mod->sect_attrs->attrs[0];
+ for (i = 0; i < nsect; i++) {
+ if (! (sechdrs[i].sh_flags & SHF_ALLOC))
+ continue;
+ sattr->address = sechdrs[i].sh_addr;
+ strlcpy(sattr->name, secstrings + sechdrs[i].sh_name,
+ MODULE_SECT_NAME_LEN);
+ sattr->attr.name = sattr->name;
+ sattr->attr.owner = mod;
+ sattr->attr.mode = S_IRUGO;
+ (void) sysfs_create_file(&mod->sect_attrs->kobj, &sattr->attr);
+ sattr++;
+ }
+ return;
+ out:
+ kfree(mod->sect_attrs);
+ mod->sect_attrs = NULL;
+}
+
+static void remove_sect_attrs(struct module *mod)
+{
+ if (mod->sect_attrs) {
+ kobject_unregister(&mod->sect_attrs->kobj);
+ mod->sect_attrs = NULL;
+ }
+}
+
+
+#else
+static inline void add_sect_attrs(struct module *mod, unsigned int nsect,
+ char *sectstrings, Elf_Shdr *sechdrs)
+{
+}
+
+static inline void remove_sect_attrs(struct module *mod)
+{
+}
+#endif /* CONFIG_KALLSYMS */
+
+
+
+
#define to_module_attr(n) container_of(n, struct module_attribute, attr);

static ssize_t module_attr_show(struct kobject *kobj,
@@ -1099,6 +1197,7 @@
list_del(&mod->list);
spin_unlock_irq(&modlist_lock);

+ remove_sect_attrs(mod);
mod_kobject_remove(mod);

/* Arch-specific cleanup. */
@@ -1712,6 +1811,7 @@
/ sizeof(struct kernel_param));
if (err < 0)
goto arch_cleanup;
+ add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);

/* Get rid of temporary copy */
vfree(hdr);

2004-06-22 18:07:13

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.57, 2004/06/08 16:28:02-07:00, [email protected]

[PATCH] Add platform_get_resource()

This patch adds management of platform device resources to the
device model, allowing drivers to lookup resources, IRQs and DMA
numbers in the platform device resource array. We also add a
couple of functions which allow platform devices and their resources
to be registered.

Signed-off-by: Russell King <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/base/platform.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/device.h | 5 ++
2 files changed, 91 insertions(+)


diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c Tue Jun 22 09:47:40 2004
+++ b/drivers/base/platform.c Tue Jun 22 09:47:40 2004
@@ -19,6 +19,90 @@
};

/**
+ * platform_get_resource - get a resource for a device
+ * @dev: platform device
+ * @type: resource type
+ * @num: resource index
+ */
+struct resource *
+platform_get_resource(struct platform_device *dev, unsigned int type,
+ unsigned int num)
+{
+ int i;
+
+ for (i = 0; i < dev->num_resources; i++) {
+ struct resource *r = &dev->resource[i];
+
+ if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM|
+ IORESOURCE_IRQ|IORESOURCE_DMA))
+ == type)
+ if (num-- == 0)
+ return r;
+ }
+ return NULL;
+}
+
+/**
+ * platform_get_irq - get an IRQ for a device
+ * @dev: platform device
+ * @num: IRQ number index
+ */
+int platform_get_irq(struct platform_device *dev, unsigned int num)
+{
+ struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, num);
+
+ return r ? r->start : 0;
+}
+
+/**
+ * platform_add_device - add one platform device
+ * @dev: platform device
+ *
+ * Adds one platform device, claiming the memory resources
+ */
+int platform_add_device(struct platform_device *dev)
+{
+ int i;
+
+ for (i = 0; i < dev->num_resources; i++) {
+ struct resource *p, *r = &dev->resource[i];
+
+ r->name = dev->dev.bus_id;
+
+ p = NULL;
+ if (r->flags & IORESOURCE_MEM)
+ p = &iomem_resource;
+ else if (r->flags & IORESOURCE_IO)
+ p = &ioport_resource;
+
+ if (p && request_resource(p, r)) {
+ printk(KERN_ERR
+ "%s%d: failed to claim resource %d\n",
+ dev->name, dev->id, i);
+ break;
+ }
+ }
+ if (i == dev->num_resources)
+ platform_device_register(dev);
+ return 0;
+}
+
+/**
+ * platform_add_devices - add a numbers of platform devices
+ * @devs: array of platform devices to add
+ * @num: number of platform devices in array
+ */
+int platform_add_devices(struct platform_device **devs, int num)
+{
+ int i;
+
+ for (i = 0; i < num; i++)
+ platform_add_device(devs[i]);
+
+ return 0;
+}
+
+/**
* platform_device_register - add a platform-level device
* @dev: platform device we're adding
*
@@ -114,3 +198,5 @@
EXPORT_SYMBOL(platform_bus_type);
EXPORT_SYMBOL(platform_device_register);
EXPORT_SYMBOL(platform_device_unregister);
+EXPORT_SYMBOL(platform_get_irq);
+EXPORT_SYMBOL(platform_get_resource);
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Tue Jun 22 09:47:40 2004
+++ b/include/linux/device.h Tue Jun 22 09:47:40 2004
@@ -377,6 +377,11 @@
extern struct bus_type platform_bus_type;
extern struct device platform_bus;

+extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int);
+extern int platform_get_irq(struct platform_device *, unsigned int);
+extern int platform_add_device(struct platform_device *);
+extern int platform_add_devices(struct platform_device **, int);
+
/* drivers/base/power.c */
extern void device_shutdown(void);


2004-06-22 18:07:12

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.85.3, 2004/06/03 10:27:16-07:00, [email protected]

[sysfs] Add attr_name() macro

- Returns the name of an embedded attribute in a higher-level
attribute.


include/linux/sysfs.h | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)


diff -Nru a/include/linux/sysfs.h b/include/linux/sysfs.h
--- a/include/linux/sysfs.h Tue Jun 22 09:49:05 2004
+++ b/include/linux/sysfs.h Tue Jun 22 09:49:05 2004
@@ -43,7 +43,7 @@

#define __ATTR_NULL { .attr = { .name = NULL } }

-
+#define attr_name(_attr) (_attr).attr.name

struct bin_attribute {
struct attribute attr;

2004-06-22 18:07:12

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.52, 2004/06/04 13:24:29-07:00, [email protected]

PCI: convert to using dev_attrs for all PCI devices.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/pci/pci-driver.c | 1 +
drivers/pci/pci-sysfs.c | 33 +++++++++++++++------------------
drivers/pci/pci.h | 1 +
3 files changed, 17 insertions(+), 18 deletions(-)


diff -Nru a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
--- a/drivers/pci/pci-driver.c Tue Jun 22 09:48:25 2004
+++ b/drivers/pci/pci-driver.c Tue Jun 22 09:48:25 2004
@@ -539,6 +539,7 @@
.hotplug = pci_hotplug,
.suspend = pci_device_suspend,
.resume = pci_device_resume,
+ .dev_attrs = pci_dev_attrs,
};

static int __init pci_driver_init(void)
diff -Nru a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
--- a/drivers/pci/pci-sysfs.c Tue Jun 22 09:48:25 2004
+++ b/drivers/pci/pci-sysfs.c Tue Jun 22 09:48:25 2004
@@ -23,14 +23,13 @@
/* show configuration fields */
#define pci_config_attr(field, format_string) \
static ssize_t \
-show_##field (struct device *dev, char *buf) \
+field##_show(struct device *dev, char *buf) \
{ \
struct pci_dev *pdev; \
\
pdev = to_pci_dev (dev); \
return sprintf (buf, format_string, pdev->field); \
-} \
-static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
+}

pci_config_attr(vendor, "0x%04x\n");
pci_config_attr(device, "0x%04x\n");
@@ -41,7 +40,7 @@

/* show resources */
static ssize_t
-pci_show_resources(struct device * dev, char * buf)
+resource_show(struct device * dev, char * buf)
{
struct pci_dev * pci_dev = to_pci_dev(dev);
char * str = buf;
@@ -60,7 +59,16 @@
return (str - buf);
}

-static DEVICE_ATTR(resource,S_IRUGO,pci_show_resources,NULL);
+struct device_attribute pci_dev_attrs[] = {
+ __ATTR_RO(resource),
+ __ATTR_RO(vendor),
+ __ATTR_RO(device),
+ __ATTR_RO(subsystem_vendor),
+ __ATTR_RO(subsystem_device),
+ __ATTR_RO(class),
+ __ATTR_RO(irq),
+ __ATTR_NULL,
+};

static ssize_t
pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
@@ -180,21 +188,10 @@

void pci_create_sysfs_dev_files (struct pci_dev *pdev)
{
- struct device *dev = &pdev->dev;
-
- /* current configuration's attributes */
- device_create_file (dev, &dev_attr_vendor);
- device_create_file (dev, &dev_attr_device);
- device_create_file (dev, &dev_attr_subsystem_vendor);
- device_create_file (dev, &dev_attr_subsystem_device);
- device_create_file (dev, &dev_attr_class);
- device_create_file (dev, &dev_attr_irq);
- device_create_file (dev, &dev_attr_resource);
-
if (pdev->cfg_size < 4096)
- sysfs_create_bin_file(&dev->kobj, &pci_config_attr);
+ sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
else
- sysfs_create_bin_file(&dev->kobj, &pcie_config_attr);
+ sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);

/* add platform-specific attributes */
pcibios_add_platform_entries(pdev);
diff -Nru a/drivers/pci/pci.h b/drivers/pci/pci.h
--- a/drivers/pci/pci.h Tue Jun 22 09:48:25 2004
+++ b/drivers/pci/pci.h Tue Jun 22 09:48:25 2004
@@ -62,3 +62,4 @@
extern spinlock_t pci_bus_lock;

extern int pciehp_msi_quirk;
+extern struct device_attribute pci_dev_attrs[];

2004-06-22 18:07:12

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.85.6, 2004/06/03 17:37:14-07:00, [email protected]

[Driver Model] Add default device attributes to struct bus_type.

- Add struct bus_type::dev_attrs, which is an array of device
attributes that are added to each device as they are registered.

- Also make sure that we don't hang when removing bus attributes
if adding one failed..


drivers/base/bus.c | 36 +++++++++++++++++++++++++++++++++++-
include/linux/device.h | 1 +
2 files changed, 36 insertions(+), 1 deletion(-)


diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c Tue Jun 22 09:48:35 2004
+++ b/drivers/base/bus.c Tue Jun 22 09:48:35 2004
@@ -392,6 +392,38 @@

}

+static int device_add_attrs(struct bus_type * bus, struct device * dev)
+{
+ int error = 0;
+ int i;
+
+ if (bus->dev_attrs) {
+ for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
+ error = device_create_file(dev,&bus->dev_attrs[i]);
+ if (error)
+ goto Err;
+ }
+ }
+ Done:
+ return error;
+ Err:
+ while (--i >= 0)
+ device_remove_file(dev,&bus->dev_attrs[i]);
+ goto Done;
+}
+
+
+static void device_remove_attrs(struct bus_type * bus, struct device * dev)
+{
+ int i;
+
+ if (bus->dev_attrs) {
+ for (i = 0; attr_name(bus->dev_attrs[i]); i++)
+ device_remove_file(dev,&bus->dev_attrs[i]);
+ }
+}
+
+
/**
* bus_add_device - add device to bus
* @dev: device being added
@@ -411,6 +443,7 @@
list_add_tail(&dev->bus_list,&dev->bus->devices.list);
device_attach(dev);
up_write(&dev->bus->subsys.rwsem);
+ device_add_attrs(bus,dev);
sysfs_create_link(&bus->devices.kobj,&dev->kobj,dev->bus_id);
}
return error;
@@ -429,6 +462,7 @@
{
if (dev->bus) {
sysfs_remove_link(&dev->bus->devices.kobj,dev->bus_id);
+ device_remove_attrs(dev->bus,dev);
down_write(&dev->bus->subsys.rwsem);
pr_debug("bus %s: remove device %s\n",dev->bus->name,dev->bus_id);
device_release_driver(dev);
@@ -569,7 +603,7 @@
Done:
return error;
Err:
- while (i >= 0)
+ while (--i >= 0)
bus_remove_file(bus,&bus->bus_attrs[i]);
goto Done;
}
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Tue Jun 22 09:48:35 2004
+++ b/include/linux/device.h Tue Jun 22 09:48:35 2004
@@ -55,6 +55,7 @@
struct kset devices;

struct bus_attribute * bus_attrs;
+ struct device_attribute * dev_attrs;

int (*match)(struct device * dev, struct device_driver * drv);
struct device * (*add) (struct device * parent, char * bus_id);

2004-06-22 18:07:08

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.51, 2004/06/04 11:09:29-07:00, [email protected]

Driver Model: And even more cleanup of silly scsi use of the *ATTR macros...

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/scsi/scsi_sysfs.c | 10 +++++-----
drivers/scsi/scsi_transport_spi.c | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)


diff -Nru a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c Tue Jun 22 09:48:30 2004
+++ b/drivers/scsi/scsi_sysfs.c Tue Jun 22 09:48:30 2004
@@ -99,7 +99,7 @@
*/
#define shost_rd_attr2(name, field, format_string) \
shost_show_function(name, field, format_string) \
-static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
+static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);

#define shost_rd_attr(field, format_string) \
shost_rd_attr2(field, field, format_string)
@@ -228,8 +228,8 @@
* read only field.
*/
#define sdev_rd_attr(field, format_string) \
- sdev_show_function(field, format_string) \
-static DEVICE_ATTR(field, S_IRUGO, sdev_show_##field, NULL)
+ sdev_show_function(field, format_string) \
+static DEVICE_ATTR(field, S_IRUGO, sdev_show_##field, NULL);


/*
@@ -247,7 +247,7 @@
snscanf (buf, 20, format_string, &sdev->field); \
return count; \
} \
-static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##field)
+static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##field);

/* Currently we don't export bit fields, but we might in future,
* so leave this code in */
@@ -272,7 +272,7 @@
} \
return ret; \
} \
-static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##field)
+static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##field);

/*
* scsi_sdev_check_buf_bit: return 0 if buf is "0", return 1 if buf is "1",
diff -Nru a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
--- a/drivers/scsi/scsi_transport_spi.c Tue Jun 22 09:48:30 2004
+++ b/drivers/scsi/scsi_transport_spi.c Tue Jun 22 09:48:30 2004
@@ -152,7 +152,7 @@
spi_transport_store_function(field, format_string) \
static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \
show_spi_transport_##field, \
- store_spi_transport_##field)
+ store_spi_transport_##field);

/* The Parallel SCSI Tranport Attributes: */
spi_transport_rd_attr(offset, "%d\n");
@@ -173,7 +173,7 @@
spi_dv_device(sdev);
return count;
}
-static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate)
+static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);

/* Translate the period into ns according to the current spec
* for SDTR/PPR messages */

2004-06-22 18:07:11

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.85.4, 2004/06/03 10:41:29-07:00, [email protected]

[Driver Model] Add default attributes for classes class devices.

- add struct class::class_attrs, which is designed to point to an
array of class_attributes that are added when the class is registered
and removed when the class is unregistered.
This allows for more consolidated and cleaner definition of and
management of attributes.

- Add struct class::class_dev_attrs to do something similarly for
class devices. Each class device that is registered with the class
gets that set of attributes added for them, and subsequently removed
when the device is unregistered.

Each array depends on a terminating attribute with a NULL name. Hint:
use the new __ATTR_NULL macro to terminate it.


drivers/base/class.c | 81 +++++++++++++++++++++++++++++++++++++++++++++----
include/linux/device.h | 3 +
2 files changed, 78 insertions(+), 6 deletions(-)


diff -Nru a/drivers/base/class.c b/drivers/base/class.c
--- a/drivers/base/class.c Tue Jun 22 09:49:00 2004
+++ b/drivers/base/class.c Tue Jun 22 09:49:00 2004
@@ -100,6 +100,37 @@
subsys_put(&cls->subsys);
}

+
+static int add_class_attrs(struct class * cls)
+{
+ int i;
+ int error = 0;
+
+ if (cls->class_attrs) {
+ for (i = 0; attr_name(cls->class_attrs[i]); i++) {
+ error = class_create_file(cls,&cls->class_attrs[i]);
+ if (error)
+ goto Err;
+ }
+ }
+ Done:
+ return error;
+ Err:
+ while (--i >= 0)
+ class_remove_file(cls,&cls->class_attrs[i]);
+ goto Done;
+}
+
+static void remove_class_attrs(struct class * cls)
+{
+ int i;
+
+ if (cls->class_attrs) {
+ for (i = 0; attr_name(cls->class_attrs[i]); i++)
+ class_remove_file(cls,&cls->class_attrs[i]);
+ }
+}
+
int class_register(struct class * cls)
{
int error;
@@ -115,18 +146,21 @@
subsys_set_kset(cls,class_subsys);

error = subsystem_register(&cls->subsys);
- if (error)
- return error;
-
- return 0;
+ if (!error) {
+ error = add_class_attrs(class_get(cls));
+ class_put(cls);
+ }
+ return error;
}

void class_unregister(struct class * cls)
{
pr_debug("device class '%s': unregistering\n",cls->name);
+ remove_class_attrs(cls);
subsystem_unregister(&cls->subsys);
}

+
/* Class Device Stuff */

int class_device_create_file(struct class_device * class_dev,
@@ -272,6 +306,40 @@

static decl_subsys(class_obj, &ktype_class_device, &class_hotplug_ops);

+
+static int class_device_add_attrs(struct class_device * cd)
+{
+ int i;
+ int error = 0;
+ struct class * cls = cd->class;
+
+ if (cls->class_dev_attrs) {
+ for (i = 0; attr_name(cls->class_dev_attrs[i]); i++) {
+ error = class_device_create_file(cd,
+ &cls->class_dev_attrs[i]);
+ if (error)
+ goto Err;
+ }
+ }
+ Done:
+ return error;
+ Err:
+ while (--i >= 0)
+ class_device_remove_file(cd,&cls->class_dev_attrs[i]);
+ goto Done;
+}
+
+static void class_device_remove_attrs(struct class_device * cd)
+{
+ int i;
+ struct class * cls = cd->class;
+
+ if (cls->class_dev_attrs) {
+ for (i = 0; attr_name(cls->class_dev_attrs[i]); i++)
+ class_device_remove_file(cd,&cls->class_dev_attrs[i]);
+ }
+}
+
void class_device_initialize(struct class_device *class_dev)
{
kobj_set_kset_s(class_dev, class_obj_subsys);
@@ -311,7 +379,7 @@
class_intf->add(class_dev);
up_write(&parent->subsys.rwsem);
}
-
+ class_device_add_attrs(class_dev);
class_device_dev_link(class_dev);
class_device_driver_link(class_dev);

@@ -344,7 +412,8 @@

class_device_dev_unlink(class_dev);
class_device_driver_unlink(class_dev);
-
+ class_device_remove_attrs(class_dev);
+
kobject_del(&class_dev->kobj);

if (parent)
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Tue Jun 22 09:49:00 2004
+++ b/include/linux/device.h Tue Jun 22 09:49:00 2004
@@ -143,6 +143,9 @@
struct list_head children;
struct list_head interfaces;

+ struct class_attribute * class_attrs;
+ struct class_device_attribute * class_dev_attrs;
+
int (*hotplug)(struct class_device *dev, char **envp,
int num_envp, char *buffer, int buffer_size);


2004-06-22 18:01:42

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.102.3, 2004/06/08 14:31:15-07:00, [email protected]

[PATCH] I2C: add alternate VCORE calculations for w83627thf and w83637hf

This patch adds support for the alternate in0/VCORE calculation which is
available for 2 of 4 chips this driver supports. It also fixes a minor
bug in the standard voltage input calculation.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/chips/w83627hf.c | 94 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 91 insertions(+), 3 deletions(-)


diff -Nru a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
--- a/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:47:55 2004
+++ b/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:47:55 2004
@@ -199,7 +199,7 @@
#define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */
#define W83627THF_REG_PWM3 0x11 /* 637HF too */

-#define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF too, unused yet */
+#define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF too */

static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 };
static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2,
@@ -222,7 +222,7 @@
these macros are called: arguments may be evaluated more than once.
Fixing this is just not worth it. */
#define IN_TO_REG(val) (SENSORS_LIMIT((((val) + 8)/16),0,255))
-#define IN_FROM_REG(val) ((val) * 16 + 5)
+#define IN_FROM_REG(val) ((val) * 16)

static inline u8 FAN_TO_REG(long rpm, int div)
{
@@ -312,6 +312,7 @@
Default = 3435.
Other Betas unimplemented */
u8 vrm;
+ u8 vrm_ovt; /* Register value, 627thf & 637hf only */
};


@@ -391,7 +392,6 @@
sysfs_in_reg_offset(min, offset) \
sysfs_in_reg_offset(max, offset)

-sysfs_in_offsets(0)
sysfs_in_offsets(1)
sysfs_in_offsets(2)
sysfs_in_offsets(3)
@@ -401,6 +401,89 @@
sysfs_in_offsets(7)
sysfs_in_offsets(8)

+/* use a different set of functions for in0 */
+static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg)
+{
+ long in0;
+
+ if ((data->vrm_ovt & 0x01) &&
+ (w83627thf == data->type || w83637hf == data->type))
+
+ /* use VRM9 calculation */
+ in0 = (long)((reg * 488 + 70000 + 50) / 100);
+ else
+ /* use VRM8 (standard) calculation */
+ in0 = (long)IN_FROM_REG(reg);
+
+ return sprintf(buf,"%ld\n", in0);
+}
+
+static ssize_t show_regs_in_0(struct device *dev, char *buf)
+{
+ struct w83627hf_data *data = w83627hf_update_device(dev);
+ return show_in_0(data, buf, data->in[0]);
+}
+
+static ssize_t show_regs_in_min0(struct device *dev, char *buf)
+{
+ struct w83627hf_data *data = w83627hf_update_device(dev);
+ return show_in_0(data, buf, data->in_min[0]);
+}
+
+static ssize_t show_regs_in_max0(struct device *dev, char *buf)
+{
+ struct w83627hf_data *data = w83627hf_update_device(dev);
+ return show_in_0(data, buf, data->in_max[0]);
+}
+
+static ssize_t store_regs_in_min0(struct device *dev,
+ const char *buf, size_t count)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct w83627hf_data *data = i2c_get_clientdata(client);
+ u32 val;
+
+ val = simple_strtoul(buf, NULL, 10);
+ if ((data->vrm_ovt & 0x01) &&
+ (w83627thf == data->type || w83637hf == data->type))
+
+ /* use VRM9 calculation */
+ data->in_min[0] = (u8)(((val * 100) - 70000 + 244) / 488);
+ else
+ /* use VRM8 (standard) calculation */
+ data->in_min[0] = IN_TO_REG(val);
+
+ w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]);
+ return count;
+}
+
+static ssize_t store_regs_in_max0(struct device *dev,
+ const char *buf, size_t count)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct w83627hf_data *data = i2c_get_clientdata(client);
+ u32 val;
+
+ val = simple_strtoul(buf, NULL, 10);
+ if ((data->vrm_ovt & 0x01) &&
+ (w83627thf == data->type || w83637hf == data->type))
+
+ /* use VRM9 calculation */
+ data->in_max[0] = (u8)(((val * 100) - 70000 + 244) / 488);
+ else
+ /* use VRM8 (standard) calculation */
+ data->in_max[0] = IN_TO_REG(val);
+
+ w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]);
+ return count;
+}
+
+static DEVICE_ATTR(in0_input, S_IRUGO, show_regs_in_0, NULL)
+static DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR,
+ show_regs_in_min0, store_regs_in_min0)
+static DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR,
+ show_regs_in_max0, store_regs_in_max0)
+
#define device_create_file_in(client, offset) \
do { \
device_create_file(&client->dev, &dev_attr_in##offset##_input); \
@@ -1190,6 +1273,11 @@
} else if (w83627thf == data->type) {
data->vid = w83627thf_read_gpio5(client) & 0x1f;
}
+
+ /* Read VRM & OVT Config only once */
+ if (w83627thf == data->type || w83637hf == data->type)
+ data->vrm_ovt =
+ w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);

/* Convert VID to voltage based on default VRM */
data->vrm = DEFAULT_VRM;

2004-06-22 18:01:42

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.19, 2004/06/09 10:34:09-07:00, [email protected]

[PATCH] I2C: w83627hf.c build fix

with gcc-2.95:

drivers/i2c/chips/w83627hf.c:482: parse error before `static'
drivers/i2c/chips/w83627hf.c:502: parse error before `static'
drivers/i2c/chips/w83627hf.c: In function `show_regs_fan_1':
drivers/i2c/chips/w83627hf.c:541: warning: implicit declaration of function `show_fan'
drivers/i2c/chips/w83627hf.c: In function `w83627hf_detect':
drivers/i2c/chips/w83627hf.c:1074: `dev_attr_in0_min' undeclared (first use in this function)
drivers/i2c/chips/w83627hf.c:1074: (Each undeclared identifier is reported only once
drivers/i2c/chips/w83627hf.c:1074: for each function it appears in.)
drivers/i2c/chips/w83627hf.c: At top level:
drivers/i2c/chips/w83627hf.c:428: warning: `show_regs_in_min0' defined but not used
drivers/i2c/chips/w83627hf.c:441: warning: `store_regs_in_min0' defined but not used

Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/chips/w83627hf.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)


diff -Nru a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
--- a/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:47:24 2004
+++ b/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:47:24 2004
@@ -478,11 +478,11 @@
return count;
}

-static DEVICE_ATTR(in0_input, S_IRUGO, show_regs_in_0, NULL)
+static DEVICE_ATTR(in0_input, S_IRUGO, show_regs_in_0, NULL);
static DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR,
- show_regs_in_min0, store_regs_in_min0)
+ show_regs_in_min0, store_regs_in_min0);
static DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR,
- show_regs_in_max0, store_regs_in_max0)
+ show_regs_in_max0, store_regs_in_max0);

#define device_create_file_in(client, offset) \
do { \

2004-06-22 22:56:29

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.85.5, 2004/06/03 17:05:41-07:00, [email protected]

[Driver Model] Add default attributes for struct bus_type.

- Similar to default attributes for struct class, this is an array
of attributes, terminated with an attribute with a NULL name, that
are added when the bus is registered, and removed when the bus is
unregistered.


drivers/base/bus.c | 37 +++++++++++++++++++++++++++++++++++++
include/linux/device.h | 2 ++
2 files changed, 39 insertions(+)


diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c Tue Jun 22 09:48:40 2004
+++ b/drivers/base/bus.c Tue Jun 22 09:48:40 2004
@@ -549,6 +549,41 @@
return k ? to_bus(k) : NULL;
}

+
+/**
+ * bus_add_attrs - Add default attributes for this bus.
+ * @bus: Bus that has just been registered.
+ */
+
+static int bus_add_attrs(struct bus_type * bus)
+{
+ int error = 0;
+ int i;
+
+ if (bus->bus_attrs) {
+ for (i = 0; attr_name(bus->bus_attrs[i]); i++) {
+ if ((error = bus_create_file(bus,&bus->bus_attrs[i])))
+ goto Err;
+ }
+ }
+ Done:
+ return error;
+ Err:
+ while (i >= 0)
+ bus_remove_file(bus,&bus->bus_attrs[i]);
+ goto Done;
+}
+
+static void bus_remove_attrs(struct bus_type * bus)
+{
+ int i;
+
+ if (bus->bus_attrs) {
+ for (i = 0; attr_name(bus->bus_attrs[i]); i++)
+ bus_remove_file(bus,&bus->bus_attrs[i]);
+ }
+}
+
/**
* bus_register - register a bus with the system.
* @bus: bus.
@@ -582,6 +617,7 @@
retval = kset_register(&bus->drivers);
if (retval)
goto bus_drivers_fail;
+ bus_add_attrs(bus);

pr_debug("bus type '%s' registered\n",bus->name);
return 0;
@@ -605,6 +641,7 @@
void bus_unregister(struct bus_type * bus)
{
pr_debug("bus %s: unregistering\n",bus->name);
+ bus_remove_attrs(bus);
kset_unregister(&bus->drivers);
kset_unregister(&bus->devices);
subsystem_unregister(&bus->subsys);
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Tue Jun 22 09:48:40 2004
+++ b/include/linux/device.h Tue Jun 22 09:48:40 2004
@@ -54,6 +54,8 @@
struct kset drivers;
struct kset devices;

+ struct bus_attribute * bus_attrs;
+
int (*match)(struct device * dev, struct device_driver * drv);
struct device * (*add) (struct device * parent, char * bus_id);
int (*hotplug) (struct device *dev, char **envp,

2004-06-22 22:56:45

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.18, 2004/06/09 10:19:23-07:00, [email protected]

merge i2c-2.6 into driver-2.6 trees due to problems people reported.


MAINTAINERS | 6 +-
drivers/i2c/chips/it87.c | 22 ++++-----
drivers/i2c/chips/w83627hf.c | 96 +++++++++++++++++++++----------------------
drivers/scsi/scsi_debug.c | 16 +++----
4 files changed, 70 insertions(+), 70 deletions(-)


diff -Nru a/MAINTAINERS b/MAINTAINERS
--- a/MAINTAINERS Tue Jun 22 09:47:29 2004
+++ b/MAINTAINERS Tue Jun 22 09:47:29 2004
@@ -950,15 +950,15 @@
IA64 (Itanium) PLATFORM
P: David Mosberger-Tang
M: [email protected]
-L: [email protected]
-W: http://www.linuxia64.org/
+L: [email protected]
+W: http://www.ia64-linux.org/
S: Maintained

SN-IA64 (Itanium) SUB-PLATFORM
P: Jesse Barnes
M: [email protected]
L: [email protected]
-L: [email protected]
+L: [email protected]
W: http://www.sgi.com/altix
S: Maintained

diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c Tue Jun 22 09:47:29 2004
+++ b/drivers/i2c/chips/it87.c Tue Jun 22 09:47:29 2004
@@ -275,7 +275,7 @@
{ \
return show_in(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL)
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);

#define limit_in_offset(offset) \
static ssize_t \
@@ -299,9 +299,9 @@
return set_in_max(dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
- show_in##offset##_min, set_in##offset##_min) \
+ show_in##offset##_min, set_in##offset##_min); \
static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
- show_in##offset##_max, set_in##offset##_max)
+ show_in##offset##_max, set_in##offset##_max);

show_in_offset(0);
limit_in_offset(0);
@@ -382,11 +382,11 @@
{ \
return set_temp_min(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL) \
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
- show_temp_##offset##_max, set_temp_##offset##_max) \
+ show_temp_##offset##_max, set_temp_##offset##_max); \
static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
- show_temp_##offset##_min, set_temp_##offset##_min)
+ show_temp_##offset##_min, set_temp_##offset##_min);

show_temp_offset(1);
show_temp_offset(2);
@@ -430,8 +430,8 @@
{ \
return set_sensor(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
- show_sensor_##offset, set_sensor_##offset)
+static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
+ show_sensor_##offset, set_sensor_##offset);

show_sensor_offset(1);
show_sensor_offset(2);
@@ -525,11 +525,11 @@
{ \
return set_fan_div(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL) \
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_fan_##offset##_min, set_fan_##offset##_min) \
+ show_fan_##offset##_min, set_fan_##offset##_min); \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
- show_fan_##offset##_div, set_fan_##offset##_div)
+ show_fan_##offset##_div, set_fan_##offset##_div);

show_fan_offset(1);
show_fan_offset(2);
diff -Nru a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
--- a/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:47:29 2004
+++ b/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:47:29 2004
@@ -371,7 +371,7 @@
{ \
return show_in(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL)
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);

#define sysfs_in_reg_offset(reg, offset) \
static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
@@ -385,21 +385,21 @@
return store_in_##reg (dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, \
- show_regs_in_##reg##offset, store_regs_in_##reg##offset)
+ show_regs_in_##reg##offset, store_regs_in_##reg##offset);

#define sysfs_in_offsets(offset) \
sysfs_in_offset(offset) \
sysfs_in_reg_offset(min, offset) \
sysfs_in_reg_offset(max, offset)

-sysfs_in_offsets(1)
-sysfs_in_offsets(2)
-sysfs_in_offsets(3)
-sysfs_in_offsets(4)
-sysfs_in_offsets(5)
-sysfs_in_offsets(6)
-sysfs_in_offsets(7)
-sysfs_in_offsets(8)
+sysfs_in_offsets(1);
+sysfs_in_offsets(2);
+sysfs_in_offsets(3);
+sysfs_in_offsets(4);
+sysfs_in_offsets(5);
+sysfs_in_offsets(6);
+sysfs_in_offsets(7);
+sysfs_in_offsets(8);

/* use a different set of functions for in0 */
static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg)
@@ -499,8 +499,8 @@
FAN_FROM_REG(data->reg[nr-1], \
(long)DIV_FROM_REG(data->fan_div[nr-1]))); \
}
-show_fan_reg(fan)
-show_fan_reg(fan_min)
+show_fan_reg(fan);
+show_fan_reg(fan_min);

static ssize_t
store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
@@ -523,7 +523,7 @@
{ \
return show_fan(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL)
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);

#define sysfs_fan_min_offset(offset) \
static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
@@ -536,14 +536,14 @@
return store_fan_min(dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_regs_fan_min##offset, store_regs_fan_min##offset)
+ show_regs_fan_min##offset, store_regs_fan_min##offset);

-sysfs_fan_offset(1)
-sysfs_fan_min_offset(1)
-sysfs_fan_offset(2)
-sysfs_fan_min_offset(2)
-sysfs_fan_offset(3)
-sysfs_fan_min_offset(3)
+sysfs_fan_offset(1);
+sysfs_fan_min_offset(1);
+sysfs_fan_offset(2);
+sysfs_fan_min_offset(2);
+sysfs_fan_offset(3);
+sysfs_fan_min_offset(3);

#define device_create_file_fan(client, offset) \
do { \
@@ -562,9 +562,9 @@
return sprintf(buf,"%ld\n", (long)TEMP_FROM_REG(data->reg)); \
} \
}
-show_temp_reg(temp)
-show_temp_reg(temp_max)
-show_temp_reg(temp_max_hyst)
+show_temp_reg(temp);
+show_temp_reg(temp_max);
+show_temp_reg(temp_max_hyst);

#define store_temp_reg(REG, reg) \
static ssize_t \
@@ -588,8 +588,8 @@
\
return count; \
}
-store_temp_reg(OVER, max)
-store_temp_reg(HYST, max_hyst)
+store_temp_reg(OVER, max);
+store_temp_reg(HYST, max_hyst);

#define sysfs_temp_offset(offset) \
static ssize_t \
@@ -597,7 +597,7 @@
{ \
return show_temp(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL)
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);

#define sysfs_temp_reg_offset(reg, offset) \
static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
@@ -611,16 +611,16 @@
return store_temp_##reg (dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
- show_regs_temp_##reg##offset, store_regs_temp_##reg##offset)
+ show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);

#define sysfs_temp_offsets(offset) \
sysfs_temp_offset(offset) \
sysfs_temp_reg_offset(max, offset) \
sysfs_temp_reg_offset(max_hyst, offset)

-sysfs_temp_offsets(1)
-sysfs_temp_offsets(2)
-sysfs_temp_offsets(3)
+sysfs_temp_offsets(1);
+sysfs_temp_offsets(2);
+sysfs_temp_offsets(3);

#define device_create_file_temp(client, offset) \
do { \
@@ -635,7 +635,7 @@
struct w83627hf_data *data = w83627hf_update_device(dev);
return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
}
-static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL)
+static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL);
#define device_create_file_vid(client) \
device_create_file(&client->dev, &dev_attr_in0_ref)

@@ -657,7 +657,7 @@

return count;
}
-static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg)
+static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
#define device_create_file_vrm(client) \
device_create_file(&client->dev, &dev_attr_vrm)

@@ -667,7 +667,7 @@
struct w83627hf_data *data = w83627hf_update_device(dev);
return sprintf(buf, "%ld\n", (long) data->alarms);
}
-static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL)
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
#define device_create_file_alarms(client) \
device_create_file(&client->dev, &dev_attr_alarms)

@@ -724,10 +724,10 @@
return store_beep_reg(dev, buf, count, BEEP_##REG); \
} \
static DEVICE_ATTR(beep_##reg, S_IRUGO | S_IWUSR, \
- show_regs_beep_##reg, store_regs_beep_##reg)
+ show_regs_beep_##reg, store_regs_beep_##reg);

-sysfs_beep(ENABLE, enable)
-sysfs_beep(MASK, mask)
+sysfs_beep(ENABLE, enable);
+sysfs_beep(MASK, mask);

#define device_create_file_beep(client) \
do { \
@@ -790,11 +790,11 @@
return store_fan_div_reg(dev, buf, count, offset - 1); \
} \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
- show_regs_fan_div_##offset, store_regs_fan_div_##offset)
+ show_regs_fan_div_##offset, store_regs_fan_div_##offset);

-sysfs_fan_div(1)
-sysfs_fan_div(2)
-sysfs_fan_div(3)
+sysfs_fan_div(1);
+sysfs_fan_div(2);
+sysfs_fan_div(3);

#define device_create_file_fan_div(client, offset) \
do { \
@@ -846,11 +846,11 @@
return store_pwm_reg(dev, buf, count, offset); \
} \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \
- show_regs_pwm_##offset, store_regs_pwm_##offset)
+ show_regs_pwm_##offset, store_regs_pwm_##offset);

-sysfs_pwm(1)
-sysfs_pwm(2)
-sysfs_pwm(3)
+sysfs_pwm(1);
+sysfs_pwm(2);
+sysfs_pwm(3);

#define device_create_file_pwm(client, offset) \
do { \
@@ -919,11 +919,11 @@
return store_sensor_reg(dev, buf, count, offset); \
} \
static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
- show_regs_sensor_##offset, store_regs_sensor_##offset)
+ show_regs_sensor_##offset, store_regs_sensor_##offset);

-sysfs_sensor(1)
-sysfs_sensor(2)
-sysfs_sensor(3)
+sysfs_sensor(1);
+sysfs_sensor(2);
+sysfs_sensor(3);

#define device_create_file_sensor(client, offset) \
do { \
diff -Nru a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
--- a/drivers/scsi/scsi_debug.c Tue Jun 22 09:47:29 2004
+++ b/drivers/scsi/scsi_debug.c Tue Jun 22 09:47:29 2004
@@ -1326,7 +1326,7 @@
return -EINVAL;
}
DRIVER_ATTR(delay, S_IRUGO | S_IWUSR, sdebug_delay_show,
- sdebug_delay_store)
+ sdebug_delay_store);

static ssize_t sdebug_opts_show(struct device_driver * ddp, char * buf)
{
@@ -1355,7 +1355,7 @@
return count;
}
DRIVER_ATTR(opts, S_IRUGO | S_IWUSR, sdebug_opts_show,
- sdebug_opts_store)
+ sdebug_opts_store);

static ssize_t sdebug_num_tgts_show(struct device_driver * ddp, char * buf)
{
@@ -1373,13 +1373,13 @@
return -EINVAL;
}
DRIVER_ATTR(num_tgts, S_IRUGO | S_IWUSR, sdebug_num_tgts_show,
- sdebug_num_tgts_store)
+ sdebug_num_tgts_store);

static ssize_t sdebug_dev_size_mb_show(struct device_driver * ddp, char * buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dev_size_mb);
}
-DRIVER_ATTR(dev_size_mb, S_IRUGO, sdebug_dev_size_mb_show, NULL)
+DRIVER_ATTR(dev_size_mb, S_IRUGO, sdebug_dev_size_mb_show, NULL);

static ssize_t sdebug_every_nth_show(struct device_driver * ddp, char * buf)
{
@@ -1398,7 +1398,7 @@
return -EINVAL;
}
DRIVER_ATTR(every_nth, S_IRUGO | S_IWUSR, sdebug_every_nth_show,
- sdebug_every_nth_store)
+ sdebug_every_nth_store);

static ssize_t sdebug_max_luns_show(struct device_driver * ddp, char * buf)
{
@@ -1416,13 +1416,13 @@
return -EINVAL;
}
DRIVER_ATTR(max_luns, S_IRUGO | S_IWUSR, sdebug_max_luns_show,
- sdebug_max_luns_store)
+ sdebug_max_luns_store);

static ssize_t sdebug_scsi_level_show(struct device_driver * ddp, char * buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level);
}
-DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL)
+DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL);

static ssize_t sdebug_add_host_show(struct device_driver * ddp, char * buf)
{
@@ -1459,7 +1459,7 @@
return count;
}
DRIVER_ATTR(add_host, S_IRUGO | S_IWUSR, sdebug_add_host_show,
- sdebug_add_host_store)
+ sdebug_add_host_store);

static void do_create_driverfs_files(void)
{

2004-06-22 17:57:22

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.47, 2004/06/03 11:40:44-07:00, [email protected]

Driver Model: More cleanup of silly scsi use of the *ATTR macros...

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/scsi/scsi_debug.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)


diff -Nru a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
--- a/drivers/scsi/scsi_debug.c Tue Jun 22 09:48:55 2004
+++ b/drivers/scsi/scsi_debug.c Tue Jun 22 09:48:55 2004
@@ -1326,7 +1326,7 @@
return -EINVAL;
}
DRIVER_ATTR(delay, S_IRUGO | S_IWUSR, sdebug_delay_show,
- sdebug_delay_store)
+ sdebug_delay_store);

static ssize_t sdebug_opts_show(struct device_driver * ddp, char * buf)
{
@@ -1355,7 +1355,7 @@
return count;
}
DRIVER_ATTR(opts, S_IRUGO | S_IWUSR, sdebug_opts_show,
- sdebug_opts_store)
+ sdebug_opts_store);

static ssize_t sdebug_num_tgts_show(struct device_driver * ddp, char * buf)
{
@@ -1373,13 +1373,13 @@
return -EINVAL;
}
DRIVER_ATTR(num_tgts, S_IRUGO | S_IWUSR, sdebug_num_tgts_show,
- sdebug_num_tgts_store)
+ sdebug_num_tgts_store);

static ssize_t sdebug_dev_size_mb_show(struct device_driver * ddp, char * buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dev_size_mb);
}
-DRIVER_ATTR(dev_size_mb, S_IRUGO, sdebug_dev_size_mb_show, NULL)
+DRIVER_ATTR(dev_size_mb, S_IRUGO, sdebug_dev_size_mb_show, NULL);

static ssize_t sdebug_every_nth_show(struct device_driver * ddp, char * buf)
{
@@ -1398,7 +1398,7 @@
return -EINVAL;
}
DRIVER_ATTR(every_nth, S_IRUGO | S_IWUSR, sdebug_every_nth_show,
- sdebug_every_nth_store)
+ sdebug_every_nth_store);

static ssize_t sdebug_max_luns_show(struct device_driver * ddp, char * buf)
{
@@ -1416,13 +1416,13 @@
return -EINVAL;
}
DRIVER_ATTR(max_luns, S_IRUGO | S_IWUSR, sdebug_max_luns_show,
- sdebug_max_luns_store)
+ sdebug_max_luns_store);

static ssize_t sdebug_scsi_level_show(struct device_driver * ddp, char * buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level);
}
-DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL)
+DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL);

static ssize_t sdebug_add_host_show(struct device_driver * ddp, char * buf)
{
@@ -1459,7 +1459,7 @@
return count;
}
DRIVER_ATTR(add_host, S_IRUGO | S_IWUSR, sdebug_add_host_show,
- sdebug_add_host_store)
+ sdebug_add_host_store);

static void do_create_driverfs_files()
{

2004-06-22 17:57:21

by Greg KH

[permalink] [raw]
Subject: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.85.1, 2004/06/02 17:10:52-07:00, [email protected]

[Driver Model] Consolidate attribute definition macros

- Create __ATTR(), __ATTR_RO(), and __ATTR_NULL macros to help define
attributes in a neat, short-hand form.

- Apply these macros to the attribute definition in include/linux/device.h

- Note: These can be used to more cleanly define attributes in your own
code. e.g:

static struct device_attribute attrs[] = {
__ATTR_RO(foo),
__ATTR_RO(bar),
__ATTR(baz,0666,baz_show,baz_store),
__ATTR_NULL,
};

...etc.

Signed-off-by: Greg Kroah-Hartman <[email protected]>


include/linux/device.h | 31 ++++++-------------------------
include/linux/sysfs.h | 21 +++++++++++++++++++++
2 files changed, 27 insertions(+), 25 deletions(-)


diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Tue Jun 22 09:49:19 2004
+++ b/include/linux/device.h Tue Jun 22 09:49:19 2004
@@ -90,11 +90,7 @@
};

#define BUS_ATTR(_name,_mode,_show,_store) \
-struct bus_attribute bus_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
- .show = _show, \
- .store = _store, \
-};
+struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store)

extern int bus_create_file(struct bus_type *, struct bus_attribute *);
extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
@@ -131,11 +127,7 @@
};

#define DRIVER_ATTR(_name,_mode,_show,_store) \
-struct driver_attribute driver_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
- .show = _show, \
- .store = _store, \
-};
+struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store)

extern int driver_create_file(struct device_driver *, struct driver_attribute *);
extern void driver_remove_file(struct device_driver *, struct driver_attribute *);
@@ -172,11 +164,7 @@
};

#define CLASS_ATTR(_name,_mode,_show,_store) \
-struct class_attribute class_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
- .show = _show, \
- .store = _store, \
-};
+struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store)

extern int class_create_file(struct class *, const struct class_attribute *);
extern void class_remove_file(struct class *, const struct class_attribute *);
@@ -224,11 +212,8 @@
};

#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
-struct class_device_attribute class_device_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
- .show = _show, \
- .store = _store, \
-};
+struct class_device_attribute class_device_attr_##_name = \
+ __ATTR(_name,_mode,_show,_store)

extern int class_device_create_file(struct class_device *,
const struct class_device_attribute *);
@@ -342,11 +327,7 @@
};

#define DEVICE_ATTR(_name,_mode,_show,_store) \
-struct device_attribute dev_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
- .show = _show, \
- .store = _store, \
-};
+struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)


extern int device_create_file(struct device *device, struct device_attribute * entry);
diff -Nru a/include/linux/sysfs.h b/include/linux/sysfs.h
--- a/include/linux/sysfs.h Tue Jun 22 09:49:19 2004
+++ b/include/linux/sysfs.h Tue Jun 22 09:49:19 2004
@@ -24,6 +24,27 @@
};


+
+/**
+ * Use these macros to make defining attributes easier. See include/linux/device.h
+ * for examples..
+ */
+
+#define __ATTR(_name,_mode,_show,_store) { \
+ .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
+ .show = _show, \
+ .store = _store, \
+}
+
+#define __ATTR_RO(_name) { \
+ .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \
+ .show = _name##_show, \
+}
+
+#define __ATTR_NULL { .attr = { .name = NULL } }
+
+
+
struct bin_attribute {
struct attribute attr;
size_t size;

2004-06-22 17:57:20

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.111.23, 2004/06/10 12:52:02-07:00, [email protected]

I2C: sparse cleanups for drivers/i2c/*

Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/chips/it87.c | 5 ++++-
drivers/i2c/i2c-dev.c | 7 +++----
2 files changed, 7 insertions(+), 5 deletions(-)


diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c Tue Jun 22 09:47:03 2004
+++ b/drivers/i2c/chips/it87.c Tue Jun 22 09:47:03 2004
@@ -170,8 +170,11 @@
static int DIV_TO_REG(int val)
{
int answer = 0;
- while ((val >>= 1))
+ val >>= 1;
+ while (val) {
answer++;
+ val >>= 1;
+ }
return answer;
}
#define DIV_FROM_REG(val) (1 << (val))
diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
--- a/drivers/i2c/i2c-dev.c Tue Jun 22 09:47:03 2004
+++ b/drivers/i2c/i2c-dev.c Tue Jun 22 09:47:03 2004
@@ -181,7 +181,7 @@
struct i2c_smbus_ioctl_data data_arg;
union i2c_smbus_data temp;
struct i2c_msg *rdwr_pa;
- u8 **data_ptrs;
+ u8 __user **data_ptrs;
int i,datasize,res;
unsigned long funcs;

@@ -238,8 +238,7 @@
return -EFAULT;
}

- data_ptrs = (u8 **) kmalloc(rdwr_arg.nmsgs * sizeof(u8 *),
- GFP_KERNEL);
+ data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL);
if (data_ptrs == NULL) {
kfree(rdwr_pa);
return -ENOMEM;
@@ -252,7 +251,7 @@
res = -EINVAL;
break;
}
- data_ptrs[i] = rdwr_pa[i].buf;
+ data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL);
if(rdwr_pa[i].buf == NULL) {
res = -ENOMEM;

2004-06-22 23:24:16

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

On Tuesday 22 June 2004 12:41 pm, Greg KH wrote:

>
> void class_unregister(struct class * cls)
> {
> pr_debug("device class '%s': unregistering\n",cls->name);
> + remove_class_attrs(cls);
> subsystem_unregister(&cls->subsys);
> }
>

Question: is it necessary to call remove_class_attrs? I thought that sysfs
automatically destroys all children when parent is destroyed? Am I imagining
things?

--
Dmitry

2004-06-22 23:28:16

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

ChangeSet 1.1722.89.48, 2004/06/03 11:42:20-07:00, [email protected]

Driver Model: Cleanup the i2c driver silly use of the *ATTR macros which just broke


Signed-off-by: Greg Kroah-Hartman <[email protected]>


drivers/i2c/chips/asb100.c | 66 ++++++++++++++--------------
drivers/i2c/chips/it87.c | 22 ++++-----
drivers/i2c/chips/lm78.c | 22 ++++-----
drivers/i2c/chips/lm85.c | 26 +++++------
drivers/i2c/chips/via686a.c | 18 +++----
drivers/i2c/chips/w83627hf.c | 98 +++++++++++++++++++++---------------------
drivers/i2c/chips/w83781d.c | 30 ++++++------
drivers/i2c/chips/w83l785ts.c | 4 -
8 files changed, 143 insertions(+), 143 deletions(-)


diff -Nru a/drivers/i2c/chips/asb100.c b/drivers/i2c/chips/asb100.c
--- a/drivers/i2c/chips/asb100.c Tue Jun 22 09:48:50 2004
+++ b/drivers/i2c/chips/asb100.c Tue Jun 22 09:48:50 2004
@@ -272,7 +272,7 @@
return show_in(dev, buf, 0x##offset); \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
- show_in##offset, NULL) \
+ show_in##offset, NULL); \
static ssize_t \
show_in##offset##_min (struct device *dev, char *buf) \
{ \
@@ -294,17 +294,17 @@
return set_in_max(dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
- show_in##offset##_min, set_in##offset##_min) \
+ show_in##offset##_min, set_in##offset##_min); \
static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
- show_in##offset##_max, set_in##offset##_max)
+ show_in##offset##_max, set_in##offset##_max);

-sysfs_in(0)
-sysfs_in(1)
-sysfs_in(2)
-sysfs_in(3)
-sysfs_in(4)
-sysfs_in(5)
-sysfs_in(6)
+sysfs_in(0);
+sysfs_in(1);
+sysfs_in(2);
+sysfs_in(3);
+sysfs_in(4);
+sysfs_in(5);
+sysfs_in(6);

#define device_create_file_in(client, offset) do { \
device_create_file(&client->dev, &dev_attr_in##offset##_input); \
@@ -410,15 +410,15 @@
return set_fan_div(dev, buf, count, offset - 1); \
} \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
- show_fan##offset, NULL) \
+ show_fan##offset, NULL); \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_fan##offset##_min, set_fan##offset##_min) \
+ show_fan##offset##_min, set_fan##offset##_min); \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
- show_fan##offset##_div, set_fan##offset##_div)
+ show_fan##offset##_div, set_fan##offset##_div);

-sysfs_fan(1)
-sysfs_fan(2)
-sysfs_fan(3)
+sysfs_fan(1);
+sysfs_fan(2);
+sysfs_fan(3);

#define device_create_file_fan(client, offset) do { \
device_create_file(&client->dev, &dev_attr_fan##offset##_input); \
@@ -449,9 +449,9 @@
return sprintf_temp_from_reg(data->reg[nr], buf, nr); \
}

-show_temp_reg(temp)
-show_temp_reg(temp_max)
-show_temp_reg(temp_hyst)
+show_temp_reg(temp);
+show_temp_reg(temp_max);
+show_temp_reg(temp_hyst);

#define set_temp_reg(REG, reg) \
static ssize_t set_##reg(struct device *dev, const char *buf, \
@@ -473,15 +473,15 @@
return count; \
}

-set_temp_reg(MAX, temp_max)
-set_temp_reg(HYST, temp_hyst)
+set_temp_reg(MAX, temp_max);
+set_temp_reg(HYST, temp_hyst);

#define sysfs_temp(num) \
static ssize_t show_temp##num(struct device *dev, char *buf) \
{ \
return show_temp(dev, buf, num-1); \
} \
-static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL) \
+static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \
static ssize_t show_temp_max##num(struct device *dev, char *buf) \
{ \
return show_temp_max(dev, buf, num-1); \
@@ -492,7 +492,7 @@
return set_temp_max(dev, buf, count, num-1); \
} \
static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \
- show_temp_max##num, set_temp_max##num) \
+ show_temp_max##num, set_temp_max##num); \
static ssize_t show_temp_hyst##num(struct device *dev, char *buf) \
{ \
return show_temp_hyst(dev, buf, num-1); \
@@ -503,12 +503,12 @@
return set_temp_hyst(dev, buf, count, num-1); \
} \
static DEVICE_ATTR(temp##num##_max_hyst, S_IRUGO | S_IWUSR, \
- show_temp_hyst##num, set_temp_hyst##num)
+ show_temp_hyst##num, set_temp_hyst##num);

-sysfs_temp(1)
-sysfs_temp(2)
-sysfs_temp(3)
-sysfs_temp(4)
+sysfs_temp(1);
+sysfs_temp(2);
+sysfs_temp(3);
+sysfs_temp(4);

/* VID */
#define device_create_file_temp(client, num) do { \
@@ -523,7 +523,7 @@
return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
}

-static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid, NULL)
+static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid, NULL);
#define device_create_file_vid(client) \
device_create_file(&client->dev, &dev_attr_in0_ref)

@@ -544,7 +544,7 @@
}

/* Alarms */
-static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm)
+static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
#define device_create_file_vrm(client) \
device_create_file(&client->dev, &dev_attr_vrm);

@@ -554,7 +554,7 @@
return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms));
}

-static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL)
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
#define device_create_file_alarms(client) \
device_create_file(&client->dev, &dev_attr_alarms)

@@ -594,9 +594,9 @@
return count;
}

-static DEVICE_ATTR(fan1_pwm, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1)
+static DEVICE_ATTR(fan1_pwm, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1);
static DEVICE_ATTR(fan1_pwm_enable, S_IRUGO | S_IWUSR,
- show_pwm_enable1, set_pwm_enable1)
+ show_pwm_enable1, set_pwm_enable1);
#define device_create_file_pwm1(client) do { \
device_create_file(&new_client->dev, &dev_attr_fan1_pwm); \
device_create_file(&new_client->dev, &dev_attr_fan1_pwm_enable); \
diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c Tue Jun 22 09:48:50 2004
+++ b/drivers/i2c/chips/it87.c Tue Jun 22 09:48:50 2004
@@ -275,7 +275,7 @@
{ \
return show_in(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL)
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);

#define limit_in_offset(offset) \
static ssize_t \
@@ -299,9 +299,9 @@
return set_in_max(dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
- show_in##offset##_min, set_in##offset##_min) \
+ show_in##offset##_min, set_in##offset##_min); \
static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
- show_in##offset##_max, set_in##offset##_max)
+ show_in##offset##_max, set_in##offset##_max);

show_in_offset(0);
limit_in_offset(0);
@@ -382,11 +382,11 @@
{ \
return set_temp_min(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL) \
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
- show_temp_##offset##_max, set_temp_##offset##_max) \
+ show_temp_##offset##_max, set_temp_##offset##_max); \
static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
- show_temp_##offset##_min, set_temp_##offset##_min)
+ show_temp_##offset##_min, set_temp_##offset##_min);

show_temp_offset(1);
show_temp_offset(2);
@@ -430,8 +430,8 @@
{ \
return set_sensor(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
- show_sensor_##offset, set_sensor_##offset)
+static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
+ show_sensor_##offset, set_sensor_##offset);

show_sensor_offset(1);
show_sensor_offset(2);
@@ -525,11 +525,11 @@
{ \
return set_fan_div(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL) \
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_fan_##offset##_min, set_fan_##offset##_min) \
+ show_fan_##offset##_min, set_fan_##offset##_min); \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
- show_fan_##offset##_div, set_fan_##offset##_div)
+ show_fan_##offset##_div, set_fan_##offset##_div);

show_fan_offset(1);
show_fan_offset(2);
diff -Nru a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c
--- a/drivers/i2c/chips/lm78.c Tue Jun 22 09:48:50 2004
+++ b/drivers/i2c/chips/lm78.c Tue Jun 22 09:48:50 2004
@@ -281,7 +281,7 @@
return show_in(dev, buf, 0x##offset); \
} \
static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
- show_in##offset, NULL) \
+ show_in##offset, NULL); \
static ssize_t \
show_in##offset##_min (struct device *dev, char *buf) \
{ \
@@ -303,9 +303,9 @@
return set_in_max(dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
- show_in##offset##_min, set_in##offset##_min) \
+ show_in##offset##_min, set_in##offset##_min); \
static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
- show_in##offset##_max, set_in##offset##_max)
+ show_in##offset##_max, set_in##offset##_max);

show_in_offset(0);
show_in_offset(1);
@@ -354,11 +354,11 @@
return count;
}

-static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL)
+static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,
- show_temp_over, set_temp_over)
+ show_temp_over, set_temp_over);
static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
- show_temp_hyst, set_temp_hyst)
+ show_temp_hyst, set_temp_hyst);

/* 3 Fans */
static ssize_t show_fan(struct device *dev, char *buf, int nr)
@@ -439,9 +439,9 @@
{ \
return set_fan_min(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL) \
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_fan_##offset##_min, set_fan_##offset##_min)
+ show_fan_##offset##_min, set_fan_##offset##_min);

static ssize_t set_fan_1_div(struct device *dev, const char *buf,
size_t count)
@@ -461,10 +461,10 @@

/* Fan 3 divisor is locked in H/W */
static DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR,
- show_fan_1_div, set_fan_1_div)
+ show_fan_1_div, set_fan_1_div);
static DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
- show_fan_2_div, set_fan_2_div)
-static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL)
+ show_fan_2_div, set_fan_2_div);
+static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL);

/* VID */
static ssize_t show_vid(struct device *dev, char *buf)
diff -Nru a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c
--- a/drivers/i2c/chips/lm85.c Tue Jun 22 09:48:50 2004
+++ b/drivers/i2c/chips/lm85.c Tue Jun 22 09:48:50 2004
@@ -451,9 +451,9 @@
{ \
return set_fan_min(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL) \
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_fan_##offset##_min, set_fan_##offset##_min)
+ show_fan_##offset##_min, set_fan_##offset##_min);

show_fan_offset(1);
show_fan_offset(2);
@@ -468,7 +468,7 @@
return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
}

-static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL)
+static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL);

static ssize_t show_vrm_reg(struct device *dev, char *buf)
{
@@ -487,7 +487,7 @@
return count;
}

-static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg)
+static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);

static ssize_t show_alarms_reg(struct device *dev, char *buf)
{
@@ -495,7 +495,7 @@
return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms));
}

-static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL)
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);

/* pwm */

@@ -542,8 +542,8 @@
return show_pwm_enable(dev, buf, 0x##offset - 1); \
} \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \
- show_pwm_##offset, set_pwm_##offset) \
-static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO, show_pwm_enable##offset, NULL)
+ show_pwm_##offset, set_pwm_##offset); \
+static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO, show_pwm_enable##offset, NULL);

show_pwm_reg(1);
show_pwm_reg(2);
@@ -617,11 +617,11 @@
{ \
return set_in_max(dev, buf, count, 0x##offset); \
} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in_##offset, NULL) \
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in_##offset, NULL); \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
- show_in_##offset##_min, set_in_##offset##_min) \
+ show_in_##offset##_min, set_in_##offset##_min); \
static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
- show_in_##offset##_max, set_in_##offset##_max)
+ show_in_##offset##_max, set_in_##offset##_max);

show_in_reg(0);
show_in_reg(1);
@@ -697,11 +697,11 @@
{ \
return set_temp_max(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL) \
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
- show_temp_##offset##_min, set_temp_##offset##_min) \
+ show_temp_##offset##_min, set_temp_##offset##_min); \
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
- show_temp_##offset##_max, set_temp_##offset##_max)
+ show_temp_##offset##_max, set_temp_##offset##_max);

show_temp_reg(1);
show_temp_reg(2);
diff -Nru a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
--- a/drivers/i2c/chips/via686a.c Tue Jun 22 09:48:50 2004
+++ b/drivers/i2c/chips/via686a.c Tue Jun 22 09:48:50 2004
@@ -405,11 +405,11 @@
{ \
return set_in_max(dev, buf, count, 0x##offset); \
} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL) \
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);\
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
- show_in##offset##_min, set_in##offset##_min) \
+ show_in##offset##_min, set_in##offset##_min); \
static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
- show_in##offset##_max, set_in##offset##_max)
+ show_in##offset##_max, set_in##offset##_max);

show_in_offset(0);
show_in_offset(1);
@@ -473,11 +473,11 @@
{ \
return set_temp_hyst(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL) \
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);\
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
- show_temp_##offset##_over, set_temp_##offset##_over) \
+ show_temp_##offset##_over, set_temp_##offset##_over); \
static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \
- show_temp_##offset##_hyst, set_temp_##offset##_hyst)
+ show_temp_##offset##_hyst, set_temp_##offset##_hyst);

show_temp_offset(1);
show_temp_offset(2);
@@ -542,11 +542,11 @@
{ \
return set_fan_div(dev, buf, count, 0x##offset - 1); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL) \
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_fan_##offset##_min, set_fan_##offset##_min) \
+ show_fan_##offset##_min, set_fan_##offset##_min); \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
- show_fan_##offset##_div, set_fan_##offset##_div)
+ show_fan_##offset##_div, set_fan_##offset##_div);

show_fan_offset(1);
show_fan_offset(2);
diff -Nru a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
--- a/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:48:50 2004
+++ b/drivers/i2c/chips/w83627hf.c Tue Jun 22 09:48:50 2004
@@ -370,7 +370,7 @@
{ \
return show_in(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL)
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);

#define sysfs_in_reg_offset(reg, offset) \
static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
@@ -384,22 +384,22 @@
return store_in_##reg (dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, \
- show_regs_in_##reg##offset, store_regs_in_##reg##offset)
+ show_regs_in_##reg##offset, store_regs_in_##reg##offset);

#define sysfs_in_offsets(offset) \
sysfs_in_offset(offset) \
sysfs_in_reg_offset(min, offset) \
sysfs_in_reg_offset(max, offset)

-sysfs_in_offsets(0)
-sysfs_in_offsets(1)
-sysfs_in_offsets(2)
-sysfs_in_offsets(3)
-sysfs_in_offsets(4)
-sysfs_in_offsets(5)
-sysfs_in_offsets(6)
-sysfs_in_offsets(7)
-sysfs_in_offsets(8)
+sysfs_in_offsets(0);
+sysfs_in_offsets(1);
+sysfs_in_offsets(2);
+sysfs_in_offsets(3);
+sysfs_in_offsets(4);
+sysfs_in_offsets(5);
+sysfs_in_offsets(6);
+sysfs_in_offsets(7);
+sysfs_in_offsets(8);

#define device_create_file_in(client, offset) \
do { \
@@ -416,8 +416,8 @@
FAN_FROM_REG(data->reg[nr-1], \
(long)DIV_FROM_REG(data->fan_div[nr-1]))); \
}
-show_fan_reg(fan)
-show_fan_reg(fan_min)
+show_fan_reg(fan);
+show_fan_reg(fan_min);

static ssize_t
store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
@@ -440,7 +440,7 @@
{ \
return show_fan(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL)
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);

#define sysfs_fan_min_offset(offset) \
static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
@@ -453,14 +453,14 @@
return store_fan_min(dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_regs_fan_min##offset, store_regs_fan_min##offset)
+ show_regs_fan_min##offset, store_regs_fan_min##offset);

-sysfs_fan_offset(1)
-sysfs_fan_min_offset(1)
-sysfs_fan_offset(2)
-sysfs_fan_min_offset(2)
-sysfs_fan_offset(3)
-sysfs_fan_min_offset(3)
+sysfs_fan_offset(1);
+sysfs_fan_min_offset(1);
+sysfs_fan_offset(2);
+sysfs_fan_min_offset(2);
+sysfs_fan_offset(3);
+sysfs_fan_min_offset(3);

#define device_create_file_fan(client, offset) \
do { \
@@ -479,9 +479,9 @@
return sprintf(buf,"%ld\n", (long)TEMP_FROM_REG(data->reg)); \
} \
}
-show_temp_reg(temp)
-show_temp_reg(temp_max)
-show_temp_reg(temp_max_hyst)
+show_temp_reg(temp);
+show_temp_reg(temp_max);
+show_temp_reg(temp_max_hyst);

#define store_temp_reg(REG, reg) \
static ssize_t \
@@ -505,8 +505,8 @@
\
return count; \
}
-store_temp_reg(OVER, max)
-store_temp_reg(HYST, max_hyst)
+store_temp_reg(OVER, max);
+store_temp_reg(HYST, max_hyst);

#define sysfs_temp_offset(offset) \
static ssize_t \
@@ -514,7 +514,7 @@
{ \
return show_temp(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL)
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);

#define sysfs_temp_reg_offset(reg, offset) \
static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
@@ -528,16 +528,16 @@
return store_temp_##reg (dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
- show_regs_temp_##reg##offset, store_regs_temp_##reg##offset)
+ show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);

#define sysfs_temp_offsets(offset) \
sysfs_temp_offset(offset) \
sysfs_temp_reg_offset(max, offset) \
sysfs_temp_reg_offset(max_hyst, offset)

-sysfs_temp_offsets(1)
-sysfs_temp_offsets(2)
-sysfs_temp_offsets(3)
+sysfs_temp_offsets(1);
+sysfs_temp_offsets(2);
+sysfs_temp_offsets(3);

#define device_create_file_temp(client, offset) \
do { \
@@ -552,7 +552,7 @@
struct w83627hf_data *data = w83627hf_update_device(dev);
return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
}
-static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL)
+static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL);
#define device_create_file_vid(client) \
device_create_file(&client->dev, &dev_attr_in0_ref)

@@ -574,7 +574,7 @@

return count;
}
-static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg)
+static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
#define device_create_file_vrm(client) \
device_create_file(&client->dev, &dev_attr_vrm)

@@ -584,7 +584,7 @@
struct w83627hf_data *data = w83627hf_update_device(dev);
return sprintf(buf, "%ld\n", (long) data->alarms);
}
-static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL)
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
#define device_create_file_alarms(client) \
device_create_file(&client->dev, &dev_attr_alarms)

@@ -641,10 +641,10 @@
return store_beep_reg(dev, buf, count, BEEP_##REG); \
} \
static DEVICE_ATTR(beep_##reg, S_IRUGO | S_IWUSR, \
- show_regs_beep_##reg, store_regs_beep_##reg)
+ show_regs_beep_##reg, store_regs_beep_##reg);

-sysfs_beep(ENABLE, enable)
-sysfs_beep(MASK, mask)
+sysfs_beep(ENABLE, enable);
+sysfs_beep(MASK, mask);

#define device_create_file_beep(client) \
do { \
@@ -707,11 +707,11 @@
return store_fan_div_reg(dev, buf, count, offset - 1); \
} \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
- show_regs_fan_div_##offset, store_regs_fan_div_##offset)
+ show_regs_fan_div_##offset, store_regs_fan_div_##offset);

-sysfs_fan_div(1)
-sysfs_fan_div(2)
-sysfs_fan_div(3)
+sysfs_fan_div(1);
+sysfs_fan_div(2);
+sysfs_fan_div(3);

#define device_create_file_fan_div(client, offset) \
do { \
@@ -763,11 +763,11 @@
return store_pwm_reg(dev, buf, count, offset); \
} \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \
- show_regs_pwm_##offset, store_regs_pwm_##offset)
+ show_regs_pwm_##offset, store_regs_pwm_##offset);

-sysfs_pwm(1)
-sysfs_pwm(2)
-sysfs_pwm(3)
+sysfs_pwm(1);
+sysfs_pwm(2);
+sysfs_pwm(3);

#define device_create_file_pwm(client, offset) \
do { \
@@ -836,11 +836,11 @@
return store_sensor_reg(dev, buf, count, offset); \
} \
static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
- show_regs_sensor_##offset, store_regs_sensor_##offset)
+ show_regs_sensor_##offset, store_regs_sensor_##offset);

-sysfs_sensor(1)
-sysfs_sensor(2)
-sysfs_sensor(3)
+sysfs_sensor(1);
+sysfs_sensor(2);
+sysfs_sensor(3);

#define device_create_file_sensor(client, offset) \
do { \
diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
--- a/drivers/i2c/chips/w83781d.c Tue Jun 22 09:48:50 2004
+++ b/drivers/i2c/chips/w83781d.c Tue Jun 22 09:48:50 2004
@@ -320,7 +320,7 @@
{ \
return show_in(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL)
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);

#define sysfs_in_reg_offset(reg, offset) \
static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
@@ -331,7 +331,7 @@
{ \
return store_in_##reg (dev, buf, count, 0x##offset); \
} \
-static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_in_##reg##offset, store_regs_in_##reg##offset)
+static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_in_##reg##offset, store_regs_in_##reg##offset);

#define sysfs_in_offsets(offset) \
sysfs_in_offset(offset); \
@@ -386,7 +386,7 @@
{ \
return show_fan(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL)
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);

#define sysfs_fan_min_offset(offset) \
static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
@@ -397,7 +397,7 @@
{ \
return store_fan_min(dev, buf, count, 0x##offset); \
} \
-static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, show_regs_fan_min##offset, store_regs_fan_min##offset)
+static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, show_regs_fan_min##offset, store_regs_fan_min##offset);

sysfs_fan_offset(1);
sysfs_fan_min_offset(1);
@@ -466,7 +466,7 @@
{ \
return show_temp(dev, buf, 0x##offset); \
} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL)
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);

#define sysfs_temp_reg_offset(reg, offset) \
static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
@@ -477,7 +477,7 @@
{ \
return store_temp_##reg (dev, buf, count, 0x##offset); \
} \
-static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_temp_##reg##offset, store_regs_temp_##reg##offset)
+static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);

#define sysfs_temp_offsets(offset) \
sysfs_temp_offset(offset); \
@@ -503,7 +503,7 @@
}

static
-DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL)
+DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL);
#define device_create_file_vid(client) \
device_create_file(&client->dev, &dev_attr_in0_ref);
static ssize_t
@@ -527,7 +527,7 @@
}

static
-DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg)
+DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
#define device_create_file_vrm(client) \
device_create_file(&client->dev, &dev_attr_vrm);
static ssize_t
@@ -538,7 +538,7 @@
}

static
-DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL)
+DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
#define device_create_file_alarms(client) \
device_create_file(&client->dev, &dev_attr_alarms);
static ssize_t show_beep_mask (struct device *dev, char *buf)
@@ -598,7 +598,7 @@
{ \
return store_beep_reg(dev, buf, count, BEEP_##REG); \
} \
-static DEVICE_ATTR(beep_##reg, S_IRUGO | S_IWUSR, show_regs_beep_##reg, store_regs_beep_##reg)
+static DEVICE_ATTR(beep_##reg, S_IRUGO | S_IWUSR, show_regs_beep_##reg, store_regs_beep_##reg);

sysfs_beep(ENABLE, enable);
sysfs_beep(MASK, mask);
@@ -665,7 +665,7 @@
{ \
return store_fan_div_reg(dev, buf, count, offset - 1); \
} \
-static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, show_regs_fan_div_##offset, store_regs_fan_div_##offset)
+static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, show_regs_fan_div_##offset, store_regs_fan_div_##offset);

sysfs_fan_div(1);
sysfs_fan_div(2);
@@ -744,7 +744,7 @@
{ \
return store_pwm_reg(dev, buf, count, offset); \
} \
-static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, show_regs_pwm_##offset, store_regs_pwm_##offset)
+static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, show_regs_pwm_##offset, store_regs_pwm_##offset);

#define sysfs_pwmenable(offset) \
static ssize_t show_regs_pwmenable_##offset (struct device *dev, char *buf) \
@@ -755,7 +755,7 @@
{ \
return store_pwmenable_reg(dev, buf, count, offset); \
} \
-static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO | S_IWUSR, show_regs_pwmenable_##offset, store_regs_pwmenable_##offset)
+static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO | S_IWUSR, show_regs_pwmenable_##offset, store_regs_pwmenable_##offset);

sysfs_pwm(1);
sysfs_pwm(2);
@@ -833,7 +833,7 @@
{ \
return store_sensor_reg(dev, buf, count, offset); \
} \
-static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, show_regs_sensor_##offset, store_regs_sensor_##offset)
+static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, show_regs_sensor_##offset, store_regs_sensor_##offset);

sysfs_sensor(1);
sysfs_sensor(2);
@@ -891,7 +891,7 @@
{ \
return store_rt_reg(dev, buf, count, offset); \
} \
-static DEVICE_ATTR(rt##offset, S_IRUGO | S_IWUSR, show_regs_rt_##offset, store_regs_rt_##offset)
+static DEVICE_ATTR(rt##offset, S_IRUGO | S_IWUSR, show_regs_rt_##offset, store_regs_rt_##offset);

sysfs_rt(1);
sysfs_rt(2);
diff -Nru a/drivers/i2c/chips/w83l785ts.c b/drivers/i2c/chips/w83l785ts.c
--- a/drivers/i2c/chips/w83l785ts.c Tue Jun 22 09:48:50 2004
+++ b/drivers/i2c/chips/w83l785ts.c Tue Jun 22 09:48:50 2004
@@ -137,8 +137,8 @@
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
}

-static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL)
-static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL)
+static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
+static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL);

/*
* Real code

2004-06-22 23:33:26

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

On Tue, Jun 22, 2004 at 06:21:01PM -0500, Dmitry Torokhov wrote:
> On Tuesday 22 June 2004 12:41 pm, Greg KH wrote:
>
> >
> > void class_unregister(struct class * cls)
> > {
> > pr_debug("device class '%s': unregistering\n",cls->name);
> > + remove_class_attrs(cls);
> > subsystem_unregister(&cls->subsys);
> > }
> >
>
> Question: is it necessary to call remove_class_attrs? I thought that sysfs
> automatically destroys all children when parent is destroyed? Am I imagining
> things?

No, you aren't imagining things. But it's considered "good form" to
remove them if you can, as this will probably change in 2.7, and it will
make my life easier trying to audit the whole tree at that time...

thanks,

greg k-h

2004-06-22 23:44:50

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

On Tuesday 22 June 2004 06:31 pm, Greg KH wrote:
> On Tue, Jun 22, 2004 at 06:21:01PM -0500, Dmitry Torokhov wrote:
> > On Tuesday 22 June 2004 12:41 pm, Greg KH wrote:
> >
> > >
> > > void class_unregister(struct class * cls)
> > > {
> > > pr_debug("device class '%s': unregistering\n",cls->name);
> > > + remove_class_attrs(cls);
> > > subsystem_unregister(&cls->subsys);
> > > }
> > >
> >
> > Question: is it necessary to call remove_class_attrs? I thought that sysfs
> > automatically destroys all children when parent is destroyed? Am I imagining
> > things?
>
> No, you aren't imagining things. But it's considered "good form" to
> remove them if you can, as this will probably change in 2.7, and it will
> make my life easier trying to audit the whole tree at that time...
>

Is there any specific reason for such a change? I kinda like the idea of
registering attributes and then having driver code do the bean counting
for me.

Btw, is there a chance for platform_device_register_simple that I sent to
you earlier be included?

--
Dmitry

2004-06-22 23:52:54

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Driver Core patches for 2.6.7

On Tue, Jun 22, 2004 at 06:44:38PM -0500, Dmitry Torokhov wrote:
> On Tuesday 22 June 2004 06:31 pm, Greg KH wrote:
> > On Tue, Jun 22, 2004 at 06:21:01PM -0500, Dmitry Torokhov wrote:
> > > On Tuesday 22 June 2004 12:41 pm, Greg KH wrote:
> > >
> > > >
> > > > void class_unregister(struct class * cls)
> > > > {
> > > > pr_debug("device class '%s': unregistering\n",cls->name);
> > > > + remove_class_attrs(cls);
> > > > subsystem_unregister(&cls->subsys);
> > > > }
> > > >
> > >
> > > Question: is it necessary to call remove_class_attrs? I thought that sysfs
> > > automatically destroys all children when parent is destroyed? Am I imagining
> > > things?
> >
> > No, you aren't imagining things. But it's considered "good form" to
> > remove them if you can, as this will probably change in 2.7, and it will
> > make my life easier trying to audit the whole tree at that time...
> >
>
> Is there any specific reason for such a change? I kinda like the idea of
> registering attributes and then having driver code do the bean counting
> for me.

Watch out if your driver is unloaded, but the device is still hanging
around. If that could happen, you need to get rid of those attributes.

But the main reason is we want to split attributes out of sysfs to make
sysfs simpler, and provide the ability for other representations of the
driver tree other than sysfs. But more about this at the kernel
summit...

> Btw, is there a chance for platform_device_register_simple that I sent to
> you earlier be included?

Yes, it's in my todo queue, trying to catch up on older patches still,
will get to it by the end of the week, sorry for the delay.

thanks,

greg k-h