From patchwork Thu Oct 20 11:44:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 6175 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp72898wrr; Thu, 20 Oct 2022 05:15:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5pK1bBFA5htINQ6/+y2IiHxCuBK0x6lCTXCkBQLOIFPjL1C3dMIfy5MDm/K87brxLAzl1a X-Received: by 2002:a63:1718:0:b0:447:9ff3:66c0 with SMTP id x24-20020a631718000000b004479ff366c0mr11342094pgl.521.1666268135146; Thu, 20 Oct 2022 05:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666268135; cv=none; d=google.com; s=arc-20160816; b=HI7ipeeuzW4vwbW9Jftmf5a8Y/VrJDU6iDnBqcQ7HQc7csjaa6/Pux6Xq0MKaohBe9 NWnW9m5wcFCo8WB9ZwMD4n/U5pfYDx1MJnVh7aCTnlwbI7PEmoJqJog+3shwRBn7Xeu9 9JMutDadsyF85v0JPrhNoOLEVsPj08ppLOJoQrAtVGTcQ2+psDivBPlrYXQ+jRxFNtc/ 84EGZrGIrRqzHokb2jjSOsIbaJxlcBtXvj8a4eJa7CbiakqTUJPzi4KlEfF3nQG80pQG t4wInRRv234kFU545RA9eJR8G+cK/JOGpc0FlTEDZvSbvwZaXPb1mXuTIb10aUNiD4hW u2KA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=KWh0qYj9ci/7l0SX9GJj178mtuBeJCrc8Rr6rhBv1Jc=; b=aWzax4y5F0VSXZo1NwdoI0np7mLtu30zfunfUqZDbzGUq0xTktnj5euosRNBk+RqMK nCL8QGpVFqcx2dhC/jfaik5l+u+XZjsEPupPF6HuNrmclIh65qkPJkO+0Wbx21gVo/01 MiaHj3MgXFhIg22S5YsrZB1xf8b12OoayifMMbey9J2KOupV3kj2nUb2AahlN7mWchA4 JeepD/cdeP2w4zjhcrcpDAobMXxHScrdqAShcDO7qd4xw+IPtrDjh5eUMbW/Vtgf8O+x exWPpP2PKpUngrX1NLn5DLYAXGa0GtQ/TTkV5DGzB/x+303BhskDEBcMcFnPfmbm3ZMM iZAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=u83sYt3G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020aa78c13000000b00536bf099c14si20017362pfd.307.2022.10.20.05.15.20; Thu, 20 Oct 2022 05:15:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=u83sYt3G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbiJTLpF (ORCPT + 99 others); Thu, 20 Oct 2022 07:45:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbiJTLpD (ORCPT ); Thu, 20 Oct 2022 07:45:03 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60CF43846A; Thu, 20 Oct 2022 04:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1666266291; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=KWh0qYj9ci/7l0SX9GJj178mtuBeJCrc8Rr6rhBv1Jc=; b=u83sYt3GAv6rj/z9kDSku4S97vyjayKoxcYlVSdoKPNL/KY3brawOXpGYHm4rObisxIstC l6mglpeBzZ5d9fTxnPNgopGjabTMtIDybi+x6J6UF5tSUMs+petIMQSGBYp0r4sZnUOwFp L6e4gPyLTaKccL986vLX5YQHEaz1N9w= From: Paul Cercueil To: Pavel Machek Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil , Andy Shevchenko Subject: [PATCH v2] leds: max8997: Don't error if there is no pdata Date: Thu, 20 Oct 2022 12:44:42 +0100 Message-Id: <20221020114442.22215-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747208775888387459?= X-GMAIL-MSGID: =?utf-8?q?1747208775888387459?= The driver works just fine if no platform data is supplied. Signed-off-by: Paul Cercueil Reviewed-by: Andy Shevchenko --- v2: Add Andy's reviewed-by and reword the commit description. drivers/leds/leds-max8997.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/leds/leds-max8997.c b/drivers/leds/leds-max8997.c index c0bddb33888d..c8d7f55c9dec 100644 --- a/drivers/leds/leds-max8997.c +++ b/drivers/leds/leds-max8997.c @@ -238,11 +238,6 @@ static int max8997_led_probe(struct platform_device *pdev) char name[20]; int ret = 0; - if (pdata == NULL) { - dev_err(&pdev->dev, "no platform data\n"); - return -ENODEV; - } - led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); if (led == NULL) return -ENOMEM; @@ -258,7 +253,7 @@ static int max8997_led_probe(struct platform_device *pdev) led->iodev = iodev; /* initialize mode and brightness according to platform_data */ - if (pdata->led_pdata) { + if (pdata && pdata->led_pdata) { u8 mode = 0, brightness = 0; mode = pdata->led_pdata->mode[led->id];