Skip to contentSkip to conversation

RFC: of_device_id: use pointer for the data field

DISCUSSION Antony Pavlov 2 participants 3 messages Apr 26, 2015 – Apr 27, 2015

lore
Share & tools
lore
#0 lore raw

Hi!

Just now barebox' of_device_id struct uses unsigned long type for data field:

  struct of_device_id {
          char *compatible;
          unsigned long data;
  };

Here is of_device_id struct in linux kernel:

  struct of_device_id {
          char name[32];
          char type[32];
          char compatible[128];
          const void *data;
  };

Just all data fields are used as pointers and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output:

  drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = {
  drivers/ata/sata-imx.c- {
  drivers/ata/sata-imx.c-         .compatible = "fsl,imx6q-ahci",
  drivers/ata/sata-imx.c-         .data = (unsigned long)&data_imx6,
  drivers/ata/sata-imx.c- }, {

Could we use 'const void *' type for data field as linux kernel does?

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw
Quoted 21 lines · Antony Pavlov

Hi!

Just now barebox' of_device_id struct uses unsigned long type for data field:

  struct of_device_id {
          char *compatible;
          unsigned long data;
  };

Here is of_device_id struct in linux kernel:

  struct of_device_id {
          char name[32];
          char type[32];
          char compatible[128];
          const void *data;
  };

Just all data fields are used as pointers and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output:

Quoted 7 lines
  drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = {
  drivers/ata/sata-imx.c- {
  drivers/ata/sata-imx.c-         .compatible = "fsl,imx6q-ahci",
  drivers/ata/sata-imx.c-         .data = (unsigned long)&data_imx6,
  drivers/ata/sata-imx.c- }, {

Could we use 'const void *' type for data field as linux kernel does?

Yes, good idea.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 28 lines · On Mon, 27 Apr 2015 08:00:59 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 27 lines · Antony Pavlov

Hi!

Just now barebox' of_device_id struct uses unsigned long type for data field:

  struct of_device_id {
          char *compatible;
          unsigned long data;
  };

Here is of_device_id struct in linux kernel:

  struct of_device_id {
          char name[32];
          char type[32];
          char compatible[128];
          const void *data;
  };

Just all data fields are used as pointers and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output:

  drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = {
  drivers/ata/sata-imx.c- {
  drivers/ata/sata-imx.c-         .compatible = "fsl,imx6q-ahci",
  drivers/ata/sata-imx.c-         .data = (unsigned long)&data_imx6,
  drivers/ata/sata-imx.c- }, {
Quoted 3 lines
Quoted 1 line

Could we use 'const void *' type for data field as linux kernel does?

Yes, good idea.

Ok, I'll try to prepare the patch in several days.

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox