All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Andrzej Hajda <a.hajda@samsung.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Magnus Damm <magnus.damm@gmail.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Biju Das <biju.das@bp.renesas.com>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>,
	Simon Horman <horms@verge.net.au>,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Peter Rosin <peda@axentia.se>
Subject: Re: [PATCH v4 06/13] drm/bridge: lvds-codec: Add "lvds-decoder" support
Date: Tue, 17 Dec 2019 13:38:51 +0100	[thread overview]
Message-ID: <CAMuHMdVqHekyeOaHwpFyG5buNZp-XmvGizqZ=Gbg40_=NL+s2A@mail.gmail.com> (raw)
In-Reply-To: <TY1PR01MB17705FC08F72875484DF2208C0500@TY1PR01MB1770.jpnprd01.prod.outlook.com>

Hi Fabrizio,

On Tue, Dec 17, 2019 at 1:31 PM Fabrizio Castro
<fabrizio.castro@bp.renesas.com> wrote:
> > From: linux-renesas-soc-owner@vger.kernel.org <linux-renesas-soc-owner@vger.kernel.org> On Behalf Of Geert Uytterhoeven
> > Sent: 17 December 2019 12:21
> > Subject: Re: [PATCH v4 06/13] drm/bridge: lvds-codec: Add "lvds-decoder" support
> >
> > On Tue, Dec 17, 2019 at 12:03 PM Fabrizio Castro
> > <fabrizio.castro@bp.renesas.com> wrote:
> > > > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > > Sent: 13 December 2019 17:11
> > > > Subject: Re: [PATCH v4 06/13] drm/bridge: lvds-codec: Add "lvds-decoder" support
> > > >
> > > > On Wed, Nov 13, 2019 at 03:51:25PM +0000, Fabrizio Castro wrote:
> > > > > Add support for transparent LVDS decoders by adding a new
> > > > > compatible string ("lvds-decoder") to the driver.
> > > > > This patch also adds member connector_type to struct lvds_codec,
> > > > > and that's because LVDS decoders have a different connector type
> > > > > from LVDS encoders. We fill this new member up with the data
> > > > > matching the compatible string.
> > > > >
> > > > > Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>

> > > > > --- a/drivers/gpu/drm/bridge/lvds-codec.c
> > > > > +++ b/drivers/gpu/drm/bridge/lvds-codec.c

> > > > > @@ -65,6 +67,7 @@ static int lvds_codec_probe(struct platform_device *pdev)
> > > > >     if (!lvds_codec)
> > > > >             return -ENOMEM;
> > > > >
> > > > > +   lvds_codec->connector_type = (u32)of_device_get_match_data(&pdev->dev);
> > > >
> > > > I'm now getting a compilation failure here:
> > > >
> > > > drivers/gpu/drm/bridge/lvds-codec.c: In function ‘lvds_codec_probe’:
> > > > drivers/gpu/drm/bridge/lvds-codec.c:68:31: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
> > > >   lvds_codec->connector_type = (u32)of_device_get_match_data(&pdev->dev);
> > > >                                ^
> > > >
> > > > The fix should be simple:
> > > >
> > > >       lvds_codec->connector_type = (uintptr_t)of_device_get_match_data(dev);
> > > >
> > > > I'm bothered by the fact that I've compiled this before without any
> > > > issue, so this really puzzles me. Do you get the same warning ?
> > >
> > > The warning appears when compiling for arm64, understandably so.
> > > We must have compiled this for arm only the first time around.
> > >
> > > I think the right way to solve this is to either cast to (u32)(uintptr_t) or (u32)(unsigned long).
> >
> > Just casting to uintptr_t should be sufficient.
>
> It should be sufficient for the compiler, but I have seen examples where people
> preferred to be explicit, like in:
> drivers/mailbox/mtk-cmdq-mailbox.c
> drivers/leds/leds-pm8058.c
>
> Since the kernel is increasing its tightness with respect to warnings, I personally prefer
> (u32)(uintptr_t), even though not strictly necessary, but I am fine with (uintptr_t) if you
> don't like (u32)(uintptr_t).

It depends. I try to have as few casts as possible ("casts are evil").

While adding the extra (u32) cast makes it clearer that the intended
result is a u32 (for now), it will cause silent truncation on 64-bit if
connector_type is ever enlarged to unsigned long, and larger values are
used.

