From patchwork Fri Aug 11 13:49:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9895991 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 44837602DA for ; Fri, 11 Aug 2017 13:49:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36527280B0 for ; Fri, 11 Aug 2017 13:49:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B6932847B; Fri, 11 Aug 2017 13:49:14 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 E3E5D280B0 for ; Fri, 11 Aug 2017 13:49:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C9E0D6E6E3; Fri, 11 Aug 2017 13:49:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from galahad.ideasonboard.com (galahad.ideasonboard.com [IPv6:2001:4b98:dc2:45:216:3eff:febb:480d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9DC196E6E3 for ; Fri, 11 Aug 2017 13:49:04 +0000 (UTC) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 93ABA20FB5; Fri, 11 Aug 2017 15:47:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1502459269; bh=Gjxp18tjzzAitu3WNYMMtkL/REuC6b6YlTFIcsJDM0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ehork5azYY5CmpXh003u1yT89J3Uk5/pyCfBNT6SVDNUvlFiEpPjhLVUpOq4Zyjuc lnx/pTVhYtQiANsO+Z+zlHX9zt17E2Qfs5QzXbbRX+EvADFebIgCsPu2ta6oOsuHfa dGFastjnpmkxYOq9F2TSOpUrdEB7xMo37+koGhGw= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 06/11] drm: omapdrm: hdmi: Don't allocate PHY features dynamically Date: Fri, 11 Aug 2017 16:49:07 +0300 Message-Id: <20170811134912.6429-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170811134912.6429-1-laurent.pinchart@ideasonboard.com> References: <20170811134912.6429-1-laurent.pinchart@ideasonboard.com> Cc: Tomi Valkeinen 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-Virus-Scanned: ClamAV using ClamSMTP There's no need to allocate memory dynamically to duplicate the contents of a const structure, only to store the memory pointer in a const pointer field. Just use the original structures directly. Signed-off-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/hdmi_phy.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c index 95770c3203a1..a156292b1820 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c @@ -182,39 +182,15 @@ static const struct hdmi_phy_features omap54xx_phy_feats = { .max_phy = 186000000, }; -static int hdmi_phy_init_features(struct platform_device *pdev, - struct hdmi_phy_data *phy, - unsigned int version) -{ - struct hdmi_phy_features *dst; - const struct hdmi_phy_features *src; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate HDMI PHY Features\n"); - return -ENOMEM; - } - - if (version == 4) - src = &omap44xx_phy_feats; - else - src = &omap54xx_phy_feats; - - memcpy(dst, src, sizeof(*dst)); - phy->features = dst; - - return 0; -} - int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy, unsigned int version) { - int r; struct resource *res; - r = hdmi_phy_init_features(pdev, phy, version); - if (r) - return r; + if (version == 4) + phy->features = &omap44xx_phy_feats; + else + phy->features = &omap54xx_phy_feats; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); phy->base = devm_ioremap_resource(&pdev->dev, res);