C

My First Patch Ever

I have never contributed to any OSS ever before, in any way. I always wanted too, but “some stuff”, kept be holded.

I read a lot that it’s very easy, and believe me it’s damn easy! Also as people are really helpful.

This post is about my first patch ever, and it is for Linux kernel.

The first patch Greg added to his staging-next tree is about fixing a warning generated by checkpatch.pl in staging/iio/accel.

The Linux Staging tree (or just “staging”) is used to hold stand-alone drivers and filesystems that are not ready to be merged into the main portion of the Linux kernel tree at this point in time for various reasons. They keep adding and removing drivers from the staging directory.

This is what Kconfig of drivers/staging/ says :


menuconfig STAGING
 bool "Staging drivers"
 default n
 ---help---
 This option allows you to select a number of drivers that are not of the "normal" Linux kernel quality level. These drivers are placed here in order to get a wider audience to make use of
 them. Please note that these drivers are under heavy
 development, may or may not work, and may contain userspace
 interfaces that most likely will be changed in the near
 future.

Using any of these drivers will taint your kernel which might
 affect support options from both the community, and various
 commercial support organizations.

If you wish to work on these drivers, to help improve them, or
 to report problems you have with them, please see the
 driver_name.README file in the drivers/staging/ directory to
 see what needs to be worked on, and who to contact.

If in doubt, say N here.

The warning was else is not generally useful after break or return.

Yes, these people has a script to keep them aligned with a coding style, they use.

It is a script in the kernel tree that facilitates better kernel code, and can be used to check many coding style rules.

Here is my first patch to Linux kernel. I know it’s easy and simple but it’s cool.

I got the following auto generated mail from Greg, and it feels awesome. 🙂

This is a note to let you know that I've just added the patch titled

staging: iio: accel: remove else after return

to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git in the staging-next branch.

The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)

The patch will also be merged in the next major kernel release
during the merge window.

If you have any questions about this process, please let me know.

From b5e736bd6881d9e78384eed8ab7fdcb586f0e402 Mon Sep 17 00:00:00 2001
From: Tapasweni Pathak <tapaswenipathak@gmail.com>
Date: Mon, 22 Sep 2014 14:50:22 +0530
Subject: staging: iio: accel: remove else after return

This patch fixes checkpatch.pl warning in files of iio: accel
WARNING : else is not generally useful after a break or return

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/staging/iio/accel/adis16240_core.c | 3 +--
drivers/staging/iio/accel/lis3l02dq_ring.c | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c
index 205d6d0a2206..3f46086eab3a 100644
--- a/drivers/staging/iio/accel/adis16240_core.c
+++ b/drivers/staging/iio/accel/adis16240_core.c
@@ -99,9 +99,8 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
*val = 4;
*val2 = 880000; /* 4.88 mV */
return IIO_VAL_INT_PLUS_MICRO;
-                       } else {
-                               return -EINVAL;
}
+                       return -EINVAL;
case IIO_TEMP:
*val = 244; /* 0.244 C */
*val2 = 0;
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index 1d934ee3bb5f..61f94221b8b7 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -34,8 +34,8 @@ irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private)
if (st->trigger_on) {
iio_trigger_poll(st->trig);
return IRQ_HANDLED;
-       } else
-               return IRQ_WAKE_THREAD;
+       }
+       return IRQ_WAKE_THREAD;
}

static const u8 read_all_tx_array[] = {

 

I’ll be soon adding tutorial on how to send your first simple patch for Linux kernel.

 

 

Advertisements

5 thoughts on “My First Patch Ever

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s