From patchwork Sun Jan 22 16:14:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9531145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BFB676020B for ; Sun, 22 Jan 2017 16:14:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B222C27E22 for ; Sun, 22 Jan 2017 16:14:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A71A927FA8; Sun, 22 Jan 2017 16:14:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6752427E22 for ; Sun, 22 Jan 2017 16:14:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E1F2E6E339; Sun, 22 Jan 2017 16:14:18 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 422CB6E337 for ; Sun, 22 Jan 2017 16:14:17 +0000 (UTC) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D58C9C057EC9; Sun, 22 Jan 2017 16:14:17 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0MGEBqL020584; Sun, 22 Jan 2017 11:14:16 -0500 From: Hans de Goede To: Thierry Reding , "Rafael J . Wysocki" , Len Brown Date: Sun, 22 Jan 2017 17:14:08 +0100 Message-Id: <20170122161409.21601-3-hdegoede@redhat.com> In-Reply-To: <20170122161409.21601-1-hdegoede@redhat.com> References: <20170122161409.21601-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 22 Jan 2017 16:14:17 +0000 (UTC) Cc: linux-pwm@vger.kernel.org, linux-acpi@vger.kernel.org, intel-gfx , Hans de Goede Subject: [Intel-gfx] [PATCH v2 2/3] pwm/core: Try to get the module from pwm_get X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add a module_name string to the pwm_lookup struct and if specified and pwmchip_find_by_name() does not find the pwmchip try calling request_module with the specified name. Signed-off-by: Hans de Goede --- drivers/pwm/core.c | 4 ++++ include/linux/pwm.h | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 0d3ef29..c418a7a 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -823,6 +823,10 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id) return ERR_PTR(-ENODEV); chip = pwmchip_find_by_name(chosen->provider); + if (!chip && chosen->module_name) { + request_module(chosen->module_name); + chip = pwmchip_find_by_name(chosen->provider); + } if (!chip) return ERR_PTR(-EPROBE_DEFER); diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 2c6c511..40ab8b6 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -613,18 +613,25 @@ struct pwm_lookup { const char *con_id; unsigned int period; enum pwm_polarity polarity; + const char *module_name; /* Optional may be NULL */ }; -#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \ +#define PWM_LOOKUP_MODNAME(_provider, _index, _dev_id, _con_id, _period, \ + _polarity, _module_name) \ { \ .provider = _provider, \ .index = _index, \ .dev_id = _dev_id, \ .con_id = _con_id, \ .period = _period, \ - .polarity = _polarity \ + .polarity = _polarity, \ + .module_name = _module_name \ } +#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \ + PWM_LOOKUP_MODNAME(_provider, _index, _dev_id, _con_id, _period, \ + _polarity, NULL) + #if IS_ENABLED(CONFIG_PWM) void pwm_add_table(struct pwm_lookup *table, size_t num); void pwm_remove_table(struct pwm_lookup *table, size_t num);