Re: [PATCH 4/9] mtd: devices: add AT24 eeprom support

2024-07-09 Thread Marco Felsch
On 24-07-09, Miquel Raynal wrote:
> Hi Marco,
> 
> > > > > >> I also found a thread from 2013 by Maxime Ripard (+Cc) suggesting 
> > > > > >> adding
> > > > > >> EEPROMs to MTD [1]. The main purpose would have been unifying the 
> > > > > >> EEPROM
> > > > > >> drivers under a single interface. I am not sure what came of it 
> > > > > >> though,
> > > > > >> since I can't find any patches that followed up with the proposal. 
> > > > > >>
> > > > > >
> > > > > > That discussion led to drivers/nvmem after I started to work on
> > > > > > some early prototype, and Srinivas took over that work.
> > > > > 
> > > > > So would you say it is better for EEPROM drivers to use nvmem instead 
> > > > > of
> > > > > moving under MTD?
> > > > 
> > > > I thought so at the time, but that was more than 10y ago, and I have
> > > > followed neither nvmem nor MTD since so I don't really have an opinion
> > > > there.
> > > > 
> > > > It looks like drivers/misc/eeprom/at24.c has support for nvmem though,
> > > > and MTD can be used as an nvmem provider too, so it's not clear to me
> > > > why we would want to create yet another variant.
> > > > 
> > > > But again, you shouldn't really ask me in the first place :)
> > > > 
> > > > I'm sure Miquel, Srinivas, and surely others, are much more relevant to
> > > > answer that question.  
> > > 
> > > More relevant, I doubt, but just a feeling: EEPROMs have their own
> > > subsystem now, NVMEM, which, as Maxime said, was initially written for
> > > that very specific case. EEPROMs don't have the complexity of MTD
> > > devices, and thus pulling the whole MTD subsystem just for getting
> > > partitions seems counter intuitive to me. You can definitely "split"
> > > EEPROM devices with NVMEM as well anyway.  
> > 
> > I asked for feedback on my RFC [1] and all I got was to merge both
> > drivers into one and make the driver backward compatible, which I did by
> > this commit.
> 
> I'm sorry for not bringing this earlier.

The purpose of the RFC was exactly to figure out the way to go therefore
I'm a bit surprised now :/

> > > Overall I think the idea of getting rid of these misc/ drivers is goes
> > > into the right direction, but registering directly into NVMEM makes
> > > more sense IMO.  
> > 
> > So you propose to have two places for the partition handling (one for
> > MTD and one for NVMEM) instead of one and moving the code into NVMEM
> > directly?
> 
> Why two places for the partitions handling? Just one, in NVMEM. Also

Without checking the details I think that converting the MTD
partitioning code into NVMEM partitioning code is a bigger task. As you
said below there are many legacy code paths you need to consider so they
still work afterwards as well.

> usually EEPROMs don't require very advanced partitioning schemes,
> unlike flashes (which are the most common MTD devices today).

As said in my cover letter EEPROMs can become quite large and MTD
supports partitioning storage devices which is very handy for large
EEPROMs as well.

> > That doesn't sound right to me either. Also I don't get the
> > point why EEPROMs can't be handled by the MTD layer?
> 
> They can, but should they? Just compile the two layers and observe
> the size difference. MTD is complex and old, carries a lot of history,
> and the user interface is also not straightforward because you need to
> handle pages, blocks, erases, bitflips, ECC stats, OOB bytes and
> positions, two OTP areas... None of that exists in the EEPROM world. So
> why would you want to register into MTD and pull a huge subsystem while
> there is a much more recent, simpler and way lighter subsystem fitting
> much better your device?

Didn't checked the size but the honest, MTD provides many Kconfig
switches to trim the size down. As of now the mtd.o is made of up to 5
(6 if chipreg.o is counted -> should be an opt) files which is of course
larger than the pure misc/eeprom/at24.c driver but not that large. 

Regards,
  Marco

> > The layer already
> > supports devices of type MTD_RAM which are very simple and don't require
> > an erase-op at least I don't see one.
> 
> MTD_RAM has been there forever, probably for "bad" reasons. BTW there
> has been an attempt at removing it which was reverted in _2006_ and then
> felt into the cracks:
> 21c8db9eff95 ("[MTD] Restore MTD_ROM and MTD_RAM types")
> 
> Thanks,
> Miquèl
> 


Re: [PATCH 4/9] mtd: devices: add AT24 eeprom support

2024-07-09 Thread Marco Felsch
Hi Miquel,

On 24-07-08, Miquel Raynal wrote:
> Hi,
> 
> > > >> >> Port the current misc/eeprom/at24.c driver to the MTD framework 
> > > >> >> since
> > > >> >> EEPROMs are memory-technology devices and the framework already 
> > > >> >> supports  
> > > >> >
> > > >> > I was under the impression that MTD devices are tightly coupled by 
> > > >> > erase
> > > >> > blocks. But then we see MTD_NO_ERASE, so what are MTD devices after 
> > > >> > all?  
> > > >> 
> > > >> I was curious as well so I did some digging.
> > > >>   
> > > [...]  
> > > >> 
> > > >> I also found a thread from 2013 by Maxime Ripard (+Cc) suggesting 
> > > >> adding
> > > >> EEPROMs to MTD [1]. The main purpose would have been unifying the 
> > > >> EEPROM
> > > >> drivers under a single interface. I am not sure what came of it though,
> > > >> since I can't find any patches that followed up with the proposal.  
> > > >
> > > > That discussion led to drivers/nvmem after I started to work on
> > > > some early prototype, and Srinivas took over that work.  
> > > 
> > > So would you say it is better for EEPROM drivers to use nvmem instead of
> > > moving under MTD?  
> > 
> > I thought so at the time, but that was more than 10y ago, and I have
> > followed neither nvmem nor MTD since so I don't really have an opinion
> > there.
> > 
> > It looks like drivers/misc/eeprom/at24.c has support for nvmem though,
> > and MTD can be used as an nvmem provider too, so it's not clear to me
> > why we would want to create yet another variant.
> > 
> > But again, you shouldn't really ask me in the first place :)
> > 
> > I'm sure Miquel, Srinivas, and surely others, are much more relevant to
> > answer that question.
> 
> More relevant, I doubt, but just a feeling: EEPROMs have their own
> subsystem now, NVMEM, which, as Maxime said, was initially written for
> that very specific case. EEPROMs don't have the complexity of MTD
> devices, and thus pulling the whole MTD subsystem just for getting
> partitions seems counter intuitive to me. You can definitely "split"
> EEPROM devices with NVMEM as well anyway.

