diff --git a/doc/source/algorithm.rst b/doc/source/algorithm.rst
index 94758f7129d7e302e64e6251c645f99b791ed95a..781cbcb608705c7a4a4799d4b5d00d28bc93d68b 100644
--- a/doc/source/algorithm.rst
+++ b/doc/source/algorithm.rst
@@ -193,10 +193,12 @@ Making Custom Scan Kernels
 
 .. autoclass:: GenericScanKernel
 
-    .. method:: __call__(*args, allocator=None, queue=None)
+    .. method:: __call__(*args, allocator=None, queue=None, size=None)
 
         *queue* and *allocator* default to the ones provided on the first
-        :class:`pyopencl.array.Array` in *args*.
+        :class:`pyopencl.array.Array` in *args*. *size* may specify the
+        length of the scan to be carried out. If not given, this length
+        is inferred from the first array argument passed.
 
 Debugging aids
 ~~~~~~~~~~~~~~
diff --git a/pyopencl/scan.py b/pyopencl/scan.py
index 61cf90a94c87875c846806e4ffa24732fb9efd54..9e2487feaedd18a36d3f9b58c3e64d41670ccae5 100644
--- a/pyopencl/scan.py
+++ b/pyopencl/scan.py
@@ -1258,6 +1258,7 @@ class GenericScanKernel(_GenericScanKernelBase):
 
         allocator = kwargs.get("allocator")
         queue = kwargs.get("queue")
+        n = kwargs.get("size")
 
         if len(args) != len(self.parsed_args):
             raise TypeError("expected %d arguments, got %d" %
@@ -1267,7 +1268,8 @@ class GenericScanKernel(_GenericScanKernelBase):
         allocator = allocator or first_array.allocator
         queue = queue or first_array.queue
 
-        n, = first_array.shape
+        if n is None:
+            n, = first_array.shape
 
         data_args = []
         from pyopencl.tools import VectorArg