Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp367710imu; Fri, 21 Dec 2018 00:08:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN5cqdPOxvZ/puQvq7LfYJDPti+EGhTXHr6nPoCOUwvq9xH0MBg9GeSza4T9MBbdkLPr8JmD X-Received: by 2002:a62:31c1:: with SMTP id x184mr1563050pfx.204.1545379693630; Fri, 21 Dec 2018 00:08:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545379693; cv=none; d=google.com; s=arc-20160816; b=KXH2DVuL0AB1L23cQaGFFtWbfPIql/G4cMbOxVYFU+gqCp4fT6Whv6QgN7D3rmEUOd LEppF5C7wfIMFkHeBUUVwHykfaQRrJcnrSiT0RR6Jytf1DAo5VyZrZICARNv0GOTcR9B CNGkHmkOLyf69vQXNx+9Ovx2zRyzcRMx8KdybhSiLLH8iSfHtCvEJ1+Jw1gHEbm+yEsW 9MEkkUEkBbfjLvuodPWG4C2TPfL7ncbXTsF4gjqkoWKBa7TIGwqSbDEWYJS1X5zJrQhc TzRt0FDcDB94AHjEd7tH5TREQ3VjVzeQvFYBuTGWlkm08uz0rW+CAtIgbkz7jpZnbDRc jXBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pljUxpLoKgsf8qucj7vWRW9Ldqg3BVZUob+yqcraEmw=; b=sHXC2m9+0GZjVPbugcHhcxVE7zSsRlRC7WUstMcAqTKUupjScx1vssRdnf5IxjcWZa 9RS1St9/CfeF7DKe0fCS7ygQcoxMDeiD4qXPFRXetBUvjDsS4kiAqIGxNLgYJCGDVgjf T3pyWSpxNBCETTuaJ4j0Mn4UM6q1nwPbZSrEZnnYNHJOyvEHvrB+fNp102FcQTp5rW6p 4N9Hai15P6yruEHdZ7xLDiGncYx4Rf1M/YcBDOXzUxGCa2nFf6EUtSJeUCqjOezVRDFb shSC1/FSICI2UvczSo1O1OHDRrh6+1TtA+wyc32DiQNjhUfOIRoW3SM3O9Jvm9LBPm7j hMag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rcScYlho; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si215851pgd.68.2018.12.21.00.07.57; Fri, 21 Dec 2018 00:08:13 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=rcScYlho; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390517AbeLUBSa (ORCPT + 99 others); Thu, 20 Dec 2018 20:18:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:37434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388729AbeLUBS1 (ORCPT ); Thu, 20 Dec 2018 20:18:27 -0500 Received: from mail.kernel.org (unknown [185.216.33.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE51E218E0; Fri, 21 Dec 2018 01:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545355107; bh=Xh3KpJCTdqxj3scIi4cEDHdR1UqNfPBIZHB31JVxXzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rcScYlhoQHhPJ7ctOPkew6qst/ED3apy3BMLa+PVddFC5bIOSGtZTLXRxSFkhg8lv 2laA9vKTDhdw7axM9tZrJKnzJGnbDgqLfZvv2Y4EnUB+wEuYKUCRaEVIgzhq2+fEE7 7/x9Qc0aLWjd8w2NfJPn5TXl4ldHPWs7mo+8P8OU= From: Sebastian Reichel To: Sebastian Reichel , Mauro Carvalho Chehab , Marcel Holtmann , Tony Lindgren Cc: Rob Herring , Greg Kroah-Hartman , Pavel Machek , linux-bluetooth@vger.kernel.org, linux-media@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel Subject: [PATCH 08/14] media: wl128x-radio: use device managed memory allocation Date: Fri, 21 Dec 2018 02:17:46 +0100 Message-Id: <20181221011752.25627-9-sre@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181221011752.25627-1-sre@kernel.org> References: <20181221011752.25627-1-sre@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Reichel This simplifies memory allocation and removes a few useless errors in case of -ENOMEM errors. Signed-off-by: Sebastian Reichel --- drivers/media/radio/wl128x/fmdrv_common.c | 41 +++++++---------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c index 9526613adf91..3f189d093eeb 100644 --- a/drivers/media/radio/wl128x/fmdrv_common.c +++ b/drivers/media/radio/wl128x/fmdrv_common.c @@ -1614,55 +1614,40 @@ int fmc_release(struct fmdev *fmdev) return ret; } -static int wl128x_fm_probe(struct platform_device *dev) +static int wl128x_fm_probe(struct platform_device *pdev) { - struct fmdev *fmdev = NULL; - int ret = -ENOMEM; - - fmdbg("FM driver\n"); + struct fmdev *fmdev; + int ret; /* Allocate memory for FM driver context and RX RDS buffer. */ - fmdev = kzalloc(sizeof(struct fmdev), GFP_KERNEL); - if (NULL == fmdev) { - fmerr("Can't allocate operation structure memory\n"); - return ret; - } + fmdev = devm_kzalloc(&pdev->dev, sizeof(*fmdev), GFP_KERNEL); + if (!fmdev) + return -ENOMEM; + platform_set_drvdata(pdev, fmdev); + fmdev->rx.rds.buf_size = default_rds_buf * FM_RDS_BLK_SIZE; - fmdev->rx.rds.buff = kzalloc(fmdev->rx.rds.buf_size, GFP_KERNEL); - if (NULL == fmdev->rx.rds.buff) { - fmerr("Can't allocate rds ring buffer\n"); - goto rel_dev; - } + fmdev->rx.rds.buff = devm_kzalloc(&pdev->dev, fmdev->rx.rds.buf_size, GFP_KERNEL); + if (!fmdev->rx.rds.buff) + return -ENOMEM; /* Ask FM V4L module to register video device. */ ret = fm_v4l2_init_video_device(fmdev, radio_nr); if (ret < 0) - goto rel_rdsbuf; + return ret; fmdev->irq_info.handlers = int_handler_table; fmdev->curr_fmmode = FM_MODE_OFF; fmdev->tx_data.pwr_lvl = FM_PWR_LVL_DEF; fmdev->tx_data.preemph = FM_TX_PREEMPH_50US; return ret; - -rel_rdsbuf: - kfree(fmdev->rx.rds.buff); -rel_dev: - kfree(fmdev); - - return ret; } -static int wl128x_fm_remove(struct platform_device *dev) +static int wl128x_fm_remove(struct platform_device *pdev) { struct fmdev *fmdev = platform_get_drvdata(pdev); /* Ask FM V4L module to unregister video device */ fm_v4l2_deinit_video_device(fmdev); - if (fmdev != NULL) { - kfree(fmdev->rx.rds.buff); - kfree(fmdev); - } return 0; } -- 2.19.2