From patchwork Sat Nov 15 09:54:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar X-Patchwork-Id: 5314151 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BC47BC11AC for ; Sun, 16 Nov 2014 13:58:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A44E3201DD for ; Sun, 16 Nov 2014 13:58:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 715D620155 for ; Sun, 16 Nov 2014 13:58:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE2916E8CA; Sun, 16 Nov 2014 05:57:55 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id B948E6EE6A for ; Sat, 15 Nov 2014 02:01:20 -0800 (PST) Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NF200BKCRU79R80@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Sat, 15 Nov 2014 19:01:19 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.124]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 00.35.18167.F6427645; Sat, 15 Nov 2014 19:01:19 +0900 (KST) X-AuditID: cbfee690-f79ab6d0000046f7-a7-5467246f4fdb Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id CC.73.09430.F6427645; Sat, 15 Nov 2014 19:01:19 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NF200LRLRTSF980@mmp1.samsung.com>; Sat, 15 Nov 2014 19:01:19 +0900 (KST) From: Ajay Kumar To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH V8 01/14] drm/bridge: ptn3460: Few trivial cleanups Date: Sat, 15 Nov 2014 15:24:56 +0530 Message-id: <1416045309-13359-2-git-send-email-ajaykumar.rs@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1416045309-13359-1-git-send-email-ajaykumar.rs@samsung.com> References: <1416045309-13359-1-git-send-email-ajaykumar.rs@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeLIzCtJLcpLzFFi42JZI2JSo5uvkh5i8OyxhsWB9wdZLDa8Wchs sWztPxaLhQ/vMlvMP3KO1eLK1/dsFpPuT2Cx6F1wlc1i0+NrrBYzzu9jslh1eAO7xdyDuRY/ d81jceD12PttAYvHzll32T0WbCr1uN99nMlj85J6j74tqxg9Pm+SC2CP4rJJSc3JLEst0rdL 4Mo4fP44U8Epr4pDN0+zNjD+tO1i5OSQEDCR2HCokRXCFpO4cG89WxcjF4eQwFJGiWN7f7PB FD36v5oFIrGIUWLezmdMEM4EJomWDSeZQKrYBLQltk2/CVYlItDFKPH+wCp2EIdZ4DlQy4UO FpAqYQFniQtd19lBbBYBVYmTJ5YzdzFycPAKeEi0tRqCmBICChJzJtmAVHAKeEps/zgfrFMI qGLtwX9g50kIXGOXOLTtPgvEGAGJb5MPsUD0ykpsOsAMcbWkxMEVN1gmMAovYGRYxSiaWpBc UJyUXmSiV5yYW1y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YNTqoHRT4Nd /ThH7/x/gprpuucUnS53u0079+GZ8+yH5f9jDno5TljIpTyDNTRUq2JGZBan0JL/nEK/bR7t nusYuPSkFX8f/2295euScs680ZW32MLoVVGVvKbV9bCG9fWYJ4uiOART/fs4fbS0tr1NTflb 0HFSv6t5ogXLa8bggJypoRvndxzKlVdiKc5INNRiLipOBACPtfUE3gIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Mailman-Approved-At: Sun, 16 Nov 2014 05:57:21 -0800 Cc: kgene.kim@samsung.com, seanpaul@google.com, daniel.vetter@ffwll.ch, ajaynumb@gmail.com, bhushan.r@samsung.com, prashanth.g@samsung.com, Ajay Kumar X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch does the following changes: -- Use usleep_range instead of udelay. -- Remove driver_private member from ptn3460 structure. -- Make all possible functions and structures static. -- Use dev_err for non-DRM errors. -- Arrange header files alphabetically. -- s/edid/EDID in all error messages. Signed-off-by: Ajay Kumar --- drivers/gpu/drm/bridge/ptn3460.c | 95 +++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/bridge/ptn3460.c b/drivers/gpu/drm/bridge/ptn3460.c index d466696..4db38e1 100644 --- a/drivers/gpu/drm/bridge/ptn3460.c +++ b/drivers/gpu/drm/bridge/ptn3460.c @@ -13,19 +13,19 @@ * GNU General Public License for more details. */ +#include +#include +#include #include #include #include -#include -#include -#include -#include "drmP.h" -#include "drm_edid.h" +#include "bridge/ptn3460.h" + #include "drm_crtc.h" #include "drm_crtc_helper.h" - -#include "bridge/ptn3460.h" +#include "drm_edid.h" +#include "drmP.h" #define PTN3460_EDID_ADDR 0x0 #define PTN3460_EDID_EMULATION_ADDR 0x84 @@ -37,7 +37,7 @@ struct ptn3460_bridge { struct drm_connector connector; struct i2c_client *client; struct drm_encoder *encoder; - struct drm_bridge *bridge; + struct drm_bridge bridge; struct edid *edid; int gpio_pd_n; int gpio_rst_n; @@ -45,6 +45,18 @@ struct ptn3460_bridge { bool enabled; }; +static inline struct ptn3460_bridge * + bridge_to_ptn3460(struct drm_bridge *bridge) +{ + return container_of(bridge, struct ptn3460_bridge, bridge); +} + +static inline struct ptn3460_bridge * + connector_to_ptn3460(struct drm_connector *connector) +{ + return container_of(connector, struct ptn3460_bridge, connector); +} + static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr, u8 *buf, int len) { @@ -92,7 +104,7 @@ static int ptn3460_select_edid(struct ptn3460_bridge *ptn_bridge) ret = ptn3460_write_byte(ptn_bridge, PTN3460_EDID_SRAM_LOAD_ADDR, ptn_bridge->edid_emulation); if (ret) { - DRM_ERROR("Failed to transfer edid to sram, ret=%d\n", ret); + DRM_ERROR("Failed to transfer EDID to sram, ret=%d\n", ret); return ret; } @@ -102,7 +114,7 @@ static int ptn3460_select_edid(struct ptn3460_bridge *ptn_bridge) ret = ptn3460_write_byte(ptn_bridge, PTN3460_EDID_EMULATION_ADDR, val); if (ret) { - DRM_ERROR("Failed to write edid value, ret=%d\n", ret); + DRM_ERROR("Failed to write EDID value, ret=%d\n", ret); return ret; } @@ -111,7 +123,7 @@ static int ptn3460_select_edid(struct ptn3460_bridge *ptn_bridge) static void ptn3460_pre_enable(struct drm_bridge *bridge) { - struct ptn3460_bridge *ptn_bridge = bridge->driver_private; + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); int ret; if (ptn_bridge->enabled) @@ -122,7 +134,7 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge) if (gpio_is_valid(ptn_bridge->gpio_rst_n)) { gpio_set_value(ptn_bridge->gpio_rst_n, 0); - udelay(10); + usleep_range(10, 20); gpio_set_value(ptn_bridge->gpio_rst_n, 1); } @@ -135,7 +147,7 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge) ret = ptn3460_select_edid(ptn_bridge); if (ret) - DRM_ERROR("Select edid failed ret=%d\n", ret); + DRM_ERROR("Select EDID failed ret=%d\n", ret); ptn_bridge->enabled = true; } @@ -146,7 +158,7 @@ static void ptn3460_enable(struct drm_bridge *bridge) static void ptn3460_disable(struct drm_bridge *bridge) { - struct ptn3460_bridge *ptn_bridge = bridge->driver_private; + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); if (!ptn_bridge->enabled) return; @@ -164,9 +176,9 @@ static void ptn3460_post_disable(struct drm_bridge *bridge) { } -void ptn3460_bridge_destroy(struct drm_bridge *bridge) +static void ptn3460_bridge_destroy(struct drm_bridge *bridge) { - struct ptn3460_bridge *ptn_bridge = bridge->driver_private; + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); drm_bridge_cleanup(bridge); if (gpio_is_valid(ptn_bridge->gpio_pd_n)) @@ -176,7 +188,7 @@ void ptn3460_bridge_destroy(struct drm_bridge *bridge) /* Nothing else to free, we've got devm allocated memory */ } -struct drm_bridge_funcs ptn3460_bridge_funcs = { +static struct drm_bridge_funcs ptn3460_bridge_funcs = { .pre_enable = ptn3460_pre_enable, .enable = ptn3460_enable, .disable = ptn3460_disable, @@ -184,24 +196,24 @@ struct drm_bridge_funcs ptn3460_bridge_funcs = { .destroy = ptn3460_bridge_destroy, }; -int ptn3460_get_modes(struct drm_connector *connector) +static int ptn3460_get_modes(struct drm_connector *connector) { struct ptn3460_bridge *ptn_bridge; u8 *edid; - int ret, num_modes; + int ret, num_modes = 0; bool power_off; - ptn_bridge = container_of(connector, struct ptn3460_bridge, connector); + ptn_bridge = connector_to_ptn3460(connector); if (ptn_bridge->edid) return drm_add_edid_modes(connector, ptn_bridge->edid); power_off = !ptn_bridge->enabled; - ptn3460_pre_enable(ptn_bridge->bridge); + ptn3460_pre_enable(&ptn_bridge->bridge); edid = kmalloc(EDID_LENGTH, GFP_KERNEL); if (!edid) { - DRM_ERROR("Failed to allocate edid\n"); + DRM_ERROR("Failed to allocate EDID\n"); return 0; } @@ -209,7 +221,6 @@ int ptn3460_get_modes(struct drm_connector *connector) EDID_LENGTH); if (ret) { kfree(edid); - num_modes = 0; goto out; } @@ -220,37 +231,35 @@ int ptn3460_get_modes(struct drm_connector *connector) out: if (power_off) - ptn3460_disable(ptn_bridge->bridge); + ptn3460_disable(&ptn_bridge->bridge); return num_modes; } -struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector) +static struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector) { - struct ptn3460_bridge *ptn_bridge; - - ptn_bridge = container_of(connector, struct ptn3460_bridge, connector); + struct ptn3460_bridge *ptn_bridge = connector_to_ptn3460(connector); return ptn_bridge->encoder; } -struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = { +static struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = { .get_modes = ptn3460_get_modes, .best_encoder = ptn3460_best_encoder, }; -enum drm_connector_status ptn3460_detect(struct drm_connector *connector, +static enum drm_connector_status ptn3460_detect(struct drm_connector *connector, bool force) { return connector_status_connected; } -void ptn3460_connector_destroy(struct drm_connector *connector) +static void ptn3460_connector_destroy(struct drm_connector *connector) { drm_connector_cleanup(connector); } -struct drm_connector_funcs ptn3460_connector_funcs = { +static struct drm_connector_funcs ptn3460_connector_funcs = { .dpms = drm_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = ptn3460_detect, @@ -261,30 +270,22 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder, struct i2c_client *client, struct device_node *node) { int ret; - struct drm_bridge *bridge; struct ptn3460_bridge *ptn_bridge; - bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL); - if (!bridge) { - DRM_ERROR("Failed to allocate drm bridge\n"); - return -ENOMEM; - } - ptn_bridge = devm_kzalloc(dev->dev, sizeof(*ptn_bridge), GFP_KERNEL); if (!ptn_bridge) { - DRM_ERROR("Failed to allocate ptn bridge\n"); return -ENOMEM; } ptn_bridge->client = client; ptn_bridge->encoder = encoder; - ptn_bridge->bridge = bridge; ptn_bridge->gpio_pd_n = of_get_named_gpio(node, "powerdown-gpio", 0); if (gpio_is_valid(ptn_bridge->gpio_pd_n)) { ret = gpio_request_one(ptn_bridge->gpio_pd_n, GPIOF_OUT_INIT_HIGH, "PTN3460_PD_N"); if (ret) { - DRM_ERROR("Request powerdown-gpio failed (%d)\n", ret); + dev_err(&client->dev, + "Request powerdown-gpio failed (%d)\n", ret); return ret; } } @@ -298,7 +299,8 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder, ret = gpio_request_one(ptn_bridge->gpio_rst_n, GPIOF_OUT_INIT_LOW, "PTN3460_RST_N"); if (ret) { - DRM_ERROR("Request reset-gpio failed (%d)\n", ret); + dev_err(&client->dev, + "Request reset-gpio failed (%d)\n", ret); gpio_free(ptn_bridge->gpio_pd_n); return ret; } @@ -307,18 +309,17 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder, ret = of_property_read_u32(node, "edid-emulation", &ptn_bridge->edid_emulation); if (ret) { - DRM_ERROR("Can't read edid emulation value\n"); + dev_err(&client->dev, "Can't read EDID emulation value\n"); goto err; } - ret = drm_bridge_init(dev, bridge, &ptn3460_bridge_funcs); + ret = drm_bridge_init(dev, &ptn_bridge->bridge, &ptn3460_bridge_funcs); if (ret) { DRM_ERROR("Failed to initialize bridge with drm\n"); goto err; } - bridge->driver_private = ptn_bridge; - encoder->bridge = bridge; + encoder->bridge = &ptn_bridge->bridge; ret = drm_connector_init(dev, &ptn_bridge->connector, &ptn3460_connector_funcs, DRM_MODE_CONNECTOR_LVDS);