I asked for feedback on my RFC [1] and all I got was to merge both
drivers into one and make the driver backward compatible, which I did by
this commit.

> Overall I think the idea of getting rid of these misc/ drivers is goes
> into the right direction, but registering directly into NVMEM makes
> more sense IMO.

So you propose to have two places for the partition handling (one for
MTD and one for NVMEM) instead of one and moving the code into NVMEM
directly? That doesn't sound right to me either. Also I don't get the
point why EEPROMs can't be handled by the MTD layer? The layer already
supports devices of type MTD_RAM which are very simple and don't require
an erase-op at least I don't see one.

[1] https://lore.kernel.org/all/20231127164623.1008176-1-m.fel...@pengutronix.de

Regards,
  Marco

> 
> Thanks,
> Miquèl
> 


Re: [PATCH 9/9] eeprom: at24: remove deprecated Kconfig symbol

2024-07-02 Thread Marco Felsch
Hi,

On 24-07-02, Bartosz Golaszewski wrote:
> On Mon, Jul 1, 2024 at 3:54 PM Marco Felsch  wrote:
> >
> > All kernel users are shifted to the new MTD_EEPROM_AT24 Kconfig symbol
> > so we can drop the old one.
> >
> 
> Nope, with this series arm64 still selects the old symbol.

sry. I must have forgotten to add the arm64 hunk :/ I also noticed one
powerpc config which still select the old symbol. I will fix this in v2.

Thank you,
  Marco

> 
> Bart
> 


Re: [PATCH 2/9] mtd: add mtd_is_master helper

2024-07-02 Thread Marco Felsch
On 24-07-01, Sergei Shtylyov wrote:
> On 7/1/24 4:53 PM, Marco Felsch wrote:
> 
> > Provide a simple helper to make it easy to detect an master mtd device.
> > 
> > Signed-off-by: Marco Felsch 
> > ---
> >  include/linux/mtd/mtd.h | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> > index 8d10d9d2e830..bf3fc2ea7230 100644
> > --- a/include/linux/mtd/mtd.h
> > +++ b/include/linux/mtd/mtd.h
> > @@ -408,6 +408,11 @@ static inline struct mtd_info *mtd_get_master(struct 
> > mtd_info *mtd)
> > return mtd;
> >  }
> >  
> > +static inline bool mtd_is_master(struct mtd_info *mtd)
> > +{
> > +   return mtd->parent ? false : true;
> 
>Perhaps:
> 
>   return !mtd->parent;

Sure, if you prefer this style rather I will change it.

Regards,
  Marco


[PATCH 4/9] mtd: devices: add AT24 eeprom support

2024-07-01 Thread Marco Felsch
At the moment there are three ways to access EEPROM content from
user-space:

  1st) via the single nvmem device (rw)
  2nd) via the single 'eeprom' device (rw)
  3th) via nvmem-cells (r)

EEPROMs can become quite large nowadays (>=64K). Exposing such devices
as single device isn't always sufficient. There may be partitions which
require different access permissions. Also write access always need to
to verify the offset.

Port the current misc/eeprom/at24.c driver to the MTD framework since
EEPROMs are memory-technology devices and the framework already supports
partitioning. This allow using of-paritions like we do for SPI-NOR
devices already:

 {
compatible = "atmel,24c02";
reg = <0x52>;
pagesize = <16>;
#address-cells = <1>;
#size-cells = <0>;

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
label = "board-eeprom";

otp@0 {
compatible = "nvmem-cells";
label = "manufaturing";
reg = <0x0 0xe0>;

nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;

/* MACs stored in ASCII */
ethmac1: mac-address@0 {
reg = <0x0 0xc>;
};

ethmac2: mac-address@c {
reg = <0xc 0xc>;
};

test@d8 {
reg = <0xd8 0x8>;
};
};
j};

user@e0 {
reg = <0xe0 0x100>;
};
};
};

The porting was straight forward:
 - at24_read/write funcs are adapted to be MTD compatible
 - (re-)adding the write-protection gpio handling since the devices can
   now be accessed via NVMEM and MTD API
 - Replace the NVMEM with MTD registration. The mtdcore is taking care
   of exposing the NVMEM and eeprom device correctly ensure backward
   compatibility.

Signed-off-by: Marco Felsch 

Changelog:
v2:
- resync misc/eeprom/at24.c with mtd/at24.c driver
- add backward compatibility
- drop misc/eeprom/at24.c driver
- adapt Kconfig EEPROM_AT24 Kconfig entry
- shift infrastructure support into separate patch
- adapt commit message
---
 MAINTAINERS |   2 +-
 drivers/misc/eeprom/Kconfig |  30 +--
 drivers/misc/eeprom/Makefile|   1 -
 drivers/mtd/devices/Kconfig |  31 +++
 drivers/mtd/devices/Makefile|   1 +
 drivers/{misc/eeprom => mtd/devices}/at24.c | 122 +++-
 6 files changed, 103 insertions(+), 84 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index d6c90161c7bf..a3a56f34d754 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3355,7 +3355,7 @@ L:linux-...@vger.kernel.org
 S: Maintained
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git
 F: Documentation/devicetree/bindings/eeprom/at24.yaml
-F: drivers/misc/eeprom/at24.c
+F: drivers/mtd/devices/at24.c
 
 ATA OVER ETHERNET (AOE) DRIVER
 M: "Justin Sanders" 
diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig
index 4e61ac18cc96..3a9aaec2f2c7 100644
--- a/drivers/misc/eeprom/Kconfig
+++ b/drivers/misc/eeprom/Kconfig
@@ -3,34 +3,10 @@ menu "EEPROM support"
 
 config EEPROM_AT24
tristate "I2C EEPROMs / RAMs / ROMs from most vendors"
-   depends on I2C && SYSFS
-   select NVMEM
-   select NVMEM_SYSFS
-   select REGMAP
-   select REGMAP_I2C
+   select MTD_EEPROM_AT24
help
- Enable this driver to get read/write support to most I2C EEPROMs
- and compatible devices like FRAMs, SRAMs, ROMs etc. After you
- configure the driver to know about each chip on your target
- board.  Use these generic chip names, instead of vendor-specific
- ones like at24c64, 24lc02 or fm24c04:
-
-24c00, 24c01, 24c02, spd (readonly 24c02), 24c04, 24c08,
-24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024, 24c2048
-
- Unless you like data loss puzzles, always be sure that any chip
- you configure as a 24c32 (32 kbit) or larger is NOT really a
- 24c16 (16 kbit) or smaller, and vice versa. Marking the chip
- as read-only won't help recover from this. Also, if your chip
- has any software write-protect 

[PATCH 0/9] AT24 EEPROM MTD Support

2024-07-01 Thread Marco Felsch
This series adds the intial support to handle EEPROMs via the MTD layer
as well. This allow the user-space to have separate paritions since
EEPROMs can become quite large nowadays.

With this patchset applied EEPROMs can be accessed via:
  - legacy 'eeprom' device
  - nvmem device
  - mtd device(s)

