From nobody Tue Nov 26 00:26:04 2024 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B2B9200133 for ; Wed, 23 Oct 2024 23:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729727685; cv=none; b=Kr2/5xXo/7/SJVKV5wQEXvFX25m/SwbV2FN3BLsV6PeOU6JJfQKhx7p07s5DB6k6pSRlJKsE/wgToRTgCUEbvY3Jhvj4L4ORFS8cOB/+K2QFKX/JXjEPXmmFA8gNNBikd8dY0/QRKv7Sv4oLh8pRm0f969I/w8qcCVCErP5ZaOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729727685; c=relaxed/simple; bh=JtWsVW1/ip3tWEUoknaHJGDygDmPAYBD4bgqX9vG02Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tS/mQj+WBaKNzPZ87OF/mqzuHEGFFxC9GdsKdCIbp9EOC5j1zgzlZFlpPagZ0xCQkvHxpI7SrCSorb9OQWr7O4lnZobh77f7vXHo4JIxOITYy3RwsMhvH6PqrHDOf8e+NA7YBwSicX4WAQISAiJNKGCaNrzjV0CiQxJBLL/3Sv0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=CpzOMGl8; arc=none smtp.client-ip=209.85.210.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="CpzOMGl8" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-71809fe188cso219751a34.0 for ; Wed, 23 Oct 2024 16:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729727683; x=1730332483; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=11WZ5IF5KUkagJDeN3d2nVfidgojedjqvRS83nA7Gyo=; b=CpzOMGl8oBhdlSnTxb8e2+tfug+urxNZPDsTvSDP8Y2BTc1xDMVaI+AQ2TCltswb64 5U3+2GQyI5o0BJqKuUszaFRufSGXcXue///V82qptpuaxK0vOfspCO7BMf5sdDE1zHVS 8p+Se0p3AUJB4F76TbCWiXWrG0nG2akIHKawydlHBG1Qid4BU5CL49TFmWIR5WSPwuc/ 5nKWHCFoBf130W5ZIGW0TmnTIudb/TuPOY1HKcO+wudLGR6QxIKONxQU9PLv+z9USUOH 6apP0YseakEuVfhkANHEQKrVgCjCBMru/+sv290cGBhPj63ZgBjesRTtbYVrbJXa1Fxn tIYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729727683; x=1730332483; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=11WZ5IF5KUkagJDeN3d2nVfidgojedjqvRS83nA7Gyo=; b=jKT2XbOI5/rbo8DNPxSfkj/Ppzv1l40N6dST8mHOGQnqQF+gXtLhR737o8gfl4MxkW 3UQNcLDxsXVrK15VoK1DEkjv24n51ihquiFStyhSwN7S6+dbgNYSixSSv6pUr5BeKBDr 23cTy4L5Iy9285hSLsJzU2y0otC7V7KqJlt9pY896q6VqtVCk3SVQL+OIgK62C1IFUFC XhC1FxzJAxQgIahjvnNCLcTwuH/9dODVFUSjV/MsWmzi8M5AJBj9GQZ+rX8O3yCEpx0/ /sQM6WjiaMs3YEjCFd5TMW+G4ugARwE7CUT6sqv8/UcffOEpEiFYuVN/hsw3EChLIzwR sllw== X-Forwarded-Encrypted: i=1; AJvYcCWInXFXzUZ5QQ/7IwjuX7WA3EkZvOG2DODhXhPO1uDd8KaMjPGPUk8Ha8VmJ0A2NlqS8gr9bMrywBgrxLw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxjg79G97t/fu8vYEcFgg4YwUrUJAj92m0frZ3PNTmbh1Mu3B1d M/45lhEVHoPNFTZwB2jNmkB9Zw7TcGMHwAzZ+hf8g1gZLMkpJhNxk8QSKUOyhII= X-Google-Smtp-Source: AGHT+IHPtJ7lzyKKMxRzAqXtGDZhRStmKcjf90mmLH4koSMdK6Z/hi1YrpCJ0SuS0YG7xtlRaOdYZw== X-Received: by 2002:a05:6830:314c:b0:715:4e38:a1ab with SMTP id 46e09a7af769-7184b32308bmr4590372a34.22.1729727682667; Wed, 23 Oct 2024 16:54:42 -0700 (PDT) Received: from [127.0.1.1] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5ec02c2b25bsm132002eaf.39.2024.10.23.16.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 16:54:41 -0700 (PDT) From: David Lechner Date: Wed, 23 Oct 2024 18:54:06 -0500 Subject: [PATCH 02/11] iio: dac: ad5380: drop driver remove callbacks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241023-iio-regulator-refactor-round-5-v1-2-d0bd396b3f50@baylibre.com> References: <20241023-iio-regulator-refactor-round-5-v1-0-d0bd396b3f50@baylibre.com> In-Reply-To: <20241023-iio-regulator-refactor-round-5-v1-0-d0bd396b3f50@baylibre.com> To: Jonathan Cameron Cc: Michael Hennerich , Liam Girdwood , Mark Brown , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, David Lechner X-Mailer: b4 0.14.1 Drop use of the driver remove callbacks in the ad5380 driver. By making use of a few more devm_ helpers, we can avoid the need for remove callbacks entirely. Also make use of dev_err_probe() while at it. Signed-off-by: David Lechner --- drivers/iio/dac/ad5380.c | 61 +++++++++++---------------------------------= ---- 1 file changed, 13 insertions(+), 48 deletions(-) diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c index 7d1d7053c29e..392a1c7aee03 100644 --- a/drivers/iio/dac/ad5380.c +++ b/drivers/iio/dac/ad5380.c @@ -339,14 +339,14 @@ static const struct ad5380_chip_info ad5380_chip_info= _tbl[] =3D { }, }; =20 -static int ad5380_alloc_channels(struct iio_dev *indio_dev) +static int ad5380_alloc_channels(struct device *dev, struct iio_dev *indio= _dev) { struct ad5380_state *st =3D iio_priv(indio_dev); struct iio_chan_spec *channels; unsigned int i; =20 - channels =3D kcalloc(st->chip_info->num_channels, - sizeof(struct iio_chan_spec), GFP_KERNEL); + channels =3D devm_kcalloc(dev, st->chip_info->num_channels, + sizeof(struct iio_chan_spec), GFP_KERNEL); =20 if (!channels) return -ENOMEM; @@ -377,7 +377,6 @@ static int ad5380_probe(struct device *dev, struct regm= ap *regmap, } =20 st =3D iio_priv(indio_dev); - dev_set_drvdata(dev, indio_dev); =20 st->chip_info =3D &ad5380_chip_info_tbl[type]; st->regmap =3D regmap; @@ -389,20 +388,16 @@ static int ad5380_probe(struct device *dev, struct re= gmap *regmap, =20 mutex_init(&st->lock); =20 - ret =3D ad5380_alloc_channels(indio_dev); - if (ret) { - dev_err(dev, "Failed to allocate channel spec: %d\n", ret); - return ret; - } + ret =3D ad5380_alloc_channels(dev, indio_dev); + if (ret) + return dev_err_probe(dev, ret, "Failed to allocate channel spec\n"); =20 if (st->chip_info->int_vref =3D=3D 2500) ctrl |=3D AD5380_CTRL_INT_VREF_2V5; =20 ret =3D devm_regulator_get_enable_read_voltage(dev, "vref"); - if (ret < 0 && ret !=3D -ENODEV) { - dev_err(dev, "Failed to get vref voltage: %d\n", ret); - goto error_free_reg; - } + if (ret < 0 && ret !=3D -ENODEV) + return dev_err_probe(dev, ret, "Failed to get vref voltage\n"); if (ret =3D=3D -ENODEV) { st->vref =3D st->chip_info->int_vref; ctrl |=3D AD5380_CTRL_INT_VREF_EN; @@ -411,32 +406,14 @@ static int ad5380_probe(struct device *dev, struct re= gmap *regmap, } =20 ret =3D regmap_write(st->regmap, AD5380_REG_SF_CTRL, ctrl); - if (ret) { - dev_err(dev, "Failed to write to device: %d\n", ret); - goto error_free_reg; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to write to device\n"); =20 - ret =3D iio_device_register(indio_dev); - if (ret) { - dev_err(dev, "Failed to register iio device: %d\n", ret); - goto error_free_reg; - } + ret =3D devm_iio_device_register(dev, indio_dev); + if (ret) + return dev_err_probe(dev, ret, "Failed to register iio device\n"); =20 return 0; - -error_free_reg: - kfree(indio_dev->channels); - - return ret; -} - -static void ad5380_remove(struct device *dev) -{ - struct iio_dev *indio_dev =3D dev_get_drvdata(dev); - - iio_device_unregister(indio_dev); - - kfree(indio_dev->channels); } =20 static bool ad5380_reg_false(struct device *dev, unsigned int reg) @@ -470,11 +447,6 @@ static int ad5380_spi_probe(struct spi_device *spi) return ad5380_probe(&spi->dev, regmap, id->driver_data, id->name); } =20 -static void ad5380_spi_remove(struct spi_device *spi) -{ - ad5380_remove(&spi->dev); -} - static const struct spi_device_id ad5380_spi_ids[] =3D { { "ad5380-3", ID_AD5380_3 }, { "ad5380-5", ID_AD5380_5 }, @@ -501,7 +473,6 @@ static struct spi_driver ad5380_spi_driver =3D { .name =3D "ad5380", }, .probe =3D ad5380_spi_probe, - .remove =3D ad5380_spi_remove, .id_table =3D ad5380_spi_ids, }; =20 @@ -543,11 +514,6 @@ static int ad5380_i2c_probe(struct i2c_client *i2c) return ad5380_probe(&i2c->dev, regmap, id->driver_data, id->name); } =20 -static void ad5380_i2c_remove(struct i2c_client *i2c) -{ - ad5380_remove(&i2c->dev); -} - static const struct i2c_device_id ad5380_i2c_ids[] =3D { { "ad5380-3", ID_AD5380_3 }, { "ad5380-5", ID_AD5380_5 }, @@ -574,7 +540,6 @@ static struct i2c_driver ad5380_i2c_driver =3D { .name =3D "ad5380", }, .probe =3D ad5380_i2c_probe, - .remove =3D ad5380_i2c_remove, .id_table =3D ad5380_i2c_ids, }; =20 --=20 2.43.0