All of lore.kernel.org
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: linux-kernel@vger.kernel.org, sensors@Stimpy.netroedge.com
Cc: khali@linux-fr.org
Subject: [PATCH] I2C: Cleanups to the eeprom driver
Date: Thu, 19 May 2005 06:25:31 +0000	[thread overview]
Message-ID: <1105998395257@kroah.com> (raw)
In-Reply-To: <11059983951840@kroah.com>

ChangeSet 1.2329.2.6, 2005/01/14 14:43:10-08:00, khali@linux-fr.org

[PATCH] I2C: Cleanups to the eeprom driver

Here comes a cleanup patch to the i2c eeprom client driver:

* Get rid of the unused i2c_client client_id.
* Get rid of the redundant non-ISA bus check.
* Fix the adapter capability check. We were previously using
  capabilities without checking if they were supported. Document
  which capabilities are required and which are optional.
* Reorder things a bit. In particular, wait to have a valid client
  before we bother checking if this is a Vaio EEPROM.
* Use strlcpy instead of strncpy, because I Heard It Was Better (TM) and
  all other chip drivers use it.
* Take benefit of the auto-increment feature of EEPROMs to speed up the
  Vaio check.
* Display an information message when a Vaio EEPROM is detected.

Tested successfully on my laptop, which happens to be a Vaio.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


 drivers/i2c/chips/eeprom.c |   47 +++++++++++++++++++++------------------------
 1 files changed, 22 insertions(+), 25 deletions(-)


diff -Nru a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
--- a/drivers/i2c/chips/eeprom.c	2005-01-17 13:20:34 -08:00
+++ b/drivers/i2c/chips/eeprom.c	2005-01-17 13:20:34 -08:00
@@ -78,8 +78,6 @@
 	.detach_client	= eeprom_detach_client,
 };
 
-static int eeprom_id;
-
 static void eeprom_update_client(struct i2c_client *client, u8 slice)
 {
 	struct eeprom_data *data = i2c_get_clientdata(client);
@@ -165,16 +163,14 @@
 	struct eeprom_data *data;
 	int err = 0;
 
-	/* Make sure we aren't probing the ISA bus!! This is just a safety check
-	   at this moment; i2c_detect really won't call us. */
-#ifdef DEBUG
-	if (i2c_is_isa_adapter(adapter)) {
-		dev_dbg(&adapter->dev, " eeprom_detect called for an ISA bus adapter?!?\n");
-		return 0;
-	}
-#endif
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+	/* There are three ways we can read the EEPROM data:
+	   (1) I2C block reads (faster, but unsupported by most adapters)
+	   (2) Consecutive byte reads (100% overhead)
+	   (3) Regular byte data reads (200% overhead)
+	   The third method is not implemented by this driver because all
+	   known adapters support at least the second. */
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA
+					    | I2C_FUNC_SMBUS_BYTE))
 		goto exit;
 
 	/* OK. For now, we presume we have a valid client. We now create the
@@ -197,26 +193,27 @@
 	/* prevent 24RF08 corruption */
 	i2c_smbus_write_quick(new_client, 0);
 
-	data->nature = UNKNOWN;
-	/* Detect the Vaio nature of EEPROMs.
-	   We use the "PCG-" prefix as the signature. */
-	if (address = 0x57) {
-		if (i2c_smbus_read_byte_data(new_client, 0x80) = 'P' && 
-		    i2c_smbus_read_byte_data(new_client, 0x81) = 'C' && 
-		    i2c_smbus_read_byte_data(new_client, 0x82) = 'G' &&
-		    i2c_smbus_read_byte_data(new_client, 0x83) = '-')
-			data->nature = VAIO;
-	}
-
 	/* Fill in the remaining client fields */
-	strncpy(new_client->name, "eeprom", I2C_NAME_SIZE);
-	new_client->id = eeprom_id++;
+	strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE);
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
+	data->nature = UNKNOWN;
 
 	/* Tell the I2C layer a new client has arrived */
 	if ((err = i2c_attach_client(new_client)))
 		goto exit_kfree;
