Commit 1838d743 authored by Patrick Mochel's avatar Patrick Mochel

[PATCH] driver model updates (3/5)

Patch 3: Make default callbacks simpler.

I want to move as much to a 1 file/1 value model as possible. I haven't
come up with a clean way to enforce it except via social pressure.

This patch is a step in that direction. It:

- Reduces the output of 'power' to just the decimal state of the device
- Adds a 'name' file which exports just the device name
- Reduces the 'status' file to just export the bus ID. (This will change,
  since the bus ID is obvious based on what directory you're in, but it's
  another patch at another time)
parent e03a933d
...@@ -19,15 +19,7 @@ ...@@ -19,15 +19,7 @@
*/ */
static ssize_t device_read_status(struct device * dev, char * page, size_t count, loff_t off) static ssize_t device_read_status(struct device * dev, char * page, size_t count, loff_t off)
{ {
char *str = page; return off ? 0 : sprintf(page,"%s\n",dev->bus_id);
if (off)
return 0;
str += sprintf(str,"Name: %s\n",dev->name);
str += sprintf(str,"Bus ID: %s\n",dev->bus_id);
return (str - page);
} }
/** /**
...@@ -84,17 +76,21 @@ static struct driver_file_entry device_status_entry = { ...@@ -84,17 +76,21 @@ static struct driver_file_entry device_status_entry = {
store: device_write_status, store: device_write_status,
}; };
static ssize_t static ssize_t device_read_name(struct device * dev, char * buf, size_t count, loff_t off)
device_read_power(struct device * dev, char * page, size_t count, loff_t off)
{ {
char * str = page; return off ? 0 : sprintf(buf,"%s\n",dev->name);
}
if (off)
return 0;
str += sprintf(str,"State: %d\n",dev->current_state); static struct driver_file_entry device_name_entry = {
name: "name",
mode: S_IRUGO,
show: device_read_name,
};
return (str - page); static ssize_t
device_read_power(struct device * dev, char * page, size_t count, loff_t off)
{
return off ? 0 : sprintf(page,"%d\n",dev->current_state);
} }
static ssize_t static ssize_t
...@@ -169,6 +165,7 @@ static struct driver_file_entry device_power_entry = { ...@@ -169,6 +165,7 @@ static struct driver_file_entry device_power_entry = {
struct driver_file_entry * device_default_files[] = { struct driver_file_entry * device_default_files[] = {
&device_status_entry, &device_status_entry,
&device_name_entry,
&device_power_entry, &device_power_entry,
NULL, NULL,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment