All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 08/21] usb: ulpi: Fix compile warning in read/write on 64-bit machines.
Date: Thu, 31 Mar 2016 23:12:21 +0200	[thread overview]
Message-ID: <1459458754-29559-9-git-send-email-mateusz.kulikowski@gmail.com> (raw)
In-Reply-To: <1459458754-29559-1-git-send-email-mateusz.kulikowski@gmail.com>

ulpi_read and ulpi_write are used to read/write registers via ULPI bus.
Code generates compilation warnings on 64-bit machines where pointer
is cast to u32.

This patch drops all but last 8 bits of register address.
It is possible, because addresses on ULPI bus are 6- or 8-bit.

It is not possible (according to ULPI 1.1 spec) to have more
than 8-bit addressing.

This patch should not cause regressions as all calls to
ulpi_read/write use either structure pointer (@ address 0) or integer
offsets cast to pointer - addresses requested are way below 8-bit range.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Acked-by: Marek Vasut <marex@denx.de>
---

Changes in v4:
- Add Ack from Marek

Changes in v3:
- New patch

Changes in v2: None
Changes in v1: None

 drivers/usb/ulpi/ulpi-viewport.c | 5 +++--
 include/usb/ulpi.h               | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/ulpi/ulpi-viewport.c b/drivers/usb/ulpi/ulpi-viewport.c
index 72a06de..d111680 100644
--- a/drivers/usb/ulpi/ulpi-viewport.c
+++ b/drivers/usb/ulpi/ulpi-viewport.c
@@ -92,7 +92,8 @@ static int ulpi_request(struct ulpi_viewport *ulpi_vp, u32 value)
 
 int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)
 {
-	u32 val = ULPI_RWRUN | ULPI_RWCTRL | ((u32)reg << 16) | (value & 0xff);
+	u32 addr = (uintptr_t)reg & 0xFF;
+	u32 val = ULPI_RWRUN | ULPI_RWCTRL | addr << 16 | (value & 0xff);
 
 	val |= (ulpi_vp->port_num & 0x7) << 24;
 	return ulpi_request(ulpi_vp, val);
@@ -101,7 +102,7 @@ int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)
 u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg)
 {
 	int err;
-	u32 val = ULPI_RWRUN | ((u32)reg << 16);
+	u32 val = ULPI_RWRUN | ((uintptr_t)reg & 0xFF) << 16;
 
 	val |= (ulpi_vp->port_num & 0x7) << 24;
 	err = ulpi_request(ulpi_vp, val);
diff --git a/include/usb/ulpi.h b/include/usb/ulpi.h
index dfea395..747fb0a 100644
--- a/include/usb/ulpi.h
+++ b/include/usb/ulpi.h
@@ -123,6 +123,7 @@ int ulpi_reset(struct ulpi_viewport *ulpi_vp);
 /*
  * Write to the ULPI PHY register via the viewport.
  * @reg		- the ULPI register (one of the fields in struct ulpi_regs).
+ *		  Due to ULPI design, only 8 lsb of address are used.
  * @value	- the value - only 8 lower bits are used, others ignored.
  *
  * returns 0 on success, ULPI_ERROR on failure.
@@ -132,6 +133,7 @@ int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value);
 /*
  * Read the ULPI PHY register content via the viewport.
  * @reg		- the ULPI register (one of the fields in struct ulpi_regs).
+ *		  Due to ULPI design, only 8 lsb of address are used.
  *
  * returns register content on success, ULPI_ERROR on failure.
  */
-- 
2.5.0

  parent reply	other threads:[~2016-03-31 21:12 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-31 21:12 [U-Boot] [PATCH v4 00/21] Add support for 96boards Dragonboard410C board Mateusz Kulikowski
2016-03-31 21:12 ` [U-Boot] [PATCH v4 01/21] serial: Add support for Qualcomm serial port Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 02/21] gpio: Add support for Qualcomm gpio controller Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 03/21] mmc: Add support for Qualcomm SDHCI controller Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 04/21] ehci-hcd: Add init_after_reset Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot,v4,04/21] " Tom Rini
2016-04-03 10:58     ` Bernhard Nortmann
2016-04-03 11:40       ` Mateusz Kulikowski
2016-03-31 21:12 ` [U-Boot] [PATCH v4 05/21] usb: ulpi: Add Kconfig options for ULPI Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 06/21] Migrate CONFIG_ULPI* to Kconfig Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot,v4,06/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 07/21] usb: ulpi: Fix viewport_addr type Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot,v4,07/21] " Tom Rini
2016-03-31 21:12 ` Mateusz Kulikowski [this message]
2016-04-02  2:02   ` [U-Boot] [U-Boot, v4, 08/21] usb: ulpi: Fix compile warning in read/write on 64-bit machines Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 09/21] eth: asix88179: Print packet length properly Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 10/21] usb: Rename ehci-fsl.h to ehci-ci.h Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot,v4,10/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 11/21] usb: ehci-ci: Add missing registers Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 12/21] ehci-ci.h: drop generic USBCMD fields Mateusz Kulikowski
2016-04-02  2:03   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 13/21] ehci: Add support for Qualcomm EHCI Mateusz Kulikowski
2016-04-02  2:03   ` [U-Boot] [U-Boot,v4,13/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 14/21] drivers: Add SPMI bus uclass Mateusz Kulikowski
2016-04-02  2:04   ` [U-Boot] [U-Boot,v4,14/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 15/21] spmi: Add sandbox test driver Mateusz Kulikowski
2016-04-02  2:04   ` [U-Boot] [U-Boot,v4,15/21] " Tom Rini
2016-04-04 15:49     ` Stephen Warren
2016-04-04 16:19       ` Mateusz Kulikowski
2016-04-04 17:09         ` Stephen Warren
2016-04-04 18:02           ` Mateusz Kulikowski
2016-04-04 17:16       ` Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 16/21] drivers: spmi: Add support for Qualcomm SPMI bus driver Mateusz Kulikowski
2016-04-02  2:04   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 17/21] pmic: Add support for Qualcomm PM8916 PMIC Mateusz Kulikowski
2016-04-02  2:04   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 18/21] gpio: Add support for Qualcomm PM8916 gpios Mateusz Kulikowski
2016-04-02  2:05   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 19/21] arm: Add support for Qualcomm Snapdragon family Mateusz Kulikowski
2016-04-02  2:05   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 20/21] board: Add Qualcomm Dragonboard 410C support Mateusz Kulikowski
2016-04-02  2:05   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-04-04 23:13   ` [U-Boot] [PATCH v4 " Andreas Färber
2016-04-04 23:54     ` Daniel Glöckner
2016-04-05  0:15       ` Andreas Färber
2016-03-31 21:12 ` [U-Boot] [PATCH v4 21/21] Add myself as Snapdragon and SPMI maintainer Mateusz Kulikowski
2016-04-02  2:06   ` [U-Boot] [U-Boot, v4, " Tom Rini

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=1459458754-29559-9-git-send-email-mateusz.kulikowski@gmail.com \
    --to=mateusz.kulikowski@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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.