Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2794340imm; Wed, 3 Oct 2018 09:15:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV61VdAEe4QdQXBtvLgew0eTO2saF+CFYm4r36xYHPOvnSzyFrmpeulsjsgwHbm00C3alU3s1 X-Received: by 2002:a63:d00b:: with SMTP id z11-v6mr2008283pgf.317.1538583304716; Wed, 03 Oct 2018 09:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538583304; cv=none; d=google.com; s=arc-20160816; b=hbmFPe4uIwHEaMf47PvSxwRYUM0j15yZNyeRSjNm7+pTtRRUBRZsoScGgT/JT2vHaW mS2mTJm13wxz2excXVjirOkFPDGqdrSV6vmSmp/FqIvY0yiF/33zu/tKKQ4coOPevxhZ 08k43IAr5PpIWcqVha9nJ4dF3t3ih5ZOfOJ1VJAFLgd1xUEq4BDGin5q/P6uGBCvr7Xs m2WsqErHaAat/KJARc6NUpnJHxXLM3MBmKrth0Cc/8nbOdFrWRHgobvz0DNSM2Epp4I/ 6ZRmt8mNH0NlfQBCPJ+ShF7f1HZ6mXqKMqaTJTZZ8OLSBm0yZyE2b2ptwFrDep8Z8Yvi 7xvA== 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; bh=vLkPmzuqtgjkplu2IF6/eZkyS5RYQOO6lm/eVV30n6E=; b=vwA95UKajrvS1xhRmEOfBV6/MKKxYnqtwmJvx+2MrAIwDZT4qHQzNDMv7/Sx8mkoaO dn4X2JeoCK7v0wVqMFGsSkQilFdD9Lx1fCuD8SXETX+6Fu3/jGvhj/HseWrNoSb2Cc+j v+uJEgRS1JLTWIaZkqCin4bZH286koEV68+QVkP1s9atlen1yFpcZrPv91HPNqyG+h+8 alc1nZXNBgzXndgMKrxyAVuyXn1Ju0Cbo0nv20ZZSFiY0Z6HJTmNtQtqmq0Hs9QJ1Kvz 0ekJcw1fDBVxEy393b9tTsf4j+Qm0dJy033k7Ti4WlSyBFs3uRDRq3iRF+/gGCq3TwG+ ClNA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12-v6si1755903pgi.467.2018.10.03.09.14.48; Wed, 03 Oct 2018 09:15:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbeJCXDN (ORCPT + 99 others); Wed, 3 Oct 2018 19:03:13 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:36243 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726811AbeJCXDN (ORCPT ); Wed, 3 Oct 2018 19:03:13 -0400 X-Originating-IP: 2.224.242.101 Received: from w540 (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id DFADE1BF207; Wed, 3 Oct 2018 16:14:02 +0000 (UTC) Date: Wed, 3 Oct 2018 18:14:01 +0200 From: jacopo mondi To: ektor5 Cc: hverkuil@xs4all.nl, luca.pisani@udoo.org, jose.abreu@synopsys.com, sean@mess.org, sakari.ailus@linux.intel.com, Mauro Carvalho Chehab , "David S. Miller" , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Hans Verkuil , Laurent Pinchart , Geert Uytterhoeven , Jacob Chen , Jacopo Mondi , Neil Armstrong , Todor Tomov , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH 1/2] media: add SECO cec driver Message-ID: <20181003161401.GG20786@w540> References: <20181003093532.GF20786@w540> <20181003153204.ou3zup3jeoa34vvc@Ettosoft-T55> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IuhbYIxU28t+Kd57" Content-Disposition: inline In-Reply-To: <20181003153204.ou3zup3jeoa34vvc@Ettosoft-T55> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --IuhbYIxU28t+Kd57 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hello, On Wed, Oct 03, 2018 at 05:50:04PM +0200, ektor5 wrote: > Hi Jacopo, > Thanks for the quick reply, I will respond inline, > > On Wed, Oct 03, 2018 at 11:35:32AM +0200, jacopo mondi wrote: > > Hi Ettore, > > thanks for the patch. > > > > A few comments below, please have a look... > > > > On Tue, Oct 02, 2018 at 06:59:55PM +0200, ektor5 wrote: > > > From: Ettore Chimenti > > > +/* ----------------------------------------------------------------------- */ [snip] > > > + > > > +#ifdef CONFIG_PM_SLEEP > > > > I see CONFIG_PM_SLEEP is only selected if support for > > 'suspend'/'hibernate' is enabled. Is this what you want, or you should > > check for CONFIG_PM? > > I was just inspired by the implementation of cros-ec-cec, but I think > this is right, because the device actually has suspend/hibernate states. > Your device maybe does... I feel like CONFIG_PM is the right choice, but I let others to comment further. > > > > > +static int secocec_suspend(struct device *dev) > > > +{ > > > + u16 val; > > > + int status; > > > + > > > + dev_dbg(dev, "Device going to suspend, disabling"); > > > + > > > + /* Clear the status register */ > > > + status = smb_rd16(SECOCEC_STATUS_REG_1, &val); > > > + if (status) > > > + goto err; > > > + > > > + status = smb_wr16(SECOCEC_STATUS_REG_1, val); > > > + if (status) > > > + goto err; > > > + > > > + /* Disable the interrupts */ > > > + status = smb_rd16(SECOCEC_ENABLE_REG_1, &val); > > > + if (status) > > > + goto err; > > > + > > > + status = smb_wr16(SECOCEC_ENABLE_REG_1, val & > > > + ~SECOCEC_ENABLE_REG_1_CEC & ~SECOCEC_ENABLE_REG_1_IR); > > > + if (status) > > > + goto err; > > > + > > > + return 0; > > > + > > > +err: > > > + dev_err(dev, "Suspend failed (err: %d)", status); > > > + return status; > > > +} > > > + > > > +static int secocec_resume(struct device *dev) > > > +{ > > > + u16 val; > > > + int status; > > > + > > > + dev_dbg(dev, "Resuming device from suspend"); > > > + > > > + /* Clear the status register */ > > > + status = smb_rd16(SECOCEC_STATUS_REG_1, &val); > > > + if (status) > > > + goto err; > > > + > > > + status = smb_wr16(SECOCEC_STATUS_REG_1, val); > > > + if (status) > > > + goto err; > > > + > > > + /* Enable the interrupts */ > > > + status = smb_rd16(SECOCEC_ENABLE_REG_1, &val); > > > + if (status) > > > + goto err; > > > + > > > + status = smb_wr16(SECOCEC_ENABLE_REG_1, val | SECOCEC_ENABLE_REG_1_CEC); > > > + if (status) > > > + goto err; > > > + > > > + dev_dbg(dev, "Device resumed from suspend"); > > > + > > > + return 0; > > > + > > > +err: > > > + dev_err(dev, "Resume failed (err: %d)", status); > > > + return status; > > > +} > > > + > > > +static SIMPLE_DEV_PM_OPS(secocec_pm_ops, secocec_suspend, secocec_resume); > > > +#define SECOCEC_PM_OPS (&secocec_pm_ops) > > > +#else > > > +#define SECOCEC_PM_OPS NULL > > > +#endif > > > + > > > +#ifdef CONFIG_ACPI > > > +static const struct acpi_device_id secocec_acpi_match[] = { > > > + {"CEC00001", 0}, > > > + {}, > > > +}; > > > + > > > +MODULE_DEVICE_TABLE(acpi, secocec_acpi_match); > > > +#endif > > > + > > > +static struct platform_driver secocec_driver = { > > > + .driver = { > > > + .name = SECOCEC_DEV_NAME, > > > + .acpi_match_table = ACPI_PTR(secocec_acpi_match), > > > + .pm = SECOCEC_PM_OPS, > > > + }, > > > + .probe = secocec_probe, > > > + .remove = secocec_remove, > > > +}; > > > > As you can see most of my comments are nits or trivial things. I would > > wait for more feedbacks on the CEC and x86/SMbus part from others before > > sending v2 if I were you :) > > > > Thanks > > j > > > > Many thanks, this is my first patch, so I need plenty of comments. :) > I wish my first patches were as good as this one! Thanks for sharing j --IuhbYIxU28t+Kd57 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJbtOrIAAoJEHI0Bo8WoVY8EnAQALOc1HFJBvUw1vTBqkXrLrCr UpIPttl6tg5m1cDTgwqZuQbn9WfghAyZC2J4uv7y0kBKDIvwzyJBqnws4pE+/Ion yeyNtBtBBPHVcZpArbGtHDazYygjPR7cWtQo80CIIc6VW8t6xlw2sf7c3xGyPcRf ADkzZta8mFx0supTVPD+x8GxQWcc8RdzMbCSN5IVXiHrZ0TG3lgXqolldTOJANjB B2KxvnMXyR3vTcuky+bRl53gYzol6rbpiSLN6UjVZLEiC3KpSU/3l1ejvgCRdozn 6M3S8vDgZUG2b5tVpunHqZzdRWfrD7tsXYPgVo5kuAduBp8VUgRHPWECPRAZgjF7 bOjxWjSxFnsh6wBgnS9+7CLcsiWLMh9kl2d9T8ZnysVJo0F+akSJ3fdqypcHMUni JUSjS3QDIiePDWKldjRj49n7ATQ/axbYrNAsIn2T2FXIMj5n6ic+HR0h0ub56wer UEVLqshkzMyXrwEUm0IUnjQNe2PdhxMQuRm5285Y1XRNhxgVZlEoRRZ6Mr9cjGDG AvPdrooqNeU6fK3tPNb3GipozYEqMJaLpbK/EAINw5aZy1YW+N8GQ//IuqzmBCOp l27typ3W3znKo4izmZHfj5DJDHsBZu3QGejlJxGl4lTaiov985LEBj9KJwOiDitc f426eZd3u0O89DGIGXRK =D8Pj -----END PGP SIGNATURE----- --IuhbYIxU28t+Kd57--