Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ffa0285 authored by Hans-Peter Nilsson's avatar Hans-Peter Nilsson Committed by Linus Torvalds
Browse files

[PATCH] SPI cleanup() method param becomes non-const



I'd like to assign NULL to kfree()d members of a structure.  I can't do
that without ugly casting (see the PXA patch) when the structure pointed to
is const-qualified.  I don't really see a reason why the cleanup method
isn't allowed to alter the object it should clean up.  :-)

No, I didn't test the PXA patch, but I verified that the NULL-assignment
doesn't stop me from doing rmmod/insmodding my own spi_bitbang-based
driver.

Signed-off-by: default avatarHans-Peter Nilsson <hp@axis.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7f8c7619
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1214,9 +1214,9 @@ static int setup(struct spi_device *spi)
	return 0;
}

static void cleanup(const struct spi_device *spi)
static void cleanup(struct spi_device *spi)
{
	struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
	struct chip_data *chip = spi_get_ctldata(spi);

	kfree(chip);
}
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
 */
static void spidev_release(struct device *dev)
{
	const struct spi_device	*spi = to_spi_device(dev);
	struct spi_device	*spi = to_spi_device(dev);

	/* spi masters may cleanup for released devices */
	if (spi->master->cleanup)
+1 −1
Original line number Diff line number Diff line
@@ -238,7 +238,7 @@ EXPORT_SYMBOL_GPL(spi_bitbang_setup);
/**
 * spi_bitbang_cleanup - default cleanup for per-word I/O loops
 */
void spi_bitbang_cleanup(const struct spi_device *spi)
void spi_bitbang_cleanup(struct spi_device *spi)
{
	kfree(spi->controller_state);
}
+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ struct spi_master {
						struct spi_message *mesg);

	/* called on release() to free memory provided by spi_master */
	void			(*cleanup)(const struct spi_device *spi);
	void			(*cleanup)(struct spi_device *spi);
};

static inline void *spi_master_get_devdata(struct spi_master *master)
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ struct spi_bitbang {
 * methods, if you like.
 */
extern int spi_bitbang_setup(struct spi_device *spi);
extern void spi_bitbang_cleanup(const struct spi_device *spi);
extern void spi_bitbang_cleanup(struct spi_device *spi);
extern int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m);
extern int spi_bitbang_setup_transfer(struct spi_device *spi,
				      struct spi_transfer *t);