In this particular case this is unlikely, though, as unsigned long would
still be 32-bit on 32-bit platforms, so the larger values cannot be
used.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Neil Armstrong <narmstrong@baylibre.com>,
	David Airlie <airlied@linux.ie>,
	Simon Horman <horms@verge.net.au>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Magnus Damm <magnus.damm@gmail.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Biju Das <biju.das@bp.renesas.com>,
	"linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Peter Rosin <peda@axentia.se>
Subject: Re: [PATCH v4 06/13] drm/bridge: lvds-codec: Add "lvds-decoder" support
Date: Tue, 17 Dec 2019 13:38:51 +0100	[thread overview]
Message-ID: <CAMuHMdVqHekyeOaHwpFyG5buNZp-XmvGizqZ=Gbg40_=NL+s2A@mail.gmail.com> (raw)
In-Reply-To: <TY1PR01MB17705FC08F72875484DF2208C0500@TY1PR01MB1770.jpnprd01.prod.outlook.com>

Hi Fabrizio,

On Tue, Dec 17, 2019 at 1:31 PM Fabrizio Castro
<fabrizio.castro@bp.renesas.com> wrote:
> > From: linux-renesas-soc-owner@vger.kernel.org <linux-renesas-soc-owner@vger.kernel.org> On Behalf Of Geert Uytterhoeven
> > Sent: 17 December 2019 12:21
> > Subject: Re: [PATCH v4 06/13] drm/bridge: lvds-codec: Add "lvds-decoder" support
> >
> > On Tue, Dec 17, 2019 at 12:03 PM Fabrizio Castro
> > <fabrizio.castro@bp.renesas.com> wrote:
> > > > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > > Sent: 13 December 2019 17:11
> > > > Subject: Re: [PATCH v4 06/13] drm/bridge: lvds-codec: Add "lvds-decoder" support
> > > >
> > > > On Wed, Nov 13, 2019 at 03:51:25PM +0000, Fabrizio Castro wrote:
> > > > > Add support for transparent LVDS decoders by adding a new
> > > > > compatible string ("lvds-decoder") to the driver.
> > > > > This patch also adds member connector_type to struct lvds_codec,
> > > > > and that's because LVDS decoders have a different connector type
> > > > > from LVDS encoders. We fill this new member up with the data
> > > > > matching the compatible string.
> > > > >
> > > > > Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>

> > > > > --- a/drivers/gpu/drm/bridge/lvds-codec.c
> > > > > +++ b/drivers/gpu/drm/bridge/lvds-codec.c

> > > > > @@ -65,6 +67,7 @@ static int lvds_codec_probe(struct platform_device *pdev)
> > > > >     if (!lvds_codec)
> > > > >             return -ENOMEM;
> > > > >
> > > > > +   lvds_codec->connector_type = (u32)of_device_get_match_data(&pdev->dev);
> > > >
> > > > I'm now getting a compilation failure here:
> > > >
> > > > drivers/gpu/drm/bridge/lvds-codec.c: In function ‘lvds_codec_probe’:
> > > > drivers/gpu/drm/bridge/lvds-codec.c:68:31: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
> > > >   lvds_codec->connector_type = (u32)of_device_get_match_data(&pdev->dev);
> > > >                                ^
> > > >
> > > > The fix should be simple:
> > > >
> > > >       lvds_codec->connector_type = (uintptr_t)of_device_get_match_data(dev);
> > > >
> > > > I'm bothered by the fact that I've compiled this before without any
> > > > issue, so this really puzzles me. Do you get the same warning ?
> > >
> > > The warning appears when compiling for arm64, understandably so.
> > > We must have compiled this for arm only the first time around.
> > >
> > > I think the right way to solve this is to either cast to (u32)(uintptr_t) or (u32)(unsigned long).
> >
> > Just casting to uintptr_t should be sufficient.
>
> It should be sufficient for the compiler, but I have seen examples where people
> preferred to be explicit, like in:
> drivers/mailbox/mtk-cmdq-mailbox.c
> drivers/leds/leds-pm8058.c
>
> Since the kernel is increasing its tightness with respect to warnings, I personally prefer
> (u32)(uintptr_t), even though not strictly necessary, but I am fine with (uintptr_t) if you
> don't like (u32)(uintptr_t).

It depends. I try to have as few casts as possible ("casts are evil").

