[PATCH 2/2] eeprom: at24: add enable gpio support

From: Eliav Farber
Date: Tue Aug 16 2022 - 09:02:40 EST


Add gpio support to enable the eeprom device as part of probe sequence.

Signed-off-by: Eliav Farber <farbere@xxxxxxxxxx>
---
drivers/misc/eeprom/at24.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index dc3537651b80..06535b9e1da5 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -623,6 +623,7 @@ static int at24_probe(struct i2c_client *client)
struct device *dev = &client->dev;
bool i2c_fn_i2c, i2c_fn_block;
unsigned int i, num_addresses;
+ struct gpio_desc *enable_gpio;
struct at24_data *at24;
struct regmap *regmap;
size_t at24_size;
@@ -630,6 +631,10 @@ static int at24_probe(struct i2c_client *client)
u8 test_byte;
int err;

+ enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
+ if (IS_ERR(enable_gpio))
+ return PTR_ERR(enable_gpio);
+
i2c_fn_i2c = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
i2c_fn_block = i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
--
2.37.1