The patchset targets only the AT24 (I2C) EEPROMs since I have no access
to AT25 (SPI) EEPROMs nor to one of the other misc/eeprom/* devices.

Note: I'm not familiar with Kconfig symbol migration so I don't know if
the last patch is required at the moment. Please be notified that the
list of recipients is quite large due to the defconfig changes.

Regards,
  Marco

Signed-off-by: Marco Felsch 
---
Marco Felsch (9):
  mtd: core: add nvmem_write support
  mtd: add mtd_is_master helper
  mtd: add support to handle EEPROM devices
  mtd: devices: add AT24 eeprom support
  ARM: defconfig: convert to MTD_EEPROM_AT24
  powerpc: convert to MTD_EEPROM_AT24
  MIPS: configs: convert to MTD_EEPROM_AT24
  LoongArch: convert to MTD_EEPROM_AT24
  eeprom: at24: remove deprecated Kconfig symbol

 MAINTAINERS |   2 +-
 arch/arm/configs/aspeed_g4_defconfig|   2 +-
 arch/arm/configs/aspeed_g5_defconfig|   2 +-
 arch/arm/configs/at91_dt_defconfig  |   2 +-
 arch/arm/configs/axm55xx_defconfig  |   2 +-
 arch/arm/configs/davinci_all_defconfig  |   2 +-
 arch/arm/configs/imx_v4_v5_defconfig|   2 +-
 arch/arm/configs/imx_v6_v7_defconfig|   2 +-
 arch/arm/configs/ixp4xx_defconfig   |   2 +-
 arch/arm/configs/keystone_defconfig |   2 +-
 arch/arm/configs/lpc18xx_defconfig  |   2 +-
 arch/arm/configs/lpc32xx_defconfig  |   2 +-
 arch/arm/configs/multi_v5_defconfig |   2 +-
 arch/arm/configs/multi_v7_defconfig |   2 +-
 arch/arm/configs/mvebu_v5_defconfig |   2 +-
 arch/arm/configs/mvebu_v7_defconfig |   2 +-
 arch/arm/configs/mxs_defconfig  |   2 +-
 arch/arm/configs/omap2plus_defconfig|   2 +-
 arch/arm/configs/pxa_defconfig  |   2 +-
 arch/arm/configs/s3c6400_defconfig  |   2 +-
 arch/arm/configs/sama5_defconfig|   2 +-
 arch/arm/configs/sama7_defconfig|   2 +-
 arch/arm/configs/shmobile_defconfig |   2 +-
 arch/arm/configs/socfpga_defconfig  |   2 +-
 arch/arm/configs/tegra_defconfig|   2 +-
 arch/arm/configs/wpcm450_defconfig  |   2 +-
 arch/loongarch/configs/loongson3_defconfig  |   2 +-
 arch/mips/configs/cavium_octeon_defconfig   |   2 +-
 arch/mips/configs/db1xxx_defconfig  |   2 +-
 arch/powerpc/configs/44x/warp_defconfig |   2 +-
 arch/powerpc/configs/mpc512x_defconfig  |   2 +-
 arch/powerpc/configs/mpc5200_defconfig  |   2 +-
 arch/powerpc/configs/ppc6xx_defconfig   |   2 +-
 arch/powerpc/configs/skiroot_defconfig  |   2 +-
 drivers/misc/eeprom/Kconfig |  31 ---
 drivers/misc/eeprom/Makefile|   1 -
 drivers/mtd/devices/Kconfig |  31 +++
 drivers/mtd/devices/Makefile|   1 +
 drivers/{misc/eeprom => mtd/devices}/at24.c | 122 +++-
 drivers/mtd/mtdcore.c   |  49 ++-
 include/linux/mtd/mtd.h |   5 ++
 include/uapi/mtd/mtd-abi.h  |   2 +
 42 files changed, 187 insertions(+), 123 deletions(-)
---
base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
change-id: 20240701-b4-v6-10-topic-usbc-tcpci-c4bc9bcce604

Best regards,
-- 
Marco Felsch 



[PATCH 2/9] mtd: add mtd_is_master helper

2024-07-01 Thread Marco Felsch
Provide a simple helper to make it easy to detect an master mtd device.

Signed-off-by: Marco Felsch 
---
 include/linux/mtd/mtd.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 8d10d9d2e830..bf3fc2ea7230 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -408,6 +408,11 @@ static inline struct mtd_info *mtd_get_master(struct 
mtd_info *mtd)
return mtd;
 }
 
+static inline bool mtd_is_master(struct mtd_info *mtd)
+{
+   return mtd->parent ? false : true;
+}
+
 static inline u64 mtd_get_master_ofs(struct mtd_info *mtd, u64 ofs)
 {
while (mtd->parent) {

-- 
2.39.2



[PATCH 6/9] powerpc: convert to MTD_EEPROM_AT24

2024-07-01 Thread Marco Felsch
The EEPROM_AT24 Kconfig symbol is marked as deprecated. Make use of the
new Kconfig symbol to select the I2C EEPROM driver support.

Signed-off-by: Marco Felsch 
---
 arch/powerpc/configs/44x/warp_defconfig | 2 +-
 arch/powerpc/configs/mpc512x_defconfig  | 2 +-
 arch/powerpc/configs/mpc5200_defconfig  | 2 +-
 arch/powerpc/configs/ppc6xx_defconfig   | 2 +-
 arch/powerpc/configs/skiroot_defconfig  | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/configs/44x/warp_defconfig 
b/arch/powerpc/configs/44x/warp_defconfig
index 20891c413149..d8cab860c9d9 100644
--- a/arch/powerpc/configs/44x/warp_defconfig
+++ b/arch/powerpc/configs/44x/warp_defconfig
@@ -36,7 +36,7 @@ CONFIG_MTD_RAW_NAND=y
 CONFIG_MTD_NAND_NDFC=y
 CONFIG_MTD_UBI=y
 CONFIG_BLK_DEV_RAM=y
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_SCSI_SPI_ATTRS=y
diff --git a/arch/powerpc/configs/mpc512x_defconfig 
b/arch/powerpc/configs/mpc512x_defconfig
index d24457bc5791..0a919a76cfb8 100644
--- a/arch/powerpc/configs/mpc512x_defconfig
+++ b/arch/powerpc/configs/mpc512x_defconfig
@@ -46,7 +46,7 @@ CONFIG_MTD_UBI=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=1
 CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_EEPROM_AT25=y
 CONFIG_SCSI=y
 # CONFIG_SCSI_PROC_FS is not set
diff --git a/arch/powerpc/configs/mpc5200_defconfig 
b/arch/powerpc/configs/mpc5200_defconfig
index c0fe5e76604a..8142836ef61a 100644
--- a/arch/powerpc/configs/mpc5200_defconfig
+++ b/arch/powerpc/configs/mpc5200_defconfig
@@ -38,7 +38,7 @@ CONFIG_MTD_UBI=m
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=32768
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y
 CONFIG_ATA=y
diff --git a/arch/powerpc/configs/ppc6xx_defconfig 
b/arch/powerpc/configs/ppc6xx_defconfig
index 66c7b28d7450..5bca729a57c2 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -318,7 +318,7 @@ CONFIG_CDROM_PKTCDVD=m
 CONFIG_VIRTIO_BLK=m
 CONFIG_ENCLOSURE_SERVICES=m
 CONFIG_SENSORS_TSL2550=m
-CONFIG_EEPROM_AT24=m
+CONFIG_MTD_EEPROM_AT24=m
 CONFIG_EEPROM_LEGACY=m
 CONFIG_EEPROM_MAX6875=m
 CONFIG_EEPROM_93CX6=m
diff --git a/arch/powerpc/configs/skiroot_defconfig 
b/arch/powerpc/configs/skiroot_defconfig
index 9d44e6630908..e9be7f217cea 100644
--- a/arch/powerpc/configs/skiroot_defconfig
+++ b/arch/powerpc/configs/skiroot_defconfig
@@ -77,7 +77,7 @@ CONFIG_BLK_DEV_RAM_SIZE=65536
 CONFIG_VIRTIO_BLK=m
 CONFIG_BLK_DEV_NVME=m
 CONFIG_NVME_MULTIPATH=y
-CONFIG_EEPROM_AT24=m
+CONFIG_MTD_EEPROM_AT24=m
 # CONFIG_CXL is not set
 # CONFIG_OCXL is not set
 CONFIG_BLK_DEV_SD=m

-- 
2.39.2



[PATCH 5/9] ARM: defconfig: convert to MTD_EEPROM_AT24

2024-07-01 Thread Marco Felsch
The EEPROM_AT24 Kconfig symbol is marked as deprecated. Make use of the
new Kconfig symbol to select the I2C EEPROM driver support.

Signed-off-by: Marco Felsch 
---
 arch/arm/configs/aspeed_g4_defconfig   | 2 +-
 arch/arm/configs/aspeed_g5_defconfig   | 2 +-
 arch/arm/configs/at91_dt_defconfig | 2 +-
 arch/arm/configs/axm55xx_defconfig | 2 +-
 arch/arm/configs/davinci_all_defconfig | 2 +-
 arch/arm/configs/imx_v4_v5_defconfig   | 2 +-
 arch/arm/configs/imx_v6_v7_defconfig   | 2 +-
 arch/arm/configs/ixp4xx_defconfig  | 2 +-
 arch/arm/configs/keystone_defconfig| 2 +-
 arch/arm/configs/lpc18xx_defconfig | 2 +-
 arch/arm/configs/lpc32xx_defconfig | 2 +-
 arch/arm/configs/multi_v5_defconfig| 2 +-
 arch/arm/configs/multi_v7_defconfig| 2 +-
 arch/arm/configs/mvebu_v5_defconfig| 2 +-
 arch/arm/configs/mvebu_v7_defconfig| 2 +-
 arch/arm/configs/mxs_defconfig | 2 +-
 arch/arm/configs/omap2plus_defconfig   | 2 +-
 arch/arm/configs/pxa_defconfig | 2 +-
 arch/arm/configs/s3c6400_defconfig | 2 +-
 arch/arm/configs/sama5_defconfig   | 2 +-
 arch/arm/configs/sama7_defconfig   | 2 +-
 arch/arm/configs/shmobile_defconfig| 2 +-
 arch/arm/configs/socfpga_defconfig | 2 +-
 arch/arm/configs/tegra_defconfig   | 2 +-
 arch/arm/configs/wpcm450_defconfig | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/arch/arm/configs/aspeed_g4_defconfig 
b/arch/arm/configs/aspeed_g4_defconfig
index 28b724d59e7e..341f7ca4ff8c 100644
--- a/arch/arm/configs/aspeed_g4_defconfig
+++ b/arch/arm/configs/aspeed_g4_defconfig
@@ -68,7 +68,7 @@ CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_MTD_UBI_BLOCK=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_NBD=y
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_NETDEVICES=y
 CONFIG_NETCONSOLE=y
 # CONFIG_NET_VENDOR_ALACRITECH is not set
diff --git a/arch/arm/configs/aspeed_g5_defconfig 
b/arch/arm/configs/aspeed_g5_defconfig
index 61cee1e7ebea..9c180658341f 100644
--- a/arch/arm/configs/aspeed_g5_defconfig
+++ b/arch/arm/configs/aspeed_g5_defconfig
@@ -82,7 +82,7 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_NBD=y
 CONFIG_SMPRO_ERRMON=y
 CONFIG_SMPRO_MISC=y
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_EEPROM_AT25=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
diff --git a/arch/arm/configs/at91_dt_defconfig 
b/arch/arm/configs/at91_dt_defconfig
index 1d53aec4c836..fb40790fc730 100644
--- a/arch/arm/configs/at91_dt_defconfig
+++ b/arch/arm/configs/at91_dt_defconfig
@@ -60,7 +60,7 @@ CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=4
 CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_ATMEL_SSC=y
-CONFIG_EEPROM_AT24=m
+CONFIG_MTD_EEPROM_AT24=m
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 # CONFIG_BLK_DEV_BSG is not set
diff --git a/arch/arm/configs/axm55xx_defconfig 
b/arch/arm/configs/axm55xx_defconfig
index 516689dc6cf1..473404f468f9 100644
--- a/arch/arm/configs/axm55xx_defconfig
+++ b/arch/arm/configs/axm55xx_defconfig
@@ -89,7 +89,7 @@ CONFIG_MTD_M25P80=y
 CONFIG_PROC_DEVICETREE=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_EEPROM_AT25=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y
diff --git a/arch/arm/configs/davinci_all_defconfig 
b/arch/arm/configs/davinci_all_defconfig
index 3474e475373a..46701916c82d 100644
--- a/arch/arm/configs/davinci_all_defconfig
+++ b/arch/arm/configs/davinci_all_defconfig
@@ -73,7 +73,7 @@ CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=1
 CONFIG_BLK_DEV_RAM_SIZE=32768
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_BLK_DEV_SD=m
 CONFIG_ATA=m
 CONFIG_AHCI_DA850=m
diff --git a/arch/arm/configs/imx_v4_v5_defconfig 
b/arch/arm/configs/imx_v4_v5_defconfig
index 875c8cdbada7..685e685baa21 100644
--- a/arch/arm/configs/imx_v4_v5_defconfig
+++ b/arch/arm/configs/imx_v4_v5_defconfig
@@ -51,7 +51,7 @@ CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_MTD_NAND_MXC=y
 CONFIG_MTD_UBI=y
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_EEPROM_AT25=y
 CONFIG_BLK_DEV_SD=y
 # CONFIG_BLK_DEV_BSG is not set
diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index cf2480dce285..03d71abf587e 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -104,7 +104,7 @@ CONFIG_MTD_UBI_BLOCK=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=65536
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_EEPROM_AT25=y
 # CONFIG_SCSI_PROC_FS is not set
 CONFIG_BLK_DEV_SD=y
diff --git a/arch/arm/configs/ixp4xx_defconfig 
b/arch/arm/configs/ixp4xx_defconfig
index 3cb995b9616a..af36c0a7c8ae 100644
--- a/arch/arm/configs/ixp4xx_defconfig
+++ b/arch/arm/configs/ixp4xx_defconfig
@@ -98,7 +98,7 @@ CONFIG_MTD_RAW_NAND=m
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 # CONFIG_EEPROM_LEGACY is not set
 # CONFIG_SCSI_PROC_FS is not set
 CONFIG_BLK_DEV_SD=y
diff --git a/arch/arm/configs

[PATCH 8/9] LoongArch: convert to MTD_EEPROM_AT24

2024-07-01 Thread Marco Felsch
The EEPROM_AT24 Kconfig symbol is marked as deprecated. Make use of the
new Kconfig symbol to select the I2C EEPROM driver support.

Signed-off-by: Marco Felsch 
---
 arch/loongarch/configs/loongson3_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/loongarch/configs/loongson3_defconfig 
b/arch/loongarch/configs/loongson3_defconfig
index b4252c357c8e..31daff75a01a 100644
--- a/arch/loongarch/configs/loongson3_defconfig
+++ b/arch/loongarch/configs/loongson3_defconfig
@@ -433,7 +433,7 @@ CONFIG_NVME_TARGET_LOOP=m
 CONFIG_NVME_TARGET_RDMA=m
 CONFIG_NVME_TARGET_FC=m
 CONFIG_NVME_TARGET_TCP=m
-CONFIG_EEPROM_AT24=m
+CONFIG_MTD_EEPROM_AT24=m
 CONFIG_BLK_DEV_SD=y
 CONFIG_BLK_DEV_SR=y
 CONFIG_CHR_DEV_SG=y

-- 
2.39.2



[PATCH 9/9] eeprom: at24: remove deprecated Kconfig symbol

2024-07-01 Thread Marco Felsch
All kernel users are shifted to the new MTD_EEPROM_AT24 Kconfig symbol
so we can drop the old one.

Signed-off-by: Marco Felsch 
---
 drivers/misc/eeprom/Kconfig | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig
index 3a9aaec2f2c7..9e071cfdc6c6 100644
--- a/drivers/misc/eeprom/Kconfig
+++ b/drivers/misc/eeprom/Kconfig
@@ -1,13 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 menu "EEPROM support"
 
-config EEPROM_AT24
-   tristate "I2C EEPROMs / RAMs / ROMs from most vendors"
-   select MTD_EEPROM_AT24
-   help
- Deprecated config option to get read/write support to most I2C
- EEPROMs. Please use MTD_EEPROM_AT24 instead.
-
 config EEPROM_AT25
tristate "SPI EEPROMs (FRAMs) from most vendors"
depends on SPI && SYSFS

-- 
2.39.2



[PATCH 3/9] mtd: add support to handle EEPROM devices

2024-07-01 Thread Marco Felsch
At the moment EEPROMs are covered by misc/driver/eeprom/* drivers. This
commit prepares the MTD framework to handle EEPROM devices within the
MTD layer.

To keep the backward compatibility with the current misc drivers the
master device must be exposed always. Furthermore the NVMEM device
parent must be set to the I2C device instead of the MTD device and the
name must be either the I2C device name or the name specified via the
label.

Signed-off-by: Marco Felsch 
---
 drivers/mtd/mtdcore.c  | 32 +++-
 include/uapi/mtd/mtd-abi.h |  2 ++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index dcd97e59425e..e2a996ccd17e 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -149,6 +149,9 @@ static ssize_t mtd_type_show(struct device *dev,
case MTD_ROM:
type = "rom";
break;
+   case MTD_EEPROM:
+   type = "eeprom";
+   break;
case MTD_NORFLASH:
type = "nor";
break;
@@ -578,6 +581,33 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
config.ignore_wp = true;
config.priv = mtd;
 
+   switch (mtd->type) {
+   case MTD_EEPROM:
+   config.type = NVMEM_TYPE_EEPROM;
+   /*
+* The master device must be backward compatible with the
+* predecessor (misc/eeprom/at24.c) driver. Therefore we need to
+* adapt the naming scheme.
+*
+* Initialize config.id to NVMEM_DEVID_AUTO even if the
+* mtd->name is provided via an label as some platform can have
+* multiple eeproms with same label and we can not register each
+* of those with same label. Failing to register those eeproms
+* trigger cascade failure on such platform.
+*/
+   if (mtd_is_master(mtd)) {
+   config.id = NVMEM_DEVID_AUTO;
+   config.compat = true;
+   config.name = mtd->name;
+   config.dev = mtd->dev.parent;
+   config.base_dev = mtd->dev.parent;
+   }
+   break;
+   default:
+   config.type = NVMEM_TYPE_UNKNOWN;
+   break;
+   }
+
mtd->nvmem = nvmem_register();
if (IS_ERR(mtd->nvmem)) {
/* Just ignore if there is no NVMEM support in the kernel */
@@ -1076,7 +1106,7 @@ int mtd_device_parse_register(struct mtd_info *mtd, const 
char * const *types,
if (ret)
goto out;
 
-   if (IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER)) {
+   if (IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) || mtd->type == 
MTD_EEPROM) {
ret = add_mtd_device(mtd);
if (ret)
goto out;
diff --git a/include/uapi/mtd/mtd-abi.h b/include/uapi/mtd/mtd-abi.h
index 714d55b49d2a..59bf43d58ddb 100644
--- a/include/uapi/mtd/mtd-abi.h
+++ b/include/uapi/mtd/mtd-abi.h
@@ -146,6 +146,7 @@ struct mtd_read_req {
 #define MTD_DATAFLASH  6
 #define MTD_UBIVOLUME  7
 #define MTD_MLCNANDFLASH   8   /* MLC NAND (including TLC) */
+#define MTD_EEPROM 9
 
 #define MTD_WRITEABLE  0x400   /* Device is writeable */
 #define MTD_BIT_WRITEABLE  0x800   /* Single bits can be flipped */
@@ -159,6 +160,7 @@ struct mtd_read_req {
 #define MTD_CAP_NORFLASH   (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
 #define MTD_CAP_NANDFLASH  (MTD_WRITEABLE)
 #define MTD_CAP_NVRAM  (MTD_WRITEABLE | MTD_BIT_WRITEABLE | 
MTD_NO_ERASE)
+#define MTD_CAP_EEPROM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | 
MTD_NO_ERASE)
 
 /* Obsolete ECC byte placement modes (used with obsolete MEMGETOOBSEL) */
 #define MTD_NANDECC_OFF0   /* Switch off ECC (Not 
recommended) */

-- 
2.39.2



[PATCH 7/9] MIPS: configs: convert to MTD_EEPROM_AT24

2024-07-01 Thread Marco Felsch
The EEPROM_AT24 Kconfig symbol is marked as deprecated. Make use of the
new Kconfig symbol to select the I2C EEPROM driver support.

Signed-off-by: Marco Felsch 
---
 arch/mips/configs/cavium_octeon_defconfig | 2 +-
 arch/mips/configs/db1xxx_defconfig| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/configs/cavium_octeon_defconfig 
b/arch/mips/configs/cavium_octeon_defconfig
index f523ee6f25bf..a5bb80a59c6e 100644
--- a/arch/mips/configs/cavium_octeon_defconfig
+++ b/arch/mips/configs/cavium_octeon_defconfig
@@ -50,7 +50,7 @@ CONFIG_MTD_CFI=y
 CONFIG_MTD_CFI_AMDSTD=y
 CONFIG_MTD_SLRAM=y
 CONFIG_BLK_DEV_LOOP=y
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_EEPROM_AT25=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_ATA=y
diff --git a/arch/mips/configs/db1xxx_defconfig 
b/arch/mips/configs/db1xxx_defconfig
index b2d9253ff786..b1c1777df16c 100644
--- a/arch/mips/configs/db1xxx_defconfig
+++ b/arch/mips/configs/db1xxx_defconfig
@@ -95,7 +95,7 @@ CONFIG_MTD_NAND_ECC_SW_BCH=y
 CONFIG_MTD_NAND_AU1550=y
 CONFIG_MTD_NAND_PLATFORM=y
 CONFIG_MTD_SPI_NOR=y
-CONFIG_EEPROM_AT24=y
+CONFIG_MTD_EEPROM_AT24=y
 CONFIG_EEPROM_AT25=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y

-- 
2.39.2



[PATCH 1/9] mtd: core: add nvmem_write support

2024-07-01 Thread Marco Felsch
The MTD framework does support the NVMEM framework already but only the
read support was implemented. This commit adds the write support if the
MTD device supports writing (MTD_WRITEABLE is set).

Signed-off-by: Marco Felsch 
---
 drivers/mtd/mtdcore.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 724f917f91ba..dcd97e59425e 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -544,6 +544,20 @@ static int mtd_nvmem_reg_read(void *priv, unsigned int 
offset,
return retlen == bytes ? 0 : -EIO;
 }
 
+static int mtd_nvmem_reg_write(void *priv, unsigned int offset,
+  void *val, size_t bytes)
+{
+   struct mtd_info *mtd = priv;
+   size_t retlen;
+   int err;
+
+   err = mtd_write(mtd, offset, bytes, , val);
+   if (err && err != -EUCLEAN)
+   return err;
+
+   return retlen == bytes ? 0 : -EIO;
+}
+
 static int mtd_nvmem_add(struct mtd_info *mtd)
 {
struct device_node *node = mtd_get_of_node(mtd);
@@ -555,10 +569,11 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
config.owner = THIS_MODULE;
config.add_legacy_fixed_of_cells = of_device_is_compatible(node, 
"nvmem-cells");
config.reg_read = mtd_nvmem_reg_read;
+   config.reg_write = mtd_nvmem_reg_write;
config.size = mtd->size;
config.word_size = 1;
config.stride = 1;
-   config.read_only = true;
+   config.read_only = !(mtd->flags & MTD_WRITEABLE);
config.root_only = true;
config.ignore_wp = true;
config.priv = mtd;

-- 
2.39.2



[PATCH 2/3] ASoC: fsl_sai: convert to dev_err_probe

2022-06-01 Thread Marco Felsch
Make use of the new macro to get device defered information for free
and to cleanup the code a bit. No functional changes.

Signed-off-by: Marco Felsch 
---
 sound/soc/fsl/fsl_sai.c | 33 +++--
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index a7637d602f3c..3e54f1f71c1e 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -1034,21 +1034,15 @@ static int fsl_sai_probe(struct platform_device *pdev)
}
 
sai->regmap = devm_regmap_init_mmio(dev, base, _sai_regmap_config);
-   if (IS_ERR(sai->regmap)) {
-   dev_err(dev, "regmap init failed\n");
-   return PTR_ERR(sai->regmap);
-   }
+   if (IS_ERR(sai->regmap))
+   return dev_err_probe(dev, PTR_ERR(sai->regmap), "regmap init 
failed\n");
 
sai->bus_clk = devm_clk_get(dev, "bus");
/* Compatible with old DTB cases */
if (IS_ERR(sai->bus_clk) && PTR_ERR(sai->bus_clk) != -EPROBE_DEFER)
sai->bus_clk = devm_clk_get(dev, "sai");
-   if (IS_ERR(sai->bus_clk)) {
-   dev_err(dev, "failed to get bus clock: %ld\n",
-   PTR_ERR(sai->bus_clk));
-   /* -EPROBE_DEFER */
-   return PTR_ERR(sai->bus_clk);
-   }
+   if (IS_ERR(sai->bus_clk))
+   return dev_err_probe(dev, PTR_ERR(sai->bus_clk), "failed to get 
bus clock\n");
 
for (i = 1; i < FSL_SAI_MCLK_MAX; i++) {
sprintf(tmp, "mclk%d", i);
@@ -1067,14 +1061,12 @@ static int fsl_sai_probe(struct platform_device *pdev)
 
irq = platform_get_irq(pdev, 0);
if (irq < 0)
-   return irq;
+   return dev_err_probe(dev, irq, "failed to get the irq\n");
 
ret = devm_request_irq(dev, irq, fsl_sai_isr, IRQF_SHARED,
   np->name, sai);
-   if (ret) {
-   dev_err(dev, "failed to claim irq %u\n", irq);
-   return ret;
-   }
+   if (ret)
+   return dev_err_probe(dev, ret, "failed to claim irq %u\n", irq);
 
memcpy(>cpu_dai_drv, _sai_dai_template,
   sizeof(fsl_sai_dai_template));
@@ -1089,8 +1081,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
if (of_find_property(np, "fsl,sai-synchronous-rx", NULL) &&
of_find_property(np, "fsl,sai-asynchronous", NULL)) {
/* error out if both synchronous and asynchronous are present */
-   dev_err(dev, "invalid binding for synchronous mode\n");
-   return -EINVAL;
+   return dev_err_probe(dev, -EINVAL, "invalid binding for 
synchronous mode\n");
}
 
if (of_find_property(np, "fsl,sai-synchronous-rx", NULL)) {
@@ -1109,14 +1100,12 @@ static int fsl_sai_probe(struct platform_device *pdev)
if (of_find_property(np, "fsl,sai-mclk-direction-output", NULL) &&
of_device_is_compatible(np, "fsl,imx6ul-sai")) {
gpr = 
syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr");
-   if (IS_ERR(gpr)) {
-   dev_err(dev, "cannot find iomuxc registers\n");
-   return PTR_ERR(gpr);
-   }
+   if (IS_ERR(gpr))
+   return dev_err_probe(dev, PTR_ERR(gpr), "cannot find 
iomuxc registers\n");
 
index = of_alias_get_id(np, "sai");
if (index < 0)
-   return index;
+   return dev_err_probe(dev, index, "cannot find sai 
aliases\n");
 
regmap_update_bits(gpr, IOMUXC_GPR1, MCLK_DIR(index),
   MCLK_DIR(index));
-- 
2.30.2



[PATCH 1/3] ASoC: fsl_sai: use local device pointer

2022-06-01 Thread Marco Felsch
Use a local variable to dereference the device pointer once and use the
local variable in further calls. No functional changes.

Signed-off-by: Marco Felsch 
---
 sound/soc/fsl/fsl_sai.c | 53 +
 1 file changed, 27 insertions(+), 26 deletions(-)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index fa950dde5310..a7637d602f3c 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -1004,6 +1004,7 @@ static int fsl_sai_runtime_resume(struct device *dev);
 static int fsl_sai_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev->dev.of_node;
+   struct device *dev = >dev;
struct fsl_sai *sai;
struct regmap *gpr;
struct resource *res;
@@ -1012,12 +1013,12 @@ static int fsl_sai_probe(struct platform_device *pdev)
int irq, ret, i;
int index;
 
-   sai = devm_kzalloc(>dev, sizeof(*sai), GFP_KERNEL);
+   sai = devm_kzalloc(dev, sizeof(*sai), GFP_KERNEL);
if (!sai)
return -ENOMEM;
 
sai->pdev = pdev;
-   sai->soc_data = of_device_get_match_data(>dev);
+   sai->soc_data = of_device_get_match_data(dev);
 
sai->is_lsb_first = of_property_read_bool(np, "lsb-first");
 
@@ -1032,18 +1033,18 @@ static int fsl_sai_probe(struct platform_device *pdev)
ARRAY_SIZE(fsl_sai_reg_defaults_ofs8);
}
 
-   sai->regmap = devm_regmap_init_mmio(>dev, base, 
_sai_regmap_config);
+   sai->regmap = devm_regmap_init_mmio(dev, base, _sai_regmap_config);
if (IS_ERR(sai->regmap)) {
-   dev_err(>dev, "regmap init failed\n");
+   dev_err(dev, "regmap init failed\n");
return PTR_ERR(sai->regmap);
}
 
-   sai->bus_clk = devm_clk_get(>dev, "bus");
+   sai->bus_clk = devm_clk_get(dev, "bus");
/* Compatible with old DTB cases */
if (IS_ERR(sai->bus_clk) && PTR_ERR(sai->bus_clk) != -EPROBE_DEFER)
-   sai->bus_clk = devm_clk_get(>dev, "sai");
+   sai->bus_clk = devm_clk_get(dev, "sai");
if (IS_ERR(sai->bus_clk)) {
-   dev_err(>dev, "failed to get bus clock: %ld\n",
+   dev_err(dev, "failed to get bus clock: %ld\n",
PTR_ERR(sai->bus_clk));
/* -EPROBE_DEFER */
return PTR_ERR(sai->bus_clk);
@@ -1051,9 +1052,9 @@ static int fsl_sai_probe(struct platform_device *pdev)
 
for (i = 1; i < FSL_SAI_MCLK_MAX; i++) {
sprintf(tmp, "mclk%d", i);
-   sai->mclk_clk[i] = devm_clk_get(>dev, tmp);
+   sai->mclk_clk[i] = devm_clk_get(dev, tmp);
if (IS_ERR(sai->mclk_clk[i])) {
-   dev_err(>dev, "failed to get mclk%d clock: %ld\n",
+   dev_err(dev, "failed to get mclk%d clock: %ld\n",
i + 1, PTR_ERR(sai->mclk_clk[i]));
sai->mclk_clk[i] = NULL;
}
@@ -1068,10 +1069,10 @@ static int fsl_sai_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
 
-   ret = devm_request_irq(>dev, irq, fsl_sai_isr, IRQF_SHARED,
+   ret = devm_request_irq(dev, irq, fsl_sai_isr, IRQF_SHARED,
   np->name, sai);
if (ret) {
-   dev_err(>dev, "failed to claim irq %u\n", irq);
+   dev_err(dev, "failed to claim irq %u\n", irq);
return ret;
}
 
@@ -1088,7 +1089,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
if (of_find_property(np, "fsl,sai-synchronous-rx", NULL) &&
of_find_property(np, "fsl,sai-asynchronous", NULL)) {
/* error out if both synchronous and asynchronous are present */
-   dev_err(>dev, "invalid binding for synchronous mode\n");
+   dev_err(dev, "invalid binding for synchronous mode\n");
return -EINVAL;
}
 
@@ -1109,7 +1110,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
of_device_is_compatible(np, "fsl,imx6ul-sai")) {
gpr = 
syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr");
if (IS_ERR(gpr)) {
-   dev_err(>dev, "cannot find iomuxc registers\n");
+   dev_err(dev, "cannot find iomuxc registers\n");
return PTR_ERR(gpr);
}
 
@@ -1127,23 +1128,23 @@ static int fsl_sai_probe(struct platform_device *pdev)
sai->dma_params_tx.maxburst = FSL_SAI_MAXBURST_TX;
 

[PATCH 3/3] ASoC: fsl_sai: add error message in case of missing imx-pcm-dma support

2022-06-01 Thread Marco Felsch
If the imx-pcm-dma is required we need to have the module enabled. For
all NXP/FSL sound cards using the ASoC architecture this is the case but
in case of using the simple-audio-card sound card this isn't the case.

In such case the driver probe fails silently and the card isn't
available. It took a while to find the missing Kconfig. Make this easier
for others by printing a error if this the module isn't available but
required by the HW.

Signed-off-by: Marco Felsch 
---
 sound/soc/fsl/fsl_sai.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 3e54f1f71c1e..2371da814b09 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -1152,8 +1152,11 @@ static int fsl_sai_probe(struct platform_device *pdev)
 */
if (sai->soc_data->use_imx_pcm) {
ret = imx_pcm_dma_init(pdev);
-   if (ret)
+   if (ret) {
+   if (!IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_DMA))
+   dev_err(dev, "Error: You must enable the 
imx-pcm-dma support!\n");
goto err_pm_get_sync;
+   }
} else {
ret = devm_snd_dmaengine_pcm_register(dev, NULL, 0);
if (ret)
-- 
2.30.2



Re: [PATCH 2/2] ASoC: fsl: imx-es8328: add missing put_device() call in imx_es8328_probe()

2020-08-27 Thread Marco Felsch
On 20-08-25 20:05, Yu Kuai wrote:
> if of_find_device_by_node() succeed, imx_es8328_probe() doesn't have
> a corresponding put_device().

Why do we need the ssi_pdev reference here at all?

Regards,
  Marco