Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5539461pxb; Mon, 14 Feb 2022 01:15:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8Y2KVhYcDF3cxkxV7azxZLX3D64hPzXIJQzUFj0EC9061cQNdNFhx7LEStL7/yVPsjH7c X-Received: by 2002:a63:5b62:: with SMTP id l34mr5817492pgm.440.1644830156763; Mon, 14 Feb 2022 01:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644830156; cv=none; d=google.com; s=arc-20160816; b=w4bAZ7hbLET4/I8qm2au+7Dyz9c6UZENS016ai0xe3HAaRibQkf4x9mGSf46RtgLgU sC+R/+KCBLNF1iQ7IlQgH8pq1Vtvm7xB+Ojcok5RNMkyIivCnmheZjLNAec2uRoJfFnl dMCJDzjQlCsh23Z63COQXzw9UdtMgvBx3tizTw2HeQnWlROPoiZrOT6QBeL2q1sS39lQ WxsFxwm1oxaUWjJGvaZkL3MWb4J0QbhYNcbXKAB0n/9Kcvl9LnzN1EWBohGmvnuA2m9B f/RxTg9KpdzMu0shfRORFDfWiXf7fvJF/OEWs3MJ9P5t7IOBwooxbNkoVs0g68l8OE84 E02w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QHozGP9RRVImmG1Bwvi4/BvJey4/MkMCfQ+0w/9b+ew=; b=vcXTLo+v1MZqhgk9/tCIT2Kt1KDTGor3JbjYAZtYgIgo7iMKA3Q+FQRNB+kQVxMO4u lh74qdqSGptQ4kJDJBqYi8qXMcN0/dt5rPengJ9Tr5sCS+q9i4Top4GhSAHlxEZwYI0z CFl/cbNPTqP54rtlzqvbJORO5Yh12EX/jMYbYJ2WKxJq9m9OLNu0PYwuQwupXJZJIrbs /TrX1sX6wcU1EYPpOw9r+WXK0f6AGeSUfLMvl1/P/HCQBGqSOISqFVoIomPd+BZBy2vG 24TVjmOPR/xHNVtJ109qj4gy958mWzIIBhRXZjnDXUs6wKs6mhMsp3sfrwQi1ih8Bqph Jy2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BRQDU42v; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik2si10894375plb.519.2022.02.14.01.15.44; Mon, 14 Feb 2022 01:15:56 -0800 (PST) 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=@intel.com header.s=Intel header.b=BRQDU42v; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349497AbiBKLfD (ORCPT + 94 others); Fri, 11 Feb 2022 06:35:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234009AbiBKLfB (ORCPT ); Fri, 11 Feb 2022 06:35:01 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20E0EE76; Fri, 11 Feb 2022 03:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644579301; x=1676115301; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Ta83snNi9vzAwFFKvrm3a20yLtYu4gS2g5TL8vXcfj4=; b=BRQDU42vhDGS5xctnb1zLn98/7uH9e7tnusZOQ7F9KjxzWaU2nwtJRUC xo6jrkM7GB6yXL8XYYsDi4YAceMVmxRcDAh6mcABtj2X03Ev0ch7nHEGM KJABKbSUMUX4/y9tsH6B9Fvcm89Mp2p2E5RAooJMPpAI5ftrwHg9M+J+8 9726Jrtt/ApRhXakiGOzw+3PH7Dlpjo0/lxO/j0RUhDvEP4uD/VQqQmZO HvMhRDAJO2WvewAz+hiBlTVjbO7T6TDW4nIPuTnivJrOjYxnY7A6hfxpo x58gOY0DWdTjBVS49Bh+DSK7S23UCsg/aNY+f9YAzAifI+oXYTcEllFBa Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10254"; a="336138185" X-IronPort-AV: E=Sophos;i="5.88,360,1635231600"; d="scan'208";a="336138185" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2022 03:35:00 -0800 X-IronPort-AV: E=Sophos;i="5.88,360,1635231600"; d="scan'208";a="623197161" Received: from smile.fi.intel.com ([10.237.72.61]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2022 03:34:56 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nIUBa-003QNQ-Nz; Fri, 11 Feb 2022 13:33:58 +0200 Date: Fri, 11 Feb 2022 13:33:58 +0200 From: Andy Shevchenko To: Javier Martinez Canillas Cc: linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, Geert Uytterhoeven , Maxime Ripard , Daniel Vetter , dri-devel@lists.freedesktop.org, Thomas Zimmermann , Sam Ravnborg , Noralf =?iso-8859-1?Q?Tr=F8nnes?= , Daniel Vetter , David Airlie , Lee Jones , Maarten Lankhorst , Maxime Ripard , Thierry Reding , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , linux-pwm@vger.kernel.org Subject: Re: [PATCH v4 3/6] drm: Add driver for Solomon SSD130x OLED displays Message-ID: References: <20220211091927.2988283-1-javierm@redhat.com> <20220211091927.2988283-4-javierm@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220211091927.2988283-4-javierm@redhat.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Fri, Feb 11, 2022 at 10:19:24AM +0100, Javier Martinez Canillas wrote: > This adds a DRM driver for SSD1305, SSD1306, SSD1307 and SSD1309 Solomon > OLED display controllers. > > It's only the core part of the driver and a bus specific driver is needed > for each transport interface supported by the display controllers. ... > +#include > +#include bits.h (FYI, specifically sent a patch few days ago to add explicitly the inclusions that needed for bitfield operations in the example inside bitfield.h). > +#include > +#include > +#include > +#include > +#include ... > +#define SSD130X_SET_ADDRESS_MODE_HORIZONTAL (0x00) > +#define SSD130X_SET_ADDRESS_MODE_VERTICAL (0x01) > +#define SSD130X_SET_ADDRESS_MODE_PAGE (0x02) > + > +#define SSD130X_SET_AREA_COLOR_MODE_ENABLE (0x1e) > +#define SSD130X_SET_AREA_COLOR_MODE_LOW_POWER (0x05) Do the parentheses add anything here? ... > +/* > + * Helper to write command (SSD130X_COMMAND). The fist variadic argument > + * is the command to write and the following are the command options. This is not correct explanation. Please, rephrase to show that _each_ of the options is sent with a preceding command. > + */ > +static int ssd130x_write_cmd(struct ssd130x_device *ssd130x, int count, > + /* u8 cmd, u8 option, ... */...) > +{ > + va_list ap; > + u8 value; > + int ret; > + > + va_start(ap, count); > + > + do { > + value = va_arg(ap, int); > + ret = regmap_write(ssd130x->regmap, SSD130X_COMMAND, (u8)value); > + if (ret) > + goto out_end; > + } while (--count); > + > +out_end: > + va_end(ap); > + > + return ret; > +} ... > + if (ssd130x->device_info->need_pwm) { Yeah, unfortunately we still don't have pwm_get_optional()... > + ret = ssd130x_pwm_enable(ssd130x); > + if (ret) { > + dev_err(dev, "Failed to enable PWM: %d\n", ret); > + regulator_disable(ssd130x->vcc_reg); > + return ret; > + } > + } ... > +static void ssd130x_power_off(struct ssd130x_device *ssd130x) > +{ > + if (ssd130x->device_info->need_pwm) { Redundant check. The two below are NULL-aware. > + pwm_disable(ssd130x->pwm); > + pwm_put(ssd130x->pwm); > + } > + > + regulator_disable(ssd130x->vcc_reg); > +} ... > + ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_COM_PINS_CONFIG, compins); > + if (ret < 0) > + return ret; > + > + One blank line is enough. ... > + for (i = y / 8; i < y / 8 + pages; i++) { > + int m = 8; > + > + /* Last page may be partial */ > + if (8 * (i + 1) > ssd130x->height) > + m = ssd130x->height % 8; Perhaps it can be moved out of the loop with refactored piece below. > + for (j = x; j < x + width; j++) { > + u8 data = 0; > + > + for (k = 0; k < m; k++) { > + u8 byte = buf[(8 * i + k) * line_length + j / 8]; > + u8 bit = (byte >> (j % 8)) & 1; > + > + data |= bit << k; > + } > + data_array[array_idx++] = data; > + } > + } ... > + bl = devm_backlight_device_register(dev, dev_name(dev), dev, ssd130x, > + &ssd130xfb_bl_ops, NULL); > + if (IS_ERR(bl)) { > + ret = PTR_ERR(bl); > + dev_err_probe(dev, ret, "Unable to register backlight device\n"); > + return ERR_PTR(ret); dev_err_probe(dev, PTR_ERR(bl), "Unable to register backlight device\n"); return bl; ? > + } -- With Best Regards, Andy Shevchenko