From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECE55FA3728 for ; Wed, 16 Oct 2019 14:34:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C607D2067D for ; Wed, 16 Oct 2019 14:34:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="NnGUwC3N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394117AbfJPOea (ORCPT ); Wed, 16 Oct 2019 10:34:30 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:58688 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731987AbfJPOea (ORCPT ); Wed, 16 Oct 2019 10:34:30 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9GEYOuC002057; Wed, 16 Oct 2019 09:34:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1571236464; bh=sL1OOfBP4VKCoJ3rIFCH/P3XqaR9GzNKjyDtWXF3MBU=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=NnGUwC3NzS3mrMrBSxIGGpbjHNlwiEZWnY5lgWZUj6A9VgA7Sg0q7OmFkPEz25Zwi VKLwtoJQ2y+ySJgAFd+itQkKTpJK8aU7z+/MCUYYFfMsXMlGBvBgQi3BtLvldS9mb8 zCdBMHRTDIsYfyTrvr97VwO3BDic79QEy6LijNnM= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9GEYOv4096679 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 16 Oct 2019 09:34:24 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 16 Oct 2019 09:34:17 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 16 Oct 2019 09:34:17 -0500 Received: from [10.250.65.13] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9GEYOln020144; Wed, 16 Oct 2019 09:34:24 -0500 Subject: Re: [PATCH v2] leds: an30259a: add a check for devm_regmap_init_i2c To: Chuhong Yuan CC: Jacek Anaszewski , Pavel Machek , , References: <20191016125403.23359-1-hslester96@gmail.com> From: Dan Murphy Message-ID: <1f4282aa-edb2-2683-bfff-8805a972710b@ti.com> Date: Wed, 16 Oct 2019 09:33:53 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191016125403.23359-1-hslester96@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Chuhong On 10/16/19 7:54 AM, Chuhong Yuan wrote: > an30259a_probe misses a check for devm_regmap_init_i2c and may cause > problems. > Add a check and print errors like other leds drivers. > > Signed-off-by: Chuhong Yuan > --- > Changes in v2: > - Use goto exit instead of return to destroy the mutex when failed. > > drivers/leds/leds-an30259a.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c > index 250dc9d6f635..82350a28a564 100644 > --- a/drivers/leds/leds-an30259a.c > +++ b/drivers/leds/leds-an30259a.c > @@ -305,6 +305,13 @@ static int an30259a_probe(struct i2c_client *client) > > chip->regmap = devm_regmap_init_i2c(client, &an30259a_regmap_config); > > + if (IS_ERR(chip->regmap)) { > + err = PTR_ERR(chip->regmap); > + dev_err(&client->dev, "Failed to allocate register map: %d\n", > + err); > + goto exit; > + } > + Reviewed-by: Dan Murphy > for (i = 0; i < chip->num_leds; i++) { > struct led_init_data init_data = {}; >