All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/8] dm-sf: use mtd_ops, drop dm_spi_flash_ops
Date: Thu, 29 Oct 2015 07:35:30 +0100	[thread overview]
Message-ID: <5631BE32.8040106@denx.de> (raw)
In-Reply-To: <1444679655-30349-4-git-send-email-jteki@openedev.com>

Hello Jagan,

Am 12.10.2015 um 21:54 schrieb Jagan Teki:
> Since mtd_info ops got introduced, just drop the unneeded
> dm_spi_flash operations.
>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
>   drivers/mtd/spi/sf-uclass.c | 16 --------
>   drivers/mtd/spi/sf_probe.c  | 30 ---------------
>   include/spi_flash.h         | 91 +++++++--------------------------------------
>   3 files changed, 14 insertions(+), 123 deletions(-)

Does this not break: drivers/mtd/spi/sf-uclass.c ?

added simon to cc.

bye,
Heiko
>
> diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
> index 350e21a..5cdbd1b 100644
> --- a/drivers/mtd/spi/sf-uclass.c
> +++ b/drivers/mtd/spi/sf-uclass.c
> @@ -11,22 +11,6 @@
>   #include <dm/device-internal.h>
>   #include "sf_internal.h"
>
> -int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf)
> -{
> -	return sf_get_ops(dev)->read(dev, offset, len, buf);
> -}
> -
> -int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
> -		       const void *buf)
> -{
> -	return sf_get_ops(dev)->write(dev, offset, len, buf);
> -}
> -
> -int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
> -{
> -	return sf_get_ops(dev)->erase(dev, offset, len);
> -}
> -
>   /*
>    * TODO(sjg at chromium.org): This is an old-style function. We should remove
>    * it when all SPI flash drivers use dm
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index b8704e2..5e314e2 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -104,29 +104,6 @@ void spi_flash_free(struct spi_flash *flash)
>
>   #else /* defined CONFIG_DM_SPI_FLASH */
>
> -static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,
> -			      void *buf)
> -{
> -	struct spi_flash *flash = dev_get_uclass_priv(dev);
> -
> -	return flash->read(flash, offset, len, buf);
> -}
> -
> -int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
> -			const void *buf)
> -{
> -	struct spi_flash *flash = dev_get_uclass_priv(dev);
> -
> -	return flash->write(flash, offset, len, buf);
> -}
> -
> -int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len)
> -{
> -	struct spi_flash *flash = dev_get_uclass_priv(dev);
> -
> -	return flash->erase(flash, offset, len);
> -}
> -
>   int spi_flash_std_probe(struct udevice *dev)
>   {
>   	struct spi_flash_priv *priv = dev_get_uclass_priv(dev);
> @@ -171,12 +148,6 @@ err_scan:
>   	return ret;
>   }
>
> -static const struct dm_spi_flash_ops spi_flash_std_ops = {
> -	.read = spi_flash_std_read,
> -	.write = spi_flash_std_write,
> -	.erase = spi_flash_std_erase,
> -};
> -
>   static const struct udevice_id spi_flash_std_ids[] = {
>   	{ .compatible = "spi-flash" },
>   	{ }
> @@ -188,7 +159,6 @@ U_BOOT_DRIVER(spi_flash_std) = {
>   	.of_match	= spi_flash_std_ids,
>   	.probe		= spi_flash_std_probe,
>   	.priv_auto_alloc_size = sizeof(struct spi_flash_priv),
> -	.ops		= &spi_flash_std_ops,
>   };
>
>   #endif /* CONFIG_DM_SPI_FLASH */
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index fe03b8d..8dd000d 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -83,52 +83,7 @@ struct spi_flash {
>   	void *priv;
>   };
>
> -struct dm_spi_flash_ops {
> -	int (*read)(struct udevice *dev, u32 offset, size_t len, void *buf);
> -	int (*write)(struct udevice *dev, u32 offset, size_t len,
> -		     const void *buf);
> -	int (*erase)(struct udevice *dev, u32 offset, size_t len);
> -};
> -
> -/* Access the serial operations for a device */
> -#define sf_get_ops(dev) ((struct dm_spi_flash_ops *)(dev)->driver->ops)
> -
>   #ifdef CONFIG_DM_SPI_FLASH
> -/**
> - * spi_flash_read_dm() - Read data from SPI flash
> - *
> - * @dev:	SPI flash device
> - * @offset:	Offset into device in bytes to read from
> - * @len:	Number of bytes to read
> - * @buf:	Buffer to put the data that is read
> - * @return 0 if OK, -ve on error
> - */
> -int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf);
> -
> -/**
> - * spi_flash_write_dm() - Write data to SPI flash
> - *
> - * @dev:	SPI flash device
> - * @offset:	Offset into device in bytes to write to
> - * @len:	Number of bytes to write
> - * @buf:	Buffer containing bytes to write
> - * @return 0 if OK, -ve on error
> - */
> -int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
> -		       const void *buf);
> -
> -/**
> - * spi_flash_erase_dm() - Erase blocks of the SPI flash
> - *
> - * Note that @len must be a muiltiple of the flash sector size.
> - *
> - * @dev:	SPI flash device
> - * @offset:	Offset into device in bytes to start erasing
> - * @len:	Number of bytes to erase
> - * @return 0 if OK, -ve on error
> - */
> -int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
> -
>   int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
>   			   unsigned int max_hz, unsigned int spi_mode,
>   			   struct udevice **devp);
> @@ -142,31 +97,6 @@ void spi_flash_free(struct spi_flash *flash);
>
>   int spi_flash_remove(struct udevice *flash);
>
> -static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
> -				 size_t len, void *buf)
> -{
> -	return mtd_read(flash->mtd, offset, len, &len, (u_char *)buf);
> -}
> -
> -static inline int spi_flash_write(struct spi_flash *flash, u32 offset,
> -				  size_t len, const void *buf)
> -{
> -	return mtd_write(flash->mtd, offset, len, &len, (u_char *)buf);
> -}
> -
> -static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
> -				  size_t len)
> -{
> -	struct erase_info instr;
> -
> -	instr.mtd = flash->mtd;
> -	instr.addr = offset;
> -	instr.len = len;
> -	instr.callback = 0;
> -
> -	return mtd_erase(flash->mtd, &instr);
> -}
> -
>   struct sandbox_state;
>
>   int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
> @@ -191,25 +121,32 @@ struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node,
>   				      int spi_node);
>
>   void spi_flash_free(struct spi_flash *flash);
> +#endif
>
>   static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
> -		size_t len, void *buf)
> +				 size_t len, void *buf)
>   {
> -	return flash->read(flash, offset, len, buf);
> +	return mtd_read(flash->mtd, offset, len, &len, (u_char *)buf);
>   }
>
>   static inline int spi_flash_write(struct spi_flash *flash, u32 offset,
> -		size_t len, const void *buf)
> +				  size_t len, const void *buf)
>   {
> -	return flash->write(flash, offset, len, buf);
> +	return mtd_write(flash->mtd, offset, len, &len, (u_char *)buf);
>   }
>
>   static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
> -		size_t len)
> +				  size_t len)
>   {
> -	return flash->erase(flash, offset, len);
> +	struct erase_info instr;
> +
> +	instr.mtd = flash->mtd;
> +	instr.addr = offset;
> +	instr.len = len;
> +	instr.callback = 0;
> +
> +	return mtd_erase(flash->mtd, &instr);
>   }
> -#endif
>
>   void spi_boot(void) __noreturn;
>   void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst);
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2015-10-29  6:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 19:54 [U-Boot] [PATCH 1/8] sf: Add MTD support to spi_flash Jagan Teki
2015-10-12 19:54 ` [U-Boot] [PATCH 2/8] sf: Use mtd_info ops instead of spi_flash ops Jagan Teki
2015-10-29  6:29   ` Heiko Schocher
2015-10-12 19:54 ` [U-Boot] [PATCH 3/8] cmd_sf: Use mtd->size instead of flash->size Jagan Teki
2015-10-29  6:32   ` Heiko Schocher
2015-10-12 19:54 ` [U-Boot] [PATCH 4/8] dm-sf: use mtd_ops, drop dm_spi_flash_ops Jagan Teki
2015-10-29  6:35   ` Heiko Schocher [this message]
2015-10-29 13:11     ` Jagan Teki
2015-11-06  3:15       ` Simon Glass
2015-10-12 19:54 ` [U-Boot] [PATCH 5/8] sf: Add MTD support for non-dm spi_flash interface Jagan Teki
2015-10-29  6:37   ` Heiko Schocher
2015-10-12 19:54 ` [U-Boot] [PATCH 6/8] sf: probe: Minor cleanup Jagan Teki
2015-10-29  6:54   ` Heiko Schocher
2015-10-12 19:54 ` [U-Boot] [PATCH 7/8] sf: Drop SPI_FLASH_MTD driver Jagan Teki
2015-10-12 19:54 ` [U-Boot] [PATCH 8/8] configs: Remove CONFIG_SPI_FLASH_MTD Jagan Teki
2015-10-29  6:04 ` [U-Boot] [PATCH 1/8] sf: Add MTD support to spi_flash Heiko Schocher

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=5631BE32.8040106@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.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.