Received: by 10.213.65.68 with SMTP id h4csp277740imn; Tue, 20 Mar 2018 03:21:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELv5J/+Ejy8dUs5VNOcUOAsmIGBOMePb/HwulL6fPF+rIxDvdjui8/j2rA1b87uEETQzDePc X-Received: by 10.98.217.139 with SMTP id b11mr1013011pfl.113.1521541306079; Tue, 20 Mar 2018 03:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521541306; cv=none; d=google.com; s=arc-20160816; b=S8NtFDEUoO+zpVO/ilUGbYZYok1AJk9hGSJdosJrxgi3/vVUunAcCjCAeHUUn/SGZD 5KIBJ6z6znuGQSubXYV8aVHfQzlzDSciKzUjUmkyIfcCtwvNGIboi+BKBT7ByxJN9nWg 1EEx11K2dx3Og5UB7/vrqwGabxSo8oxTa77f6SG8iIbn3nGs3FjehzU0t0LYoSWSzNUv wI2X6aQOW2ME3robA+1+rGZ78kFUI4hfm6YfIxAmIeLtVilIdHVLWowu7eZfl9YSc1yM 99A0HNUKmFqQRyoU87JcpX/ZVAsKiI+UOrIGUnmrARBNAxJ1Y5Lszk9VlCbUuHCdJptq HtBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=L2wLkGdLMCzYKbiYjnLJgLScdBQ7l1ty1f1T56nsg7E=; b=LKTyjgHnpWRnw7No3rrN3ndxTGbFxrS9oTvjpBN1wevnD9nvOjNqmUHmOtN5zRsTpF Cs74EbiqaZWGBEKGR6/BeiRWSe92KNvSK4xjYKTDngwlCiwbWsgfX7PE+BVLYGkp1IxJ 2fyFewLw4pTyeCvKEA7ljKh5+CtsmKagFTlKVC3WzM91ahZ05mbgYuiSXZePwdRR+zAv M6Gf/dLWh6X/Npqry8bUOgYuSdFLiYrAcYkfVXqGIg6o82VWyb0CSHjVFhmDo8wNxV9P wFAD0qEMpuAE9pB/9jM5LW67QBmuyp/4SZSXWl/IOYVSp/e8g4wJWTF0HXG26TCQxcoe 3+Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OZEbfSFu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si1013887pgf.5.2018.03.20.03.21.31; Tue, 20 Mar 2018 03:21:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OZEbfSFu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752552AbeCTKUZ (ORCPT + 99 others); Tue, 20 Mar 2018 06:20:25 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:42006 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbeCTKUW (ORCPT ); Tue, 20 Mar 2018 06:20:22 -0400 Received: by mail-wr0-f193.google.com with SMTP id s18so1071165wrg.9 for ; Tue, 20 Mar 2018 03:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=L2wLkGdLMCzYKbiYjnLJgLScdBQ7l1ty1f1T56nsg7E=; b=OZEbfSFu15qfSKMhz8yjDXz11R6KAH5sVNDFFedK6wkOTf+SG+Xkjjt+OzpoE1IqkL +XcWX7BGUSpvAHE3b8QYYl3vmrJEom3oVWJiPvnBPc/Q/+y5PstTredEhrDJOKcp0k2d yVkZ0weRfeD5Bl+c+P/xEK/c8h4dKwLjdk5Gu6JNR6+6U/30rGv/4PHzWHwRIQNEtMRt me9rtpz8kKSwQRhxQv8CkgZJwpcyNOKTQcAwcf47xJ7NyxFO0qu0no3zagZ2ePh/VGu9 Qn2M5GLJrSA/VyKQR3aFR73wNIMSDHhoy1jXz8d6dbSnafzDN7+SNpzkH9FMrezQMDso OcnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=L2wLkGdLMCzYKbiYjnLJgLScdBQ7l1ty1f1T56nsg7E=; b=LleTQc0lIT4qjKtpcyaWY1wb9gGuQEDsf+Z5oH7S8mv+eA3Dq0p+fWJj5FnWWU01fx L3TsIqvGKnmY0T3e/2xLC28527C0ulYgyQpyM01Lb5YJiQ5T6Xd5KTW4LHZZZq9JQNEv B04aPJ0dNLrIllUr+gggwS2zZKHy56Agkf3xBf6WV3dDXGPmG5eOaD9dXjG/ND9Erqq7 3XxuFwPsvRzpcnkmnNSg981J5+a8cPRCInSkd57xulDuMZEHMGtRSi0wLOLNeaUbHxlK IXUupa9oTBys/eHUC6o07TBQiSvoqBSm8Et0MgmWhkaPrM0dFeX7vtBTa5Q1jYjGuZM+ SEJw== X-Gm-Message-State: AElRT7H+++tNyRUX2oxYrZgf/5yj0GAbFklvy2fa85/P5R0LEPtWpSko Dfejw8AFFn40y5jficpN4eNC5x8pv0wznMAz/Q9Mhw== X-Received: by 10.223.166.179 with SMTP id t48mr12309352wrc.161.1521541220935; Tue, 20 Mar 2018 03:20:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.179.86 with HTTP; Tue, 20 Mar 2018 03:20:20 -0700 (PDT) In-Reply-To: <577e35f7-b7ca-ca97-1391-f5759e81254e@rock-chips.com> References: <1521018736-20980-1-git-send-email-hl@rock-chips.com> <577e35f7-b7ca-ca97-1391-f5759e81254e@rock-chips.com> From: Emil Velikov Date: Tue, 20 Mar 2018 10:20:20 +0000 Message-ID: Subject: Re: [PATCH v4 1/3] drm/panel: refactor INNOLUX P079ZCA panel driver To: hl Cc: Thierry Reding , Brian Norris , Rob Herring , Sean Paul , David Airlie , "Linux-Kernel@Vger. Kernel. Org" , ML dri-devel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20 March 2018 at 06:24, hl wrote: > Hi Emil, > > > > On Monday, March 19, 2018 09:09 PM, Emil Velikov wrote: >> >> On 15 March 2018 at 02:35, hl wrote: >>> >>> Hi Emil, >>> >>> >>> >>> On Wednesday, March 14, 2018 08:02 PM, Emil Velikov wrote: >>>> >>>> Hi Lin, >>>> >>>> On 14 March 2018 at 09:12, Lin Huang wrote: >>>>> >>>>> From: huang lin >>>>> >>>>> Refactor Innolux P079ZCA panel driver, let it support >>>>> multi panel. >>>>> >>>>> Change-Id: If89be5e56dba8cb498e2d50c1bbeb0e8016123a2 >>>>> Signed-off-by: Lin Huang >>>>> --- >>>>> Changes in v2: >>>>> - Change regulator property name to meet the panel datasheet >>>>> Changes in v3: >>>>> - this patch only refactor P079ZCA panel to support multi panel, >>>>> support >>>>> P097PFG panel in another patch >>>>> Changes in v4: >>>>> - Modify the patch which suggest by Thierry >>>>> >>>> Thanks for splitting this up. I think there's another piece that fell >>>> through the cracks. >>>> I'm not deeply familiar with the driver, so just sharing some quick >>>> notes. >>>> >>>> >>>>> struct innolux_panel { >>>>> struct drm_panel base; >>>>> struct mipi_dsi_device *link; >>>>> + const struct panel_desc *desc; >>>>> >>>>> struct backlight_device *backlight; >>>>> - struct regulator *supply; >>>>> + struct regulator *vddi; >>>>> + struct regulator *avdd; >>>>> + struct regulator *avee; >>>> >>>> These two seem are new addition, as opposed to a dummy refactor. >>>> Are they optional, does one need them for the existing panel (separate >>>> patch?) or only for the new one (squash with the new panel code)? >>>> >>>> >>>>> struct gpio_desc *enable_gpio; >>>>> >>>>> bool prepared; >>>>> @@ -77,9 +93,9 @@ static int innolux_panel_unprepare(struct drm_panel >>>>> *panel) >>>>> /* T8: 80ms - 1000ms */ >>>>> msleep(80); >>>>> >>>>> - err = regulator_disable(innolux->supply); >>>>> - if (err < 0) >>>>> - return err; >>>> >>>> Good call on dropping the early return here. >>>> >>>> >>>>> @@ -207,19 +248,28 @@ static const struct drm_panel_funcs >>>>> innolux_panel_funcs = { >>>>> - innolux->supply = devm_regulator_get(dev, "power"); >>>>> - if (IS_ERR(innolux->supply)) >>>>> - return PTR_ERR(innolux->supply); >>>>> + innolux = devm_kzalloc(dev, sizeof(*innolux), GFP_KERNEL); >>>>> + if (!innolux) >>>>> + return -ENOMEM; >>>>> + >>>>> + innolux->desc = desc; >>>>> + innolux->vddi = devm_regulator_get(dev, "power"); >>>>> + innolux->avdd = devm_regulator_get(dev, "avdd"); >>>>> + innolux->avee = devm_regulator_get(dev, "avee"); >>>>> >>>> AFAICT devm_regulator_get returns a pointer which is unsuitable to be >>>> passed into regulator_{enable,disable}. >>>> Hence, the IS_ERR check should stay. If any of the regulators are >>>> optional, you want to call regulator_{enable,disable} only as >>>> applicable. >>> >>> >>> devm_regulator_get() will use dummy_regulator if there not regulator pass >>> to >>> driver, so it not affect regulator_{enable, disable}. >> >> One of us is getting confused here: >> devm_regulator_get does not _use_ a regulator, it returns a pointer to >> a regulator, right? >> >> According to the 4.16-rc6 codebase - one error >> returns a ERR_PTR [1]. > > devm_regulator_get() will not reurn a ERR_PTR, it will pass NORMAL_GET mode > to > _regulator_get() when you call devm_regulator_get(), and with following > code: > Just before the _regulator_get() call we have "return ERR_PTR(-ENOMEM);" See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/regulator/devres.c?h=v4.16-rc6#n34 >> With the pointer dereferenced in regulator_enable [2], without a >> IS_ERR check, hence thing will go boom(?) >> >>> These three regulator are >>> optional, >>> the p079zca will use "power" and , >>> so i think it better not to check ERR here. >>> >> What should happen if p079zca is missing "power" or p097pgf - "avdd" and >> "avee"? >> Obviously the latter two should be introduced with the p097pgf support. > > i think it need dts to make sure configure the power node correct, if > missing > "power" node fo p079zca or "avdd" "avee" node for p097pgf, the panel can > not work, but do not affcet other driver, the kernel do not crash(as i > explain before and i also test it). > If you know it won't work just don't continue? And yes, it will crash ;-) Either way, if you don't like my feedback so be it. HTH Emil P.S. As a non native English speaker to another - spell checker helps a lot ;-)