From patchwork Fri Oct 13 20:23:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jasmin J." X-Patchwork-Id: 10005859 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 EF19E602B3 for ; Fri, 13 Oct 2017 20:23:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E08E629166 for ; Fri, 13 Oct 2017 20:23:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D53FB2916B; Fri, 13 Oct 2017 20:23:55 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B622829166 for ; Fri, 13 Oct 2017 20:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752096AbdJMUXx (ORCPT ); Fri, 13 Oct 2017 16:23:53 -0400 Received: from mail.anw.at ([195.234.101.228]:33007 "EHLO mail.anw.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751981AbdJMUXw (ORCPT ); Fri, 13 Oct 2017 16:23:52 -0400 Received: from hoppel.217.196.72.190 (anwhome.anw.at [195.234.103.23]) by mail.anw.at (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id v9DKNai6002993; Fri, 13 Oct 2017 22:23:36 +0200 From: "Jasmin J." To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, d.scheller@gmx.net, david@hardeman.nu, jasmin@anw.at Subject: [PATCH] build: Remove IDA from lirc_dev Date: Fri, 13 Oct 2017 22:23:29 +0200 Message-Id: <1507926209-9654-1-git-send-email-jasmin@anw.at> X-Mailer: git-send-email 2.7.4 X-Antivirus: checked in 0.021sec at mail.anw.at ([195.234.102.72]) by smf-clamd v1.2.1 - http://smfs.sf.net/ Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jasmin Jessich Compiling for Kernel 2.6.x failed in "lirc_dev.c" with implicit declaration of function 'ida_simple_get' This will in principle revert commit 46c8f4771154eb0dc21f5f2bc2640a33e8fe1d02 . Signed-off-by: Jasmin Jessich --- backports/backports.txt | 1 + backports/v3.0_remove_ida_lird_dev.patch | 111 +++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 backports/v3.0_remove_ida_lird_dev.patch diff --git a/backports/backports.txt b/backports/backports.txt index b245e3b..618c4e8 100644 --- a/backports/backports.txt +++ b/backports/backports.txt @@ -126,6 +126,7 @@ add v3.1_no_pm_qos.patch add no_atomic_include.patch add v4l2-compat-timespec.patch add v3.0_ida2bit.patch +add v3.0_remove_ida_lird_dev.patch [2.6.39] add v2.6_rc_main_bsearch_h.patch diff --git a/backports/v3.0_remove_ida_lird_dev.patch b/backports/v3.0_remove_ida_lird_dev.patch new file mode 100644 index 0000000..8fafa6a --- /dev/null +++ b/backports/v3.0_remove_ida_lird_dev.patch @@ -0,0 +1,111 @@ +diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c +index e16d113..67f1f7d 100644 +--- a/drivers/media/rc/lirc_dev.c ++++ b/drivers/media/rc/lirc_dev.c +@@ -24,7 +24,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -34,9 +33,10 @@ + + static dev_t lirc_base_dev; + +-/* Used to keep track of allocated lirc devices */ +-#define LIRC_MAX_DEVICES 256 +-static DEFINE_IDA(lirc_ida); ++/* This mutex protects the irctls array */ ++static DEFINE_MUTEX(lirc_dev_lock); ++ ++static struct lirc_dev *irctls[MAX_IRCTL_DEVICES]; + + /* Only used for sysfs but defined to void otherwise */ + static struct class *lirc_class; +@@ -45,6 +45,10 @@ static void lirc_release_device(struct device *ld) + { + struct lirc_dev *d = container_of(ld, struct lirc_dev, dev); + ++ mutex_lock(&lirc_dev_lock); ++ irctls[d->minor] = NULL; ++ mutex_unlock(&lirc_dev_lock); ++ + put_device(d->dev.parent); + + if (d->buf_internal) { +@@ -161,9 +165,20 @@ int lirc_register_device(struct lirc_dev *d) + return err; + } + +- minor = ida_simple_get(&lirc_ida, 0, LIRC_MAX_DEVICES, GFP_KERNEL); +- if (minor < 0) +- return minor; ++ mutex_lock(&lirc_dev_lock); ++ ++ /* find first free slot for driver */ ++ for (minor = 0; minor < MAX_IRCTL_DEVICES; minor++) ++ if (!irctls[minor]) ++ break; ++ ++ if (minor == MAX_IRCTL_DEVICES) { ++ dev_err(&d->dev, "no free slots for drivers!\n"); ++ mutex_unlock(&lirc_dev_lock); ++ return -ENOMEM; ++ } ++ irctls[minor] = d; ++ mutex_unlock(&lirc_dev_lock); + + d->minor = minor; + d->dev.devt = MKDEV(MAJOR(lirc_base_dev), d->minor); +@@ -175,7 +190,10 @@ int lirc_register_device(struct lirc_dev *d) + + err = cdev_device_add(&d->cdev, &d->dev); + if (err) { +- ida_simple_remove(&lirc_ida, minor); ++ mutex_lock(&lirc_dev_lock); ++ irctls[minor] = NULL; ++ mutex_unlock(&lirc_dev_lock); ++ + return err; + } + +@@ -208,7 +226,6 @@ void lirc_unregister_device(struct lirc_dev *d) + mutex_unlock(&d->mutex); + + cdev_device_del(&d->cdev, &d->dev); +- ida_simple_remove(&lirc_ida, d->minor); + put_device(&d->dev); + } + EXPORT_SYMBOL(lirc_unregister_device); +@@ -487,7 +504,7 @@ static int __init lirc_dev_init(void) + return PTR_ERR(lirc_class); + } + +- retval = alloc_chrdev_region(&lirc_base_dev, 0, LIRC_MAX_DEVICES, ++ retval = alloc_chrdev_region(&lirc_base_dev, 0, MAX_IRCTL_DEVICES, + "BaseRemoteCtl"); + if (retval) { + class_destroy(lirc_class); +@@ -504,7 +521,7 @@ static int __init lirc_dev_init(void) + static void __exit lirc_dev_exit(void) + { + class_destroy(lirc_class); +- unregister_chrdev_region(lirc_base_dev, LIRC_MAX_DEVICES); ++ unregister_chrdev_region(lirc_base_dev, MAX_IRCTL_DEVICES); + pr_info("module unloaded\n"); + } + +diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h +index 857da67..47bcd39 100644 +--- a/include/media/lirc_dev.h ++++ b/include/media/lirc_dev.h +@@ -9,6 +9,7 @@ + #ifndef _LINUX_LIRC_DEV_H + #define _LINUX_LIRC_DEV_H + ++#define MAX_IRCTL_DEVICES 8 + #define BUFLEN 16 + + #include