Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4780861pxb; Tue, 2 Nov 2021 15:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu97FFh11YeMsdT6G6FHXiCGQZuWYwh/qpQV1lRVXo3e5KIR+Up6e2lfzVxX2ov3tXCxyU X-Received: by 2002:a50:da42:: with SMTP id a2mr52847279edk.361.1635893888013; Tue, 02 Nov 2021 15:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635893888; cv=none; d=google.com; s=arc-20160816; b=DVFs6sGSVFlhJ4QFmE4kDfYMK+XQrwIf50lHCb5/gUZlFv7ozfUQ5E7uCZuK0OhtrJ W2CG4sh53o5SI36ZxEHw4Ea/7vJWFfAFVl6FCzEpMdyBykCN+/d5ad3ULzRN3y0cR9d1 wO174LdT2EfYBzK2tMqEakvnB/iUn3nfcAuxFvpIBpUAYdlsB7UKOzPerbrfQYV1Nbw5 gUFCUNlrsXrJBAqI65CHfde2u2bH2S0fKBcu0DTd7MyFqKr87zaNkQ0y/m1n3M8mo9tf 4piAubcqnPR92w9Rm3lcq2c0/bv/PjAZ9gUHON5E22b1TVxYEg/MsTgfLeVc0e/XUAsi 4NtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=in9V/I6P5nWl0b1aEtKrhnbWkSaRhk1SKLF5QfaiNRA=; b=08Ha5HqMQuZVWAz3d8pan47dx4fxCRHtTDilb3SFjYaqnwWZL8eD5q1ez1brdp5oU7 ScJnjoQLvcvniq6C9eAj7rPqNcFJq9GCUzy9wQMoXWCaaICZ4imwydlr9ehYElWgV4g5 3DZ4U1VuxgrAQcN9PML21DW1ruM2gnIPKdfYc0DF+jvrllt/9/jYl3kOtl1seuo4Az6N jxJuDKFqq+fjD0LduHaQN/UA05/E4aLYesMWuvYULHiJTEpsoWZf1swOiKL62EBgv5Xh aMZwktt7DvCNXf63O7cADFrNfRdLupEUW1aEXBohYI0MtZjLFF2rJNF9pi5JWhVEkaMc EZdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="BSJCIm4/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt30si629667ejc.298.2021.11.02.15.57.44; Tue, 02 Nov 2021 15:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="BSJCIm4/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbhKBW6R (ORCPT + 99 others); Tue, 2 Nov 2021 18:58:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29246 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbhKBW6K (ORCPT ); Tue, 2 Nov 2021 18:58:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635893734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=in9V/I6P5nWl0b1aEtKrhnbWkSaRhk1SKLF5QfaiNRA=; b=BSJCIm4/TRqh0C73h9HyhEUAl5zk9qNa2MkbXwBLmhgtk4QtM3qoocida8AJQMzcns9Cda yHs1W+JDETxf3POtu3oURt20ZchNERtwqY3FvlQhi24qhr4fwvpP/6SGSRNjEZ9Q1w+NIX 5uwaJx/3pjT8vOpzZJ32Er/LVhwranA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-fylSlgtvNQy1V-2NcFpYlw-1; Tue, 02 Nov 2021 18:55:31 -0400 X-MC-Unique: fylSlgtvNQy1V-2NcFpYlw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6837E10A8E00; Tue, 2 Nov 2021 22:55:30 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1103A60657; Tue, 2 Nov 2021 22:55:28 +0000 (UTC) From: Hans de Goede To: Lee Jones , Daniel Thompson , Jingoo Han Cc: Hans de Goede , Tsuchiya Yuto , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] backlight: lp855x: Add dev helper variable to lp855x_probe() Date: Tue, 2 Nov 2021 23:55:03 +0100 Message-Id: <20211102225504.18920-2-hdegoede@redhat.com> In-Reply-To: <20211102225504.18920-1-hdegoede@redhat.com> References: <20211102225504.18920-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a dev local variable to the lp855x_probe(), to replace "&cl->dev" and "lp->dev" in various places. Also switch to dev_err_probe() in one case which takes care of not printing -EPROBE_DEFER errors for us. This is mostly a preparation for adding ACPI enumeration support which will use the new "dev" variable more. Reviewed-by: Daniel Thompson Signed-off-by: Hans de Goede --- drivers/video/backlight/lp855x_bl.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 808ff00b2003..d1d27d5eb0f2 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -381,21 +381,22 @@ static int lp855x_parse_dt(struct lp855x *lp) static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) { + struct device *dev = &cl->dev; struct lp855x *lp; int ret; if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) return -EIO; - lp = devm_kzalloc(&cl->dev, sizeof(struct lp855x), GFP_KERNEL); + lp = devm_kzalloc(dev, sizeof(struct lp855x), GFP_KERNEL); if (!lp) return -ENOMEM; lp->client = cl; - lp->dev = &cl->dev; + lp->dev = dev; lp->chipname = id->name; lp->chip_id = id->driver_data; - lp->pdata = dev_get_platdata(&cl->dev); + lp->pdata = dev_get_platdata(dev); switch (lp->chip_id) { case LP8550: @@ -424,30 +425,27 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) else lp->mode = REGISTER_BASED; - lp->supply = devm_regulator_get(lp->dev, "power"); + lp->supply = devm_regulator_get(dev, "power"); if (IS_ERR(lp->supply)) { if (PTR_ERR(lp->supply) == -EPROBE_DEFER) return -EPROBE_DEFER; lp->supply = NULL; } - lp->enable = devm_regulator_get_optional(lp->dev, "enable"); + lp->enable = devm_regulator_get_optional(dev, "enable"); if (IS_ERR(lp->enable)) { ret = PTR_ERR(lp->enable); if (ret == -ENODEV) { lp->enable = NULL; } else { - if (ret != -EPROBE_DEFER) - dev_err(lp->dev, "error getting enable regulator: %d\n", - ret); - return ret; + return dev_err_probe(dev, ret, "getting enable regulator\n"); } } if (lp->supply) { ret = regulator_enable(lp->supply); if (ret < 0) { - dev_err(&cl->dev, "failed to enable supply: %d\n", ret); + dev_err(dev, "failed to enable supply: %d\n", ret); return ret; } } @@ -455,7 +453,7 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) if (lp->enable) { ret = regulator_enable(lp->enable); if (ret < 0) { - dev_err(lp->dev, "failed to enable vddio: %d\n", ret); + dev_err(dev, "failed to enable vddio: %d\n", ret); goto disable_supply; } @@ -470,20 +468,19 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) ret = lp855x_configure(lp); if (ret) { - dev_err(lp->dev, "device config err: %d", ret); + dev_err(dev, "device config err: %d", ret); goto disable_vddio; } ret = lp855x_backlight_register(lp); if (ret) { - dev_err(lp->dev, - "failed to register backlight. err: %d\n", ret); + dev_err(dev, "failed to register backlight. err: %d\n", ret); goto disable_vddio; } - ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group); + ret = sysfs_create_group(&dev->kobj, &lp855x_attr_group); if (ret) { - dev_err(lp->dev, "failed to register sysfs. err: %d\n", ret); + dev_err(dev, "failed to register sysfs. err: %d\n", ret); goto disable_vddio; } -- 2.31.1