kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Tanure <tanure@linux.com>
To: Linux Kernel List <kernelnewbies@kernelnewbies.org>
Subject: Questions about mfd_add_devices and platform_data
Date: Thu, 1 Aug 2019 17:05:21 +0100	[thread overview]
Message-ID: <CAJX_Q+2OmPa0jNG135z4zUCet=jVXnoaEQereT1oYcFPoWaWDg@mail.gmail.com> (raw)
In-Reply-To: <CACYKDtghiTsv8zGgoVvuQHqo=dmt_22GrK9xie-Y-3sNkiFfrw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1038 bytes --]

Hi,

I would like to understand mfd_add_devices call and platform_data section.

All the drivers I read the platform_data is static, but mfd_add_devices
will call platform_device_add_data which duplicates that memory and frees
the first pointer given.
But the first pointer is static and kfrees says:

"Don't free memory not originally allocated by kmalloc() or you will run
into trouble."

So, my questions is : Should my driver kmalloc platform_data first and then
call mfd_add_devices ? Or it's fine to give static memory to it ?

Example driver:

drivers/mfd/vexpress-sysreg.c:

static struct syscon_platform_data vexpress_sysreg_sys_id_pdata = {
.label = "sys_id",
};

static struct mfd_cell vexpress_sysreg_cells[] = {
{
.name = "syscon",
.num_resources = 1,
.resources = (struct resource []) {
DEFINE_RES_MEM(SYS_ID, 0x4),
},
.platform_data = &vexpress_sysreg_sys_id_pdata,
.pdata_size = sizeof(vexpress_sysreg_sys_id_pdata),
},

For this case mfd_add_devices will free vexpress_sysreg_sys_id_pdata, but
it's static.

Thanks
Lucas

[-- Attachment #1.2: Type: text/html, Size: 1224 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

      reply	other threads:[~2019-08-01 16:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 23:56 WOL from S5 (shutdown) Abu Rasheda
2019-07-31 19:32 ` Abu Rasheda
2019-08-01 16:05   ` Lucas Tanure [this message]

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='CAJX_Q+2OmPa0jNG135z4zUCet=jVXnoaEQereT1oYcFPoWaWDg@mail.gmail.com' \
    --to=tanure@linux.com \
    --cc=kernelnewbies@kernelnewbies.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).