iio: accel: adxl345: Get rid of name parameter in adxl345_core_probe()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 22 Feb 2022 09:00:04 +0000 (11:00 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 26 Feb 2022 19:11:05 +0000 (19:11 +0000)
As a preparation to switch to use device properties, get rid of name
parameter in adxl345_core_probe(). Instead, choose it based on the type.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20220222090009.2060-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/adxl345.h
drivers/iio/accel/adxl345_core.c
drivers/iio/accel/adxl345_i2c.c
drivers/iio/accel/adxl345_spi.c

index 5a68d4d..9b0d4f4 100644 (file)
@@ -13,7 +13,6 @@ enum adxl345_device_type {
        ADXL375 = 2,
 };
 
-int adxl345_core_probe(struct device *dev, struct regmap *regmap,
-                      enum adxl345_device_type type, const char *name);
+int adxl345_core_probe(struct device *dev, struct regmap *regmap, enum adxl345_device_type type);
 
 #endif /* _ADXL345_H_ */
index 078e102..0f34c34 100644 (file)
@@ -213,14 +213,25 @@ static void adxl345_powerdown(void *regmap)
        regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_STANDBY);
 }
 
-int adxl345_core_probe(struct device *dev, struct regmap *regmap,
-                      enum adxl345_device_type type, const char *name)
+int adxl345_core_probe(struct device *dev, struct regmap *regmap, enum adxl345_device_type type)
 {
        struct adxl345_data *data;
        struct iio_dev *indio_dev;
+       const char *name;
        u32 regval;
        int ret;
 
+       switch (type) {
+       case ADXL345:
+               name = "adxl345";
+               break;
+       case ADXL375:
+               name = "adxl375";
+               break;
+       default:
+               return -EINVAL;
+       }
+
        ret = regmap_read(regmap, ADXL345_REG_DEVID, &regval);
        if (ret < 0)
                return dev_err_probe(dev, ret, "Error reading device ID\n");
index 4c6efe2..1e42cf3 100644 (file)
@@ -31,8 +31,7 @@ static int adxl345_i2c_probe(struct i2c_client *client,
        if (IS_ERR(regmap))
                return dev_err_probe(&client->dev, PTR_ERR(regmap), "Error initializing regmap\n");
 
-       return adxl345_core_probe(&client->dev, regmap, id->driver_data,
-                                 id->name);
+       return adxl345_core_probe(&client->dev, regmap, id->driver_data);
 }
 
 static const struct i2c_device_id adxl345_i2c_id[] = {
index 7255013..34b7001 100644 (file)
@@ -34,7 +34,7 @@ static int adxl345_spi_probe(struct spi_device *spi)
        if (IS_ERR(regmap))
                return dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing regmap\n");
 
-       return adxl345_core_probe(&spi->dev, regmap, id->driver_data, id->name);
+       return adxl345_core_probe(&spi->dev, regmap, id->driver_data);
 }
 
 static const struct spi_device_id adxl345_spi_id[] = {