While adding the extra (u32) cast makes it clearer that the intended
result is a u32 (for now), it will cause silent truncation on 64-bit if
connector_type is ever enlarged to unsigned long, and larger values are
used.

In this particular case this is unlikely, though, as unsigned long would
still be 32-bit on 32-bit platforms, so the larger values cannot be
used.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-12-17 12:39 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 15:51 [PATCH v4 00/13] Add LCD panel support to iwg20d Fabrizio Castro
2019-11-13 15:51 ` Fabrizio Castro
2019-11-13 15:51 ` [PATCH v4 01/13] dt-bindings: display: bridge: Convert lvds-transmitter binding to json-schema Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-18 21:35   ` Rob Herring
2019-11-18 21:35     ` Rob Herring
2019-11-18 21:35     ` Rob Herring
2019-11-18 23:51   ` Laurent Pinchart
2019-11-18 23:51     ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 02/13] dt-bindings: display: bridge: lvds-transmitter: Document powerdown-gpios Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-18 21:36   ` Rob Herring
2019-11-18 21:36     ` Rob Herring
2019-11-18 21:36     ` Rob Herring
2019-11-18 23:55   ` Laurent Pinchart
2019-11-18 23:55     ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 03/13] dt-bindings: display: bridge: lvds-transmitter: Absorb ti,ds90c185.txt Fabrizio Castro
2019-11-13 15:51   ` [PATCH v4 03/13] dt-bindings: display: bridge: lvds-transmitter: Absorb ti, ds90c185.txt Fabrizio Castro
2019-11-18 21:38   ` [PATCH v4 03/13] dt-bindings: display: bridge: lvds-transmitter: Absorb ti,ds90c185.txt Rob Herring
2019-11-18 21:38     ` Rob Herring
2019-11-18 21:38     ` Rob Herring
2019-11-18 23:56   ` Laurent Pinchart
2019-11-18 23:56     ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 04/13] dt-bindings: display: bridge: lvds-transmitter: Document "ti,sn75lvds83" Fabrizio Castro
2019-11-13 15:51   ` [PATCH v4 04/13] dt-bindings: display: bridge: lvds-transmitter: Document "ti, sn75lvds83" Fabrizio Castro
2019-11-18 21:38   ` [PATCH v4 04/13] dt-bindings: display: bridge: lvds-transmitter: Document "ti,sn75lvds83" Rob Herring
2019-11-18 21:38     ` Rob Herring
2019-11-18 21:38     ` Rob Herring
2019-11-18 23:57   ` Laurent Pinchart
2019-11-18 23:57     ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 05/13] drm/bridge: Repurpose lvds-encoder.c Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-19  0:00   ` Laurent Pinchart
2019-11-19  0:00     ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 06/13] drm/bridge: lvds-codec: Add "lvds-decoder" support Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-19  0:02   ` Laurent Pinchart
2019-11-19  0:02     ` Laurent Pinchart
2019-12-13 17:10   ` Laurent Pinchart
2019-12-13 17:10     ` Laurent Pinchart
2019-12-16 21:22     ` Laurent Pinchart
2019-12-16 21:22       ` Laurent Pinchart
2019-12-17 11:02     ` Fabrizio Castro
2019-12-17 11:02       ` Fabrizio Castro
2019-12-17 12:21       ` Geert Uytterhoeven
2019-12-17 12:21         ` Geert Uytterhoeven
2019-12-17 12:31         ` Fabrizio Castro
2019-12-17 12:31           ` Fabrizio Castro
2019-12-17 12:38           ` Geert Uytterhoeven [this message]
2019-12-17 12:38             ` Geert Uytterhoeven
2019-12-17 13:54             ` Laurent Pinchart
2019-12-17 13:54               ` Laurent Pinchart
2019-12-17 22:06               ` Fabrizio Castro
2019-12-17 22:06                 ` Fabrizio Castro
2019-12-17 23:08                 ` Laurent Pinchart
2019-12-17 23:08                   ` Laurent Pinchart
2019-12-18 12:00                   ` Fabrizio Castro
2019-12-18 12:00                     ` Fabrizio Castro
2019-12-17 23:07   ` [PATCH v4.1 " Laurent Pinchart
2019-12-17 23:07     ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 07/13] drm/bridge: lvds-codec: Simplify panel DT node localisation Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-19  0:03   ` Laurent Pinchart
2019-11-19  0:03     ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 08/13] dt-bindings: display: bridge: Repurpose lvds-encoder Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-18 21:40   ` Rob Herring
2019-11-18 21:40     ` Rob Herring
2019-11-18 21:40     ` Rob Herring
2019-11-19  0:07   ` Laurent Pinchart
2019-11-19  0:07     ` Laurent Pinchart
2019-11-19 10:35     ` Fabrizio Castro
2019-11-19 10:35       ` Fabrizio Castro
2019-11-13 15:51 ` [PATCH v4 09/13] dt-bindings: display: bridge: lvds-codec: Document ti,ds90cf384a Fabrizio Castro
2019-11-13 15:51   ` [PATCH v4 09/13] dt-bindings: display: bridge: lvds-codec: Document ti, ds90cf384a Fabrizio Castro
2019-11-18 21:41   ` [PATCH v4 09/13] dt-bindings: display: bridge: lvds-codec: Document ti,ds90cf384a Rob Herring
2019-11-18 21:41     ` Rob Herring
2019-11-18 21:41     ` Rob Herring
2019-11-19  0:09   ` Laurent Pinchart
2019-11-19  0:09     ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 10/13] ARM: dts: iwg20d-q7-common: Add LCD support Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-19  0:10   ` Laurent Pinchart
2019-11-19  0:10     ` Laurent Pinchart
2019-11-25 10:30     ` Geert Uytterhoeven
2019-11-25 10:30       ` Geert Uytterhoeven
2019-11-13 15:51 ` [PATCH v4 11/13] ARM: shmobile_defconfig: Enable support for panels from EDT Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-19  0:12   ` Laurent Pinchart
2019-11-19  0:12     ` Laurent Pinchart
2019-11-25 10:30     ` Geert Uytterhoeven
2019-11-25 10:30       ` Geert Uytterhoeven
2019-11-13 15:51 ` [PATCH v4 12/13] [HACK] drm/bridge: lvds-codec: Enforce device specific compatible strings Fabrizio Castro
2019-11-13 15:51   ` Fabrizio Castro
2019-11-19  0:16   ` Laurent Pinchart
2019-11-19  0:16     ` Laurent Pinchart
2019-11-19 11:17     ` Fabrizio Castro
2019-11-19 11:17       ` Fabrizio Castro
2019-11-19 21:51       ` Laurent Pinchart
2019-11-19 21:51         ` Laurent Pinchart
2019-11-21 16:00         ` Fabrizio Castro
2019-11-21 16:00           ` Fabrizio Castro
2019-11-22  8:16           ` Geert Uytterhoeven
2019-11-22  8:16             ` Geert Uytterhoeven
2019-11-25 11:17             ` Fabrizio Castro
2019-11-25 11:17               ` Fabrizio Castro
2019-12-02  9:42               ` Laurent Pinchart
2019-12-02  9:42                 ` Laurent Pinchart
2019-11-13 15:51 ` [PATCH v4 13/13] [HACK] dt-bindings: display: bridge: lvds-codec: Absorb thine,thc63lvdm83d.txt Fabrizio Castro
2019-11-13 15:51   ` [PATCH v4 13/13] [HACK] dt-bindings: display: bridge: lvds-codec: Absorb thine, thc63lvdm83d.txt Fabrizio Castro
2019-11-18 21:51   ` [PATCH v4 13/13] [HACK] dt-bindings: display: bridge: lvds-codec: Absorb thine,thc63lvdm83d.txt Rob Herring
2019-11-18 21:51     ` Rob Herring
2019-11-19  0:19   ` Laurent Pinchart
2019-11-19  0:19     ` Laurent Pinchart
2019-12-18 11:52 ` [PATCH v4 00/13] Add LCD panel support to iwg20d Neil Armstrong
2019-12-18 11:52   ` Neil Armstrong
2019-12-18 14:05   ` Fabrizio Castro
2019-12-18 14:05     ` Fabrizio Castro

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='CAMuHMdVqHekyeOaHwpFyG5buNZp-XmvGizqZ=Gbg40_=NL+s2A@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=Chris.Paterson2@renesas.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=biju.das@bp.renesas.com \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fabrizio.castro@bp.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=horms@verge.net.au \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=narmstrong@baylibre.com \
    --cc=peda@axentia.se \
    --cc=robh+dt@kernel.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 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.