Received: by 10.213.65.68 with SMTP id h4csp467632imn; Sat, 17 Mar 2018 10:38:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELth5v4qWlS8jazxdglTP5a3MhCEivauasJkKDGfmRGEanNECKsOm7hPytwTVNhv8YNh+/8P X-Received: by 10.99.56.11 with SMTP id f11mr4863282pga.63.1521308312521; Sat, 17 Mar 2018 10:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521308312; cv=none; d=google.com; s=arc-20160816; b=R8/gqcCdLNMEc1qpBoU2dF6m8FfX2FasxqWTvp0VEBa7a87ZocmmtTN+a4cH+zV1DF Hn27T/uTwJpXxsOp94EnyC1qu7dyEtILPBnOdM2m+nkNqh4uiqKiC4oNzlNkfxV8eLPj e9wYTXjppPBk+X1dsNVj9L6RZc/mf5RcDTCvOCYBG6O33lOhyAuVSvfDtZvbcKA5TjJJ qey8OCTmxPMXEbotsJ6K+qg5uSWKErw2tQOKH8QSz3PRV4KQtbVG7jhkhAmpiTbWpYjB uP/i5CyS3wAtxCiNJEY5RrDOwb3Ra4qLH9SqutBAbhKeeZsiRz7ZCaNSMM3qIOM39Sju WGTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=KLiFaIDGDPRT+m9vw/gNRn3WpAt6T+AkwiIUhcxTY/0=; b=OEAYiPzT7Aebrz+xPUbvflUIPFi4ffXaKXt/54EtUTEe0yzIrgHg/kbKyfkjUOz9Ce oZNeGADjuMS0didWQAb+jyTtmRR5ufHgMGBfvEjYZFaFI0YBKa4OPA4peQkaBH3wENXA wOP2DjB5mxSJvtwubhHyjjDnQk7z0WYcGmr0hLy961KPUqzMsxCevaCMpxDWg8OdmuxT fjf0o4kPc2j9pZYErRMsFzHsmpgnAU6nn6L06NuxuR0MerNCeN0QOB2ksQEkSWoZXJ90 75DdlVwSWQtIR5wn0in8qseAvd3XZf7mvYR+WJII3hI7aG6g6ta7p8z5WNUAIqBq85l+ x+lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HB5MeLib; 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 bd8-v6si8536312plb.288.2018.03.17.10.38.18; Sat, 17 Mar 2018 10:38:32 -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=HB5MeLib; 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 S1753424AbeCQRh2 (ORCPT + 99 others); Sat, 17 Mar 2018 13:37:28 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33698 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752685AbeCQRhZ (ORCPT ); Sat, 17 Mar 2018 13:37:25 -0400 Received: by mail-pf0-f194.google.com with SMTP id q13so5421877pff.0; Sat, 17 Mar 2018 10:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KLiFaIDGDPRT+m9vw/gNRn3WpAt6T+AkwiIUhcxTY/0=; b=HB5MeLib4j0/5y+sad/YmT4nKCJ0fEN5ks73462yrHeHilpRlpHsAjuqU9ycfIjvL1 zZgNyNWiBcmCZQtJjODC0PvIIuIqVrAH66tijdarYlaeBx+EUfBCPPVRcNQ7nK8pooO6 /jMK1NFhfJkHhgKWahtB4zmlv6KOwIkBaNee5uGpYLOIIYfQkDDKLYV4T3aBxk+pq0pV RPMkHSa3mPnsTKEV60sVnfs9b/kyZQoRxgFG4GIoPz1jHcHSX6SmZVN/lYJ1NAKWxrp9 i54X7tCtUpQTastuYaJI/dAjRjOYPthSIYsgirosjMsB+MwyvZ56mJPFdoTJSQuUwjrv H+tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=KLiFaIDGDPRT+m9vw/gNRn3WpAt6T+AkwiIUhcxTY/0=; b=I+NRGXJFaWBE5Kp7yh2Co0HzwzneRSZQduSWpj2tbSADM/s2XYDPQoBCL6uKLV7cnt i1pGmqPkVQTUue2y1jk9ntDepcAeIaIHGE4MkmjtLFlp++VcQbhIQBpjwnSHfnhVuU2f E6ktTfDYym2rJEY2bqlaUqOvWFw6rUgcIl7756wDn76YwQmwfQXsZYoSFGxm1Tnwx4+Y byS1/zSaLEhT+8s00G3yG87aGd6h5RnVb3wtEyFcRXcPL7g5JOP+9sS0FQP7kdtMeqMK TNFbqVi4JfjJADMNr/8+GflRe0R5HJDHi1BHJk29r5v50i2S2voJAwA8wQvwlMoHWIjO NfzQ== X-Gm-Message-State: AElRT7EQkuoxs3b7u/Pl5OCQuqzOAw2EovxMILoLy/C1VOZqGw92D7l4 PhbRDvYu10KcIY/ra8MFiuE= X-Received: by 10.101.90.203 with SMTP id d11mr4537854pgt.20.1521308244524; Sat, 17 Mar 2018 10:37:24 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id r62sm22561318pfi.52.2018.03.17.10.37.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Mar 2018 10:37:24 -0700 (PDT) Date: Sat, 17 Mar 2018 10:37:22 -0700 From: Dmitry Torokhov To: jacopo mondi Cc: Laurent Pinchart , Lee Jones , Daniel Thompson , Jingoo Han , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org, Yoshinori Sato , Rich Felker , Linus Walleij Subject: Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device Message-ID: <20180317173722.GB183240@dtor-ws> References: <20180315224202.96668-1-dmitry.torokhov@gmail.com> <20180315224202.96668-3-dmitry.torokhov@gmail.com> <20180316100748.GH16424@w540> <20180316233800.GA32310@dtor-ws> <20180317092516.g5p5ybka57abyhex@apu3b> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180317092516.g5p5ybka57abyhex@apu3b> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 17, 2018 at 10:25:16AM +0100, jacopo mondi wrote: > Hi Dmitry, > > On Fri, Mar 16, 2018 at 04:38:00PM -0700, Dmitry Torokhov wrote: > > Hi Jacopo, > > > > On Fri, Mar 16, 2018 at 11:07:48AM +0100, jacopo mondi wrote: > > > Hello Dmitry > > > > > > FYI I am brushing the ecovec board these days as well > > > https://www.spinics.net/lists/linux-sh/msg52536.html > > > > > > > What is the ecovec board BTW? Is it some devkit or what? It seems quite > > old to me. > > Yes, it is a SuperH 4 based development board. It is old for sure. I'm > also working on removing some stuff the ecovec board file is the only > user of... > > > > And I have a board to test with but without any display panel, I'm > > > afraid. > > > > > > On Thu, Mar 15, 2018 at 03:42:00PM -0700, Dmitry Torokhov wrote: > > > > Commit fe79f919f47e ("sh: ecovec24: Use gpio-backlight") removed custom > > > > backlight support and switched over to generic gpio-backlight driver. The > > > > comment when we run with DVI states "no backlight", but setting > > > > gpio_backlight_data.fbdev to NULL actually makes gpio-backlight to react to > > > > events from any framebuffer device, not ignore them. > > > > > > > > We want to get rid of platform data in favor of generic device properties > > > > in gpio_backlight driver, so we can not have kernel pointers passed around > > > > to tie the framebuffer device to backlight. Assuming that the intent of the > > > > above referenced commit was to indeed not export backlight when using DVI, > > > > let's switch to conditionally registering backlight device so it is not > > > > present at all in DVI case. > > > > > > > > Signed-off-by: Dmitry Torokhov > > > > --- > > > > arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++------- > > > > 1 file changed, 17 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c > > > > index 6f929abe0b50f..67633d2d42390 100644 > > > > --- a/arch/sh/boards/mach-ecovec24/setup.c > > > > +++ b/arch/sh/boards/mach-ecovec24/setup.c > > > > @@ -368,7 +368,6 @@ static struct platform_device lcdc_device = { > > > > }; > > > > > > > > static struct gpio_backlight_platform_data gpio_backlight_data = { > > > > - .fbdev = &lcdc_device.dev, > > > > .gpio = GPIO_PTR1, > > > > .def_value = 1, > > > > .name = "backlight", > > > > @@ -987,7 +986,6 @@ static struct platform_device *ecovec_devices[] __initdata = { > > > > &usb1_common_device, > > > > &usbhs_device, > > > > &lcdc_device, > > > > - &gpio_backlight_device, > > > > &ceu0_device, > > > > &ceu1_device, > > > > &keysc_device, > > > > @@ -1077,6 +1075,8 @@ static int __init arch_setup(void) > > > > { > > > > struct clk *clk; > > > > bool cn12_enabled = false; > > > > + bool use_backlight = false; > > > > + int error; > > > > > > > > /* register board specific self-refresh code */ > > > > sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF | > > > > @@ -1193,9 +1193,6 @@ static int __init arch_setup(void) > > > > lcdc_info.ch[0].lcd_modes = ecovec_dvi_modes; > > > > lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_dvi_modes); > > > > > > > > - /* No backlight */ > > > > - gpio_backlight_data.fbdev = NULL; > > > > - > > > > gpio_set_value(GPIO_PTA2, 1); > > > > gpio_set_value(GPIO_PTU1, 1); > > > > } else { > > > > @@ -1217,6 +1214,8 @@ static int __init arch_setup(void) > > > > /* enable TouchScreen */ > > > > i2c_register_board_info(0, &ts_i2c_clients, 1); > > > > irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW); > > > > + > > > > + use_backlight = true; > > > > } > > > > > > > > /* enable CEU0 */ > > > > @@ -1431,8 +1430,19 @@ static int __init arch_setup(void) > > > > gpio_set_value(GPIO_PTG4, 1); > > > > #endif > > > > > > > > - return platform_add_devices(ecovec_devices, > > > > - ARRAY_SIZE(ecovec_devices)); > > > > + error = platform_add_devices(ecovec_devices, > > > > + ARRAY_SIZE(ecovec_devices)); > > > > > > I would invert this. > > > Register the backlight first, then all other devices. > > > > We could do that, but why would that be better? > > > > That if backlight device registration fails we do not register all > other devices. But yes that may be a bit too harsh, isn't it? Yes, that was my reasoning. With platform_add_devices() that unwinds all the devices it created successfully we do not really have any option but return error (which is either ignored or fatal). Here we can simply warn and still let the device boot so users have easier way to see what went wrong. > > > > > > > > > > > + if (error) > > > > + return error; > > > > + > > > > + if (use_backlight) { > > > > + error = platform_device_add(&gpio_backlight_device); > > > > + if (error) > > > > + pr_warn("%s: failed to register backlight: %d\n", > > > > + error); > > > > > > Could you use dev_warn here? Also the format is wrong, I assume you > > > > I would rather not, as the backlight device would be in unknown state > > here, and using dev_warn with device that has not been fully registered > > does not give any benefits. There is also no ambiguity as there is only > > one backlight. > > You are very correct, sorry for the fuss. > > > > > > are missing a '__func__' as second function argument. > > > > I'll fix this. > > > > > > > > Also, you may want to return error. > > > > How would caller handle this error? Should we kill all successfully > > registered devices on error adding backlight? > > As the function returned an error code for 'platform_add_devices()' I > thought we may want to return one as well. That's why I proposed to > invert the registration order :) > > All minor nits btw, sorry for jumping up, I understand this is an > RFC and ecovec board file is not the real juice of this series ;) > > Ping me if I can help with testing as I've the board. Yes, I'll fix up the other mess ups and I'll post a v2. Thanks! -- Dmitry