+
+	/* Detect the Vaio nature of EEPROMs.
+	   We use the "PCG-" prefix as the signature. */
+	if (address = 0x57) {
+		if (i2c_smbus_read_byte_data(new_client, 0x80) = 'P'
+		 && i2c_smbus_read_byte(new_client) = 'C'
+		 && i2c_smbus_read_byte(new_client) = 'G'
+		 && i2c_smbus_read_byte(new_client) = '-')
+			dev_info(&new_client->dev, "Vaio EEPROM detected, "
+				"enabling password protection\n");
+			data->nature = VAIO;
+	}
 
 	/* create the sysfs eeprom file */
 	sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr);


WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@Stimpy.netroedge.com
Cc: khali@linux-fr.org
Subject: [PATCH] I2C: Cleanups to the eeprom driver
Date: Mon, 17 Jan 2005 13:46:35 -0800	[thread overview]
Message-ID: <1105998395257@kroah.com> (raw)
In-Reply-To: <11059983951840@kroah.com>

ChangeSet 1.2329.2.6, 2005/01/14 14:43:10-08:00, khali@linux-fr.org

[PATCH] I2C: Cleanups to the eeprom driver

Here comes a cleanup patch to the i2c eeprom client driver:

* Get rid of the unused i2c_client client_id.
* Get rid of the redundant non-ISA bus check.
* Fix the adapter capability check. We were previously using
  capabilities without checking if they were supported. Document
  which capabilities are required and which are optional.
* Reorder things a bit. In particular, wait to have a valid client
  before we bother checking if this is a Vaio EEPROM.
* Use strlcpy instead of strncpy, because I Heard It Was Better (TM) and
  all other chip drivers use it.
* Take benefit of the auto-increment feature of EEPROMs to speed up the
  Vaio check.
* Display an information message when a Vaio EEPROM is detected.

Tested successfully on my laptop, which happens to be a Vaio.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


 drivers/i2c/chips/eeprom.c |   47 +++++++++++++++++++++------------------------
 1 files changed, 22 insertions(+), 25 deletions(-)


diff -Nru a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
--- a/drivers/i2c/chips/eeprom.c	2005-01-17 13:20:34 -08:00
+++ b/drivers/i2c/chips/eeprom.c	2005-01-17 13:20:34 -08:00
@@ -78,8 +78,6 @@
 	.detach_client	= eeprom_detach_client,
 };
 
-static int eeprom_id;
-
 static void eeprom_update_client(struct i2c_client *client, u8 slice)
 {
 	struct eeprom_data *data = i2c_get_clientdata(client);
@@ -165,16 +163,14 @@
 	struct eeprom_data *data;
 	int err = 0;
 
-	/* Make sure we aren't probing the ISA bus!! This is just a safety check
-	   at this moment; i2c_detect really won't call us. */
-#ifdef DEBUG
-	if (i2c_is_isa_adapter(adapter)) {
-		dev_dbg(&adapter->dev, " eeprom_detect called for an ISA bus adapter?!?\n");
-		return 0;
-	}
-#endif
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+	/* There are three ways we can read the EEPROM data:
+	   (1) I2C block reads (faster, but unsupported by most adapters)
+	   (2) Consecutive byte reads (100% overhead)
+	   (3) Regular byte data reads (200% overhead)
+	   The third method is not implemented by this driver because all
+	   known adapters support at least the second. */
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA
+					    | I2C_FUNC_SMBUS_BYTE))
 		goto exit;
 
 	/* OK. For now, we presume we have a valid client. We now create the
@@ -197,26 +193,27 @@
 	/* prevent 24RF08 corruption */
 	i2c_smbus_write_quick(new_client, 0);
 
-	data->nature = UNKNOWN;
-	/* Detect the Vaio nature of EEPROMs.
-	   We use the "PCG-" prefix as the signature. */
-	if (address == 0x57) {
-		if (i2c_smbus_read_byte_data(new_client, 0x80) == 'P' && 
-		    i2c_smbus_read_byte_data(new_client, 0x81) == 'C' && 
-		    i2c_smbus_read_byte_data(new_client, 0x82) == 'G' &&
-		    i2c_smbus_read_byte_data(new_client, 0x83) == '-')
-			data->nature = VAIO;
-	}
-
 	/* Fill in the remaining client fields */
