All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-kernel@vger.kernel.org,
	Russell King <rmk+kernel@arm.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: Re: platform_device_add_data(pdev, NULL, 0)
Date: Mon, 26 Oct 2009 14:21:32 -0700	[thread overview]
Message-ID: <20091026212132.GA11973@suse.de> (raw)
In-Reply-To: <20091026211903.GA27094@pengutronix.de>

On Mon, Oct 26, 2009 at 10:19:03PM +0100, Uwe Kleine-König wrote:
> Hi Greg,
> 
> On Mon, Oct 26, 2009 at 09:48:07AM -0700, Greg KH wrote:
> > On Fri, Oct 23, 2009 at 10:26:22PM +0200, Uwe Kleine-König wrote:
> > > Hello,
> > > 
> > > mfd_add_device() (defined in drivers/mfd/mfd-core.c) is a wrapper do
> > > allocate platform_devices.
> > > 
> > > It contains:
> > > 
> > > 	ret = platform_device_add_data(pdev,
> > > 			cell->platform_data, cell->data_size);
> > > 
> > > If cell->data_size is 0 (and so likely cell->platform_data == NULL),
> > > still pdev->dev.platform_data get assigned ZERO_SIZE_PTR.
> > > 
> > > IMHO the result should better be that pdev->dev.platform_data ends being
> > > NULL, too.  Agreed?
> > 
> > Why?  Is this causing problems somewhere?
> The "problem" I as follows:  I have a driver that doesn't use
> platform_data and I want to change that.  As both the driver and the
> device probably go via different trees and I want to do the following in
> the driver:
> 
> 	if (platform_data != NULL)
> 		/* use it */
> 	else
> 		/* use the old data */
> 
> OK, I could simply use:
> 
> 	if (platform_data != NULL && platform_data != ZERO_SIZE_PTR)
> 		...
> 
> but it feels ugly.

Yes, that would be ugly.  How about just sending the driver and device
through the same trees to prevent this from happening?

thanks,

greg k-h

      reply	other threads:[~2009-10-26 21:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-23 20:26 platform_device_add_data(pdev, NULL, 0) Uwe Kleine-König
2009-10-26 16:48 ` Greg KH
2009-10-26 21:19   ` Uwe Kleine-König
2009-10-26 21:21     ` Greg KH [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=20091026212132.GA11973@suse.de \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=sameo@linux.intel.com \
    --cc=u.kleine-koenig@pengutronix.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.