devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cory Tusar <cory.tusar-J6Z/VSE8EyIAspv4Qr0y0gC/G2K4zDHf@public.gmane.org>
To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	pawel.moll-5wv7dgnIgG8@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
	galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org
Cc: jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org,
	broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	afd-l0cyMroinI0@public.gmane.org,
	andrew-g2DYL2Zd6BY@public.gmane.org,
	Chris.Healy-c8ZVq/bFV1I@public.gmane.org,
	Keith.Vennel-c8ZVq/bFV1I@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Cory Tusar
	<cory.tusar-J6Z/VSE8EyIAspv4Qr0y0gC/G2K4zDHf@public.gmane.org>
Subject: [PATCH v4 1/5] misc: eeprom_93xx46: Fix 16-bit read and write accesses.
Date: Wed,  9 Dec 2015 23:00:51 -0500	[thread overview]
Message-ID: <1449720055-25965-2-git-send-email-cory.tusar@pid1solutions.com> (raw)
In-Reply-To: <1449720055-25965-1-git-send-email-cory.tusar-J6Z/VSE8EyIAspv4Qr0y0gC/G2K4zDHf@public.gmane.org>

Compatible at93xx46 devices from both Microchip and Atmel expect a
word-based address, regardless of whether the device is strapped for 8-
or 16-bit operation.  However, the offset parameter passed in when
reading or writing at a specific location is always specified in terms
of bytes.

This commit fixes 16-bit read and write accesses by shifting the offset
parameter to account for this difference between a byte offset and a
word-based address.

Signed-off-by: Cory Tusar <cory.tusar-J6Z/VSE8EyIAspv4Qr0y0gC/G2K4zDHf@public.gmane.org>
Tested-by: Chris Healy <chris.healy-c8ZVq/bFV1I@public.gmane.org>
---
 drivers/misc/eeprom/eeprom_93xx46.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
index ff63f05..e1bf0a5 100644
--- a/drivers/misc/eeprom/eeprom_93xx46.c
+++ b/drivers/misc/eeprom/eeprom_93xx46.c
@@ -54,7 +54,7 @@ eeprom_93xx46_bin_read(struct file *filp, struct kobject *kobj,
 		cmd_addr |= off & 0x7f;
 		bits = 10;
 	} else {
-		cmd_addr |= off & 0x3f;
+		cmd_addr |= (off >> 1) & 0x3f;
 		bits = 9;
 	}
 
@@ -155,7 +155,7 @@ eeprom_93xx46_write_word(struct eeprom_93xx46_dev *edev,
 		bits = 10;
 		data_len = 1;
 	} else {
-		cmd_addr |= off & 0x3f;
+		cmd_addr |= (off >> 1) & 0x3f;
 		bits = 9;
 		data_len = 2;
 	}
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-12-10  4:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10  4:00 [PATCH v4 0/5] Devicetree support for misc/eeprom/eeprom_93xx46 Cory Tusar
     [not found] ` <1449720055-25965-1-git-send-email-cory.tusar-J6Z/VSE8EyIAspv4Qr0y0gC/G2K4zDHf@public.gmane.org>
2015-12-10  4:00   ` Cory Tusar [this message]
2015-12-10  4:00 ` [PATCH v4 2/5] Documentation: devicetree: Add DT bindings to eeprom_93xx46 driver Cory Tusar
     [not found]   ` <1449720055-25965-3-git-send-email-cory.tusar-J6Z/VSE8EyIAspv4Qr0y0gC/G2K4zDHf@public.gmane.org>
2015-12-22  0:01     ` Vladimir Zapolskiy
     [not found]       ` <567892EF.6060508-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2016-01-06  2:38         ` Cory Tusar
2015-12-10  4:00 ` [PATCH v4 3/5] misc: eeprom_93xx46: Implement eeprom_93xx46 DT bindings Cory Tusar
2015-12-22  0:12   ` Vladimir Zapolskiy
     [not found]     ` <5678955B.4070700-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2016-01-06  3:18       ` Cory Tusar
2015-12-10  4:00 ` [PATCH v4 4/5] misc: eeprom_93xx46: Add quirks to support Atmel AT93C46D device Cory Tusar
2015-12-22  0:19   ` Vladimir Zapolskiy
2016-01-06  3:20     ` Cory Tusar
2015-12-10  4:00 ` [PATCH v4 5/5] misc: eeprom_93xx46: Add support for a GPIO 'select' line Cory Tusar
     [not found]   ` <1449720055-25965-6-git-send-email-cory.tusar-J6Z/VSE8EyIAspv4Qr0y0gC/G2K4zDHf@public.gmane.org>
2015-12-22  0:30     ` Vladimir Zapolskiy
     [not found]       ` <5678999C.7040808-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2016-01-06  3:21         ` Cory Tusar

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=1449720055-25965-2-git-send-email-cory.tusar@pid1solutions.com \
    --to=cory.tusar-j6z/vse8eyiaspv4qr0y0gc/g2k4zdhf@public.gmane.org \
    --cc=Chris.Healy-c8ZVq/bFV1I@public.gmane.org \
    --cc=Keith.Vennel-c8ZVq/bFV1I@public.gmane.org \
    --cc=afd-l0cyMroinI0@public.gmane.org \
    --cc=andrew-g2DYL2Zd6BY@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org \
    /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).