-	strncpy(new_client->name, "eeprom", I2C_NAME_SIZE);
-	new_client->id = eeprom_id++;
+	strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE);
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
+	data->nature = UNKNOWN;
 
 	/* Tell the I2C layer a new client has arrived */
 	if ((err = i2c_attach_client(new_client)))
 		goto exit_kfree;
+
+	/* Detect the Vaio nature of EEPROMs.
+	   We use the "PCG-" prefix as the signature. */
+	if (address == 0x57) {
+		if (i2c_smbus_read_byte_data(new_client, 0x80) == 'P'
+		 && i2c_smbus_read_byte(new_client) == 'C'
+		 && i2c_smbus_read_byte(new_client) == 'G'
+		 && i2c_smbus_read_byte(new_client) == '-')
+			dev_info(&new_client->dev, "Vaio EEPROM detected, "
+				"enabling password protection\n");
+			data->nature = VAIO;
+	}
 
 	/* create the sysfs eeprom file */
 	sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr);


  reply	other threads:[~2005-05-19  6:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-17 21:45 [BK PATCH] I2C fixes for 2.6.11-rc1 Greg KH
2005-05-19  6:25 ` Greg KH
2005-01-17 21:46 ` [PATCH] I2C: add MODULE_DEVICE_TABLE to via686a.c driver Greg KH
2005-05-19  6:25   ` Greg KH
2005-01-17 21:46   ` [PATCH] I2C support for Intel ICH7 - 2.6.10 - resubmit Greg KH
2005-05-19  6:25     ` Greg KH
2005-01-17 21:46     ` [PATCH] I2C: it87 fan update Greg KH
2005-05-19  6:25       ` Greg KH
2005-01-17 21:46       ` [PATCH] I2C: adm1026.c fixes Greg KH
2005-05-19  6:25         ` Greg KH
2005-01-17 21:46         ` [PATCH] I2C: Fix bogus bitmask in lm63 debug message Greg KH
2005-05-19  6:25           ` Greg KH
2005-01-17 21:46           ` Greg KH [this message]
2005-05-19  6:25             ` [PATCH] I2C: Cleanups to the eeprom driver Greg KH
2005-01-17 21:46             ` [PATCH] I2C: fix it87 sensor driver stops CPU fan Greg KH
2005-05-19  6:25               ` Greg KH
2005-01-17 21:46               ` [PATCH] I2C: add EMC6D100 support in lm85 driver Greg KH
2005-05-19  6:25                 ` Greg KH
2005-01-17 21:46                 ` [PATCH] I2C: Improve it87 super-i/o detection Greg KH
2005-05-19  6:25                   ` Greg KH
2005-01-17 21:46                   ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Greg KH
2005-05-19  6:25                     ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Greg KH
2005-01-17 21:46                     ` [PATCH] I2C-MPC: Convert to platform_device driver Greg KH
2005-05-19  6:25                       ` Greg KH
2005-01-17 22:12 ` [BK PATCH] I2C fixes for 2.6.11-rc1 Greg KH
2005-05-19  6:25   ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2005-05-19  6:25 [PATCH] I2C-MPC: use wait_event_interruptible_timeout Kumar Gala
2005-05-19  6:25 ` Kumar Gala
2005-05-19  6:25 ` Greg KH
2005-01-14  3:35 [PATCH] I2C-MPC: Convert to platform_device driver Kumar Gala
2005-05-19  6:25 ` Kumar Gala
2005-01-14  3:35 ` Kumar Gala
2005-01-14 18:42 ` Greg KH
2005-05-19  6:25   ` Greg KH
2005-01-14 18:42   ` Greg KH
2005-01-14  0:21 [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Kumar Gala
2005-05-19  6:25 ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Kumar Gala
2005-01-14  0:21 ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Kumar Gala
2005-01-14 18:41 ` Greg KH
2005-05-19  6:25   ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Greg KH
2005-01-14 18:41   ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Greg KH

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=1105998395257@kroah.com \
    --to=greg@kroah.com \
    --cc=khali@linux-fr.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.