From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@stimpy.netroedge.com
Subject: Re: [PATCH] i2c driver changes 2.6.0-test3
Date: Fri, 15 Aug 2003 11:33:29 -0700 [thread overview]
Message-ID: <10609724091170@kroah.com> (raw)
In-Reply-To: <10609724081893@kroah.com>
ChangeSet 1.1123.18.8, 2003/08/15 11:06:52-07:00, greg@kroah.com
I2C: add adapter and client name files as the driver core no longer provides them.
drivers/i2c/i2c-core.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+)
diff -Nru a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
--- a/drivers/i2c/i2c-core.c Fri Aug 15 11:26:44 2003
+++ b/drivers/i2c/i2c-core.c Fri Aug 15 11:26:44 2003
@@ -79,12 +79,36 @@
.release = &i2c_adapter_class_dev_release,
};
+static ssize_t show_adapter_name(struct device *dev, char *buf)
+{
+ struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
+ return sprintf(buf, "%s\n", adap->name);
+}
+static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
+
+
static void i2c_client_release(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
complete(&client->released);
}
+static ssize_t show_client_name(struct device *dev, char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ return sprintf(buf, "%s\n", client->name);
+}
+
+/*
+ * We can't use the DEVICE_ATTR() macro here as we want the same filename for a
+ * different type of a device. So beware if the DEVICE_ATTR() macro ever
+ * changes, this definition will also have to change.
+ */
+static struct device_attribute dev_attr_client_name = {
+ .attr = {.name = "name", .mode = S_IRUGO, .owner = THIS_MODULE },
+ .show = &show_client_name,
+};
+
/* ---------------------------------------------------
* registering functions
@@ -120,6 +144,7 @@
adap->dev.driver = &i2c_adapter_driver;
adap->dev.release = &i2c_adapter_dev_release;
device_register(&adap->dev);
+ device_create_file(&adap->dev, &dev_attr_name);
/* Add this adapter to the i2c_adapter class */
memset(&adap->class_dev, 0x00, sizeof(struct class_device));
@@ -184,6 +209,7 @@
init_completion(&adap->dev_released);
init_completion(&adap->class_dev_released);
class_device_unregister(&adap->class_dev);
+ device_remove_file(&adap->dev, &dev_attr_name);
device_unregister(&adap->dev);
list_del(&adap->list);
@@ -361,6 +387,7 @@
"%d-%04x", i2c_adapter_id(adapter), client->addr);
printk("registering %s\n", client->dev.bus_id);
device_register(&client->dev);
+ device_create_file(&client->dev, &dev_attr_client_name);
return 0;
}
@@ -387,6 +414,7 @@
down(&adapter->clist_lock);
list_del(&client->list);
init_completion(&client->released);
+ device_remove_file(&client->dev, &dev_attr_client_name);
device_unregister(&client->dev);
up(&adapter->clist_lock);
wait_for_completion(&client->released);
prev parent reply other threads:[~2003-08-15 18:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-15 18:32 [BK PATCH] i2c driver fixes for 2.6.0-test3 Greg KH
2003-08-15 18:33 ` [PATCH] i2c driver changes 2.6.0-test3 Greg KH
2003-08-15 18:33 ` Greg KH
2003-08-15 18:33 ` Greg KH
2003-08-15 18:33 ` Greg KH
2003-08-15 18:33 ` Greg KH
2003-08-15 18:33 ` Greg KH
2003-08-15 18:33 ` Greg KH
2003-08-15 18:33 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10609724091170@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@stimpy.netroedge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).